This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #8096: Add blocked page interstitial
- Loading branch information
Showing
12 changed files
with
290 additions
and
6 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
10 changes: 10 additions & 0 deletions
10
Sources/Brave/Assets/Interstitial Pages/Images/warning-triangle-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
Sources/Brave/Assets/Interstitial Pages/Pages/BlockedDomain.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,25 @@ | ||
<!DOCTYPE html> | ||
<!-- 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/. | ||
--> | ||
|
||
<html lang="en"> | ||
<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/BlockedDomain.css"> | ||
</head> | ||
|
||
<body dir="&locale.dir;" class="background content"> | ||
<div class="container post"> | ||
<img src="internal://local/interstitial-icon/warning-triangle-outline.svg" alt="Icon" class="icon" /> | ||
<h1>%blocked_title%</h1> | ||
<h2>%blocked_subtitle%</h2> | ||
<pre class="domain">%blocked_domain%</pre> | ||
<p class="description">%blocked_description%</p> | ||
</div> | ||
</body> | ||
</html> |
135 changes: 135 additions & 0 deletions
135
Sources/Brave/Assets/Interstitial Pages/Styles/BlockedDomain.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,135 @@ | ||
/* | ||
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/. | ||
*/ | ||
|
||
html { | ||
overscroll-behavior: none; | ||
} | ||
|
||
.post { | ||
padding-top: max(25px, env(safe-area-inset-top)); | ||
padding-bottom: max(25px, env(safe-area-inset-bottom)); | ||
padding-left: max(25px, env(safe-area-inset-left)); | ||
padding-right: max(25px, env(safe-area-inset-right)); | ||
} | ||
|
||
.background { | ||
background-color: #FFFFFF; | ||
} | ||
|
||
.icon { | ||
width: 40px; | ||
height: 40px; | ||
margin-bottom: 1em; | ||
} | ||
|
||
h1 { | ||
font-family: SFProDisplay-Medium, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-size: 22px; | ||
font-weight: 500; | ||
line-height: 28px; | ||
letter-spacing: 0.35px; | ||
text-align: left; | ||
color: #0D0F14; | ||
margin-bottom: 0px; | ||
} | ||
|
||
h2 { | ||
font-family: SFProDisplay-Medium, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-size: 17px; | ||
font-weight: 600; | ||
line-height: 22px; | ||
letter-spacing: -0.2px; | ||
text-align: left; | ||
color: #0D0F14; | ||
margin-bottom: 0px; | ||
} | ||
|
||
.description { | ||
font-family: SFProText-Regular, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-size: 15px; | ||
font-weight: 400; | ||
line-height: 20px; | ||
letter-spacing: -0.2px; | ||
text-align: left; | ||
color: #3F4855; | ||
margin-bottom: 0px; | ||
} | ||
|
||
.domain { | ||
font-size: 15px; | ||
font-weight: 400; | ||
line-height: 20px; | ||
letter-spacing: 0em; | ||
text-align: left; | ||
color: #3F4855; | ||
margin-bottom: 0px; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: column; | ||
align-content: flex-start; | ||
} | ||
|
||
/** Center the content for iPads **/ | ||
@media (min-width: 600px) and (min-height: 600px) { | ||
.icon { | ||
width: 64px; | ||
height: 64px; | ||
} | ||
|
||
h1 { | ||
font-size: 28px; | ||
font-weight: 500; | ||
line-height: 36px; | ||
letter-spacing: 0em; | ||
} | ||
|
||
h2 { | ||
font-size: 16px; | ||
line-height: 26px; | ||
} | ||
|
||
.description { | ||
font-size: 14px; | ||
line-height: 22px; | ||
letter-spacing: -0.1px; | ||
} | ||
|
||
.domain { | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 22px; | ||
letter-spacing: 0em; | ||
} | ||
|
||
.content { | ||
margin: 0; | ||
position: absolute; | ||
top: 40%; | ||
left: 50%; | ||
max-width: 650px; | ||
-ms-transform: translate(-50%, -50%); | ||
transform: translate(-50%, -50%); | ||
} | ||
} | ||
|
||
|
||
@media (prefers-color-scheme: dark) { | ||
.background { | ||
background-color: #0D0F14; | ||
} | ||
|
||
h1, h2 { | ||
color: #F6F7F8; | ||
} | ||
|
||
.description, .domain { | ||
color: #DBDEE2; | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
Sources/Brave/Frontend/Browser/Handlers/BlockedDomainHandler.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,43 @@ | ||
// 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 WebKit | ||
import Shared | ||
import BraveShared | ||
import BraveShields | ||
|
||
public class BlockedDomainHandler: InternalSchemeResponse { | ||
public static let path = InternalURL.Path.blocked.rawValue | ||
|
||
public init() {} | ||
|
||
public func response(forRequest request: URLRequest) -> (URLResponse, Data)? { | ||
guard let url = request.url, let internalURL = InternalURL(url), let originalURL = internalURL.extractedUrlParam else { return nil } | ||
let response = InternalSchemeHandler.response(forUrl: internalURL.url) | ||
|
||
guard let asset = Bundle.module.path(forResource: "BlockedDomain", ofType: "html") else { | ||
assert(false) | ||
return nil | ||
} | ||
|
||
var html = try? String(contentsOfFile: asset) | ||
.replacingOccurrences(of: "%page_title%", with: Strings.Shields.domainBlockedTitle) | ||
.replacingOccurrences(of: "%blocked_title%", with: Strings.Shields.domainBlockedPageTitle) | ||
.replacingOccurrences(of: "%blocked_subtitle%", with: Strings.Shields.domainBlockedPageMessage) | ||
.replacingOccurrences(of: "%blocked_domain%", with: originalURL.domainURL.absoluteDisplayString) | ||
.replacingOccurrences(of: "%blocked_description%", with: Strings.Shields.domainBlockedPageDescription) | ||
|
||
if #available(iOS 16.0, *) { | ||
html = html?.replacingOccurrences(of: "<html lang=\"en\">", with: "<html lang=\"\(Locale.current.language.minimalIdentifier)\">") | ||
} | ||
|
||
guard let data = html?.data(using: .utf8) else { | ||
return nil | ||
} | ||
|
||
return (response, data) | ||
} | ||
} |
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
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
Oops, something went wrong.