Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved Adblock page to settings #12827

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,72 @@
Advanced view
</message>

<!-- Settings / Shields / ContentFilters -->
<message name="IDS_BRAVE_ADBLOCK_CONTENT_FILTERING_LABEL" desc="Label for Content Filtering">
Content Filtering
</message>
<message name="IDS_BRAVE_ADBLOCK_CONTENT_FILTER_LABEL_DESCRIPTION" desc="Long description describing what Content Filtering does">
Enable custom filters that block regional and language-specific trackers and Annoyances.
</message>
<message name="IDS_BRAVE_ADBLOCK_CONTENT_FILTERING_DESC" desc="Long description describing what Content Filtering does">
Enable custom filters that block regional and language-specific trackers and
<ph name="BEGIN_LINK">&lt;a target="_blank" href="$1"&gt;</ph>Annoyances<ph name="END_LINK">&lt;/a&gt;</ph>.
</message>
<message name="IDS_BRAVE_ADBLOCK_ADD_CUSTOM_FILTERS_LISTS_LABEL" desc="Label for custom filters lists section">
Add custom filter lists
</message>
<message name="IDS_BRAVE_ADBLOCK_ADD_CUSTOM_FILTERS_LISTS_DESC" desc="Description for custom filters lists section">
Add additional lists created and maintained by your trusted community.
</message>
<message name="IDS_BRAVE_ADBLOCK_ADD_CUSTOM_FILTERS_LISTS_NOTE" desc="Note for custom filters lists section">
Only subscribe to lists from entities you trust. Your browser will periodically check for list updates from the URL you enter, revealing your IP address to their server.
</message>
<message name="IDS_BRAVE_ADBLOCK_CUSTOM_FILTERS_LABEL" desc="Label for custom filters section">
Custom Filters
</message>
<message name="IDS_BRAVE_ADBLOCK_CUSTOM_FILTERS_DESC" desc="Description for custom filters section">
Get technical by adding your own specific filters, one by line, in <ph name="BEGIN_LINK">&lt;a target="_blank" href="$1"&gt;</ph>Adblock filter syntax<ph name="END_LINK">&lt;/a&gt;</ph>.
</message>
<message name="IDS_BRAVE_ADBLOCK_ADD_LISTS_BUTTON_LABEL" desc="Label for button that adds filter lists URL">
Add
</message>
<message name="IDS_BRAVE_ADBLOCK_FILTER_LISTS_TABLE_URL_HEADER" desc="List URL header label for custom filters table">
List URL
</message>
<message name="IDS_BRAVE_ADBLOCK_FILTER_LISTS_TABLE_UPDATED_HEADER" desc="Last updated header label for custom filters table">
Last updated
</message>
<message name="IDS_BRAVE_ADBLOCK_UPDATE_NOW_BUTTON_LABEL" desc="Button label to update the custom filter lists item">
Update now
</message>
<message name="IDS_BRAVE_ADBLOCK_VIEW_SOURCE_BUTTON_LABEL" desc="Button label to view custom filter lists item source">
View source
</message>
<message name="IDS_BRAVE_ADBLOCK_UNSUBSCRIBE_BUTTON_LABEL" desc="Button label to delete custom filter lists item from the table">
Unsubscribe
</message>
<message name="IDS_BRAVE_ADBLOCK_SAVE_BUTTON_LABEL" desc="Button label to save custom filters text">
Save changes
</message>
<message name="IDS_BRAVE_ADBLOCK_TRACKING_FILTERS_LABEL" desc="Title for tracking filters">
Brave's tracking filters
</message>
<message name="IDS_BRAVE_ADBLOCK_TRACKING_FILTERS_DESC" desc="Description for tracking filters section">
View the filters that come <ph name="BEGIN_LINK">&lt;a target="_blank" href="$1"&gt;</ph>enabled by default<ph name="END_LINK">&lt;/a&gt;</ph> as part of Brave Shields.
</message>
<message name="IDS_BRAVE_ADBLOCK_SUBSCRIBE_URL_DOWNLOAD_FAILED" desc="A label shown when a subscription has failed to download for the first time">
Download failed
</message>
<message name="IDS_BRAVE_ADBLOCK_SUBSCRIBE_URL_UPDATE_FAILED" desc="A label shown when a subscription has failed to download on a subsquent update">
Update failed
</message>
<message name="IDS_BRAVE_ADBLOCK_CUSTOM_LISTS_LABEL" desc="A label to indicate custom lists table">
Custom lists
</message>
<message name="IDS_BRAVE_ADBLOCK_SHOW_FULL_LISTS_BUTTON_LABEL" desc="A button label to expand full custom filter lists">
Show full lists
</message>

<!-- Settings / Brave Rewards -->
<message name="IDS_SETTINGS_BRAVE_REWARDS_TITLE" desc="The text label for the Rewards settings page">
Brave Rewards
Expand Down
6 changes: 5 additions & 1 deletion browser/resources/settings/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ preprocess_if_expr("preprocess") {
"brave_reset_page/brave_reset_profile_dialog_behavior.js",
"brave_routes.js",
"brave_sync_page/brave_sync_browser_proxy.js",
"default_brave_shields_page/brave_adblock_browser_proxy.js",
]
}

Expand Down Expand Up @@ -164,7 +165,10 @@ preprocess_if_expr("preprocess_generated") {
"brave_wallet_page/brave_wallet_page.js",
"brave_wallet_page/wallet_networks_subpage.js",
"default_brave_shields_page/default_brave_shields_browser_proxy.m.js",
"default_brave_shields_page/default_brave_shields_page.m.js",
"default_brave_shields_page/default_brave_shields_page.js",
"default_brave_shields_page/brave_adblock_subpage.js",
"default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js",
"default_brave_shields_page/components/brave_adblock_editor.js",
"getting_started_page/getting_started.js",
"social_blocking_page/social_blocking_page.m.js",
]
Expand Down
18 changes: 18 additions & 0 deletions browser/resources/settings/brave_icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,21 @@
</defs>
</svg>
</iron-iconset-svg>
<iron-iconset-svg name="brave_leo" size="24">
<svg>
<defs>
<g id="refresh" viewBox="0 0 24 24">
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.667 12c0 3.817-2.465 7.23-5.993 8.297a.833.833 0 1 1-.482-1.595C17.022 17.846 19 15.09 19 12c0-2.897-1.692-5.25-4.254-6.204l.832 1.665a.833.833 0 1 1-1.49.745L12.42 4.873a.833.833 0 0 1 .373-1.117l3.334-1.668a.832.832 0 1 1 .744 1.49l-1.395.699c3.103 1.236 5.19 4.21 5.19 7.723Zm-8.795 8.245L8.54 21.913a.832.832 0 0 1-1.118-.373.833.833 0 0 1 .373-1.117l1.394-.698C6.087 18.488 4 15.516 4 12c0-3.816 2.464-7.228 5.992-8.297a.833.833 0 0 1 .484 1.595c-2.832.858-4.81 3.614-4.81 6.702 0 2.9 1.693 5.254 4.255 6.206l-.833-1.666a.834.834 0 0 1 1.49-.746l1.667 3.334a.832.832 0 0 1-.372 1.117Z" />
</g>
<g id="code" viewBox="0 0 24 24">
<path fill-rule="evenodd" clip-rule="evenodd" d="m21.756 12.756-4.168 4.169a.83.83 0 0 1-1.178 0 .832.832 0 0 1 0-1.178l3.578-3.58-3.578-3.575a.833.833 0 1 1 1.178-1.18l4.168 4.166a.831.831 0 0 1 0 1.178ZM10.298 20.74a.832.832 0 0 1-1.596-.479l5-16.666a.833.833 0 0 1 1.597.478l-5 16.667ZM7.59 16.923a.83.83 0 0 1-1.178 0l-4.168-4.165a.833.833 0 0 1 0-1.178l4.168-4.168A.833.833 0 1 1 7.59 8.59l-3.578 3.58 3.578 3.574a.833.833 0 0 1 0 1.18Z" />
</g>
<g id="trash-can" viewBox="0 0 24 24">
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.833 7h-.908l-1.504 13.43c-.098.88-.87 1.57-1.754 1.57H9c-.887 0-1.656-.69-1.753-1.57L5.767 7h-.934a.834.834 0 0 1 0-1.667H9V4.5C9 3.122 10.122 2 11.5 2h1.667c1.378 0 2.5 1.122 2.5 2.5v.833h4.166a.834.834 0 0 1 0 1.667ZM14 4.5a.835.835 0 0 0-.833-.833H11.5a.835.835 0 0 0-.833.833v.833H14V4.5ZM7.443 7l1.461 13.247c.003.033.063.086.096.086h6.667c.033 0 .094-.054.098-.087L17.248 7H7.443Z"/>
</g>
<g id="magnifying-glass" viewBox="0 0 24 24">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.498 2a8.498 8.498 0 1 0 5.843 14.67l4.292 4.292a.8.8 0 1 0 1.131-1.132l-4.367-4.367A8.498 8.498 0 0 0 10.499 2ZM3.6 10.498a6.898 6.898 0 1 1 13.797 0 6.898 6.898 0 0 1-13.797 0Z" />
</g>
</defs>
</svg>
</iron-iconset-svg>
2 changes: 1 addition & 1 deletion browser/resources/settings/brave_overrides/basic_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import '../brave_rewards_page/brave_rewards_page.js'
import '../brave_search_engines_page/brave_search_engines_page.m.js'
import '../brave_sync_page/brave_sync_page.js'
import '../brave_wallet_page/brave_wallet_page.js'
import '../default_brave_shields_page/default_brave_shields_page.m.js'
import '../default_brave_shields_page/default_brave_shields_page.js'
import '../getting_started_page/getting_started.js'
import '../social_blocking_page/social_blocking_page.m.js'

Expand Down
1 change: 1 addition & 0 deletions browser/resources/settings/brave_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function addBraveRoutes(r) {
}
}
r.SHIELDS = r.BASIC.createSection('/shields', 'shields')
r.SHIELDS_ADBLOCK = r.SHIELDS.createChild('/shields/content-filters')
r.REWARDS = r.BASIC.createSection('/rewards', 'rewards')
r.SOCIAL_BLOCKING = r.BASIC.createSection('/socialBlocking', 'socialBlocking')
r.EXTENSIONS = r.BASIC.createSection('/extensions', 'extensions')
Expand Down
92 changes: 11 additions & 81 deletions browser/resources/settings/default_brave_shields_page/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,28 @@
# you can obtain one at http://mozilla.org/MPL/2.0/.

import("//third_party/closure_compiler/compile_js.gni")
import("//tools/polymer/html_to_js.gni")
import("//tools/polymer/polymer.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
import("../settings.gni")

# HTML Imports compatible compiles

js_type_check("closure_compile") {
deps = [
":default_brave_shields_browser_proxy",
":default_brave_shields_page",
]
}

js_library("default_brave_shields_browser_proxy") {
deps = [
"//ui/webui/resources/js:cr",
]
externs_list = [
"$externs_path/chrome_send.js",
]
}

js_library("default_brave_shields_page") {
deps = [
":default_brave_shields_browser_proxy",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
]
externs_list = [
"$externs_path/settings_private.js",
]
}

# ES Module compatible compiles

js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":default_brave_shields_browser_proxy.m",
":default_brave_shields_page.m",
]
}

js_library("default_brave_shields_browser_proxy.m") {
deps = [
"//ui/webui/resources/js:cr.m",
]
externs_list = [
"$externs_path/chrome_send.js",
]
extra_deps = [
":default_brave_shields_browser_proxy_module",
]
}

js_library("default_brave_shields_page.m") {
deps = [
":default_brave_shields_browser_proxy.m",
"//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:load_time_data.m",
]
externs_list = [
"$externs_path/settings_private.js",
]
extra_deps = [
":default_brave_shields_page_module",
]
}

# ES Module conversion from HTML Imports code

group("web_modules") {
public_deps = [
":default_brave_shields_page_module",
":default_brave_shields_browser_proxy_module",
":modules",
":templatize",
]
}

polymer_modulizer("default_brave_shields_page") {
js_file = "default_brave_shields_page.js"
html_file = "default_brave_shields_page.html"
html_type = "dom-module"
auto_imports = settings_auto_imports + [
"brave/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.html|DefaultBraveShieldsBrowserProxy, DefaultBraveShieldsBrowserProxyImpl",
]
js_modulizer("modules") {
input_files = [ "default_brave_shields_browser_proxy.js" ]
namespace_rewrites = settings_namespace_rewrites
}

js_modulizer("default_brave_shields_browser_proxy_module") {
input_files = [
"default_brave_shields_browser_proxy.js",
html_to_js("templatize") {
js_files = [
"default_brave_shields_page.js",
"brave_adblock_subpage.js",
"components/brave_adblock_subscribe_dropdown.js",
"components/brave_adblock_editor.js",
]
namespace_rewrites = settings_namespace_rewrites
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* Copyright 2022 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 http://mozilla.org/MPL/2.0/. */

import { sendWithPromise, addWebUIListener } from 'chrome://resources/js/cr.m.js';

/** @interface */
export class BraveAdblockBrowserProxy {
getInstance() { }
getRegionalLists() { }
enableFilterList() { }
getListSubscriptions() { }
getCustomFilters() { }
setSubscriptionEnabled() { }
addSubscription() { }
addWebUIListener() { }
updateSubscription() { }
deleteSubscription() { }
viewSubscription() { }
}

/**
* @implements {BraveAdblockBrowserProxy}
*/
export class BraveAdblockBrowserProxyImpl {
/** @instance */
static getInstance() {
return instance || (instance = new BraveAdblockBrowserProxyImpl());
}

/** @returns {Promise} */
getRegionalLists () {
return sendWithPromise('brave_adblock.getRegionalLists')
}

/** @returns {Promise} */
getListSubscriptions () {
return sendWithPromise('brave_adblock.getListSubscriptions')
}

/** @returns {Promise} */
getCustomFilters () {
return sendWithPromise('brave_adblock.getCustomFilters')
}

enableFilterList (uuid, enabled) {
chrome.send('brave_adblock.enableFilterList', [uuid, enabled])
}

setSubscriptionEnabled (url, enabled) {
chrome.send('brave_adblock.setSubscriptionEnabled', [url, enabled])
}

addSubscription (url) {
chrome.send('brave_adblock.addSubscription', [url])
}

updateSubscription (url) {
chrome.send('brave_adblock.updateSubscription', [url])
}

updateCustomFilters (value) {
chrome.send('brave_adblock.updateCustomFilters', [value])
}

deleteSubscription (url) {
chrome.send('brave_adblock.deleteSubscription', [url])
}

viewSubscription (url) {
chrome.send('brave_adblock.viewSubscription', [url])
}

addWebUIListener (event_name, callback) {
addWebUIListener(event_name, callback)
}
}

/** @type {BraveAdblockBrowserProxyImpl} */
let instance
Loading