fix adblock plus crash

This commit is contained in:
Carmelo Messina
2023-05-02 17:52:36 +02:00
parent 049b22f404
commit 6ebd45fa3f
4 changed files with 597 additions and 574 deletions
+1 -1
View File
@@ -198,7 +198,6 @@ Add-kill-switch-for-unsupported-clangd-flags.patch
00AdblockPlus.patch
00Eyeo-Adblock-Remove-Privacy-Issues.patch
00WIN-Add-adblock-plus-setting-page.patch
00WIN-ADDTO-Eyeo-Adblock.patch
00WIN-ADDTO-Add-an-always-incognito-mode.patch
@@ -276,4 +275,5 @@ AudioBuffer-AnalyserNode-fp-mitigations.patch
00Remove-https-connection-from-chrome-discards.patch
00Add-a-flag-to-disable-GamePad-API.patch
00Disable-WebGPU.patch
00Disable-FirstPartySets-and-StorageAccessAPI.patch
00v113-temp-fix-build.patch
@@ -0,0 +1,39 @@
From: uazo <uazo@users.noreply.github.com>
Date: Tue, 2 May 2023 15:26:46 +0000
Subject: Disable FirstPartySets and StorageAccessAPI
---
components/privacy_sandbox/privacy_sandbox_prefs.cc | 2 +-
content/public/common/content_features.cc | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/privacy_sandbox/privacy_sandbox_prefs.cc b/components/privacy_sandbox/privacy_sandbox_prefs.cc
--- a/components/privacy_sandbox/privacy_sandbox_prefs.cc
+++ b/components/privacy_sandbox/privacy_sandbox_prefs.cc
@@ -147,7 +147,7 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized, false);
registry->RegisterBooleanPref(
- prefs::kPrivacySandboxFirstPartySetsEnabled, true,
+ prefs::kPrivacySandboxFirstPartySetsEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(prefs::kPrivacySandboxTopicsConsentGiven,
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -465,9 +465,9 @@ BASE_FEATURE(kWebIdentityMDocs,
base::FEATURE_DISABLED_BY_DEFAULT);
// Enables usage of First Party Sets to determine cookie availability.
-BASE_FEATURE(kFirstPartySets,
- "FirstPartySets",
- base::FEATURE_DISABLED_BY_DEFAULT);
+BASE_FEATURE(kFirstPartySets, // always
+ "FirstPartySets", // disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in bromite
// Controls whether to clear sites data on FPS transitions.
const base::FeatureParam<bool> kFirstPartySetsClearSiteDataOnChangedSets{
--
2.25.1
@@ -1,8 +1,9 @@
From: Your Name <you@example.com>
From: uazo <uazo@users.noreply.github.com>
Date: Thu, 29 Sep 2022 11:27:35 +0000
Subject: Eyeo Adblock Remove
---
Removes some functions from AdBlock Plus and adds
settings ui in Windows---
.../android/java/res/xml/main_preferences.xml | 11 +-
chrome/browser/BUILD.gn | 2 -
.../adblock/adblock_content_browser_client.cc | 17 -
@@ -11,6 +12,16 @@ Subject: Eyeo Adblock Remove
.../adblock_telemetry_service_factory.h | 56 -
.../adblock/subscription_service_factory.cc | 2 +-
...hrome_browser_main_extra_parts_profiles.cc | 2 -
chrome/browser/resources/settings/BUILD.gn | 2 +
.../settings/adblock_page/adblock_page.html | 185 +
.../settings/adblock_page/adblock_page.ts | 210 ++
.../settings/basic_page/basic_page.html | 7 +
.../settings/basic_page/basic_page.ts | 1 +
.../resources/settings/page_visibility.ts | 1 +
chrome/browser/resources/settings/route.ts | 4 +
chrome/browser/resources/settings/router.ts | 1 +
chrome/browser/resources/settings/settings.ts | 1 +
.../settings/settings_menu/settings_menu.html | 5 +
chrome/browser/ui/tab_helpers.cc | 2 +
chrome/test/BUILD.gn | 1 -
components/adblock/android/BUILD.gn | 2 +-
@@ -32,10 +43,11 @@ Subject: Eyeo Adblock Remove
.../adblock/core/common/adblock_prefs.cc | 44 +-
.../adblock/core/common/adblock_utils.cc | 23 -
.../adblock/core/converter/parser/metadata.cc | 6 +-
.../core/converter/parser/url_filter.cc | 4 +
.../adblock/core/sitekey_storage_impl.cc | 6 +
...filtering_configuration_maintainer_impl.cc | 10 -
.../filtering_configuration_maintainer_impl.h | 1 -
.../ongoing_subscription_request_impl.cc | 27 +-
.../ongoing_subscription_request_impl.cc | 31 +-
.../preloaded_subscription_provider_impl.cc | 4 +-
.../core/subscription/subscription_config.cc | 8 +-
.../subscription_downloader_impl.cc | 15 +-
@@ -53,9 +65,11 @@ Subject: Eyeo Adblock Remove
.../blink/renderer/core/css/style_engine.cc | 8 +
.../blink/renderer/core/css/style_engine.h | 1 +
.../renderer/core/exported/web_document.cc | 13 +-
50 files changed, 3290 insertions(+), 1147 deletions(-)
61 files changed, 3712 insertions(+), 1150 deletions(-)
delete mode 100644 chrome/browser/adblock/adblock_telemetry_service_factory.cc
delete mode 100644 chrome/browser/adblock/adblock_telemetry_service_factory.h
create mode 100644 chrome/browser/resources/settings/adblock_page/adblock_page.html
create mode 100644 chrome/browser/resources/settings/adblock_page/adblock_page.ts
rename components/adblock/android/java/res/xml/{adblock_preferences.xml => eyeo_adblock_preferences.xml} (100%)
delete mode 100644 components/adblock/core/activeping_telemetry_topic_provider.cc
delete mode 100644 components/adblock/core/activeping_telemetry_topic_provider.h
@@ -367,6 +381,520 @@ diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
adblock::ContentSecurityPolicyInjectorFactory::GetInstance();
adblock::ElementHiderFactory::GetInstance();
adblock::ResourceClassificationRunnerFactory::GetInstance();
diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn
--- a/chrome/browser/resources/settings/BUILD.gn
+++ b/chrome/browser/resources/settings/BUILD.gn
@@ -72,6 +72,7 @@ build_webui("build") {
"a11y_page/a11y_page.ts",
"a11y_page/live_caption_section.ts",
"about_page/about_page.ts",
+ "adblock_page/adblock_page.ts",
"appearance_page/appearance_fonts_page.ts",
"appearance_page/appearance_page.ts",
"appearance_page/home_url_input.ts",
@@ -390,6 +391,7 @@ build_webui("build") {
ts_composite = true
ts_definitions = [
"//tools/typescript/definitions/autofill_private.d.ts",
+ "//tools/typescript/definitions/adblock_private.d.ts",
"//tools/typescript/definitions/chrome_send.d.ts",
"//tools/typescript/definitions/language_settings_private.d.ts",
"//tools/typescript/definitions/management.d.ts",
diff --git a/chrome/browser/resources/settings/adblock_page/adblock_page.html b/chrome/browser/resources/settings/adblock_page/adblock_page.html
new file mode 100644
--- /dev/null
+++ b/chrome/browser/resources/settings/adblock_page/adblock_page.html
@@ -0,0 +1,185 @@
+<!--
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+-->
+
+<style include="settings-shared cr-shared-style settings-shared action-link iron-flex">
+ #languagesCollapse .list-item.selected {
+ min-height: var(--settings-row-two-line-min-height);
+ }
+</style>
+<settings-toggle-button class="hr" pref="{{prefs.adblock.enable}}"
+ on-change="onAdblockEnabled_"
+ label="Ad blocking" data-qa="adblock-toogle">
+</settings-toggle-button>
+
+<div hidden$="[[!prefs.adblock.enable.value]]">
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{recommendedSubscriptions}}" data-qa="recommended-subscriptions-menu-item">
+ <div>
+ Built in Subscriptions
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{recommendedSubscriptions}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="[[subscriptions]]">
+ <div class="list-item">
+ <cr-checkbox id="[[item.url]]" no-set-pref on-change="selectRecommendedSubscription"
+ checked="{{item.enabled}}">
+ </cr-checkbox>
+ <div class="start cr-padded-text">
+ <div data-qa="recommended-subscription-list-item">
+ [[item.title]]
+ </div>
+ </div>
+ </div>
+ </template>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{allowedDomainsOpened}}" data-qa="allowed-domains-menu-item">
+ <div>
+ Allowed Domains
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{allowedDomainsOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{allowedDomains}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="allowed-domains-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeAllowedDomain" data-qa="remove-allowed-domains-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{allowedDomainInput}}" data-qa="allowed-domains-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addAllowedDomain" data-qa="add-allowed-domains-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{customSubscriptionsOpened}}" data-qa="custom-subscriptions-menu-item">
+ <div>
+ Custom Subscriptions
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{customSubscriptionsOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{customSubscriptions}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="custom-subscriptions-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeCustomSubscription" data-qa="remove-custom-subscriptions-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{customSubscriptionInput}}" data-qa="custom-subscriptions-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addCustomSubscription" data-qa="add-custom-subscription-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{customFiltersOpened}}" data-qa="custom-filters-menu-item">
+ <div>
+ Custom Filters
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{customFiltersOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{customFilters}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="custom-filters-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeCustomFilter" data-qa="remove-custom-filter-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{customFilterInput}}" data-qa="custom-filter-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addCustomFilter" data-qa="add-custom-filter-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+
+</div>
diff --git a/chrome/browser/resources/settings/adblock_page/adblock_page.ts b/chrome/browser/resources/settings/adblock_page/adblock_page.ts
new file mode 100644
--- /dev/null
+++ b/chrome/browser/resources/settings/adblock_page/adblock_page.ts
@@ -0,0 +1,210 @@
+/*
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.js';
+import 'chrome://resources/cr_elements/cr_shared_style.css.js';
+import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
+import '../controls/controlled_button.js';
+import '../controls/settings_toggle_button.js';
+import '../settings_shared.css.js';
+
+
+import { I18nMixin } from 'chrome://resources/cr_elements/i18n_mixin.js';
+import { BaseMixin } from '../base_mixin.js';
+import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+import { SettingsToggleButtonElement } from '../controls/settings_toggle_button.js';
+import { PrefsMixin } from '../prefs/prefs_mixin.js';
+import { CrCheckboxElement } from 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js';
+import { getTemplate } from './adblock_page.html.js';
+
+
+const SettingsAdblockPageElementBase =
+ I18nMixin(PrefsMixin(BaseMixin((PolymerElement))));
+
+interface Subscription {
+ url: string;
+ title: string;
+ enabled: boolean;
+}
+
+export class SettingsAdblockPageElement extends
+ SettingsAdblockPageElementBase {
+ static get is() {
+ return 'settings-adblock-page';
+ }
+
+ static get template() {
+ return getTemplate();
+ }
+
+ // input fields updated by html
+ public customSubscriptionInput: string;
+ public customFilterInput: string;
+ public allowedDomainInput: string;
+
+ // models that will fill templates lists in html
+ public customSubscriptions: Array<string> = [];
+ public customFilters: Array<string> = [];
+ public allowedDomains: Array<string> = [];
+ public subscriptions: Subscription[] = [];
+
+ private syncSubscriptions() {
+ this.subscriptions = []
+ this.customSubscriptions = [];
+
+ chrome.adblockPrivate.getBuiltInSubscriptions(list => {
+ chrome.adblockPrivate.getInstalledSubscriptions(activelist => {
+ let new_subscriptions: Subscription[] = [];
+ let custom_subscriptions: string[] = [];
+
+ list.forEach(obj => {
+ new_subscriptions.push({
+ title: obj.title,
+ enabled: false,
+ url: obj.url
+ })
+ })
+
+ activelist.forEach(obj => {
+ var found = new_subscriptions.find(element => element.url == obj.url);
+ if (found != undefined) {
+ found.enabled = true;
+ } else {
+ custom_subscriptions.push(obj.url)
+ }
+ })
+
+ this.subscriptions = new_subscriptions;
+ this.customSubscriptions = custom_subscriptions;
+ })
+ });
+ }
+
+ private syncCustomFilters() {
+ chrome.adblockPrivate.getCustomFilters(domain => {
+ this.customFilters = [];
+ domain.forEach(value => {
+ this.customFilters.push(value);
+ })
+ });
+ }
+
+ private syncAllowedDomains() {
+ chrome.adblockPrivate.getAllowedDomains(domain => {
+ this.allowedDomains = [];
+ domain.forEach(value => {
+ this.allowedDomains.push(value);
+ })
+ });
+ }
+
+ public override ready() {
+ super.ready();
+
+ this.syncSubscriptions();
+ this.syncCustomFilters();
+ this.syncAllowedDomains();
+ }
+
+ private onAdblockEnabled_(event: Event) {
+ if ((event.target as SettingsToggleButtonElement).checked) {
+ chrome.adblockPrivate.setEnabled(true);
+ } else {
+ chrome.adblockPrivate.setEnabled(false);
+ }
+ }
+
+ private cleanUrl(url: string) : string {
+ let cleanedUrl : string = "";
+ try {
+ cleanedUrl = new URL(url).host;
+ } catch (err) {
+ try {
+ // one last try by adding schema
+ cleanedUrl = new URL("https://" + url).host;
+ }
+ catch (err) {
+ console.log("malformed url " + url);
+ }
+ }
+ return cleanedUrl;
+ }
+
+ private selectRecommendedSubscription(e: Event) {
+ const url = ((e.target as CrCheckboxElement).id);
+ const enabled = ((e.target as CrCheckboxElement).checked);
+ if (enabled) {
+ chrome.adblockPrivate.installSubscription(url);
+ } else {
+ chrome.adblockPrivate.uninstallSubscription(url);
+ }
+ }
+
+ private removeCustomFilter(e: Event) {
+ const filter = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.removeCustomFilter(filter);
+ const i = this.customFilters.indexOf(filter);
+ this.splice('customFilters', i, 1);
+ }
+
+ private addCustomFilter() {
+ if (this.customFilterInput == undefined || this.customFilterInput == "") return;
+ chrome.adblockPrivate.addCustomFilter(this.customFilterInput);
+ this.customFilterInput = "";
+ this.syncCustomFilters();
+ }
+
+ private removeAllowedDomain(e: Event) {
+ const allowedDomain = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.removeAllowedDomain(allowedDomain);
+ const i = this.allowedDomains.indexOf(allowedDomain);
+ this.splice('allowedDomains', i, 1);
+ }
+
+ private addAllowedDomain() {
+ if (this.allowedDomainInput == undefined || this.allowedDomainInput == "") return;
+ const cleanedUrl = this.cleanUrl(this.allowedDomainInput);
+ if (cleanedUrl == "") return;
+ chrome.adblockPrivate.addAllowedDomain(cleanedUrl);
+ this.allowedDomainInput = "";
+ this.syncAllowedDomains();
+ }
+
+ private removeCustomSubscription(e: Event) {
+ const subscription = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.uninstallSubscription(subscription);
+ const i = this.customSubscriptions.indexOf(subscription);
+ this.splice('customSubscriptions', i, 1);
+ }
+
+ private addCustomSubscription() {
+ if (this.customSubscriptionInput == undefined || this.customSubscriptionInput == "") return;
+ chrome.adblockPrivate.installSubscription(this.customSubscriptionInput);
+ this.customSubscriptionInput = "";
+ this.syncSubscriptions();
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'settings-adblock-page': SettingsAdblockPageElement;
+ }
+}
+
+customElements.define(
+ SettingsAdblockPageElement.is, SettingsAdblockPageElement);
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.html b/chrome/browser/resources/settings/basic_page/basic_page.html
--- a/chrome/browser/resources/settings/basic_page/basic_page.html
+++ b/chrome/browser/resources/settings/basic_page/basic_page.html
@@ -24,6 +24,13 @@
</settings-people-page>
</settings-section>
</template>
+ <template is="dom-if" if="[[showPage_(pageVisibility.adblock)]]"
+ restamp>
+ <settings-section page-title="Adblock"
+ section="adblock">
+ <settings-adblock-page prefs="{{prefs}}"></settings-adblock-page>
+ </settings-section>
+ </template>
<template is="dom-if" if="[[showPage_(pageVisibility.autofill)]]"
restamp>
<settings-section page-title="$i18n{autofillPageTitle}"
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.ts b/chrome/browser/resources/settings/basic_page/basic_page.ts
--- a/chrome/browser/resources/settings/basic_page/basic_page.ts
+++ b/chrome/browser/resources/settings/basic_page/basic_page.ts
@@ -10,6 +10,7 @@ import 'chrome://resources/cr_elements/cr_hidden_style.css.js';
import 'chrome://resources/cr_elements/cr_shared_style.css.js';
import 'chrome://resources/cr_elements/cr_shared_vars.css.js';
import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import '../adblock_page/adblock_page.js';
import '../appearance_page/appearance_page.js';
import '../privacy_page/privacy_guide/privacy_guide_promo.js';
import '../privacy_page/privacy_page.js';
diff --git a/chrome/browser/resources/settings/page_visibility.ts b/chrome/browser/resources/settings/page_visibility.ts
--- a/chrome/browser/resources/settings/page_visibility.ts
+++ b/chrome/browser/resources/settings/page_visibility.ts
@@ -9,6 +9,7 @@ import {loadTimeData} from 'chrome://resources/js/load_time_data.js';
*/
export interface PageVisibility {
a11y?: boolean;
+ adblock?: boolean;
advancedSettings?: boolean;
appearance?: boolean|AppearancePageVisibility;
autofill?: boolean;
diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts
--- a/chrome/browser/resources/settings/route.ts
+++ b/chrome/browser/resources/settings/route.ts
@@ -159,6 +159,10 @@ function createBrowserSettingsRoutes(): SettingsRoutes {
r.FONTS = r.APPEARANCE.createChild('/fonts');
}
+ if (visibility.adblock !== false) {
+ r.ADBLOCK = r.BASIC.createSection('/adblock', 'adblock');
+ }
+
if (visibility.autofill !== false) {
r.AUTOFILL = r.BASIC.createSection(
'/autofill', 'autofill', loadTimeData.getString('autofillPageTitle'));
diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts
--- a/chrome/browser/resources/settings/router.ts
+++ b/chrome/browser/resources/settings/router.ts
@@ -13,6 +13,7 @@ import {dedupingMixin, PolymerElement} from 'chrome://resources/polymer/v3_0/pol
*/
export interface SettingsRoutes {
ABOUT: Route;
+ ADBLOCK: Route;
ACCESSIBILITY: Route;
ADDRESSES: Route;
ADVANCED: Route;
diff --git a/chrome/browser/resources/settings/settings.ts b/chrome/browser/resources/settings/settings.ts
--- a/chrome/browser/resources/settings/settings.ts
+++ b/chrome/browser/resources/settings/settings.ts
@@ -25,6 +25,7 @@ export {AppearanceBrowserProxy, AppearanceBrowserProxyImpl} from './appearance_p
export {SettingsAppearancePageElement, SystemTheme} from './appearance_page/appearance_page.js';
export {HomeUrlInputElement} from './appearance_page/home_url_input.js';
export {SettingsAutofillPageElement} from './autofill_page/autofill_page.js';
+export {SettingsAdblockPageElement} from './adblock_page/adblock_page.js';
export {AccountStorageOptInStateChangedListener, CredentialsChangedListener, PasswordCheckInteraction, PasswordCheckReferrer, PasswordCheckStatusChangedListener, PasswordExceptionListChangedListener, PasswordManagerAuthTimeoutListener, PasswordManagerImpl, PasswordManagerProxy, PasswordsFileExportProgressListener, SavedPasswordListChangedListener} from './autofill_page/password_manager_proxy.js';
export {BaseMixin} from './base_mixin.js';
export {SettingsBasicPageElement} from './basic_page/basic_page.js';
diff --git a/chrome/browser/resources/settings/settings_menu/settings_menu.html b/chrome/browser/resources/settings/settings_menu/settings_menu.html
--- a/chrome/browser/resources/settings/settings_menu/settings_menu.html
+++ b/chrome/browser/resources/settings/settings_menu/settings_menu.html
@@ -138,6 +138,11 @@
$i18n{a11yPageTitle}
<paper-ripple></paper-ripple>
</a>
+ <a role="menuitem" id="adblock" href="/adblock" class="cr-nav-menu-item" hidden="[[!pageVisibility.adblock]]">
+ <iron-icon icon="settings:block"></iron-icon>
+ Adblock
+ <paper-ripple></paper-ripple>
+ </a>
<if expr="not chromeos_ash">
<a role="menuitem" id="system" href="/system" class="cr-nav-menu-item"
hidden="[[!pageVisibility.system]]">
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc
--- a/chrome/browser/ui/tab_helpers.cc
+++ b/chrome/browser/ui/tab_helpers.cc
@@ -1474,6 +2002,20 @@ diff --git a/components/adblock/core/converter/parser/metadata.cc b/components/a
<< ". Will use default value of "
<< kDefaultExpirationInterval.InDays() << " days.";
return kDefaultExpirationInterval;
diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components/adblock/core/converter/parser/url_filter.cc
--- a/components/adblock/core/converter/parser/url_filter.cc
+++ b/components/adblock/core/converter/parser/url_filter.cc
@@ -47,6 +47,10 @@ std::string SanitizePipeCharacters(std::string pattern) {
// Skip up to one trailing | characters, this is the right anchor.
bool pattern_has_right_anchor = base::EndsWith(pattern, "|");
if (pattern_has_right_anchor) {
+ if (piece.size() == 0) {
+ LOG(ERROR) << "[eyeo] Found invalid pattern string '" << pattern << "'";
+ return std::string();
+ }
piece.remove_suffix(1);
}
if (piece.find('|') == base::StringPiece::npos) {
diff --git a/components/adblock/core/sitekey_storage_impl.cc b/components/adblock/core/sitekey_storage_impl.cc
--- a/components/adblock/core/sitekey_storage_impl.cc
+++ b/components/adblock/core/sitekey_storage_impl.cc
@@ -1621,6 +2163,17 @@ diff --git a/components/adblock/core/subscription/ongoing_subscription_request_i
loader_ =
network::SimpleURLLoader::Create(std::move(request), kTrafficAnnotation);
@@ -177,9 +194,7 @@ const char* OngoingSubscriptionRequestImpl::MethodToString() const {
bool OngoingSubscriptionRequestImpl::IsConnectionAvailable(
net::NetworkChangeNotifier::ConnectionType connection_type) const {
return connection_type !=
- net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE &&
- connection_type !=
- net::NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN;
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE;
}
bool OngoingSubscriptionRequestImpl::IsStarted() const {
diff --git a/components/adblock/core/subscription/preloaded_subscription_provider_impl.cc b/components/adblock/core/subscription/preloaded_subscription_provider_impl.cc
--- a/components/adblock/core/subscription/preloaded_subscription_provider_impl.cc
+++ b/components/adblock/core/subscription/preloaded_subscription_provider_impl.cc
@@ -1,569 +0,0 @@
From: Your Name <you@example.com>
Date: Thu, 9 Mar 2023 13:39:38 +0000
Subject: WIN Add adblock plus setting page
---
chrome/browser/resources/settings/BUILD.gn | 2 +
.../settings/adblock_page/adblock_page.html | 185 ++++++++++++++++
.../settings/adblock_page/adblock_page.ts | 204 ++++++++++++++++++
.../settings/basic_page/basic_page.html | 7 +
.../settings/basic_page/basic_page.ts | 1 +
.../resources/settings/page_visibility.ts | 1 +
chrome/browser/resources/settings/route.ts | 4 +
chrome/browser/resources/settings/router.ts | 1 +
chrome/browser/resources/settings/settings.ts | 1 +
.../settings/settings_menu/settings_menu.html | 5 +
tools/typescript/definitions/adblock.d.ts | 33 +++
11 files changed, 444 insertions(+)
create mode 100644 chrome/browser/resources/settings/adblock_page/adblock_page.html
create mode 100644 chrome/browser/resources/settings/adblock_page/adblock_page.ts
create mode 100644 tools/typescript/definitions/adblock.d.ts
diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn
--- a/chrome/browser/resources/settings/BUILD.gn
+++ b/chrome/browser/resources/settings/BUILD.gn
@@ -72,6 +72,7 @@ build_webui("build") {
"a11y_page/a11y_page.ts",
"a11y_page/live_caption_section.ts",
"about_page/about_page.ts",
+ "adblock_page/adblock_page.ts",
"appearance_page/appearance_fonts_page.ts",
"appearance_page/appearance_page.ts",
"appearance_page/home_url_input.ts",
@@ -390,6 +391,7 @@ build_webui("build") {
ts_composite = true
ts_definitions = [
"//tools/typescript/definitions/autofill_private.d.ts",
+ "//tools/typescript/definitions/adblock.d.ts",
"//tools/typescript/definitions/chrome_send.d.ts",
"//tools/typescript/definitions/language_settings_private.d.ts",
"//tools/typescript/definitions/management.d.ts",
diff --git a/chrome/browser/resources/settings/adblock_page/adblock_page.html b/chrome/browser/resources/settings/adblock_page/adblock_page.html
new file mode 100644
--- /dev/null
+++ b/chrome/browser/resources/settings/adblock_page/adblock_page.html
@@ -0,0 +1,185 @@
+<!--
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+-->
+
+<style include="settings-shared cr-shared-style settings-shared action-link iron-flex">
+ #languagesCollapse .list-item.selected {
+ min-height: var(--settings-row-two-line-min-height);
+ }
+</style>
+<settings-toggle-button class="hr" pref="{{prefs.adblock.enable}}"
+ on-change="onAdblockEnabled_"
+ label="Ad blocking" data-qa="adblock-toogle">
+</settings-toggle-button>
+
+<div hidden$="[[!prefs.adblock.enable.value]]">
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{recommendedSubscriptions}}" data-qa="recommended-subscriptions-menu-item">
+ <div>
+ Built in Subscriptions
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{recommendedSubscriptions}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="[[subscriptions]]">
+ <div class="list-item">
+ <cr-checkbox id="[[item.url]]" no-set-pref on-change="selectRecommendedSubscription"
+ checked="{{item.enabled}}">
+ </cr-checkbox>
+ <div class="start cr-padded-text">
+ <div data-qa="recommended-subscription-list-item">
+ [[item.title]]
+ </div>
+ </div>
+ </div>
+ </template>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{allowedDomainsOpened}}" data-qa="allowed-domains-menu-item">
+ <div>
+ Allowed Domains
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{allowedDomainsOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{allowedDomains}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="allowed-domains-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeAllowedDomain" data-qa="remove-allowed-domains-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{allowedDomainInput}}" data-qa="allowed-domains-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addAllowedDomain" data-qa="add-allowed-domains-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{customSubscriptionsOpened}}" data-qa="custom-subscriptions-menu-item">
+ <div>
+ Custom Subscriptions
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{customSubscriptionsOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{customSubscriptions}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="custom-subscriptions-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeCustomSubscription" data-qa="remove-custom-subscriptions-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{customSubscriptionInput}}" data-qa="custom-subscriptions-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addCustomSubscription" data-qa="add-custom-subscription-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+ <div>
+ <cr-expand-button class="cr-row first" expanded="{{customFiltersOpened}}" data-qa="custom-filters-menu-item">
+ <div>
+ Custom Filters
+ </div>
+ </cr-expand-button>
+ <iron-collapse opened="{{customFiltersOpened}}">
+ <div>
+ <!-- if we want description
+ <div class="cr-row continuation">
+ <div class="cr-padded-text">
+ <span>Add or remove language lists subscriptions</span>
+ </div>
+ </div>
+ -->
+ </div>
+ <div class="list-frame vertical-list">
+ <template is="dom-repeat" items="{{customFilters}}">
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <div data-qa="custom-filters-list-item">
+ [[item]]
+ </div>
+ </div>
+ <cr-button class="button" id="[[item]]" on-click="removeCustomFilter" data-qa="remove-custom-filter-btn">
+ Remove
+ </cr-button>
+ </div>
+ </template>
+ <div class="list-item">
+ <div class="start cr-padded-text">
+ <cr-input slot="inputs" value="{{customFilterInput}}" data-qa="custom-filter-input">
+ <cr-button slot="suffix" class="action-button" id="[[item]]" on-click="addCustomFilter" data-qa="add-custom-filter-btn">
+ Add
+ </cr-button>
+ </cr-input>
+ </div>
+ </div>
+ </div>
+ </iron-collapse>
+ </div>
+
+</div>
diff --git a/chrome/browser/resources/settings/adblock_page/adblock_page.ts b/chrome/browser/resources/settings/adblock_page/adblock_page.ts
new file mode 100644
--- /dev/null
+++ b/chrome/browser/resources/settings/adblock_page/adblock_page.ts
@@ -0,0 +1,204 @@
+/*
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.js';
+import 'chrome://resources/cr_elements/cr_shared_style.css.js';
+import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
+import '../controls/controlled_button.js';
+import '../controls/settings_toggle_button.js';
+import '../settings_shared.css.js';
+
+
+import { I18nMixin } from 'chrome://resources/cr_elements/i18n_mixin.js';
+import { BaseMixin } from '../base_mixin.js';
+import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+import { SettingsToggleButtonElement } from '../controls/settings_toggle_button.js';
+import { PrefsMixin } from '../prefs/prefs_mixin.js';
+import { CrCheckboxElement } from 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js';
+import { getTemplate } from './adblock_page.html.js';
+
+
+const SettingsAdblockPageElementBase =
+ I18nMixin(PrefsMixin(BaseMixin((PolymerElement))));
+
+export class SettingsAdblockPageElement extends
+ SettingsAdblockPageElementBase {
+ static get is() {
+ return 'settings-adblock-page';
+ }
+
+ static get template() {
+ return getTemplate();
+ }
+
+ // input fields updated by html
+ public customSubscriptionInput: string;
+ public customFilterInput: string;
+ public allowedDomainInput: string;
+
+ // models that will fill templates lists in html
+ public customSubscriptions: Array<string> = [];
+ public customFilters: Array<string> = [];
+ public allowedDomains: Array<string> = [];
+ public subscriptions: chrome.adblockPrivate.Subscription[] = [];
+
+ private syncSubscriptions() {
+ this.subscriptions = []
+ this.customSubscriptions = [];
+
+ chrome.adblockPrivate.getBuiltInSubscriptions(list => {
+ chrome.adblockPrivate.getInstalledSubscriptions(activelist => {
+ let new_subscriptions: chrome.adblockPrivate.Subscription[] = [];
+ let custom_subscriptions: string[] = [];
+
+ list.forEach(obj => {
+ new_subscriptions.push({
+ title: obj.title,
+ enabled: false,
+ url: obj.url
+ })
+ })
+
+ activelist.forEach(obj => {
+ var found = new_subscriptions.find(element => element.url == obj.url);
+ if (found != undefined) {
+ found.enabled = true;
+ } else {
+ custom_subscriptions.push(obj.url)
+ }
+ })
+
+ this.subscriptions = new_subscriptions;
+ this.customSubscriptions = custom_subscriptions;
+ })
+ });
+ }
+
+ private syncCustomFilters() {
+ chrome.adblockPrivate.getCustomFilters(domain => {
+ this.customFilters = [];
+ domain.forEach(value => {
+ this.customFilters.push(value);
+ })
+ });
+ }
+
+ private syncAllowedDomains() {
+ chrome.adblockPrivate.getAllowedDomains(domain => {
+ this.allowedDomains = [];
+ domain.forEach(value => {
+ this.allowedDomains.push(value);
+ })
+ });
+ }
+
+ public override ready() {
+ super.ready();
+
+ this.syncSubscriptions();
+ this.syncCustomFilters();
+ this.syncAllowedDomains();
+ }
+
+ private onAdblockEnabled_(event: Event) {
+ if ((event.target as SettingsToggleButtonElement).checked) {
+ chrome.adblockPrivate.setEnabled(true);
+ } else {
+ chrome.adblockPrivate.setEnabled(false);
+ }
+ }
+
+ private cleanUrl(url: string) : string {
+ let cleanedUrl : string = "";
+ try {
+ cleanedUrl = new URL(url).host;
+ } catch (err) {
+ try {
+ // one last try by adding schema
+ cleanedUrl = new URL("https://" + url).host;
+ }
+ catch (err) {
+ console.log("malformed url " + url);
+ }
+ }
+ return cleanedUrl;
+ }
+
+ private selectRecommendedSubscription(e: Event) {
+ const url = ((e.target as CrCheckboxElement).id);
+ const enabled = ((e.target as CrCheckboxElement).checked);
+ if (enabled) {
+ chrome.adblockPrivate.installSubscription(url);
+ } else {
+ chrome.adblockPrivate.uninstallSubscription(url);
+ }
+ }
+
+ private removeCustomFilter(e: Event) {
+ const filter = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.removeCustomFilter(filter);
+ const i = this.customFilters.indexOf(filter);
+ this.splice('customFilters', i, 1);
+ }
+
+ private addCustomFilter() {
+ if (this.customFilterInput == undefined || this.customFilterInput == "") return;
+ chrome.adblockPrivate.addCustomFilter(this.customFilterInput);
+ this.customFilterInput = "";
+ this.syncCustomFilters();
+ }
+
+ private removeAllowedDomain(e: Event) {
+ const allowedDomain = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.removeAllowedDomain(allowedDomain);
+ const i = this.allowedDomains.indexOf(allowedDomain);
+ this.splice('allowedDomains', i, 1);
+ }
+
+ private addAllowedDomain() {
+ if (this.allowedDomainInput == undefined || this.allowedDomainInput == "") return;
+ const cleanedUrl = this.cleanUrl(this.allowedDomainInput);
+ if (cleanedUrl == "") return;
+ chrome.adblockPrivate.addAllowedDomain(cleanedUrl);
+ this.allowedDomainInput = "";
+ this.syncAllowedDomains();
+ }
+
+ private removeCustomSubscription(e: Event) {
+ const subscription = ((e.target as HTMLElement).id);
+ chrome.adblockPrivate.uninstallSubscription(subscription);
+ const i = this.customSubscriptions.indexOf(subscription);
+ this.splice('customSubscriptions', i, 1);
+ }
+
+ private addCustomSubscription() {
+ if (this.customSubscriptionInput == undefined || this.customSubscriptionInput == "") return;
+ chrome.adblockPrivate.installSubscription(this.customSubscriptionInput);
+ this.customSubscriptionInput = "";
+ this.syncSubscriptions();
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'settings-adblock-page': SettingsAdblockPageElement;
+ }
+}
+
+customElements.define(
+ SettingsAdblockPageElement.is, SettingsAdblockPageElement);
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.html b/chrome/browser/resources/settings/basic_page/basic_page.html
--- a/chrome/browser/resources/settings/basic_page/basic_page.html
+++ b/chrome/browser/resources/settings/basic_page/basic_page.html
@@ -24,6 +24,13 @@
</settings-people-page>
</settings-section>
</template>
+ <template is="dom-if" if="[[showPage_(pageVisibility.adblock)]]"
+ restamp>
+ <settings-section page-title="Adblock"
+ section="adblock">
+ <settings-adblock-page prefs="{{prefs}}"></settings-adblock-page>
+ </settings-section>
+ </template>
<template is="dom-if" if="[[showPage_(pageVisibility.autofill)]]"
restamp>
<settings-section page-title="$i18n{autofillPageTitle}"
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.ts b/chrome/browser/resources/settings/basic_page/basic_page.ts
--- a/chrome/browser/resources/settings/basic_page/basic_page.ts
+++ b/chrome/browser/resources/settings/basic_page/basic_page.ts
@@ -10,6 +10,7 @@ import 'chrome://resources/cr_elements/cr_hidden_style.css.js';
import 'chrome://resources/cr_elements/cr_shared_style.css.js';
import 'chrome://resources/cr_elements/cr_shared_vars.css.js';
import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import '../adblock_page/adblock_page.js';
import '../appearance_page/appearance_page.js';
import '../privacy_page/privacy_guide/privacy_guide_promo.js';
import '../privacy_page/privacy_page.js';
diff --git a/chrome/browser/resources/settings/page_visibility.ts b/chrome/browser/resources/settings/page_visibility.ts
--- a/chrome/browser/resources/settings/page_visibility.ts
+++ b/chrome/browser/resources/settings/page_visibility.ts
@@ -9,6 +9,7 @@ import {loadTimeData} from 'chrome://resources/js/load_time_data.js';
*/
export interface PageVisibility {
a11y?: boolean;
+ adblock?: boolean;
advancedSettings?: boolean;
appearance?: boolean|AppearancePageVisibility;
autofill?: boolean;
diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts
--- a/chrome/browser/resources/settings/route.ts
+++ b/chrome/browser/resources/settings/route.ts
@@ -159,6 +159,10 @@ function createBrowserSettingsRoutes(): SettingsRoutes {
r.FONTS = r.APPEARANCE.createChild('/fonts');
}
+ if (visibility.adblock !== false) {
+ r.ADBLOCK = r.BASIC.createSection('/adblock', 'adblock');
+ }
+
if (visibility.autofill !== false) {
r.AUTOFILL = r.BASIC.createSection(
'/autofill', 'autofill', loadTimeData.getString('autofillPageTitle'));
diff --git a/chrome/browser/resources/settings/router.ts b/chrome/browser/resources/settings/router.ts
--- a/chrome/browser/resources/settings/router.ts
+++ b/chrome/browser/resources/settings/router.ts
@@ -13,6 +13,7 @@ import {dedupingMixin, PolymerElement} from 'chrome://resources/polymer/v3_0/pol
*/
export interface SettingsRoutes {
ABOUT: Route;
+ ADBLOCK: Route;
ACCESSIBILITY: Route;
ADDRESSES: Route;
ADVANCED: Route;
diff --git a/chrome/browser/resources/settings/settings.ts b/chrome/browser/resources/settings/settings.ts
--- a/chrome/browser/resources/settings/settings.ts
+++ b/chrome/browser/resources/settings/settings.ts
@@ -25,6 +25,7 @@ export {AppearanceBrowserProxy, AppearanceBrowserProxyImpl} from './appearance_p
export {SettingsAppearancePageElement, SystemTheme} from './appearance_page/appearance_page.js';
export {HomeUrlInputElement} from './appearance_page/home_url_input.js';
export {SettingsAutofillPageElement} from './autofill_page/autofill_page.js';
+export {SettingsAdblockPageElement} from './adblock_page/adblock_page.js';
export {AccountStorageOptInStateChangedListener, CredentialsChangedListener, PasswordCheckInteraction, PasswordCheckReferrer, PasswordCheckStatusChangedListener, PasswordExceptionListChangedListener, PasswordManagerAuthTimeoutListener, PasswordManagerImpl, PasswordManagerProxy, PasswordsFileExportProgressListener, SavedPasswordListChangedListener} from './autofill_page/password_manager_proxy.js';
export {BaseMixin} from './base_mixin.js';
export {SettingsBasicPageElement} from './basic_page/basic_page.js';
diff --git a/chrome/browser/resources/settings/settings_menu/settings_menu.html b/chrome/browser/resources/settings/settings_menu/settings_menu.html
--- a/chrome/browser/resources/settings/settings_menu/settings_menu.html
+++ b/chrome/browser/resources/settings/settings_menu/settings_menu.html
@@ -138,6 +138,11 @@
$i18n{a11yPageTitle}
<paper-ripple></paper-ripple>
</a>
+ <a role="menuitem" id="adblock" href="/adblock" class="cr-nav-menu-item" hidden="[[!pageVisibility.adblock]]">
+ <iron-icon icon="settings:block"></iron-icon>
+ Adblock
+ <paper-ripple></paper-ripple>
+ </a>
<if expr="not chromeos_ash">
<a role="menuitem" id="system" href="/system" class="cr-nav-menu-item"
hidden="[[!pageVisibility.system]]">
diff --git a/tools/typescript/definitions/adblock.d.ts b/tools/typescript/definitions/adblock.d.ts
new file mode 100644
--- /dev/null
+++ b/tools/typescript/definitions/adblock.d.ts
@@ -0,0 +1,33 @@
+import {ChromeEvent} from './chrome_event.js';
+
+declare global {
+ export namespace chrome {
+ export namespace adblockPrivate {
+ export interface Subscription {
+ title: string;
+ enabled: boolean;
+ url: string;
+ }
+
+ interface SubscriptionCallback { (value: Subscription[]): void }
+ interface DomainCallback { (value: string[]): void }
+ interface CustomFilterCallback { (value: string[]): void }
+
+ export function setEnabled(enabled: boolean): void;
+
+ export function getBuiltInSubscriptions(callback: SubscriptionCallback): void;
+ export function getInstalledSubscriptions(callback: SubscriptionCallback): void;
+
+ export function installSubscription(value: string): void;
+ export function uninstallSubscription(value: string): void;
+
+ export function getAllowedDomains(callback: DomainCallback): void;
+ export function addAllowedDomain(value: string): void;
+ export function removeAllowedDomain(value: string): void;
+
+ export function getCustomFilters(callback: CustomFilterCallback): void;
+ export function addCustomFilter(value: string): void;
+ export function removeCustomFilter(value: string): void;
+ }
+ }
+}
--
2.25.1