-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
711 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
Sources/Brave/Assets/Interstitial Pages/Images/IPFSBackground.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions
55
Sources/Brave/Assets/Interstitial Pages/Pages/IPFSPreference.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
You can obtain one at https://mozilla.org/MPL/2.0/. | ||
--> | ||
|
||
<head> | ||
<meta name='viewport' content='initial-scale=1, maximum-scale=1, viewport-fit=cover'> | ||
<meta name="referrer" content="no-referrer"> | ||
<title>%page_title%</title> | ||
<link rel="stylesheet" href="internal://local/interstitial-style/InterstitialStyles.css"> | ||
<link rel="stylesheet" href="internal://local/interstitial-style/IPFSPreference.css"> | ||
</head> | ||
|
||
<body dir="&locale.dir;" class="background"> | ||
<div class="container post"> | ||
<div class="header-logo"> | ||
<img src="internal://local/interstitial-icon/BraveIPFS.svg" alt="Icon" class="icon" /> | ||
</div> | ||
<div> | ||
<span class="title">%interstitial_ipfs_title%</span> | ||
<p class="description">%interstitial_ipfs_privacy% | ||
</p> | ||
</div> | ||
<div class="control-box"> | ||
<p class="option">%interstitial_ipfs_public_gateway% | ||
</p> | ||
<button id="disableIPFSButton" class="disableButton disableButtonTitle">%button_disable%</button> | ||
<button id="proceedIPFSButton" class="proceedButton proceedButtonTitle">%button_procced%</button> | ||
</div> | ||
|
||
<div class="footer-container"> | ||
<div class="ipfs-footer"></div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
var disableButton = document.getElementById("disableIPFSButton") | ||
disableButton.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
webkit.messageHandlers["%message_handler%"].postMessage({ | ||
"type": "IPFSDisable", | ||
}); | ||
}); | ||
var proceedButton = document.getElementById("proceedIPFSButton") | ||
proceedButton.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
webkit.messageHandlers["%message_handler%"].postMessage({ | ||
"type": "IPFSProceed", | ||
}); | ||
}); | ||
|
||
</script> | ||
</div> | ||
</body> |
137 changes: 137 additions & 0 deletions
137
Sources/Brave/Assets/Interstitial Pages/Styles/IPFSPreference.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
* { | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
|
||
.background { | ||
background-color: rgb(250, 249, 254); | ||
} | ||
|
||
.icon { | ||
width: 128px; | ||
height: 128px; | ||
} | ||
|
||
.footer-container { | ||
box-sizing: border-box; | ||
width: 100%; | ||
aspect-ratio: 1440 / 136; | ||
bottom: 0; | ||
position: fixed; | ||
} | ||
|
||
.ipfs-footer { | ||
box-sizing: border-box; | ||
background: url('internal://local/interstitial-icon/IPFSBackground.svg'); | ||
width: 100%; | ||
aspect-ratio: 1440 / 136; | ||
background-size: cover; | ||
background-position-x: center; | ||
} | ||
|
||
.header-logo { | ||
margin: 20px 0 20px 0; | ||
} | ||
|
||
.disableButton { | ||
background: rgb(255, 255, 255); | ||
border-radius: 100px; | ||
background-repeat: no-repeat; | ||
border: 1px solid rgb(76, 84, 210); | ||
height: 44px; | ||
margin-right: auto; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
margin-left: auto; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.disableButtonTitle { | ||
color: rgb(76, 84, 210); | ||
font-size: 16px; | ||
font-family: SFProText-Semibold, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-weight: 600; | ||
line-height: 16px; | ||
|
||
cursor: pointer; | ||
overflow: hidden; | ||
outline: none; | ||
} | ||
|
||
.proceedButton { | ||
background: rgb(76, 84, 210); | ||
border-radius: 100px; | ||
background-repeat: no-repeat; | ||
border: none; | ||
height: 44px; | ||
margin-right: auto; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
margin-left: auto; | ||
} | ||
|
||
.proceedButtonTitle { | ||
color: rgb(255, 255, 255); | ||
font-size: 16px; | ||
font-family: SFProText-Semibold, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-weight: 600; | ||
text-align: center; | ||
line-height: 16px; | ||
|
||
cursor: pointer; | ||
overflow: hidden; | ||
outline: none; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
} | ||
|
||
.control-box { | ||
display: block; | ||
} | ||
|
||
.description { | ||
color: rgb(0, 0, 0); | ||
} | ||
|
||
.option { | ||
color: rgb(82, 82, 82); | ||
font-size: 14px; | ||
font-family: SFProText-Regular, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-weight: normal; | ||
letter-spacing: 0px; | ||
line-height: 19px; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
.background { | ||
background: #17171F; | ||
} | ||
|
||
.title { | ||
color: white; | ||
} | ||
|
||
.description { | ||
color: white; | ||
} | ||
|
||
.option { | ||
color: white; | ||
} | ||
|
||
a { | ||
color: white; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+IPFSScheme.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import Foundation | ||
import BraveWallet | ||
import BraveShared | ||
import BraveCore | ||
import Data | ||
|
||
extension BrowserViewController: Web3IPFSScriptHandlerDelegate { | ||
func web3IPFSDecisionHandler(_ proceed: Bool, originalURL: URL, visitType: VisitType) { | ||
if proceed { | ||
if let resolvedUrl = braveCore.ipfsAPI.resolveGatewayUrl(for: originalURL) { | ||
finishEditingAndSubmit(resolvedUrl, visitType: visitType) | ||
} else { | ||
finishEditingAndSubmit(originalURL, visitType: visitType) | ||
} | ||
Preferences.Wallet.resolveIPFSResources.value = Preferences.Wallet.Web3IPFSOption.enabled.rawValue | ||
} else { | ||
if let errorPageHelper = tabManager.selectedTab?.getContentScript(name: ErrorPageHelper.scriptName) as? ErrorPageHelper, let webView = tabManager.selectedTab?.webView { | ||
errorPageHelper.loadPage(IPFSErrorPageHandler.disabledError, forUrl: originalURL, inWebView: webView) | ||
} | ||
|
||
Preferences.Wallet.resolveIPFSResources.value = Preferences.Wallet.Web3IPFSOption.disabled.rawValue | ||
} | ||
} | ||
} |
Oops, something went wrong.