Skip to content

Commit

Permalink
Refactored shields settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
taher authored and nullhook committed May 20, 2022
1 parent 151ab22 commit f869a5c
Show file tree
Hide file tree
Showing 22 changed files with 1,326 additions and 305 deletions.
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
15 changes: 15 additions & 0 deletions browser/resources/settings/brave_icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,18 @@
</defs>
</svg>
</iron-iconset-svg>
<iron-iconset-svg name="brave_lion" size="16">
<svg>
<defs>
<g id="refresh" viewBox="0 0 16 16">
<path d="M13.666 8c0 3.054-1.971 5.784-4.794 6.638a.667.667 0 1 1-.386-1.276c2.265-.685 3.847-2.89 3.847-5.362 0-2.318-1.353-4.2-3.403-4.963l.666 1.331a.667.667 0 1 1-1.193.597L7.07 2.299a.666.666 0 0 1 .298-.895L10.035.071a.666.666 0 1 1 .596 1.192l-1.117.558c2.483.99 4.152 3.368 4.152 6.18Zm-7.035 6.596L3.964 15.93a.665.665 0 1 1-.596-1.193l1.116-.557C2.002 13.19.333 10.813.333 8c0-3.053 1.971-5.783 4.793-6.638a.667.667 0 0 1 .388 1.276C3.248 3.325 1.666 5.53 1.666 8c0 2.32 1.354 4.204 3.404 4.965l-.667-1.333a.667.667 0 0 1 1.193-.597l1.333 2.667c.165.33.031.73-.298.894Z" />
</g>
<g id="code" viewBox="0 0 16 16">
<path d="m15.805 8.471-3.334 3.335a.665.665 0 0 1-.943 0 .666.666 0 0 1 0-.943L14.391 8l-2.863-2.86a.667.667 0 1 1 .943-.943l3.334 3.332a.665.665 0 0 1 0 .943Zm-9.166 6.387a.666.666 0 0 1-1.278-.383l4-13.333a.667.667 0 0 1 1.277.383l-4 13.333Zm-2.167-3.053a.664.664 0 0 1-.943 0L.195 8.472a.666.666 0 0 1 0-.942L3.53 4.195a.666.666 0 1 1 .943.943L1.609 8.001l2.863 2.86c.26.26.26.683 0 .944Z" />
</g>
<g id="trash-can" viewBox="0 0 16 16">
<path d="M13 4h-.727L11.07 14.745A1.429 1.429 0 0 1 9.666 16H4.333c-.71 0-1.325-.552-1.403-1.257L1.746 4H1a.667.667 0 0 1 0-1.333h3.333V2c0-1.103.897-2 2-2h1.333c1.103 0 2 .897 2 2v.667H13A.667.667 0 0 1 13 4ZM8.333 2c0-.367-.3-.667-.667-.667H6.333c-.367 0-.667.3-.667.667v.667h2.667V2ZM3.088 4l1.168 10.598c.003.026.05.069.077.069h5.333c.027 0 .076-.044.079-.07L10.932 4H3.088Z" />
</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

0 comments on commit f869a5c

Please sign in to comment.