From b3bae78c66f3964277937cd14729f990923a002b Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 22 Nov 2023 10:39:08 +0530 Subject: [PATCH 1/3] Checkout to main branch before sync --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 8cf54b48..cdc171e2 100755 --- a/build.sh +++ b/build.sh @@ -136,6 +136,7 @@ sync() { gclient_config if [ -d "$chromium_dir/src" ]; then cd $chromium_dir/src + git checkout main git fetch origin refs/tags/$chromium_version git reset --hard FETCH_HEAD fi -- GitLab From 841070830346a4087d69db297a83e51f069dbb01 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 22 Nov 2023 11:12:35 +0530 Subject: [PATCH 2/3] Update script options --- build.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index cdc171e2..577560c9 100755 --- a/build.sh +++ b/build.sh @@ -21,8 +21,9 @@ usage() { echo " Options:" echo " -a Build specified arch" echo " -c Clean" - echo " -h Show this message" - echo " -s Sync without history" + echo " -u Show this message" + echo " -s Sync source" + echo " -h Sync without history" echo exit 1 } @@ -176,12 +177,13 @@ init_repo(){ fi } -while getopts ":a:chr:s" opt; do +while getopts ":a:cur:sh" opt; do case $opt in a) arch="$OPTARG" ;; c) clean=1 ;; - h) usage ;; - s) gsync=1 && history=0 ;; + u) usage ;; + s) gsync=1 ;; + h) history=0 ;; :) echo "Option -$OPTARG requires an argument" echo -- GitLab From 4804e89d7a6c552846f89d6cd1007a88d2aeebf9 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 22 Nov 2023 11:49:41 +0530 Subject: [PATCH 3/3] add eyeo ad-filter from cromite --- ...Plus-add-blocking-in-service-workers.patch | 732 + ...00Eyeo-Adblock-Remove-Privacy-Issues.patch | 8192 + ...ix-eyeo-Browser-Ad-filtering-patches.patch | 146 + .../Bromite-subresource-adblocker.patch | 18 +- .../Disable-safety-check.patch | 24 +- .../eyeo-117.0.5938.0-android_api.patch | 6282 + .../eyeo-117.0.5938.0-android_settings.patch | 3625 + .../eyeo-117.0.5938.0-base.patch | 155264 +++++++++++++++ ...eyeo-117.0.5938.0-chrome_integration.patch | 8165 + .../eyeo-117.0.5938.0-extension_api.patch | 5830 + build/bromite_patches_list.txt | 9 + ...wser-Remove-some-preferences-from-UI.patch | 14 +- .../0003-Browser-fix-adblock-rebranding.patch | 25 - ...17-Browser-Rename-strings-to-browser.patch | 10 +- build/e_patches_list.txt | 1 - 15 files changed, 188280 insertions(+), 57 deletions(-) create mode 100644 build/bromite_patches/00AdblockPlus-add-blocking-in-service-workers.patch create mode 100644 build/bromite_patches/00Eyeo-Adblock-Remove-Privacy-Issues.patch create mode 100644 build/bromite_patches/00Fix-eyeo-Browser-Ad-filtering-patches.patch create mode 100644 build/bromite_patches/eyeo-117.0.5938.0-android_api.patch create mode 100644 build/bromite_patches/eyeo-117.0.5938.0-android_settings.patch create mode 100644 build/bromite_patches/eyeo-117.0.5938.0-base.patch create mode 100644 build/bromite_patches/eyeo-117.0.5938.0-chrome_integration.patch create mode 100644 build/bromite_patches/eyeo-117.0.5938.0-extension_api.patch delete mode 100644 build/e_patches/0003-Browser-fix-adblock-rebranding.patch diff --git a/build/bromite_patches/00AdblockPlus-add-blocking-in-service-workers.patch b/build/bromite_patches/00AdblockPlus-add-blocking-in-service-workers.patch new file mode 100644 index 00000000..fba22ba8 --- /dev/null +++ b/build/bromite_patches/00AdblockPlus-add-blocking-in-service-workers.patch @@ -0,0 +1,732 @@ +From: uazo +Date: Thu, 7 Sep 2023 07:25:25 +0000 +Subject: AdblockPlus add blocking in service workers + +License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html +--- + .../adblock/adblock_content_browser_client.cc | 184 ++++++++++++------ + .../adblock/adblock_content_browser_client.h | 27 ++- + .../browser/chrome_content_browser_client.cc | 6 +- + .../browser/chrome_content_browser_client.h | 6 +- + .../browser/adblock_url_loader_factory.cc | 10 +- + .../browser/adblock_url_loader_factory.h | 3 + + .../browser/frame_hierarchy_builder.cc | 3 +- + .../browser/resource_classification_runner.h | 8 + + .../resource_classification_runner_impl.cc | 30 ++- + .../resource_classification_runner_impl.h | 8 + + .../websockets/websocket_connector_impl.cc | 6 +- + .../public/browser/content_browser_client.cc | 4 +- + .../public/browser/content_browser_client.h | 4 +- + 13 files changed, 216 insertions(+), 83 deletions(-) + +diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/browser/adblock/adblock_content_browser_client.cc +--- a/chrome/browser/adblock/adblock_content_browser_client.cc ++++ b/chrome/browser/adblock/adblock_content_browser_client.cc +@@ -45,6 +45,7 @@ + #include "content/public/browser/web_contents.h" + #include "mojo/public/cpp/bindings/self_owned_receiver.h" + #include "services/network/public/mojom/websocket.mojom.h" ++#include "services/network/public/mojom/web_transport.mojom.h" + #include "services/service_manager/public/cpp/binder_registry.h" + #include "third_party/blink/public/common/loader/url_loader_throttle.h" + +@@ -58,6 +59,29 @@ + + namespace { + ++bool IsFilteringNeeded(Profile* profile, const GURL& embedder_url) { ++ DCHECK(profile); ++ ++ if(embedder_url.is_empty()) { ++ // in android can be empty because it was created by ++ // RenderFrameHostImpl::CreateSubresourceLoaderFactoriesForInitialEmptyDocument ++ return true; ++ } ++ ++ HostContentSettingsMap* settings_map = HostContentSettingsMapFactory::GetForProfile(profile); ++ if (settings_map && settings_map->GetContentSetting(embedder_url, GURL(), ContentSettingsType::ADS) ++ == CONTENT_SETTING_ALLOW) { ++ return false; ++ } ++ // Filtering may be needed if there's at least one enabled ++ // FilteringConfiguration. ++ bool ret = base::ranges::any_of( ++ adblock::SubscriptionServiceFactory::GetForBrowserContext(profile) ++ ->GetInstalledFilteringConfigurations(), ++ &adblock::FilteringConfiguration::IsEnabled); ++ return ret; ++} ++ + bool IsFilteringNeeded(content::RenderFrameHost* frame) { + if (frame) { + auto* profile = +@@ -65,17 +89,7 @@ bool IsFilteringNeeded(content::RenderFrameHost* frame) { + if (profile) { + content::RenderFrameHost* embedder = frame->GetOutermostMainFrameOrEmbedder(); + const auto& embedder_url = embedder->GetLastCommittedURL(); +- HostContentSettingsMap* settings_map = HostContentSettingsMapFactory::GetForProfile(profile); +- if (settings_map && settings_map->GetContentSetting(embedder_url, GURL(), ContentSettingsType::ADS) +- == CONTENT_SETTING_ALLOW) { +- return false; +- } +- // Filtering may be needed if there's at least one enabled +- // FilteringConfiguration. +- return base::ranges::any_of( +- adblock::SubscriptionServiceFactory::GetForBrowserContext(profile) +- ->GetInstalledFilteringConfigurations(), +- &adblock::FilteringConfiguration::IsEnabled); ++ return IsFilteringNeeded(profile, embedder_url); + } + } + return false; +@@ -90,6 +104,8 @@ class AdblockContextData : public base::SupportsUserData::Data { + + static void StartProxying( + Profile* profile, ++ content::BrowserContext* browser_context, ++ const url::Origin& request_initiator, + content::RenderFrameHost* frame, + int render_process_id, + mojo::PendingReceiver receiver, +@@ -102,8 +118,6 @@ class AdblockContextData : public base::SupportsUserData::Data { + self = new AdblockContextData(); + profile->SetUserData(kAdblockContextUserDataKey, base::WrapUnique(self)); + } +- auto* browser_context = +- content::WebContents::FromRenderFrameHost(frame)->GetBrowserContext(); + adblock::AdblockURLLoaderFactoryConfig config{ + adblock::SubscriptionServiceFactory::GetForBrowserContext( + browser_context), +@@ -115,8 +129,9 @@ class AdblockContextData : public base::SupportsUserData::Data { + browser_context)}; + auto proxy = std::make_unique( + std::move(config), ++ request_initiator.GetURL(), + content::GlobalRenderFrameHostId(render_process_id, +- frame->GetRoutingID()), ++ frame ? frame->GetRoutingID() : MSG_ROUTING_NONE), + std::move(receiver), std::move(target_factory), + embedder_support::GetUserAgent(), + base::BindOnce(&AdblockContextData::RemoveProxy, +@@ -157,47 +172,50 @@ void AdblockContentBrowserClient::ForceAdblockProxyForTesting() { + #endif + + bool AdblockContentBrowserClient::WillInterceptWebSocket( +- content::RenderFrameHost* frame) { ++ content::RenderFrameHost* frame, ++ content::RenderProcessHost* process, ++ const url::Origin& origin) { + if (IsFilteringNeeded(frame)) { + return true; ++ } else { ++ auto* browser_context = process->GetBrowserContext(); ++ auto* profile = Profile::FromBrowserContext(browser_context); ++ if (IsFilteringNeeded(profile, origin.GetURL().GetAsReferrer())) { ++ return true; ++ } + } + +- return ChromeContentBrowserClient::WillInterceptWebSocket(frame); ++ return ChromeContentBrowserClient::WillInterceptWebSocket(frame, process, origin); + } + + void AdblockContentBrowserClient::CreateWebSocket( ++ content::RenderProcessHost* process, + content::RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client) { +- if (IsFilteringNeeded(frame)) { +- CreateWebSocketInternal(frame->GetGlobalId(), std::move(factory), url, +- site_for_cookies, user_agent, +- std::move(handshake_client)); +- } else { +- DCHECK(ChromeContentBrowserClient::WillInterceptWebSocket(frame)); +- ChromeContentBrowserClient::CreateWebSocket(frame, std::move(factory), url, +- site_for_cookies, user_agent, +- std::move(handshake_client)); +- } ++ CreateWebSocketInternal(process, ++ frame ? frame->GetGlobalId() : content::GlobalRenderFrameHostId(), ++ std::move(factory), url, initiator_origin, ++ site_for_cookies, user_agent, ++ std::move(handshake_client)); + } + + void AdblockContentBrowserClient::CreateWebSocketInternal( ++ content::RenderProcessHost* process, + content::GlobalRenderFrameHostId render_frame_host_id, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client) { +- auto* frame = content::RenderFrameHost::FromID(render_frame_host_id); +- if (!frame) { +- return; +- } +- auto* browser_context = frame->GetProcess()->GetBrowserContext(); ++ auto* browser_context = process->GetBrowserContext(); + auto* subscription_service = + adblock::SubscriptionServiceFactory::GetForBrowserContext( + browser_context); +@@ -205,33 +223,33 @@ void AdblockContentBrowserClient::CreateWebSocketInternal( + adblock::ResourceClassificationRunnerFactory::GetForBrowserContext( + browser_context); + classification_runner->CheckRequestFilterMatchForWebSocket( +- subscription_service->GetCurrentSnapshot(), url, render_frame_host_id, ++ subscription_service->GetCurrentSnapshot(), url, ++ std::move(initiator_origin.GetURL().GetAsReferrer()), render_frame_host_id, + base::BindOnce( + &AdblockContentBrowserClient::OnWebSocketFilterCheckCompleted, +- weak_factory_.GetWeakPtr(), render_frame_host_id, std::move(factory), +- url, site_for_cookies, user_agent, std::move(handshake_client))); ++ weak_factory_.GetWeakPtr(), process, render_frame_host_id, std::move(factory), ++ url, initiator_origin, site_for_cookies, user_agent, std::move(handshake_client))); + } + + void AdblockContentBrowserClient::OnWebSocketFilterCheckCompleted( ++ content::RenderProcessHost* process, + content::GlobalRenderFrameHostId render_frame_host_id, + ChromeContentBrowserClient::WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client, + adblock::FilterMatchResult result) { + auto* frame = content::RenderFrameHost::FromID(render_frame_host_id); +- if (!frame) { +- return; +- } + const bool has_blocking_filter = + result == adblock::FilterMatchResult::kBlockRule; + if (!has_blocking_filter) { + VLOG(1) << "[eyeo] Web socket allowed for " << url; +- if (ChromeContentBrowserClient::WillInterceptWebSocket(frame)) { ++ if (ChromeContentBrowserClient::WillInterceptWebSocket(frame, process, initiator_origin)) { + ChromeContentBrowserClient::CreateWebSocket( +- frame, std::move(factory), url, site_for_cookies, user_agent, ++ process, frame, std::move(factory), url, initiator_origin, site_for_cookies, user_agent, + std::move(handshake_client)); + return; + } +@@ -248,6 +266,72 @@ void AdblockContentBrowserClient::OnWebSocketFilterCheckCompleted( + VLOG(1) << "[eyeo] Web socket blocked for " << url; + } + ++void AdblockContentBrowserClient::WillCreateWebTransport( ++ int process_id, ++ int frame_routing_id, ++ const GURL& url, ++ const url::Origin& initiator_origin, ++ mojo::PendingRemote ++ handshake_client, ++ WillCreateWebTransportCallback callback) { ++ auto* process = content::RenderProcessHost::FromID(process_id); ++ DCHECK(process); ++ ++ auto* browser_context = process->GetBrowserContext(); ++ auto* profile = Profile::FromBrowserContext(browser_context); ++ if (IsFilteringNeeded(profile, initiator_origin.GetURL().GetAsReferrer())) { ++ auto* subscription_service = ++ adblock::SubscriptionServiceFactory::GetForBrowserContext( ++ browser_context); ++ auto* classification_runner = ++ adblock::ResourceClassificationRunnerFactory::GetForBrowserContext( ++ browser_context); ++ ++ classification_runner->CheckRequestFilterMatchForWebTransport( ++ subscription_service->GetCurrentSnapshot(), url, ++ std::move(initiator_origin.GetURL().GetAsReferrer()), ++ content::GlobalRenderFrameHostId(), ++ base::BindOnce( ++ &AdblockContentBrowserClient::OnWebTransportFilterCheckCompleted, ++ weak_factory_.GetWeakPtr(), ++ process_id, frame_routing_id, url, ++ std::move(initiator_origin), std::move(handshake_client), ++ std::move(callback))); ++ return; ++ } ++ ++ ChromeContentBrowserClient::WillCreateWebTransport( ++ process_id, frame_routing_id, ++ url, std::move(initiator_origin), ++ std::move(handshake_client), std::move(callback)); ++} ++ ++void AdblockContentBrowserClient::OnWebTransportFilterCheckCompleted( ++ int process_id, ++ int frame_routing_id, ++ const GURL& url, ++ const url::Origin& initiator_origin, ++ mojo::PendingRemote ++ handshake_client, ++ WillCreateWebTransportCallback callback, ++ adblock::FilterMatchResult result) { ++ const bool has_blocking_filter = ++ result == adblock::FilterMatchResult::kBlockRule; ++ if (!has_blocking_filter) { ++ VLOG(1) << "[eyeo] Web transport allowed for " << url; ++ ChromeContentBrowserClient::WillCreateWebTransport( ++ process_id, frame_routing_id, ++ url, std::move(initiator_origin), ++ std::move(handshake_client), std::move(callback)); ++ return; ++ } ++ VLOG(1) << "[eyeo] Web transport blocked for " << url; ++ std::move(callback).Run(std::move(handshake_client), ++ network::mojom::WebTransportError::New( ++ net::ERR_BLOCKED_BY_ADMINISTRATOR, quic::QUIC_INTERNAL_ERROR, ++ "Blocked", false)); ++} ++ + bool AdblockContentBrowserClient::WillCreateURLLoaderFactory( + content::BrowserContext* browser_context, + content::RenderFrameHost* frame, +@@ -271,24 +355,12 @@ bool AdblockContentBrowserClient::WillCreateURLLoaderFactory( + navigation_id, ukm_source_id, factory_receiver, header_client, + bypass_redirect_checks, disable_secure_dns, factory_override, + navigation_response_task_runner); +- auto* profile = frame ? Profile::FromBrowserContext( +- frame->GetProcess()->GetBrowserContext()) +- : nullptr; +- +-#if BUILDFLAG(ENABLE_EXTENSIONS) +- if (!force_adblock_proxy_for_testing_ && +- request_initiator.scheme() == extensions::kExtensionScheme) { +- VLOG(1) << "[eyeo] Do not use adblock proxy for extensions requests " +- "[extension id:" +- << request_initiator.host() << "]."; +- return use_chrome_proxy; +- } +-#endif ++ auto* profile = Profile::FromBrowserContext(browser_context); + + bool use_adblock_proxy = +- (type == URLLoaderFactoryType::kDocumentSubResource || +- type == URLLoaderFactoryType::kNavigation) && +- IsFilteringNeeded(frame); ++ type != URLLoaderFactoryType::kDownload && ++ (frame ? IsFilteringNeeded(frame) ++ : IsFilteringNeeded(profile, request_initiator.GetURL().GetAsReferrer())); + + bool use_test_loader = false; + #ifdef EYEO_INTERCEPT_DEBUG_URL +@@ -307,7 +379,7 @@ bool AdblockContentBrowserClient::WillCreateURLLoaderFactory( + mojo::PendingRemote target_factory_remote; + *factory_receiver = target_factory_remote.InitWithNewPipeAndPassReceiver(); + AdblockContextData::StartProxying( +- profile, frame, render_process_id, std::move(proxied_receiver), ++ profile, browser_context, request_initiator, frame, render_process_id, std::move(proxied_receiver), + std::move(target_factory_remote), use_test_loader); + } + return use_adblock_proxy || use_chrome_proxy; +diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/browser/adblock/adblock_content_browser_client.h +--- a/chrome/browser/adblock/adblock_content_browser_client.h ++++ b/chrome/browser/adblock/adblock_content_browser_client.h +@@ -44,16 +44,27 @@ class AdblockContentBrowserClient : public ChromeContentBrowserClient { + static void ForceAdblockProxyForTesting(); + #endif + +- bool WillInterceptWebSocket(content::RenderFrameHost* frame) override; ++ bool WillInterceptWebSocket(content::RenderFrameHost* frame, content::RenderProcessHost* process, const url::Origin& origin) override; + void CreateWebSocket( ++ content::RenderProcessHost* process, + content::RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client) override; + ++ void WillCreateWebTransport( ++ int process_id, ++ int frame_routing_id, ++ const GURL& url, ++ const url::Origin& initiator_origin, ++ mojo::PendingRemote ++ handshake_client, ++ WillCreateWebTransportCallback callback) override; ++ + bool WillCreateURLLoaderFactory( + content::BrowserContext* browser_context, + content::RenderFrameHost* frame, +@@ -73,23 +84,35 @@ class AdblockContentBrowserClient : public ChromeContentBrowserClient { + + private: + void CreateWebSocketInternal( ++ content::RenderProcessHost* process, + content::GlobalRenderFrameHostId render_frame_host_id, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client); + void OnWebSocketFilterCheckCompleted( ++ content::RenderProcessHost* process, + content::GlobalRenderFrameHostId render_frame_host_id, + ChromeContentBrowserClient::WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote + handshake_client, + adblock::FilterMatchResult result); +- ++ void OnWebTransportFilterCheckCompleted( ++ int process_id, ++ int frame_routing_id, ++ const GURL& url, ++ const url::Origin& initiator_origin, ++ mojo::PendingRemote ++ handshake_client, ++ WillCreateWebTransportCallback callback, ++ adblock::FilterMatchResult result); + base::WeakPtrFactory weak_factory_{this}; + + #if BUILDFLAG(ENABLE_EXTENSIONS) +diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc +--- a/chrome/browser/chrome_content_browser_client.cc ++++ b/chrome/browser/chrome_content_browser_client.cc +@@ -6252,7 +6252,9 @@ ChromeContentBrowserClient:: + } + + bool ChromeContentBrowserClient::WillInterceptWebSocket( +- content::RenderFrameHost* frame) { ++ content::RenderFrameHost* frame, ++ content::RenderProcessHost* process, ++ const url::Origin& origin) { + #if BUILDFLAG(ENABLE_EXTENSIONS) + if (!frame) { + return false; +@@ -6273,9 +6275,11 @@ bool ChromeContentBrowserClient::WillInterceptWebSocket( + } + + void ChromeContentBrowserClient::CreateWebSocket( ++ content::RenderProcessHost* process, + content::RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote +diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h +--- a/chrome/browser/chrome_content_browser_client.h ++++ b/chrome/browser/chrome_content_browser_client.h +@@ -610,11 +610,15 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { + CreateURLLoaderHandlerForServiceWorkerNavigationPreload( + int frame_tree_node_id, + const network::ResourceRequest& resource_request) override; +- bool WillInterceptWebSocket(content::RenderFrameHost* frame) override; ++ bool WillInterceptWebSocket(content::RenderFrameHost* frame, ++ content::RenderProcessHost* process, ++ const url::Origin& origin) override; + void CreateWebSocket( ++ content::RenderProcessHost* process, + content::RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote +diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/components/adblock/content/browser/adblock_url_loader_factory.cc +--- a/components/adblock/content/browser/adblock_url_loader_factory.cc ++++ b/components/adblock/content/browser/adblock_url_loader_factory.cc +@@ -342,12 +342,6 @@ void AdblockURLLoaderFactory::InProgressRequest::OnRequestError( + + void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch( + CheckFilterMatchCallback callback) { +- if (!factory_->CheckHostValid()) { +- PostFilterMatchCallbackToUI(std::move(callback), +- FilterMatchResult::kNoRule); +- return; +- } +- + auto subscription_service = factory_->config_.subscription_service; + if (is_document_request_) { + auto* host = content::RenderFrameHost::FromID(factory_->host_id_); +@@ -386,7 +380,7 @@ void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch( + } else { + factory_->config_.resource_classifier->CheckRequestFilterMatch( + subscription_service->GetCurrentSnapshot(), request_url_, +- adblock_resource_type_, factory_->host_id_, ++ factory_->request_initiator_, adblock_resource_type_, factory_->host_id_, + base::BindOnce( + &AdblockURLLoaderFactory::InProgressRequest::OnRequestUrlClassified, + weak_factory_.GetWeakPtr(), +@@ -675,12 +669,14 @@ void AdblockURLLoaderFactory::InProgressRequest::OnRequestFilterMatchResult( + + AdblockURLLoaderFactory::AdblockURLLoaderFactory( + AdblockURLLoaderFactoryConfig config, ++ GURL request_initiator, + content::GlobalRenderFrameHostId host_id, + mojo::PendingReceiver receiver, + mojo::PendingRemote target_factory, + std::string user_agent_string, + DisconnectCallback on_disconnect) + : config_(std::move(config)), ++ request_initiator_(std::move(request_initiator)), + host_id_(host_id), + user_agent_string_(std::move(user_agent_string)), + on_disconnect_(std::move(on_disconnect)) { +diff --git a/components/adblock/content/browser/adblock_url_loader_factory.h b/components/adblock/content/browser/adblock_url_loader_factory.h +--- a/components/adblock/content/browser/adblock_url_loader_factory.h ++++ b/components/adblock/content/browser/adblock_url_loader_factory.h +@@ -25,6 +25,7 @@ + #include "mojo/public/cpp/bindings/receiver_set.h" + #include "mojo/public/cpp/bindings/remote.h" + #include "services/network/public/mojom/url_loader_factory.mojom.h" ++#include "url/gurl.h" + + namespace adblock { + +@@ -49,6 +50,7 @@ class AdblockURLLoaderFactory : public network::mojom::URLLoaderFactory { + + AdblockURLLoaderFactory( + AdblockURLLoaderFactoryConfig config, ++ GURL request_initiator, + content::GlobalRenderFrameHostId host_id, + mojo::PendingReceiver receiver, + mojo::PendingRemote target_factory, +@@ -78,6 +80,7 @@ class AdblockURLLoaderFactory : public network::mojom::URLLoaderFactory { + void MaybeDestroySelf(); + + AdblockURLLoaderFactoryConfig config_; ++ const GURL request_initiator_; + content::GlobalRenderFrameHostId host_id_; + mojo::ReceiverSet proxy_receivers_; + std::set, base::UniquePtrComparator> +diff --git a/components/adblock/content/browser/frame_hierarchy_builder.cc b/components/adblock/content/browser/frame_hierarchy_builder.cc +--- a/components/adblock/content/browser/frame_hierarchy_builder.cc ++++ b/components/adblock/content/browser/frame_hierarchy_builder.cc +@@ -76,9 +76,8 @@ std::vector FrameHierarchyBuilder::BuildFrameHierarchy( + content::RenderFrameHost* host) const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + +- DCHECK(host) << "RenderFrameHost is needed to build frame hierarchy"; +- + std::vector referrers_chain; ++ if (!host) return referrers_chain; + for (auto* iter = host; iter; iter = iter->GetParent()) { + auto last_commited_referrer = GetUrlAsReferrer(iter); + if (IsValidForFrameHierarchy(last_commited_referrer)) { +diff --git a/components/adblock/content/browser/resource_classification_runner.h b/components/adblock/content/browser/resource_classification_runner.h +--- a/components/adblock/content/browser/resource_classification_runner.h ++++ b/components/adblock/content/browser/resource_classification_runner.h +@@ -81,14 +81,22 @@ class ResourceClassificationRunner : public KeyedService { + virtual void CheckRequestFilterMatch( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + ContentType adblock_resource_type, + content::GlobalRenderFrameHostId render_frame_host_id, + CheckFilterMatchCallback callback) = 0; + virtual void CheckRequestFilterMatchForWebSocket( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + content::GlobalRenderFrameHostId render_frame_host_id, + CheckFilterMatchCallback callback) = 0; ++ virtual void CheckRequestFilterMatchForWebTransport( ++ SubscriptionService::Snapshot subscription_collections, ++ const GURL& request_url, ++ const GURL& request_initiator, ++ content::GlobalRenderFrameHostId render_frame_host_id, ++ CheckFilterMatchCallback callback); + // No callback, just notify observers + virtual void CheckDocumentAllowlisted( + SubscriptionService::Snapshot subscription_collection, +diff --git a/components/adblock/content/browser/resource_classification_runner_impl.cc b/components/adblock/content/browser/resource_classification_runner_impl.cc +--- a/components/adblock/content/browser/resource_classification_runner_impl.cc ++++ b/components/adblock/content/browser/resource_classification_runner_impl.cc +@@ -169,15 +169,28 @@ void ResourceClassificationRunnerImpl::CheckPopupFilterMatch( + void ResourceClassificationRunnerImpl::CheckRequestFilterMatchForWebSocket( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + content::GlobalRenderFrameHostId render_frame_host_id, + CheckFilterMatchCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(request_url.SchemeIsWSOrWSS()); +- CheckRequestFilterMatch(std::move(subscription_collections), request_url, ++ CheckRequestFilterMatch(std::move(subscription_collections), request_url, request_initiator, + ContentType::Websocket, render_frame_host_id, + std::move(callback)); + } + ++void ResourceClassificationRunnerImpl::CheckRequestFilterMatchForWebTransport( ++ SubscriptionService::Snapshot subscription_collections, ++ const GURL& request_url, ++ const GURL& request_initiator, ++ content::GlobalRenderFrameHostId render_frame_host_id, ++ CheckFilterMatchCallback callback) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); ++ CheckRequestFilterMatch(std::move(subscription_collections), request_url, request_initiator, ++ ContentType::Other, render_frame_host_id, ++ std::move(callback)); ++} ++ + void ResourceClassificationRunnerImpl::CheckDocumentAllowlisted( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, +@@ -212,6 +225,7 @@ void ResourceClassificationRunnerImpl::ProcessDocumentAllowlistedResponse( + void ResourceClassificationRunnerImpl::CheckRequestFilterMatch( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + ContentType adblock_resource_type, + content::GlobalRenderFrameHostId frame_host_id, + CheckFilterMatchCallback callback) { +@@ -220,14 +234,10 @@ void ResourceClassificationRunnerImpl::CheckRequestFilterMatch( + DVLOG(1) << "[eyeo] CheckRequestFilterMatchImpl for " << request_url.spec(); + + auto* host = content::RenderFrameHost::FromID(frame_host_id); +- if (!host) { +- // Host has died, likely because this is a deferred execution. It does not +- // matter anymore whether the resource is blocked, the page is gone. +- std::move(callback).Run(FilterMatchResult::kNoRule); +- return; +- } +- const std::vector frame_hierarchy_chain = ++ std::vector frame_hierarchy_chain = + frame_hierarchy_builder_->BuildFrameHierarchy(host); ++ if (!host && frame_hierarchy_chain.size() == 0) ++ frame_hierarchy_chain.emplace_back(request_initiator.GetAsReferrer()); + + DVLOG(1) << "[eyeo] Got " << frame_hierarchy_chain.size() + << " frame_hierarchy for " << request_url.spec(); +@@ -275,7 +285,8 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal( + adblock_resource_type, sitekey); + + if (classification_result.decision == ClassificationDecision::Allowed) { +- VLOG(1) << "[eyeo] Document allowed due to allowing filter " << request_url; ++ VLOG(1) << "[eyeo] Document allowed due to allowing filter " << request_url ++ << " " << classification_result.decisive_subscription.spec(); + return CheckResourceFilterMatchResult{ + FilterMatchResult::kAllowRule, + classification_result.decisive_subscription, +@@ -290,6 +301,7 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal( + classification_result.decisive_configuration_name}; + } + ++ VLOG(1) << "[eyeo] No Rule for " << request_url; + return CheckResourceFilterMatchResult{FilterMatchResult::kNoRule, {}, {}}; + } + +diff --git a/components/adblock/content/browser/resource_classification_runner_impl.h b/components/adblock/content/browser/resource_classification_runner_impl.h +--- a/components/adblock/content/browser/resource_classification_runner_impl.h ++++ b/components/adblock/content/browser/resource_classification_runner_impl.h +@@ -55,12 +55,14 @@ class ResourceClassificationRunnerImpl final + void CheckRequestFilterMatch( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + ContentType adblock_resource_type, + content::GlobalRenderFrameHostId render_frame_host_id, + CheckFilterMatchCallback callback) final; + void CheckRequestFilterMatchForWebSocket( + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, ++ const GURL& request_initiator, + content::GlobalRenderFrameHostId render_frame_host_id, + CheckFilterMatchCallback callback) final; + // No callback, just notify observers +@@ -68,6 +70,12 @@ class ResourceClassificationRunnerImpl final + SubscriptionService::Snapshot subscription_collections, + const GURL& request_url, + content::GlobalRenderFrameHostId render_frame_host_id) final; ++ void CheckRequestFilterMatchForWebTransport( ++ SubscriptionService::Snapshot subscription_collections, ++ const GURL& request_url, ++ const GURL& request_initiator, ++ content::GlobalRenderFrameHostId render_frame_host_id, ++ CheckFilterMatchCallback callback) final; + void CheckResponseFilterMatch( + SubscriptionService::Snapshot subscription_collections, + const GURL& response_url, +diff --git a/content/browser/websockets/websocket_connector_impl.cc b/content/browser/websockets/websocket_connector_impl.cc +--- a/content/browser/websockets/websocket_connector_impl.cc ++++ b/content/browser/websockets/websocket_connector_impl.cc +@@ -87,14 +87,14 @@ void WebSocketConnectorImpl::Connect( + const uint32_t options = + GetContentClient()->browser()->GetWebSocketOptions(frame); + +- if (GetContentClient()->browser()->WillInterceptWebSocket(frame)) { ++ if (GetContentClient()->browser()->WillInterceptWebSocket(frame, process, origin_)) { + GetContentClient()->browser()->CreateWebSocket( +- frame, ++ process, frame, + base::BindOnce(ConnectCalledByContentBrowserClient, requested_protocols, + site_for_cookies, isolation_info_, process_id_, + frame_id_, origin_, options, + std::move(throttling_profile_id)), +- url, site_for_cookies, user_agent, std::move(handshake_client)); ++ url, origin_, site_for_cookies, user_agent, std::move(handshake_client)); + return; + } + std::vector headers; +diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc +--- a/content/public/browser/content_browser_client.cc ++++ b/content/public/browser/content_browser_client.cc +@@ -967,7 +967,7 @@ bool ContentBrowserClient::WillCreateURLLoaderFactory( + return false; + } + +-bool ContentBrowserClient::WillInterceptWebSocket(RenderFrameHost*) { ++bool ContentBrowserClient::WillInterceptWebSocket(RenderFrameHost*, RenderProcessHost*, const url::Origin& origin) { + return false; + } + +@@ -976,9 +976,11 @@ uint32_t ContentBrowserClient::GetWebSocketOptions(RenderFrameHost* frame) { + } + + void ContentBrowserClient::CreateWebSocket( ++ RenderProcessHost* process, + RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote +diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h +--- a/content/public/browser/content_browser_client.h ++++ b/content/public/browser/content_browser_client.h +@@ -1746,7 +1746,7 @@ class CONTENT_EXPORT ContentBrowserClient { + scoped_refptr navigation_response_task_runner); + + // Returns true when the embedder wants to intercept a websocket connection. +- virtual bool WillInterceptWebSocket(RenderFrameHost* frame); ++ virtual bool WillInterceptWebSocket(RenderFrameHost* frame, RenderProcessHost* process, const url::Origin& origin); + + // Returns the WebSocket creation options. + virtual uint32_t GetWebSocketOptions(RenderFrameHost* frame); +@@ -1768,9 +1768,11 @@ class CONTENT_EXPORT ContentBrowserClient { + // Always called on the UI thread and only when the Network Service is + // enabled. + virtual void CreateWebSocket( ++ RenderProcessHost* process, + RenderFrameHost* frame, + WebSocketFactory factory, + const GURL& url, ++ const url::Origin& initiator_origin, + const net::SiteForCookies& site_for_cookies, + const absl::optional& user_agent, + mojo::PendingRemote +-- +2.25.1 diff --git a/build/bromite_patches/00Eyeo-Adblock-Remove-Privacy-Issues.patch b/build/bromite_patches/00Eyeo-Adblock-Remove-Privacy-Issues.patch new file mode 100644 index 00000000..ae26bf09 --- /dev/null +++ b/build/bromite_patches/00Eyeo-Adblock-Remove-Privacy-Issues.patch @@ -0,0 +1,8192 @@ +From: uazo +Date: Thu, 29 Sep 2022 11:27:35 +0000 +Subject: Eyeo Adblock for Bromite + +Change the normal behaviour of Eyeo Chromium SDK to +suit Bromite logic +--- + .../android/java/res/xml/main_preferences.xml | 19 +- + chrome/browser/BUILD.gn | 2 - + .../adblock/adblock_content_browser_client.cc | 26 +- + chrome/browser/android/adblock/adblock_jni.cc | 50 +- + .../adblock_private/adblock_private_api.cc | 66 +- + .../api/adblock_private/adblock_private_api.h | 49 + + .../eyeo_filtering_private_api.cc | 20 +- + ...hrome_browser_main_extra_parts_profiles.cc | 2 - + chrome/browser/resources/settings/BUILD.gn | 2 + + .../settings/adblock_page/adblock_page.html | 207 + + .../settings/adblock_page/adblock_page.ts | 286 ++ + .../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 | 6 +- + .../extensions/api/_permission_features.json | 8 - + .../common/extensions/api/adblock_private.idl | 8 + + chrome/test/BUILD.gn | 5 - + components/adblock/android/BUILD.gn | 4 +- + .../adblock/android/adblock_strings.grd | 54 +- + .../java/res/layout/adblock_custom_item.xml | 14 +- + .../layout/adblock_filter_lists_list_item.xml | 15 + + ...ences.xml => eyeo_adblock_preferences.xml} | 39 +- + .../components/adblock/AdblockController.java | 56 +- + .../AdblockAllowedDomainsFragment.java | 7 +- + .../AdblockCustomFilterListsFragment.java | 32 +- + .../AdblockCustomFiltersFragment.java | 7 +- + .../settings/AdblockCustomItemFragment.java | 20 +- + .../settings/AdblockFilterListsAdapter.java | 6 + + .../settings/AdblockSettingsFragment.java | 45 +- + components/adblock/content/browser/BUILD.gn | 18 +- + .../adblock_controller_factory_base.cc | 5 +- + .../browser/adblock_webcontents_observer.cc | 25 +- + .../browser/adblock_webcontents_observer.h | 5 +- + .../content_security_policy_injector_impl.cc | 1 + + .../subscription_service_factory_base.cc | 11 +- + .../subscription_service_factory_base.h | 1 + + components/adblock/core/BUILD.gn | 39 - + .../activeping_telemetry_topic_provider.cc | 243 -- + .../activeping_telemetry_topic_provider.h | 84 - + components/adblock/core/adblock_controller.h | 8 + + .../adblock/core/adblock_controller_impl.cc | 58 +- + .../adblock/core/adblock_controller_impl.h | 7 + + components/adblock/core/adblock_switches.cc | 1 - + components/adblock/core/adblock_switches.h | 1 - + .../adblock/core/adblock_telemetry_service.cc | 244 -- + .../adblock/core/adblock_telemetry_service.h | 107 - + components/adblock/core/common/BUILD.gn | 8 - + .../adblock/core/common/adblock_constants.cc | 2 - + .../adblock/core/common/adblock_constants.h | 1 - + .../adblock/core/common/adblock_prefs.cc | 47 +- + .../adblock/core/common/adblock_prefs.h | 1 + + .../adblock/core/common/adblock_utils.cc | 23 - + .../configuration/filtering_configuration.h | 3 + + .../persistent_filtering_configuration.cc | 10 + + .../persistent_filtering_configuration.h | 3 + + .../core/converter/flatbuffer_converter.cc | 2 +- + .../adblock/core/converter/parser/metadata.cc | 10 +- + .../core/converter/parser/test/test_rules.txt | 21 + + .../core/converter/parser/url_filter.cc | 10 +- + .../converter/parser/url_filter_options.cc | 21 +- + .../serializer/flatbuffer_serializer.cc | 75 +- + .../adblock/core/sitekey_storage_impl.cc | 7 + + .../core/subscription/conversion_executors.h | 1 + + .../filtering_configuration_maintainer.h | 4 + + ...filtering_configuration_maintainer_impl.cc | 31 +- + .../filtering_configuration_maintainer_impl.h | 4 +- + .../ongoing_subscription_request_impl.cc | 33 +- + .../preloaded_subscription_provider_impl.cc | 4 +- + .../adblock/core/subscription/subscription.cc | 19 + + .../adblock/core/subscription/subscription.h | 3 + + .../subscription_collection_impl.cc | 1 + + .../core/subscription/subscription_config.cc | 20 +- + .../core/subscription/subscription_config.h | 6 +- + .../subscription_downloader_impl.cc | 21 +- + .../subscription_persistent_metadata.h | 1 + + .../subscription_persistent_metadata_impl.cc | 7 + + .../subscription_persistent_metadata_impl.h | 1 + + .../subscription_persistent_storage_impl.cc | 11 +- + .../core/subscription/subscription_service.h | 3 + + .../subscription/subscription_service_impl.cc | 23 +- + .../subscription/subscription_service_impl.h | 3 + + .../subscription/subscription_updater_impl.cc | 8 +- + .../subscription_validator_impl.cc | 4 +- + .../browser/bromite_content_settings/ads.inc | 3 + + components/resources/BUILD.gn | 1 - + components/resources/adblock_resources.grdp | 3 - + components/resources/adblocking/.gitignore | 2 +- + components/resources/adblocking/BUILD.gn | 30 +- + .../adblocking/elemhide_for_selector.jst | 2 +- + .../resources/adblocking/elemhideemu.jst | 2 + + .../snippets/dist/isolated-first.jst | 65 + + .../snippets/dist/isolated-first.source.jst | 3624 +++++++++++++++++ + .../blink/renderer/core/css/style_engine.cc | 8 + + .../blink/renderer/core/css/style_engine.h | 1 + + .../renderer/core/exported/web_document.cc | 13 +- + tools/gritsettings/resource_ids.spec | 9 +- + .../definitions/adblock_private.d.ts | 14 + + 102 files changed, 5079 insertions(+), 1083 deletions(-) + 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} (56%) + delete mode 100644 components/adblock/core/activeping_telemetry_topic_provider.cc + delete mode 100644 components/adblock/core/activeping_telemetry_topic_provider.h + delete mode 100644 components/adblock/core/adblock_telemetry_service.cc + delete mode 100644 components/adblock/core/adblock_telemetry_service.h + create mode 100644 components/adblock/core/converter/parser/test/test_rules.txt + create mode 100644 components/content_settings/core/browser/bromite_content_settings/ads.inc + create mode 100755 components/resources/adblocking/snippets/dist/isolated-first.jst + create mode 100755 components/resources/adblocking/snippets/dist/isolated-first.source.jst + +diff --git a/chrome/android/java/res/xml/main_preferences.xml b/chrome/android/java/res/xml/main_preferences.xml +--- a/chrome/android/java/res/xml/main_preferences.xml ++++ b/chrome/android/java/res/xml/main_preferences.xml +@@ -1,13 +1,4 @@ + +- +- + +@@ -75,6 +66,11 @@ Use of this source code is governed by the GPLv3 that can be found in the compon + android:key="safety_check" + android:order="12" + android:title="@string/prefs_safety_check"/> ++ + +- + GetProcess()->GetBrowserContext()); + if (profile) { ++ content::RenderFrameHost* embedder = frame->GetOutermostMainFrameOrEmbedder(); ++ const auto& embedder_url = embedder->GetLastCommittedURL(); ++ HostContentSettingsMap* settings_map = HostContentSettingsMapFactory::GetForProfile(profile); ++ if (settings_map && settings_map->GetContentSetting(embedder_url, GURL(), ContentSettingsType::ADS) ++ == CONTENT_SETTING_ALLOW) { ++ return false; ++ } + // Filtering may be needed if there's at least one enabled + // FilteringConfiguration. + return base::ranges::any_of( +@@ -104,23 +113,6 @@ class AdblockContextData : public base::SupportsUserData::Data { + adblock::SitekeyStorageFactory::GetForBrowserContext(browser_context), + adblock::ContentSecurityPolicyInjectorFactory::GetForBrowserContext( + browser_context)}; +-#ifdef EYEO_INTERCEPT_DEBUG_URL +- if (use_test_loader) { +- auto proxy = std::make_unique( +- std::move(config), +- content::GlobalRenderFrameHostId(render_process_id, +- frame->GetRoutingID()), +- std::move(receiver), std::move(target_factory), +- embedder_support::GetUserAgent(), +- base::BindOnce(&AdblockContextData::RemoveProxy, +- self->weak_factory_.GetWeakPtr()), +- adblock::AdblockControllerFactory::GetForBrowserContext( +- Profile::FromBrowserContext( +- frame->GetProcess()->GetBrowserContext()))); +- self->proxies_.emplace(std::move(proxy)); +- return; +- } +-#endif + auto proxy = std::make_unique( + std::move(config), + content::GlobalRenderFrameHostId(render_process_id, +diff --git a/chrome/browser/android/adblock/adblock_jni.cc b/chrome/browser/android/adblock/adblock_jni.cc +--- a/chrome/browser/android/adblock/adblock_jni.cc ++++ b/chrome/browser/android/adblock/adblock_jni.cc +@@ -24,6 +24,7 @@ + #include "base/android/jni_array.h" + #include "base/android/jni_string.h" + #include "base/android/jni_weak_ref.h" ++#include "base/time/time_to_iso8601.h" + #include "base/logging.h" + #include "chrome/browser/adblock/adblock_controller_factory.h" + #include "chrome/browser/android/adblock/adblock_jni_factory.h" +@@ -71,6 +72,10 @@ ScopedJavaLocalRef ToJava(JNIEnv* env, + const std::string& url, + const std::string& title, + const std::string& version, ++ adblock::Subscription::InstallationState state, ++ const std::string& installation_time, ++ long download_success_count, ++ long download_error_count, + const std::vector& languages) { + ScopedJavaLocalRef url_param( + env, env->NewObject(url_class.obj(), url_constructor, +@@ -79,12 +84,19 @@ ScopedJavaLocalRef ToJava(JNIEnv* env, + return Java_Subscription_Constructor(env, url_param, + ConvertUTF8ToJavaString(env, title), + ConvertUTF8ToJavaString(env, version), ++ ConvertUTF8ToJavaString(env, Subscription::SubscriptionInstallationStateToString(state)), ++ ConvertUTF8ToJavaString(env, installation_time), ++ download_success_count, ++ download_error_count, + ToJavaArrayOfStrings(env, languages)); + } + + std::vector> CSubscriptionsToJObjects( + JNIEnv* env, + const std::vector>& subscriptions) { ++ auto* controller = adblock::GetController(); ++ raw_ptr metadata = ++ controller->GetMetadata(); + ScopedJavaLocalRef url_class = GetClass(env, "java/net/URL"); + jmethodID url_constructor = MethodID::Get( + env, url_class.obj(), "", "(Ljava/lang/String;)V"); +@@ -93,7 +105,11 @@ std::vector> CSubscriptionsToJObjects( + for (auto& sub : subscriptions) { + jobjects.push_back(ToJava( + env, url_class, url_constructor, sub->GetSourceUrl().spec(), +- sub->GetTitle(), sub->GetCurrentVersion(), std::vector{})); ++ sub->GetTitle(), sub->GetCurrentVersion(), ++ sub->GetInstallationState(), base::TimeToISO8601(sub->GetInstallationTime()), ++ metadata ? metadata->GetDownloadSuccessCount(sub->GetSourceUrl()) : 0, ++ metadata ? metadata->GetDownloadErrorCount(sub->GetSourceUrl()) : 0, ++ std::vector{})); + } + return jobjects; + } +@@ -113,6 +129,9 @@ std::vector> CSubscriptionsToJObjects( + if (sub.url.is_valid()) { + jobjects.push_back(ToJava(env, url_class, url_constructor, + sub.url.spec(), sub.title, "", ++ adblock::Subscription::InstallationState::Unknown, ++ /*installation_time*/ "", ++ /*download_success_count*/ 0, /*download_error_count*/ 0, + sub.languages)); + } + } +@@ -167,6 +186,35 @@ static void JNI_AdblockController_Bind( + adblock::GetJNI()->Bind(weak_controller_ref); + } + ++static void ++JNI_AdblockController_StartUpdate(JNIEnv* env) { ++ adblock::GetController()->StartUpdate(); ++} ++ ++static base::android::ScopedJavaLocalRef ++JNI_AdblockController_GetCustomSubscriptions(JNIEnv* env) { ++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); ++ if (!adblock::GetController()) { ++ return ToJavaArrayOfObjects(env, ++ std::vector>{}); ++ } ++ ++ return ToJavaArrayOfObjects( ++ env, adblock::CSubscriptionsToJObjects( ++ env, adblock::GetController()->GetCustomSubscriptions())); ++} ++ ++static jboolean JNI_AdblockController_IsPrivilegedFiltersEnabled( ++ JNIEnv* env) { ++ return adblock::GetController()->IsPrivilegedFiltersEnabled() ? JNI_TRUE : JNI_FALSE; ++} ++ ++static void JNI_AdblockController_SetPrivilegedFiltersEnabled( ++ JNIEnv* env, ++ jboolean j_enabled) { ++ adblock::GetController()->SetPrivilegedFiltersEnabled(j_enabled == JNI_TRUE); ++} ++ + static base::android::ScopedJavaLocalRef + JNI_AdblockController_GetInstalledSubscriptions(JNIEnv* env) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); +diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.cc b/chrome/browser/extensions/api/adblock_private/adblock_private_api.cc +--- a/chrome/browser/extensions/api/adblock_private/adblock_private_api.cc ++++ b/chrome/browser/extensions/api/adblock_private/adblock_private_api.cc +@@ -75,26 +75,12 @@ std::vector CopySessionsStats( + return result; + } + +-std::string SubscriptionInstallationStateToString( +- adblock::Subscription::InstallationState state) { +- using State = adblock::Subscription::InstallationState; +- switch (state) { +- case State::Installed: +- return "Installed"; +- case State::Installing: +- return "Installing"; +- case State::Preloaded: +- return "Preloaded"; +- case State::Unknown: +- return "Unknown"; +- } +- NOTREACHED(); +- return ""; +-} +- + std::vector CopySubscriptions( ++ raw_ptr controller, + const std::vector> + current_subscriptions) { ++ raw_ptr metadata = ++ controller->GetMetadata(); + std::vector result; + for (auto& sub : current_subscriptions) { + api::adblock_private::Subscription js_sub; +@@ -102,9 +88,13 @@ std::vector CopySubscriptions( + js_sub.title = sub->GetTitle(); + js_sub.current_version = sub->GetCurrentVersion(); + js_sub.installation_state = +- SubscriptionInstallationStateToString(sub->GetInstallationState()); ++ adblock::Subscription::SubscriptionInstallationStateToString(sub->GetInstallationState()); + js_sub.last_installation_time = + base::TimeToISO8601(sub->GetInstallationTime()); ++ if (metadata) { ++ js_sub.download_success_count = metadata->GetDownloadSuccessCount(sub->GetSourceUrl()); ++ js_sub.download_error_count = metadata->GetDownloadErrorCount(sub->GetSourceUrl()); ++ } + result.emplace_back(std::move(js_sub)); + } + return result; +@@ -345,6 +335,44 @@ void AdblockPrivateAPI::OnListenerAdded( + + namespace api { + ++AdblockPrivateStartUpdateFunction::AdblockPrivateStartUpdateFunction() {} ++ ++AdblockPrivateStartUpdateFunction::~AdblockPrivateStartUpdateFunction() {} ++ ++ExtensionFunction::ResponseAction AdblockPrivateStartUpdateFunction::Run() { ++ auto* controller = adblock::AdblockControllerFactory::GetForBrowserContext( ++ browser_context()); ++ controller->StartUpdate(); ++ return RespondNow(NoArguments()); ++} ++ ++AdblockPrivateSetPrivilegedFiltersEnabledFunction::AdblockPrivateSetPrivilegedFiltersEnabledFunction() {} ++ ++AdblockPrivateSetPrivilegedFiltersEnabledFunction::~AdblockPrivateSetPrivilegedFiltersEnabledFunction() {} ++ ++ExtensionFunction::ResponseAction AdblockPrivateSetPrivilegedFiltersEnabledFunction::Run() { ++ absl::optional params = ++ api::adblock_private::SetEnabled::Params::Create(args()); ++ EXTENSION_FUNCTION_VALIDATE(params); ++ ++ auto* controller = adblock::AdblockControllerFactory::GetForBrowserContext( ++ browser_context()); ++ controller->SetPrivilegedFiltersEnabled(params->enabled); ++ return RespondNow(NoArguments()); ++} ++ ++AdblockPrivateIsPrivilegedFiltersEnabledFunction::AdblockPrivateIsPrivilegedFiltersEnabledFunction() {} ++ ++AdblockPrivateIsPrivilegedFiltersEnabledFunction::~AdblockPrivateIsPrivilegedFiltersEnabledFunction() {} ++ ++ExtensionFunction::ResponseAction AdblockPrivateIsPrivilegedFiltersEnabledFunction::Run() { ++ auto* controller = adblock::AdblockControllerFactory::GetForBrowserContext( ++ browser_context()); ++ return RespondNow( ++ ArgumentList(api::adblock_private::IsEnabled::Results::Create( ++ controller->IsPrivilegedFiltersEnabled()))); ++} ++ + AdblockPrivateSetEnabledFunction::AdblockPrivateSetEnabledFunction() {} + + AdblockPrivateSetEnabledFunction::~AdblockPrivateSetEnabledFunction() {} +@@ -486,7 +514,7 @@ AdblockPrivateGetInstalledSubscriptionsFunction::Run() { + browser_context()); + return RespondNow(ArgumentList( + api::adblock_private::GetInstalledSubscriptions::Results::Create( +- CopySubscriptions(controller->GetInstalledSubscriptions())))); ++ CopySubscriptions(controller, controller->GetInstalledSubscriptions())))); + } + + AdblockPrivateAddAllowedDomainFunction:: +diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.h b/chrome/browser/extensions/api/adblock_private/adblock_private_api.h +--- a/chrome/browser/extensions/api/adblock_private/adblock_private_api.h ++++ b/chrome/browser/extensions/api/adblock_private/adblock_private_api.h +@@ -58,6 +58,55 @@ void BrowserContextKeyedAPIFactory< + + namespace api { + ++class AdblockPrivateStartUpdateFunction : public ExtensionFunction { ++ public: ++ DECLARE_EXTENSION_FUNCTION("adblockPrivate.startUpdate", UNKNOWN) ++ AdblockPrivateStartUpdateFunction(); ++ ++ private: ++ ~AdblockPrivateStartUpdateFunction() override; ++ ++ ResponseAction Run() override; ++ ++ AdblockPrivateStartUpdateFunction(const AdblockPrivateStartUpdateFunction&) = ++ delete; ++ AdblockPrivateStartUpdateFunction& operator=( ++ const AdblockPrivateStartUpdateFunction&) = delete; ++}; ++ ++ ++class AdblockPrivateSetPrivilegedFiltersEnabledFunction : public ExtensionFunction { ++ public: ++ DECLARE_EXTENSION_FUNCTION("adblockPrivate.setPrivilegedFiltersEnabled", UNKNOWN) ++ AdblockPrivateSetPrivilegedFiltersEnabledFunction(); ++ ++ private: ++ ~AdblockPrivateSetPrivilegedFiltersEnabledFunction() override; ++ ++ ResponseAction Run() override; ++ ++ AdblockPrivateSetPrivilegedFiltersEnabledFunction(const AdblockPrivateSetPrivilegedFiltersEnabledFunction&) = ++ delete; ++ AdblockPrivateSetPrivilegedFiltersEnabledFunction& operator=( ++ const AdblockPrivateSetPrivilegedFiltersEnabledFunction&) = delete; ++}; ++ ++class AdblockPrivateIsPrivilegedFiltersEnabledFunction : public ExtensionFunction { ++ public: ++ DECLARE_EXTENSION_FUNCTION("adblockPrivate.isPrivilegedFiltersEnabled", UNKNOWN) ++ AdblockPrivateIsPrivilegedFiltersEnabledFunction(); ++ ++ private: ++ ~AdblockPrivateIsPrivilegedFiltersEnabledFunction() override; ++ ++ ResponseAction Run() override; ++ ++ AdblockPrivateIsPrivilegedFiltersEnabledFunction(const AdblockPrivateIsPrivilegedFiltersEnabledFunction&) = ++ delete; ++ AdblockPrivateIsPrivilegedFiltersEnabledFunction& operator=( ++ const AdblockPrivateIsPrivilegedFiltersEnabledFunction&) = delete; ++}; ++ + class AdblockPrivateSetEnabledFunction : public ExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("adblockPrivate.setEnabled", UNKNOWN) +diff --git a/chrome/browser/extensions/api/eyeo_filtering_private/eyeo_filtering_private_api.cc b/chrome/browser/extensions/api/eyeo_filtering_private/eyeo_filtering_private_api.cc +--- a/chrome/browser/extensions/api/eyeo_filtering_private/eyeo_filtering_private_api.cc ++++ b/chrome/browser/extensions/api/eyeo_filtering_private/eyeo_filtering_private_api.cc +@@ -29,6 +29,7 @@ + #include "components/adblock/content/browser/resource_classification_runner.h" + #include "components/adblock/core/common/adblock_utils.h" + #include "components/adblock/core/common/content_type.h" ++#include "components/adblock/core/subscription/subscription.h" + #include "components/adblock/core/configuration/filtering_configuration.h" + #include "components/adblock/core/configuration/persistent_filtering_configuration.h" + #include "components/adblock/core/session_stats.h" +@@ -94,23 +95,6 @@ std::vector CopySessionsStats( + return result; + } + +-std::string SubscriptionInstallationStateToString( +- adblock::Subscription::InstallationState state) { +- using State = adblock::Subscription::InstallationState; +- switch (state) { +- case State::Installed: +- return "Installed"; +- case State::Installing: +- return "Installing"; +- case State::Preloaded: +- return "Preloaded"; +- case State::Unknown: +- return "Unknown"; +- } +- NOTREACHED(); +- return ""; +-} +- + std::vector CopySubscriptions( + const std::vector> + current_subscriptions) { +@@ -121,7 +105,7 @@ std::vector CopySubscriptions( + js_sub.title = sub->GetTitle(); + js_sub.current_version = sub->GetCurrentVersion(); + js_sub.installation_state = +- SubscriptionInstallationStateToString(sub->GetInstallationState()); ++ adblock::Subscription::SubscriptionInstallationStateToString(sub->GetInstallationState()); + js_sub.last_installation_time = + base::TimeToISO8601(sub->GetInstallationTime()); + result.emplace_back(std::move(js_sub)); +diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc ++++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +@@ -17,7 +17,6 @@ + #include "chrome/browser/accessibility/accessibility_labels_service_factory.h" + #include "chrome/browser/accessibility/page_colors_factory.h" + #include "chrome/browser/adblock/adblock_controller_factory.h" +-#include "chrome/browser/adblock/adblock_telemetry_service_factory.h" + #include "chrome/browser/adblock/content_security_policy_injector_factory.h" + #include "chrome/browser/adblock/element_hider_factory.h" + #include "chrome/browser/adblock/resource_classification_runner_factory.h" +@@ -721,7 +720,6 @@ void ChromeBrowserMainExtraPartsProfiles:: + ExitTypeServiceFactory::GetInstance(); + #endif + adblock::AdblockControllerFactory::GetInstance(); +- adblock::AdblockTelemetryServiceFactory::GetInstance(); + 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") { + web_component_files = [ + "a11y_page/a11y_page.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", +@@ -365,6 +366,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,207 @@ ++ ++ ++ ++ ++ ++ ++
++ ++
++
++
Enable anti-circumvention and snippets
++
++ Snippets are pieces of JavaScript code, injected by the Adblock Plus, that execute within the context of a website and combat advanced ads that circumvent ordinary blocking. ++ The functionality is ONLY allowed for the list ++ abp-filters-anti-cv.txt ++ which is activated by this setting. ++
Open ABP anti-circumvention filter list repo ++
Open ABP Snippets Overview ++
++
++
++ ++ ++
++ ++
++
++
++ ++ Check for updates now ++ ++
++ ++
++ ++
++
Built in Subscriptions ([[countEnabled]] selected)
++
++ Add the languages in which you regularly browse websites in ++
++
++
++ ++
++ ++
++
++
++
++ ++
++ Allowed Domains ([[allowedDomainsCount]] added) ++
++
++ Support your favorite websites by adding them to this list. You might see ads on them. ++
++
++ ++
++ ++
++
++ ++ ++ Add ++ ++ ++
++
++
++
++
++
++ ++
++ Custom Subscriptions ([[customSubscriptions.length]] added) ++
++
++ Add custom filter urls ++
++
++ ++
++ ++
++
++ ++ ++ Add ++ ++ ++
++
++
++
++
++
++ ++
++ Custom Filters ([[customFilters.length]] added) ++
++
++ Add custom filter commands ++
++
++ ++
++ ++
++
++ ++ ++ Add ++ ++ ++
++
++
++
++
++ ++
++ +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,286 @@ ++/* ++ 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 . ++*/ ++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 '../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 '/shared/settings/controls/settings_toggle_button.js'; ++import { PrefsMixin } from 'chrome://resources/cr_components/settings_prefs/prefs_mixin.js'; ++import { CrCheckboxElement } from 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js'; ++import { getTemplate } from './adblock_page.html.js'; ++import { getToastManager } from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.js'; ++ ++const SettingsAdblockPageElementBase = ++ I18nMixin(PrefsMixin(BaseMixin((PolymerElement)))); ++ ++interface Subscription { ++ url: string; ++ title: string; ++ enabled: boolean; ++ current_version: string; ++ download_error_count: number; ++ download_success_count: number; ++ installation_state: string; ++ last_installation_time: string; ++} ++ ++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; ++ public additionalMessage: string; ++ public additionalMessageIcon: string; ++ public countEnabled: number; ++ public allowedDomainsCount: number; ++ public isEnablePrivilegedFiltersToggle_: boolean; ++ ++ // models that will fill templates lists in html ++ public customSubscriptions: Subscription[] = []; ++ public customFilters: Array = []; ++ public allowedDomains: Array = []; ++ public subscriptions: Subscription[] = []; ++ ++ private syncSubscriptions() { ++ this.subscriptions = [] ++ this.customSubscriptions = []; ++ ++ chrome.adblockPrivate.getBuiltInSubscriptions(list => { ++ chrome.adblockPrivate.getInstalledSubscriptions(activelist => { ++ let new_subscriptions: Subscription[] = []; ++ let custom_subscriptions: Subscription[] = []; ++ ++ list.forEach(obj => { ++ new_subscriptions.push({ ++ title: obj.title, ++ enabled: false, ++ url: obj.url, ++ current_version: '', ++ download_error_count: 0, ++ download_success_count: 0, ++ installation_state: '', ++ last_installation_time: '' ++ }) ++ }) ++ ++ activelist.forEach(obj => { ++ var found = new_subscriptions.find(element => element.url == obj.url); ++ if (found === undefined) { ++ found = { ++ title: obj.title, ++ enabled: false, ++ url: obj.url, ++ current_version: '', ++ download_error_count: 0, ++ download_success_count: 0, ++ installation_state: '', ++ last_installation_time: '' ++ } ++ custom_subscriptions.push(found) ++ } ++ found.enabled = true; ++ found.current_version = obj.current_version; ++ found.download_error_count = obj.download_error_count; ++ found.download_success_count = obj.download_success_count; ++ found.installation_state = obj.installation_state; ++ found.last_installation_time = new Date(obj.last_installation_time).toLocaleString(); ++ }) ++ ++ this.subscriptions = new_subscriptions; ++ this.customSubscriptions = custom_subscriptions; ++ this.updateUI(); ++ }) ++ }); ++ } ++ ++ private updateUI() { ++ this.additionalMessage = ""; ++ this.additionalMessageIcon = ""; ++ this.countEnabled = 0; ++ ++ chrome.adblockPrivate.isEnabled(enabled => { ++ if (!enabled) return; ++ ++ let c = 0; ++ this.subscriptions.forEach(obj => { ++ if (obj.enabled) c++; ++ }); ++ this.countEnabled = c; ++ if (this.countEnabled == 0 && ++ this.customSubscriptions.length == 0 && ++ this.customFilters.length == 0) { ++ this.additionalMessage = "No subscriptions selected. Adblock is not active."; ++ this.additionalMessageIcon = "cr:warning"; ++ } ++ }); ++ ++ chrome.adblockPrivate.isPrivilegedFiltersEnabled(enabled => { ++ this.isEnablePrivilegedFiltersToggle_ = enabled; ++ }); ++ } ++ ++ private syncCustomFilters() { ++ chrome.adblockPrivate.getCustomFilters(domain => { ++ this.customFilters = []; ++ domain.forEach(value => { ++ this.customFilters.push(value); ++ }) ++ this.updateUI(); ++ }); ++ } ++ ++ private syncAllowedDomains() { ++ this.allowedDomainsCount = 0; ++ chrome.adblockPrivate.getAllowedDomains(domain => { ++ this.allowedDomains = []; ++ domain.forEach(value => { ++ this.allowedDomains.push(value); ++ }) ++ this.allowedDomainsCount = this.allowedDomains.length; ++ this.updateUI(); ++ }); ++ } ++ ++ 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); ++ } ++ this.updateUI(); ++ } ++ ++ private onEnablePrivilegedFiltersToggle_(_evt: any, enabled: boolean) { ++ chrome.adblockPrivate.setPrivilegedFiltersEnabled(enabled); ++ this.syncSubscriptions(); ++ } ++ ++ 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 ""; ++ } ++ } ++ 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); ++ } ++ this.updateUI(); ++ } ++ ++ 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); ++ this.updateUI(); ++ } ++ ++ 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); ++ this.allowedDomainsCount = this.allowedDomains.length; ++ this.updateUI(); ++ } ++ ++ 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 url = ((e.target as HTMLElement).id); ++ const subscription = this.customSubscriptions.find( x => x.url = url); ++ chrome.adblockPrivate.uninstallSubscription(subscription!.url); ++ this.splice('customSubscriptions', this.customSubscriptions.indexOf(subscription!), 1); ++ this.updateUI(); ++ } ++ ++ private addCustomSubscription() { ++ if (this.customSubscriptionInput == undefined || this.customSubscriptionInput == "") return; ++ chrome.adblockPrivate.installSubscription(this.customSubscriptionInput); ++ this.customSubscriptionInput = ""; ++ this.syncSubscriptions(); ++ } ++ ++ private startUpdateCycle() { ++ const toastManager = getToastManager(); ++ chrome.adblockPrivate.startUpdate(); ++ toastManager.duration = 5000; ++ toastManager.show("Starting update..."); ++ } ++} ++ ++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 @@ + + + ++ +