diff --git a/build/cromite_patches_list.txt b/build/cromite_patches_list.txt
index fb90bf44..9bb1ff57 100644
--- a/build/cromite_patches_list.txt
+++ b/build/cromite_patches_list.txt
@@ -307,9 +307,9 @@ Temporarily-disable-Tab-Group-Sync-Android.patch
Fix-chromium-build-bugs.patch
# adblock patches
-eyeo-beta-118.0.5993.48-base.patch
-eyeo-beta-118.0.5993.48-chrome_integration.patch
-eyeo-beta-118.0.5993.48-android_api.patch
-eyeo-beta-118.0.5993.48-android_settings.patch
-eyeo-beta-118.0.5993.48-extension_api.patch
+eyeo-133.0.6943.49-base.patch
+eyeo-133.0.6943.49-chrome_integration.patch
+eyeo-133.0.6943.49-android_api.patch
+eyeo-133.0.6943.49-android_settings.patch
+eyeo-133.0.6943.49-extension_api.patch
Eyeo-Adblock-for-Cromite.patch
diff --git a/build/patches/Eyeo-Adblock-for-Cromite.patch b/build/patches/Eyeo-Adblock-for-Cromite.patch
index cd7898fa..7e706907 100644
--- a/build/patches/Eyeo-Adblock-for-Cromite.patch
+++ b/build/patches/Eyeo-Adblock-for-Cromite.patch
@@ -11,16 +11,26 @@ Added "enable-stricter-popup-blocker" flag for the global
deactivation of all pop-ups (default disabled)
---
.../android/java/res/xml/main_preferences.xml | 19 +-
- chrome/browser/BUILD.gn | 2 -
- .../adblock/adblock_content_browser_client.cc | 283 +-
- .../adblock/adblock_content_browser_client.h | 46 +-
+ .../adblock_chrome_content_browser_client.cc | 6 +
+ .../adblock_chrome_content_browser_client.h | 4 +
+ chrome/browser/adblock/android/BUILD.gn | 2 +-
+ .../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 +-
+ .../AdblockAllowedDomainsFragment.java | 7 +-
+ .../AdblockCustomFilterListsFragment.java | 37 +-
+ .../AdblockCustomFiltersFragment.java | 7 +-
+ .../settings/AdblockCustomItemFragment.java | 20 +-
+ .../settings/AdblockFilterListsAdapter.java | 6 +
+ .../settings/AdblockSettingsFragment.java | 79 +-
.../browser/chrome_content_browser_client.cc | 6 +-
.../browser/chrome_content_browser_client.h | 6 +-
- .../adblock_private/adblock_private_api.cc | 74 +-
+ .../adblock_private/adblock_private_api.cc | 76 +-
.../api/adblock_private/adblock_private_api.h | 49 +
- .../eyeo_filtering_private_api.cc | 25 +-
+ .../eyeo_filtering_private_api.cc | 24 +-
+ .../api/settings_private/prefs_util.cc | 14 +
...hrome_browser_main_extra_parts_profiles.cc | 2 -
- .../resources/adblock_internals/BUILD.gn | 8 +-
chrome/browser/resources/settings/BUILD.gn | 2 +
.../settings/adblock_page/adblock_page.html | 212 +
.../settings/adblock_page/adblock_page.ts | 286 +
@@ -31,118 +41,97 @@ deactivation of all pop-ups (default disabled)
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 +-
- .../adblock_internals_page_handler_impl.cc | 21 +-
- .../adblock_internals/adblock_internals_ui.cc | 3 +-
- .../common/extensions/api/_api_features.json | 4 +-
- .../extensions/api/_permission_features.json | 8 -
+ chrome/browser/ui/tab_helpers.cc | 3 +-
+ .../extensions/api/_permission_features.json | 14 -
.../common/extensions/api/adblock_private.idl | 8 +
- components/adblock/android/BUILD.gn | 3 +-
- components/adblock/android/adblock_jni.cc | 53 +-
- .../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 | 53 +-
- .../AdblockAllowedDomainsFragment.java | 7 +-
- .../AdblockCustomFilterListsFragment.java | 32 +-
- .../AdblockCustomFiltersFragment.java | 7 +-
- .../settings/AdblockCustomItemFragment.java | 20 +-
- .../settings/AdblockFilterListsAdapter.java | 6 +
- .../settings/AdblockSettingsFragment.java | 51 +-
- components/adblock/content/browser/BUILD.gn | 18 +-
- .../adblock_controller_factory_base.cc | 5 +-
- .../browser/adblock_url_loader_factory.cc | 66 +-
- .../browser/adblock_url_loader_factory.h | 7 +-
- .../browser/adblock_webcontents_observer.cc | 25 +-
+ .../adblock/android/adblock_controller_jni.cc | 75 +-
+ .../components/adblock/AdblockController.java | 51 +-
+ components/adblock/content/browser/BUILD.gn | 22 +-
+ .../browser/adblock_content_browser_client.h | 267 +-
+ .../browser/adblock_internals_page_handler.cc | 9 +-
+ .../browser/adblock_url_loader_factory.cc | 46 +-
+ .../browser/adblock_webcontents_observer.cc | 21 +-
.../browser/adblock_webcontents_observer.h | 5 +-
- .../content/browser/element_hider_impl.cc | 9 +-
- .../browser/frame_hierarchy_builder.cc | 3 +-
- .../browser/resource_classification_runner.h | 9 +
- .../resource_classification_runner_impl.cc | 81 +-
- .../resource_classification_runner_impl.h | 10 +
- .../subscription_service_factory_base.cc | 11 +-
- .../subscription_service_factory_base.h | 1 +
+ .../content/browser/element_hider_impl.cc | 13 +-
+ .../adblock_telemetry_service_factory.cc | 7 -
+ .../browser/factories/embedding_utils.cc | 2 -
+ .../browser/factories/embedding_utils.h | 7 +-
+ .../factories/subscription_service_factory.cc | 22 +-
+ .../factories/subscription_service_factory.h | 1 +
+ .../browser/frame_hierarchy_builder.cc | 1 +
+ .../content/browser/page_view_stats.cc | 71 +-
+ .../browser/resource_classification_runner.h | 7 +
+ .../resource_classification_runner_impl.cc | 66 +-
+ .../resource_classification_runner_impl.h | 8 +
components/adblock/core/BUILD.gn | 39 -
- .../activeping_telemetry_topic_provider.cc | 285 -
- .../activeping_telemetry_topic_provider.h | 87 -
- .../adblock/core/adblock_controller_impl.cc | 10 +-
- components/adblock/core/adblock_switches.cc | 1 -
- components/adblock/core/adblock_switches.h | 1 -
- .../adblock/core/adblock_telemetry_service.cc | 258 -
- .../adblock/core/adblock_telemetry_service.h | 120 -
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 -
+ .../adblock/core/common/adblock_prefs.cc | 57 +-
+ .../adblock/core/common/adblock_prefs.h | 7 +-
+ components/adblock/core/common/app_info.cc | 12 -
.../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 +-
+ .../adblock/core/converter/parser/metadata.cc | 1 +
.../core/converter/parser/test/test_rules.txt | 21 +
.../core/converter/parser/url_filter.cc | 10 +-
.../converter/parser/url_filter_options.cc | 21 +-
- .../converter/parser/url_filter_options.h | 1 +
- .../serializer/flatbuffer_serializer.cc | 83 +-
- components/adblock/core/features.cc | 3 +-
- components/adblock/core/hash/schema_hash.h | 10 +
- .../adblock/core/sitekey_storage_impl.cc | 11 +-
+ .../serializer/flatbuffer_serializer.cc | 85 +-
+ components/adblock/core/features.cc | 6 +-
+ .../core/net/adblock_resource_request_impl.cc | 21 +-
+ components/adblock/core/resources/.gitignore | 2 +-
+ components/adblock/core/resources/BUILD.gn | 5 +-
+ .../core/resources/adblock_resources.grd | 3 -
+ .../core/resources/elemhide_for_selector.jst | 4 +-
+ .../adblock/core/resources/elemhideemu.jst | 2 +
+ .../resources/snippets/dist/dependencies.jst | 1690 ++++++
+ .../dist/isolated-first-all.source.jst | 5256 +++++++++++++++++
+ .../adblock/core/sitekey_storage_impl.cc | 17 +-
.../core/subscription/conversion_executors.h | 1 +
.../filtering_configuration_maintainer.h | 4 +
- ...filtering_configuration_maintainer_impl.cc | 31 +-
+ ...filtering_configuration_maintainer_impl.cc | 33 +-
.../filtering_configuration_maintainer_impl.h | 4 +-
- .../ongoing_subscription_request_impl.cc | 33 +-
.../preloaded_subscription_provider_impl.cc | 4 +-
- .../adblock/core/subscription/subscription.cc | 18 +
+ ...recommended_subscription_installer_impl.cc | 1 +
+ .../adblock/core/subscription/subscription.cc | 20 +
.../adblock/core/subscription/subscription.h | 3 +
.../subscription_collection_impl.cc | 1 +
- .../core/subscription/subscription_config.cc | 26 +-
+ .../core/subscription/subscription_config.cc | 28 +-
.../core/subscription/subscription_config.h | 6 +-
- .../subscription_downloader_impl.cc | 29 +-
+ .../subscription_downloader_impl.cc | 19 +-
.../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 | 9 +
- .../subscription/subscription_service_impl.cc | 78 +-
- .../subscription/subscription_service_impl.h | 9 +
- .../subscription/subscription_updater_impl.cc | 8 +-
+ .../core/subscription/subscription_service.h | 11 +
+ .../subscription/subscription_service_impl.cc | 87 +-
+ .../subscription/subscription_service_impl.h | 10 +
.../subscription_validator_impl.cc | 4 +-
+ components/adblock/features.gni | 2 +-
components/blocked_content/popup_blocker.cc | 9 +-
components/blocked_content/popup_blocker.h | 3 +
.../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 | 37 +-
- .../adblocking/elemhide_for_selector.jst | 2 +-
- .../resources/adblocking/elemhideemu.jst | 2 +
- .../snippets/dist/isolated-first.jst | 66 +
- .../snippets/dist/isolated-first.source.jst | 4793 +++++++++++++++++
.../websockets/websocket_connector_impl.cc | 6 +-
.../public/browser/content_browser_client.cc | 4 +-
.../public/browser/content_browser_client.h | 4 +-
+ content/public/common/isolated_world_ids.h | 2 +-
.../about_flags_cc/Stricter-popup-blocker.inc | 14 +
.../blink/renderer/core/css/style_engine.cc | 8 +
.../blink/renderer/core/css/style_engine.h | 1 +
- .../renderer/core/exported/web_document.cc | 15 +-
+ .../renderer/core/dom/events/event_target.cc | 5 +-
+ .../renderer/core/exported/web_document.cc | 13 +-
+ .../blink/renderer/core/html/html_element.cc | 8 +-
.../definitions/adblock_private.d.ts | 14 +
- 120 files changed, 6727 insertions(+), 1313 deletions(-)
+ 114 files changed, 8783 insertions(+), 589 deletions(-)
+ rename chrome/browser/adblock/android/java/res/xml/{adblock_preferences.xml => eyeo_adblock_preferences.xml} (60%)
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/adblock/core/hash/schema_hash.h
+ create mode 100644 components/adblock/core/resources/snippets/dist/dependencies.jst
+ create mode 100644 components/adblock/core/resources/snippets/dist/isolated-first-all.source.jst
create mode 100644 components/content_settings/core/browser/bromite_content_settings/ads.inc
- create mode 100644 components/resources/adblocking/snippets/dist/isolated-first.jst
- create mode 100644 components/resources/adblocking/snippets/dist/isolated-first.source.jst
create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Stricter-popup-blocker.inc
diff --git a/chrome/android/java/res/xml/main_preferences.xml b/chrome/android/java/res/xml/main_preferences.xml
@@ -162,564 +151,636 @@ diff --git a/chrome/android/java/res/xml/main_preferences.xml b/chrome/android/j
-@@ -129,6 +120,11 @@ for the previous order (main_preferences_legacy). -->
+@@ -99,11 +90,6 @@ for the previous order (main_preferences_legacy). -->
+ android:key="autofill_options"
+ android:order="16"
+ android:title="@string/autofill_options_title" />
+-
+
+
android:key="adblock"
android:order="13"
android:title="@string/prefs_adblock"/>
+
- android:key="accessibility"
- android:order="24"
- android:title="@string/prefs_accessibility"/>
--
- GetOriginalProfile();
+ }
++
++HostContentSettingsMap*
++AdblockChromeContentBrowserClient::GetHostContentSettingsMap(
++ content::BrowserContext* current_browser_context) {
++ return HostContentSettingsMapFactory::GetForProfile(current_browser_context);
++}
+diff --git a/chrome/browser/adblock/adblock_chrome_content_browser_client.h b/chrome/browser/adblock/adblock_chrome_content_browser_client.h
+--- a/chrome/browser/adblock/adblock_chrome_content_browser_client.h
++++ b/chrome/browser/adblock/adblock_chrome_content_browser_client.h
+@@ -20,12 +20,16 @@
+
+ #include "chrome/browser/chrome_content_browser_client.h"
+ #include "components/adblock/content/browser/adblock_content_browser_client.h"
+#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
+#include "components/content_settings/core/browser/host_content_settings_map.h"
- #include "chrome/browser/profiles/profile.h"
- #include "chrome/browser/ui/browser_navigator_params.h"
- #include "components/adblock/content/browser/adblock_url_loader_factory.h"
-@@ -40,6 +42,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"
-@@ -53,17 +56,41 @@
-
- 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;
-+ }
-+
-+ if (embedder_url.SchemeIs(content_settings::kChromeUIScheme)) {
-+ return false;
-+ }
-+
-+ 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 = std::ranges::any_of(
-+ adblock::SubscriptionServiceFactory::GetForBrowserContext(profile)
-+ ->GetInstalledFilteringConfigurations(),
-+ &adblock::FilteringConfiguration::IsEnabled);
-+ return ret;
-+}
-+
- bool IsFilteringNeeded(content::RenderFrameHost* frame) {
- if (frame) {
- auto* profile =
- Profile::FromBrowserContext(frame->GetProcess()->GetBrowserContext());
- if (profile) {
-- // 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);
-+ content::RenderFrameHost* embedder = frame->GetOutermostMainFrameOrEmbedder();
-+ const auto& embedder_url = embedder->GetLastCommittedURL();
-+ return IsFilteringNeeded(profile, embedder_url);
- }
- }
- return false;
-@@ -78,10 +105,11 @@ 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,
-- mojo::PendingRemote target_factory,
-+ network::URLLoaderFactoryBuilder& factory_builder,
- bool use_test_loader) {
- const void* const kAdblockContextUserDataKey = &kAdblockContextUserDataKey;
- auto* self = static_cast(
-@@ -90,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),
-@@ -101,28 +127,12 @@ 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::SubscriptionServiceFactory::GetForBrowserContext(
-- Profile::FromBrowserContext(
-- frame->GetProcess()->GetBrowserContext())));
-- self->proxies_.emplace(std::move(proxy));
-- return;
-- }
--#endif
- auto proxy = std::make_unique(
- std::move(config),
-+ request_initiator.GetURL(),
- content::GlobalRenderFrameHostId(render_process_id,
-- frame->GetRoutingID()),
-- std::move(receiver), std::move(target_factory),
-+ frame ? frame->GetRoutingID() : MSG_ROUTING_NONE),
-+ factory_builder,
- embedder_support::GetUserAgent(),
- base::BindOnce(&AdblockContextData::RemoveProxy,
- self->weak_factory_.GetWeakPtr()));
-@@ -162,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 std::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 std::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);
-@@ -210,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 std::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;
- }
-@@ -253,15 +266,134 @@ void AdblockContentBrowserClient::OnWebSocketFilterCheckCompleted(
- VLOG(1) << "[eyeo] Web socket blocked for " << url;
- }
-
--bool AdblockContentBrowserClient::WillCreateURLLoaderFactory(
-+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::CanCreateWindow(
-+ content::RenderFrameHost* opener,
-+ const GURL& opener_url,
-+ const GURL& opener_top_level_frame_url,
-+ const url::Origin& source_origin,
-+ content::mojom::WindowContainerType container_type,
-+ const GURL& target_url,
-+ const content::Referrer& referrer,
-+ const std::string& frame_name,
-+ WindowOpenDisposition disposition,
-+ const blink::mojom::WindowFeatures& features,
-+ bool user_gesture,
-+ bool opener_suppressed,
-+ bool* no_javascript_access) {
-+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-+ DCHECK(opener);
-+
-+ if (IsFilteringNeeded(opener)) {
-+ content::WebContents* web_contents =
-+ content::WebContents::FromRenderFrameHost(opener);
-+ auto* subscription_service =
-+ adblock::SubscriptionServiceFactory::GetForBrowserContext(
-+ web_contents->GetBrowserContext());
-+
-+ GURL popup_url(target_url);
-+ web_contents->GetPrimaryMainFrame()->GetProcess()->FilterURL(false,
-+ &popup_url);
-+ auto* classification_runner =
-+ adblock::ResourceClassificationRunnerFactory::GetForBrowserContext(
-+ web_contents->GetBrowserContext());
-+ const auto popup_blocking_decision =
-+ classification_runner->ShouldBlockPopup(
-+ subscription_service->GetCurrentSnapshot(), popup_url, opener);
-+ if (popup_blocking_decision == adblock::FilterMatchResult::kAllowRule) {
-+ return true;
-+ }
-+ if (popup_blocking_decision == adblock::FilterMatchResult::kBlockRule) {
-+ return false;
-+ }
-+ // Otherwise, if eyeo adblocking is disabled or there is no rule that
-+ // explicitly allows or blocks a popup, fall back on Chromium's built-in
-+ // popup blocker.
-+ DCHECK(popup_blocking_decision == adblock::FilterMatchResult::kDisabled ||
-+ popup_blocking_decision == adblock::FilterMatchResult::kNoRule);
-+ }
-+
-+ return ChromeContentBrowserClient::CanCreateWindow(
-+ opener, opener_url, opener_top_level_frame_url, source_origin,
-+ container_type, target_url, referrer, frame_name, disposition, features,
-+ user_gesture, opener_suppressed, no_javascript_access);
-+}
-+
-+void AdblockContentBrowserClient::WillCreateURLLoaderFactory(
- content::BrowserContext* browser_context,
- content::RenderFrameHost* frame,
- int render_process_id,
- URLLoaderFactoryType type,
- const url::Origin& request_initiator,
-+ const net::IsolationInfo& isolation_info,
- std::optional navigation_id,
- ukm::SourceIdObj ukm_source_id,
-- mojo::PendingReceiver* factory_receiver,
-+ network::URLLoaderFactoryBuilder& factory_builder,
- mojo::PendingRemote*
- header_client,
- bool* bypass_redirect_checks,
-@@ -270,30 +402,17 @@ bool AdblockContentBrowserClient::WillCreateURLLoaderFactory(
- scoped_refptr navigation_response_task_runner) {
- // Create Chromium proxy first as WebRequestProxyingURLLoaderFactory logic
- // depends on being first proxy
-- bool use_chrome_proxy =
-- ChromeContentBrowserClient::WillCreateURLLoaderFactory(
-- browser_context, frame, render_process_id, type, request_initiator,
-- 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
-+ ChromeContentBrowserClient::WillCreateURLLoaderFactory(
-+ browser_context, frame, render_process_id, type, request_initiator,
-+ isolation_info, navigation_id, ukm_source_id, factory_builder, header_client,
-+ bypass_redirect_checks, disable_secure_dns, factory_override,
-+ navigation_response_task_runner);
-+ 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
-@@ -308,12 +427,8 @@ bool AdblockContentBrowserClient::WillCreateURLLoaderFactory(
- #endif
-
- if (use_adblock_proxy) {
-- auto proxied_receiver = std::move(*factory_receiver);
-- mojo::PendingRemote target_factory_remote;
-- *factory_receiver = target_factory_remote.InitWithNewPipeAndPassReceiver();
- AdblockContextData::StartProxying(
-- profile, frame, render_process_id, std::move(proxied_receiver),
-- std::move(target_factory_remote), use_test_loader);
-+ profile, browser_context, request_initiator, frame, render_process_id,
-+ factory_builder, 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
-@@ -45,25 +45,37 @@ 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 std::optional& user_agent,
- mojo::PendingRemote
- handshake_client) override;
-
-- bool WillCreateURLLoaderFactory(
-+ void WillCreateWebTransport(
-+ int process_id,
-+ int frame_routing_id,
-+ const GURL& url,
-+ const url::Origin& initiator_origin,
-+ mojo::PendingRemote
-+ handshake_client,
-+ WillCreateWebTransportCallback callback) override;
-+
-+ void WillCreateURLLoaderFactory(
- content::BrowserContext* browser_context,
- content::RenderFrameHost* frame,
- int render_process_id,
- URLLoaderFactoryType type,
- const url::Origin& request_initiator,
-+ const net::IsolationInfo& isolation_info,
- std::optional navigation_id,
- ukm::SourceIdObj ukm_source_id,
-- mojo::PendingReceiver* factory_receiver,
-+ network::URLLoaderFactoryBuilder& factory_builder,
- mojo::PendingRemote*
- header_client,
- bool* bypass_redirect_checks,
-@@ -72,25 +84,51 @@ class AdblockContentBrowserClient : public ChromeContentBrowserClient {
- scoped_refptr navigation_response_task_runner)
- override;
-
-+ bool CanCreateWindow(content::RenderFrameHost* opener,
-+ const GURL& opener_url,
-+ const GURL& opener_top_level_frame_url,
-+ const url::Origin& source_origin,
-+ content::mojom::WindowContainerType container_type,
-+ const GURL& target_url,
-+ const content::Referrer& referrer,
-+ const std::string& frame_name,
-+ WindowOpenDisposition disposition,
-+ const blink::mojom::WindowFeatures& features,
-+ bool user_gesture,
-+ bool opener_suppressed,
-+ bool* no_javascript_access) override;
-+
+ class AdblockChromeContentBrowserClient
+ : public adblock::AdblockContentBrowserClient {
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 std::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 std::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};
+ content::BrowserContext* GetBrowserContextForEyeoFactories(
+ content::BrowserContext* current_browser_context) override;
++ HostContentSettingsMap* GetHostContentSettingsMap(
++ content::BrowserContext* current_browser_context) override;
+ };
- #if BUILDFLAG(ENABLE_EXTENSIONS)
+ #endif // CHROME_BROWSER_ADBLOCK_ADBLOCK_CHROME_CONTENT_BROWSER_CLIENT_H_
+diff --git a/chrome/browser/adblock/android/BUILD.gn b/chrome/browser/adblock/android/BUILD.gn
+--- a/chrome/browser/adblock/android/BUILD.gn
++++ b/chrome/browser/adblock/android/BUILD.gn
+@@ -148,7 +148,7 @@ android_resources("java_ui_resources") {
+ "java/res/layout/adblock_custom_item_settings.xml",
+ "java/res/layout/adblock_filter_lists_list_item.xml",
+ "java/res/xml/adblock_more_options.xml",
+- "java/res/xml/adblock_preferences.xml",
++ "java/res/xml/eyeo_adblock_preferences.xml",
+ ]
+
+ deps = [ ":adblock_strings_grd" ]
+diff --git a/chrome/browser/adblock/android/adblock_strings.grd b/chrome/browser/adblock/android/adblock_strings.grd
+--- a/chrome/browser/adblock/android/adblock_strings.grd
++++ b/chrome/browser/adblock/android/adblock_strings.grd
+@@ -186,10 +186,52 @@
+
+
+
+- Ad blocking
++ Adblock Plus settings
++
++
++ Enable Adblock Plus
++
++
++ Check for updates now
++
++
++ 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
++https://www.cromite.org/filters/abp-filters-anti-cv.txt
++which is activated by this setting.
++
++
++ Open ABP anti-circumvention filter list repo
++
++
++ Open https://gitlab.com/eyeo/anti-cv/abp-filters-anti-cv in the browser
++
++
++ https://gitlab.com/eyeo/anti-cv/abp-filters-anti-cv
++
++
++ Open ABP Snippets Overview
++
++
++ Open https://developers.eyeo.com/snippets/snippets-overview in the browser
++
++
++ https://developers.eyeo.com/snippets/snippets-overview
++
++
++ Filter lists (%s selected)
++
++
++ Custom ad filtering settings (%s selected)
++
++
++ Custom Filters (%s selected)
+
+
+- Allow ad blocking on websites in this app
++ Block ads on websites
+
+
+ Filter lists
+@@ -222,10 +264,10 @@
+ More blocking options
+
+
+- Custom ad filtering settings
++ Custom ad filtering urls
+
+
+- Add custom filter lists
++ Add custom filter urls
+
+
+ https://example.org/myFilterList.txt
+@@ -234,10 +276,10 @@
+ Custom Filters
+
+
+- Add custom filters
++ Add custom filters commands
+
+
+- Enter filter
++ Enter filter commands
+
+
+
+diff --git a/chrome/browser/adblock/android/java/res/layout/adblock_custom_item.xml b/chrome/browser/adblock/android/java/res/layout/adblock_custom_item.xml
+--- a/chrome/browser/adblock/android/java/res/layout/adblock_custom_item.xml
++++ b/chrome/browser/adblock/android/java/res/layout/adblock_custom_item.xml
+@@ -25,14 +25,24 @@
+ tools:ignore="UseCompoundDrawables">
+
+
+-
++
++
++
+
+
+
+
+@@ -32,6 +32,43 @@
+ app:iconSpaceReserved="false"
+ android:summary="@string/fragment_adblock_settings_filter_lists_summary" />
+
++
++
++
++
++
++
++
++
++
++
++
++
++
+
+ {
+ public AdblockAllowedDomainsFragment() {}
+
+ @Override
+@@ -34,6 +34,11 @@ public class AdblockAllowedDomainsFragment extends AdblockCustomItemFragment {
+ getActivity().setTitle(R.string.fragment_adblock_settings_allowed_domains_title);
+ }
+
++ @Override
++ protected String getItemText(String item) {
++ return item;
++ }
++
+ @Override
+ protected List getItems() {
+ return AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+diff --git a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFilterListsFragment.java b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFilterListsFragment.java
+--- a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFilterListsFragment.java
++++ b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFilterListsFragment.java
+@@ -26,13 +26,14 @@ import android.widget.Toast;
+ import org.chromium.chrome.browser.adblock.R;
+ import org.chromium.chrome.browser.profiles.ProfileManager;
+ import org.chromium.components.adblock.AdblockController;
++import org.chromium.components.adblock.AdblockController.Subscription;
+
+ import java.net.MalformedURLException;
+ import java.net.URL;
+ import java.util.ArrayList;
+ import java.util.List;
+
+-public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment {
++public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment {
+ private static final String TAG = AdblockCustomFilterListsFragment.class.getSimpleName();
+
+ public AdblockCustomFilterListsFragment() {}
+@@ -44,29 +45,19 @@ public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment
+ }
+
+ @Override
+- protected List getItems() {
+- final List installed =
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .getInstalledSubscriptions();
+- final List recommended =
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .getRecommendedSubscriptions();
+- final List customStrings = new ArrayList();
+- for (final AdblockController.Subscription subscription : installed) {
+- if (recommended.contains(subscription)) {
+- continue;
+- }
+- // FIXME(kzlomek): Remove this after DPD-1613
+- if (subscription
+- .url()
+- .toString()
+- .equals("https://easylist-downloads.adblockplus.org/exceptionrules.txt")) {
+- continue;
+- }
+- customStrings.add(subscription.url().toString());
+- }
++ protected List getItems() {
++ return AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
++ .getCustomSubscriptions();
++ }
++
++ @Override
++ protected String getItemText(Subscription item) {
++ return item.url().toString();
++ }
+
+- return customStrings;
++ @Override
++ protected String getItemStatus(Subscription item) {
++ return item.getDescription();
+ }
+
+ @Override
+diff --git a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFiltersFragment.java b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFiltersFragment.java
+--- a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFiltersFragment.java
++++ b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomFiltersFragment.java
+@@ -25,9 +25,14 @@ import org.chromium.components.adblock.AdblockController;
+
+ import java.util.List;
+
+-public class AdblockCustomFiltersFragment extends AdblockCustomItemFragment {
++public class AdblockCustomFiltersFragment extends AdblockCustomItemFragment {
+ public AdblockCustomFiltersFragment() {}
+
++ @Override
++ protected String getItemText(String item) {
++ return item;
++ }
++
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+diff --git a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomItemFragment.java b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomItemFragment.java
+--- a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomItemFragment.java
++++ b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockCustomItemFragment.java
+@@ -33,7 +33,7 @@ import org.chromium.chrome.browser.adblock.R;
+
+ import java.util.List;
+
+-public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat {
++public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat {
+ private EditText mItem;
+ private ImageView mAddButton;
+ private ListView mListView;
+@@ -75,7 +75,7 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
+
+ protected abstract void removeItemImpl(String item);
+
+- protected abstract List getItems();
++ protected abstract List getItems();
+
+ protected abstract String getCustomItemTextViewText();
+
+@@ -90,10 +90,12 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
+ // Holder for listview items
+ private class Holder {
+ TextView mItem;
++ TextView mStatus;
+ ImageView mRemoveButton;
+
+ Holder(View rootView) {
+ mItem = rootView.findViewById(R.id.fragment_adblock_custom_item_title);
++ mStatus = rootView.findViewById(R.id.fragment_adblock_custom_item_status);
+ mRemoveButton = rootView.findViewById(R.id.fragment_adblock_custom_item_remove);
+ mRemoveButton.setContentDescription(
+ AdblockCustomItemFragment.this.getCustomItemRemoveButtonContentDescription());
+@@ -107,6 +109,7 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
+ String item = (String) v.getTag();
+ removeItemImpl(item);
+ mAdapter.notifyDataSetChanged();
++ mItem.setText(item);
+ }
+ };
+
+@@ -134,16 +137,23 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
+ convertView.setTag(new Holder(convertView));
+ }
+
+- String item = (String) getItem(position);
++ T item = (T) getItem(position);
+ Holder holder = (Holder) convertView.getTag();
+- holder.mItem.setText(item.toString());
++ holder.mItem.setText(getItemText(item));
++ holder.mStatus.setText(getItemStatus(item));
+ holder.mRemoveButton.setOnClickListener(removeItemClickListener);
+- holder.mRemoveButton.setTag(item.toString());
++ holder.mRemoveButton.setTag(getItemText(item));
+
+ return convertView;
+ }
+ }
+
++ protected abstract String getItemText(T item);
++
++ protected String getItemStatus(T item) {
++ return null;
++ }
++
+ private void initControls() {
+ mAddButton.setOnClickListener(
+ new View.OnClickListener() {
+diff --git a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockFilterListsAdapter.java b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockFilterListsAdapter.java
+--- a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockFilterListsAdapter.java
++++ b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockFilterListsAdapter.java
+@@ -79,10 +79,13 @@ public class AdblockFilterListsAdapter extends BaseAdapter implements OnClickLis
+ mController.getInstalledSubscriptions();
+ boolean subscribed = false;
+ boolean autoinstalled = false;
++ TextView status = view.findViewById(R.id.status);
++ status.setText("");
+ for (final AdblockController.Subscription subscription : subscriptions) {
+ if (subscription.url().equals(item.url())) {
+ subscribed = true;
+ autoinstalled = subscription.autoinstalled();
++ status.setText(subscription.getDescription());
+ break;
+ }
+ }
+@@ -93,6 +96,9 @@ public class AdblockFilterListsAdapter extends BaseAdapter implements OnClickLis
+ TextView description = view.findViewById(R.id.name);
+ description.setText(item.title());
+ description.setContentDescription(item.title() + "filer list item title text");
++
++ TextView url = view.findViewById(R.id.url);
++ url.setText(item.url().toString());
+ return view;
+ }
+
+diff --git a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockSettingsFragment.java b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockSettingsFragment.java
+--- a/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockSettingsFragment.java
++++ b/chrome/browser/adblock/android/java/src/org/chromium/chrome/browser/adblock/settings/AdblockSettingsFragment.java
+@@ -13,6 +13,7 @@
+ package org.chromium.chrome.browser.adblock.settings;
+
+ import android.os.Bundle;
++import android.widget.Toast;
+
+ import androidx.preference.Preference;
+ import androidx.preference.PreferenceFragmentCompat;
+@@ -20,20 +21,33 @@ import androidx.preference.PreferenceFragmentCompat;
+ import org.chromium.build.BuildConfig;
+ import org.chromium.chrome.browser.adblock.R;
+ import org.chromium.chrome.browser.preferences.Pref;
++import org.chromium.chrome.browser.profiles.Profile;
+ import org.chromium.chrome.browser.profiles.ProfileManager;
+ import org.chromium.components.adblock.AdblockController;
+ import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
+ import org.chromium.components.user_prefs.UserPrefs;
+
+-public class AdblockSettingsFragment extends PreferenceFragmentCompat
+- implements Preference.OnPreferenceChangeListener {
++public class AdblockSettingsFragment
++ extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
+ private ChromeSwitchPreference mAdblockEnabled;
+ private ChromeSwitchPreference mAcceptableAdsEnabled;
+ private ChromeSwitchPreference mAutoInstalledEnabled;
+ private Preference mFilterLists;
+ private Preference mAllowedDomains;
+ private Preference mMoreOptions;
+-
++ private Preference mStartUpdate;
++ private ChromeSwitchPreference mPrivilegedFilters;
++
++ private static final String START_UPDATE_KEY =
++ "fragment_adblock_settings_start_update";
++ private static final String PRIVILEGED_FILTERS_KEY =
++ "fragment_adblock_privileged_filters_enabled_key";
++ private static final String FILTER_LISTS_KEY =
++ "fragment_adblock_settings_filter_lists_key";
++ private static final String CUSTOM_FILTER_LISTS_KEY =
++ "fragment_adblock_more_options_custom_filter_lists_key";
++ private static final String CUSTOM_FILTER_KEY =
++ "fragment_adblock_more_options_custom_filter_key";
+ private static final String SETTINGS_ENABLED_KEY = "fragment_adblock_settings_enabled_key";
+ private static final String SETTINGS_FILTER_LISTS_KEY =
+ "fragment_adblock_settings_filter_lists_key";
+@@ -52,9 +66,21 @@ public class AdblockSettingsFragment extends PreferenceFragmentCompat
+ private long mOnOffTogleTimestamp;
+
+ private void bindPreferences() {
++ mStartUpdate = findPreference(START_UPDATE_KEY);
++ mStartUpdate.setOnPreferenceClickListener(preference -> {
++ AdblockController.getInstance(
++ ProfileManager.getLastUsedRegularProfile()).startUpdate();
++ Toast toast = Toast.makeText(getContext(),
++ "Checking for updates in progress", Toast.LENGTH_LONG);
++ toast.show();
++ // handle the click so the default action isn't triggered.
++ return true;
++ });
++ mPrivilegedFilters = (ChromeSwitchPreference) findPreference(PRIVILEGED_FILTERS_KEY);
+ mAdblockEnabled = (ChromeSwitchPreference) findPreference(SETTINGS_ENABLED_KEY);
+ mFilterLists = findPreference(SETTINGS_FILTER_LISTS_KEY);
+ mAcceptableAdsEnabled = (ChromeSwitchPreference) findPreference(SETTINGS_AA_ENABLED_KEY);
++ mAcceptableAdsEnabled.setVisible(false);
+ mAutoInstalledEnabled =
+ (ChromeSwitchPreference) findPreference(SETTINGS_AUTO_INSTALL_ENABLED_KEY);
+ mAllowedDomains = findPreference(SETTINGS_ALLOWED_DOMAINS_KEY);
+@@ -62,35 +88,43 @@ public class AdblockSettingsFragment extends PreferenceFragmentCompat
+ }
+
+ private boolean areMoreOptionsEnabled() {
+- return UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
+- .getBoolean(Pref.ADBLOCK_MORE_OPTIONS_ENABLED);
++ return false;
+ }
+
+ private void applyAdblockEnabled(boolean enabledValue) {
+- mFilterLists.setEnabled(enabledValue);
+- mAcceptableAdsEnabled.setEnabled(enabledValue);
++ mStartUpdate.setEnabled(enabledValue);
+ mAutoInstalledEnabled.setEnabled(enabledValue);
++ mPrivilegedFilters.setEnabled(enabledValue);
+ mAllowedDomains.setEnabled(enabledValue);
+ mMoreOptions.setEnabled(enabledValue);
+ mMoreOptions.setVisible(areMoreOptionsEnabled());
+ }
+
+ private void synchronizePreferences() {
+- boolean enabled =
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .isEnabled();
++ AdblockController controller =
++ AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile());
++
++ findPreference(FILTER_LISTS_KEY).setTitle(
++ getContext().getString(R.string.fragment_adblock_settings_filter_lists_title_count,
++ controller.getInstalledSubscriptions().size()));
++ findPreference(CUSTOM_FILTER_LISTS_KEY).setTitle(
++ getContext().getString(R.string.fragment_adblock_more_options_custom_filter_lists_title_count,
++ controller.getCustomSubscriptions().size()));
++ findPreference(CUSTOM_FILTER_KEY).setTitle(
++ getContext().getString(R.string.fragment_adblock_more_options_custom_filters_title_count,
++ controller.getCustomFilters().size()));
++ mPrivilegedFilters.setChecked(controller.isPrivilegedFiltersEnabled());
++ mPrivilegedFilters.setOnPreferenceChangeListener(this);
++ boolean enabled = controller.isEnabled();
+ mAdblockEnabled.setChecked(enabled);
+ mAdblockEnabled.setOnPreferenceChangeListener(this);
+ applyAdblockEnabled(enabled);
+
+- mAcceptableAdsEnabled.setChecked(
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .isAcceptableAdsEnabled());
++ mAcceptableAdsEnabled.setChecked(controller.isAcceptableAdsEnabled());
+ mAcceptableAdsEnabled.setOnPreferenceChangeListener(this);
+
+ mAutoInstalledEnabled.setChecked(
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .isAutoInstallEnabled());
++ controller.isAutoInstallEnabled());
+ mAutoInstalledEnabled.setOnPreferenceChangeListener(this);
+ }
+
+@@ -122,7 +156,7 @@ public class AdblockSettingsFragment extends PreferenceFragmentCompat
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+- addPreferencesFromResource(R.xml.adblock_preferences);
++ addPreferencesFromResource(R.xml.eyeo_adblock_preferences);
+ bindPreferences();
+ synchronizePreferences();
+ }
+@@ -137,19 +171,16 @@ public class AdblockSettingsFragment extends PreferenceFragmentCompat
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference.getKey().equals(SETTINGS_ENABLED_KEY)) {
+ AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .setEnabled((Boolean) newValue);
++ .setEnabled(
++ (Boolean) newValue);
+
+ maybeEnableMoreOptions();
+
+ applyAdblockEnabled((Boolean) newValue);
+- } else if (preference.getKey().equals(SETTINGS_AA_ENABLED_KEY)) {
+- AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .setAcceptableAdsEnabled((Boolean) newValue);
+- } else {
+- assert preference.getKey().equals(SETTINGS_AUTO_INSTALL_ENABLED_KEY);
+-
++ } else if (preference.getKey().equals(PRIVILEGED_FILTERS_KEY)) {
+ AdblockController.getInstance(ProfileManager.getLastUsedRegularProfile())
+- .setAutoInstallEnabled((Boolean) newValue);
++ .setPrivilegedFiltersEnabled(
++ (Boolean) newValue);
+ }
+ return true;
+ }
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
@@ -769,17 +830,15 @@ diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chr
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
-@@ -18,7 +18,8 @@
+@@ -17,6 +17,7 @@
+
#include "base/containers/flat_map.h"
+ #include "base/i18n/time_formatting.h"
++#include "base/strings/utf_string_conversions.h"
#include "base/logging.h"
#include "base/no_destructor.h"
--#include "base/time/time_to_iso8601.h"
-+#include "base/i18n/time_formatting.h"
-+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
- #include "chrome/browser/adblock/resource_classification_runner_factory.h"
- #include "chrome/browser/adblock/session_stats_factory.h"
-@@ -77,26 +78,12 @@ std::vector CopySessionsStats(
+@@ -94,27 +95,12 @@ std::vector CopySessionsStats(
return result;
}
@@ -789,14 +848,15 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
- switch (state) {
- case State::Installed:
- return "Installed";
-- case State::Installing:
-- return "Installing";
+- case State::AutoInstalled:
+- return "AutoInstalled";
- case State::Preloaded:
- return "Preloaded";
+- case State::Installing:
+- return "Installing";
- case State::Unknown:
- return "Unknown";
- }
-- NOTREACHED();
- return "";
-}
-
@@ -809,14 +869,17 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
std::vector result;
for (auto& sub : current_subscriptions) {
api::adblock_private::Subscription js_sub;
-@@ -104,9 +91,13 @@ std::vector CopySubscriptions(
+@@ -122,12 +108,13 @@ std::vector CopySubscriptions(
js_sub.title = sub->GetTitle();
js_sub.current_version = sub->GetCurrentVersion();
js_sub.installation_state =
- SubscriptionInstallationStateToString(sub->GetInstallationState());
+- const auto installation_time = sub->GetInstallationTime();
+ adblock::Subscription::SubscriptionInstallationStateToString(sub->GetInstallationState());
js_sub.last_installation_time =
-- base::TimeToISO8601(sub->GetInstallationTime());
+- installation_time.is_null()
+- ? ""
+- : base::TimeFormatAsIso8601(sub->GetInstallationTime());
+ base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(sub->GetInstallationTime()));
+ if (metadata) {
+ js_sub.download_success_count = metadata->GetDownloadSuccessCount(sub->GetSourceUrl());
@@ -825,7 +888,7 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
result.emplace_back(std::move(js_sub));
}
return result;
-@@ -347,6 +338,47 @@ void AdblockPrivateAPI::OnListenerAdded(
+@@ -367,6 +354,47 @@ void AdblockPrivateAPI::OnListenerAdded(
namespace api {
@@ -873,13 +936,13 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
AdblockPrivateSetEnabledFunction::AdblockPrivateSetEnabledFunction() {}
AdblockPrivateSetEnabledFunction::~AdblockPrivateSetEnabledFunction() {}
-@@ -514,7 +546,7 @@ AdblockPrivateGetInstalledSubscriptionsFunction::Run() {
- << "adblock_private expects \"adblock\" configuration";
+@@ -555,7 +583,7 @@ AdblockPrivateGetInstalledSubscriptionsFunction::Run() {
+ GetAdblockConfiguration(GetOriginalBrowserContext(browser_context()));
return RespondNow(ArgumentList(
api::adblock_private::GetInstalledSubscriptions::Results::Create(
- CopySubscriptions(subscription_service->GetCurrentSubscriptions(
+ CopySubscriptions(subscription_service, subscription_service->GetCurrentSubscriptions(
- subscription_service->GetAdblockFilteringConfiguration())))));
+ adblock_configuration)))));
}
diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.h b/chrome/browser/extensions/api/adblock_private/adblock_private_api.h
@@ -944,25 +1007,23 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.h
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
-@@ -18,7 +18,8 @@
+@@ -17,6 +17,7 @@
+
#include "base/containers/flat_map.h"
+ #include "base/i18n/time_formatting.h"
++#include "base/strings/utf_string_conversions.h"
#include "base/logging.h"
#include "base/no_destructor.h"
--#include "base/time/time_to_iso8601.h"
-+#include "base/i18n/time_formatting.h"
-+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
- #include "chrome/browser/adblock/resource_classification_runner_factory.h"
- #include "chrome/browser/adblock/session_stats_factory.h"
-@@ -29,6 +30,7 @@
- #include "components/adblock/content/browser/resource_classification_runner.h"
+@@ -30,6 +31,7 @@
+ #include "components/adblock/core/common/adblock_prefs.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 +96,6 @@ std::vector CopySessionsStats(
+@@ -95,24 +97,6 @@ std::vector CopySessionsStats(
return result;
}
@@ -972,74 +1033,86 @@ diff --git a/chrome/browser/extensions/api/eyeo_filtering_private/eyeo_filtering
- switch (state) {
- case State::Installed:
- return "Installed";
-- case State::Installing:
-- return "Installing";
+- case State::AutoInstalled:
+- return "AutoInstalled";
- case State::Preloaded:
- return "Preloaded";
+- case State::Installing:
+- return "Installing";
- case State::Unknown:
- return "Unknown";
- }
-- NOTREACHED();
- return "";
-}
-
std::vector CopySubscriptions(
const std::vector>
current_subscriptions) {
-@@ -121,9 +106,9 @@ std::vector CopySubscriptions(
+@@ -123,12 +107,12 @@ 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());
+ const auto installation_time = sub->GetInstallationTime();
js_sub.last_installation_time =
-- base::TimeToISO8601(sub->GetInstallationTime());
-+ base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(sub->GetInstallationTime()));
+ installation_time.is_null()
+ ? ""
+- : base::TimeFormatAsIso8601(sub->GetInstallationTime());
++ : base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(sub->GetInstallationTime()));
result.emplace_back(std::move(js_sub));
}
return result;
+diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc
+--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
++++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
+@@ -32,6 +32,7 @@
+ #include "chrome/browser/ui/toolbar/toolbar_pref_names.h"
+ #include "chrome/common/chrome_features.h"
+ #include "chrome/common/pref_names.h"
++#include "components/adblock/core/common/adblock_prefs.h"
+ #include "components/autofill/core/common/autofill_prefs.h"
+ #include "components/bookmarks/common/bookmark_pref_names.h"
+ #include "components/browsing_data/core/pref_names.h"
+@@ -175,6 +176,19 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() {
+ }
+ s_allowlist = new PrefsUtil::TypedPrefMap();
+
++ // Adblock settings
++ (*s_allowlist)[adblock::common::prefs::kEnableAdblockLegacy] =
++ settings_api::PrefType::kBoolean;
++ (*s_allowlist)[adblock::common::prefs::kEnableAcceptableAdsLegacy] =
++ settings_api::PrefType::kBoolean;
++ (*s_allowlist)[adblock::common::prefs::kAdblockSubscriptionsLegacy] =
++ settings_api::PrefType::kList;
++ (*s_allowlist)[adblock::common::prefs::kAdblockCustomSubscriptionsLegacy] =
++ settings_api::PrefType::kList;
++ (*s_allowlist)[adblock::common::prefs::kAdblockAllowedDomainsLegacy] =
++ settings_api::PrefType::kList;
++ (*s_allowlist)[adblock::common::prefs::kAdblockCustomFiltersLegacy] =
++ settings_api::PrefType::kList;
+ // Miscellaneous
+ (*s_allowlist)[::embedder_support::kAlternateErrorPagesEnabled] =
+ settings_api::PrefType::kBoolean;
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
-@@ -19,7 +19,6 @@
- #include "chrome/browser/affiliations/affiliation_service_factory.h"
- #include "chrome/browser/ai/ai_data_keyed_service_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"
-@@ -906,7 +905,6 @@ void ChromeBrowserMainExtraPartsProfiles::
+@@ -250,7 +250,6 @@
+ #include "chrome/common/buildflags.h"
+ #include "chrome/common/chrome_features.h"
+ #include "components/adblock/content/browser/factories/adblock_request_throttle_factory.h"
+-#include "components/adblock/content/browser/factories/adblock_telemetry_service_factory.h"
+ #include "components/adblock/content/browser/factories/content_security_policy_injector_factory.h"
+ #include "components/adblock/content/browser/factories/element_hider_factory.h"
+ #include "components/adblock/content/browser/factories/resource_classification_runner_factory.h"
+@@ -899,7 +898,6 @@ void ChromeBrowserMainExtraPartsProfiles::
+ // Makes manual testing possible.
FakeSmartCardDeviceServiceFactory::GetInstance();
#endif
- adblock::AdblockControllerFactory::GetInstance();
- adblock::AdblockTelemetryServiceFactory::GetInstance();
+ adblock::AdblockRequestThrottleFactory::GetInstance();
adblock::ContentSecurityPolicyInjectorFactory::GetInstance();
adblock::ElementHiderFactory::GetInstance();
- adblock::ResourceClassificationRunnerFactory::GetInstance();
-diff --git a/chrome/browser/resources/adblock_internals/BUILD.gn b/chrome/browser/resources/adblock_internals/BUILD.gn
---- a/chrome/browser/resources/adblock_internals/BUILD.gn
-+++ b/chrome/browser/resources/adblock_internals/BUILD.gn
-@@ -18,12 +18,18 @@ import("//ui/webui/resources/tools/build_webui.gni")
-
- build_webui("build") {
- grd_prefix = "adblock_internals"
-+
- static_files = [ "adblock_internals.html" ]
-+
- non_web_component_files = [ "adblock_internals.ts" ]
-- mojo_files_deps = [ "//chrome/browser/ui/webui/adblock_internals:mojo_bindings_ts__generator" ]
-+
-+ mojo_files_deps =
-+ [ "//chrome/browser/ui/webui/adblock_internals:mojo_bindings_ts__generator" ]
- mojo_files = [ "$root_gen_dir/chrome/browser/ui/webui/adblock_internals/adblock_internals.mojom-webui.ts" ]
-+
- ts_deps = [
- "//ui/webui/resources/js:build_ts",
- "//ui/webui/resources/mojo:build_ts",
- ]
-+ webui_context_type = "trusted"
- }
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
@@ -1650,7 +1723,7 @@ diff --git a/chrome/browser/resources/settings/settings_menu/settings_menu.html
+
@@ -1660,166 +1733,62 @@ diff --git a/chrome/browser/resources/settings/settings_menu/settings_menu.html
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
-@@ -20,6 +20,7 @@
- #include "chrome/browser/adblock/element_hider_factory.h"
- #include "chrome/browser/adblock/sitekey_storage_factory.h"
- #include "chrome/browser/adblock/subscription_service_factory.h"
-+#include "chrome/browser/adblock/adblock_controller_factory.h"
- #include "chrome/browser/bookmarks/bookmark_model_factory.h"
- #include "chrome/browser/breadcrumbs/breadcrumb_manager_tab_helper.h"
- #include "chrome/browser/browser_process.h"
-@@ -341,6 +342,8 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
- }
- }
+@@ -342,7 +342,8 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
+ auto* original_profile = profile->GetOriginalProfile();
+ adblock::EnsureBackgroundServicesStarted(original_profile);
+ adblock::RegisterAdblockWebContentObserver<
+- adblock::AdblockWebContentObserver>(web_contents, original_profile);
++ adblock::AdblockWebContentObserver>(web_contents, original_profile,
++ HostContentSettingsMapFactory::GetForProfile(profile));
-+ adblock::AdblockControllerFactory::GetForBrowserContext(
-+ web_contents->GetBrowserContext());
- AdblockWebContentObserver::CreateForWebContents(
- web_contents,
- adblock::SubscriptionServiceFactory::GetForBrowserContext(
-@@ -349,7 +352,8 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
- web_contents->GetBrowserContext()),
- adblock::SitekeyStorageFactory::GetForBrowserContext(
- web_contents->GetBrowserContext()),
-- std::make_unique());
-+ std::make_unique(),
-+ HostContentSettingsMapFactory::GetForProfile(profile));
autofill::AutofillClientProvider& autofill_client_provider =
autofill::AutofillClientProviderFactory::GetForProfile(profile);
- autofill_client_provider.CreateClientForWebContents(web_contents);
-diff --git a/chrome/browser/ui/webui/adblock_internals/adblock_internals_page_handler_impl.cc b/chrome/browser/ui/webui/adblock_internals/adblock_internals_page_handler_impl.cc
---- a/chrome/browser/ui/webui/adblock_internals/adblock_internals_page_handler_impl.cc
-+++ b/chrome/browser/ui/webui/adblock_internals/adblock_internals_page_handler_impl.cc
-@@ -17,11 +17,10 @@
-
- #include "chrome/browser/ui/webui/adblock_internals/adblock_internals_page_handler_impl.h"
-
--#include "base/time/time_to_iso8601.h"
--#include "chrome/browser/adblock/adblock_telemetry_service_factory.h"
-+#include "base/i18n/time_formatting.h"
-+#include "base/strings/utf_string_conversions.h"
- #include "chrome/browser/adblock/session_stats_factory.h"
- #include "chrome/browser/adblock/subscription_service_factory.h"
--#include "components/adblock/core/adblock_telemetry_service.h"
- #include "components/adblock/core/session_stats.h"
- #include "components/adblock/core/subscription/subscription_config.h"
- #include "components/adblock/core/subscription/subscription_service.h"
-@@ -42,7 +41,6 @@ std::string SubscriptionInstallationStateToString(
- return "Unknown";
- }
- NOTREACHED();
-- return "";
- }
-
- std::string DebugLine(std::string name, std::string value, int level) {
-@@ -53,6 +51,13 @@ std::string DebugLine(std::string name, int value, int level) {
- return DebugLine(name, std::to_string(value), level);
- }
-
-+std::string FormatInstallationTime(base::Time time) {
-+ if (time.is_null()) {
-+ return "Never";
-+ }
-+ return base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(time));
-+}
-+
- } // namespace
-
- AdblockInternalsPageHandlerImpl::AdblockInternalsPageHandlerImpl(
-@@ -90,17 +95,13 @@ void AdblockInternalsPageHandlerImpl::GetDebugInfo(
- content += DebugLine("Title", it->GetTitle(), 2);
- content += DebugLine("Version", it->GetCurrentVersion(), 2);
- content += DebugLine("Last update",
-- base::TimeToISO8601(it->GetInstallationTime()), 2);
-+ FormatInstallationTime(it->GetInstallationTime()), 2);
- content += DebugLine("Total allowed", allowed[url], 2);
- content += DebugLine("Total blocked", blocked[url], 2);
- }
- }
-
-- auto* telemetry_service =
-- adblock::AdblockTelemetryServiceFactory::GetForProfile(profile_);
-- telemetry_service->GetTopicProvidersDebugInfo(base::BindOnce(
-- &AdblockInternalsPageHandlerImpl::OnTelemetryServiceInfoArrived,
-- std::move(callback), std::move(content)));
-+ std::move(callback).Run(std::move(content));
- }
-
- void AdblockInternalsPageHandlerImpl::OnTelemetryServiceInfoArrived(
-diff --git a/chrome/browser/ui/webui/adblock_internals/adblock_internals_ui.cc b/chrome/browser/ui/webui/adblock_internals/adblock_internals_ui.cc
---- a/chrome/browser/ui/webui/adblock_internals/adblock_internals_ui.cc
-+++ b/chrome/browser/ui/webui/adblock_internals/adblock_internals_ui.cc
-@@ -30,8 +30,7 @@ AdblockInternalsUI::AdblockInternalsUI(content::WebUI* web_ui)
- content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd(
- profile_, chrome::kChromeUIAdblockInternalsHost);
- webui::SetupWebUIDataSource(source,
-- base::make_span(kAdblockInternalsResources,
-- kAdblockInternalsResourcesSize),
-+ base::span(kAdblockInternalsResources),
- IDR_ADBLOCK_INTERNALS_ADBLOCK_INTERNALS_HTML);
- }
-
-diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
---- a/chrome/common/extensions/api/_api_features.json
-+++ b/chrome/common/extensions/api/_api_features.json
-@@ -71,7 +71,7 @@
- },
- "adblockPrivate": [{
- "dependencies": ["permission:adblockPrivate"],
-- "contexts": ["blessed_extension"]
-+ "contexts": ["privileged_extension"]
- }, {
- "channel": "stable",
- "contexts": ["webui"],
-@@ -541,7 +541,7 @@
- },
- "eyeoFilteringPrivate": [{
- "dependencies": ["permission:eyeoFilteringPrivate"],
-- "contexts": ["blessed_extension"]
-+ "contexts": ["privileged_extension"]
- }, {
- "channel": "stable",
- "contexts": ["webui"],
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
-@@ -66,10 +66,6 @@
+@@ -66,13 +66,6 @@
"extension"
]
},
- "adblockPrivate": {
- "channel": "stable",
-- "extension_types": ["extension", "platform_app"]
+- "extension_types": ["extension", "platform_app"],
+- "allowlist" : [
+- "664F11343A17783FC7F6DC994BBC8AAF6823739C" // eyeo test extension
+- ]
- },
"autofillPrivate": {
"channel": "trunk",
"extension_types": ["extension", "platform_app"],
-@@ -180,10 +176,6 @@
- "extension", "legacy_packaged_app", "hosted_app", "platform_app"
- ]
+@@ -387,13 +380,6 @@
+ "channel": "beta",
+ "command_line_switch": "extension-ai-data-collection"
},
- "eyeoFilteringPrivate": {
- "channel": "stable",
-- "extension_types": ["extension", "platform_app"]
+- "extension_types": ["extension", "platform_app"],
+- "allowlist" : [
+- "664F11343A17783FC7F6DC994BBC8AAF6823739C" // eyeo test extension
+- ]
- },
- "commandLinePrivate": {
+ "favicon": {
"channel": "stable",
- "extension_types": ["extension", "legacy_packaged_app", "platform_app"],
+ "extension_types": ["extension"]
diff --git a/chrome/common/extensions/api/adblock_private.idl b/chrome/common/extensions/api/adblock_private.idl
--- a/chrome/common/extensions/api/adblock_private.idl
+++ b/chrome/common/extensions/api/adblock_private.idl
-@@ -47,6 +47,8 @@ dictionary Subscription {
- // Time of last successful installation or update, in ISO 8601 format.
+@@ -48,6 +48,8 @@ dictionary Subscription {
// May be passed directly to the Date constructor.
+ // Empty for subscriptions that are not installed yet.
DOMString last_installation_time;
+ long download_success_count;
+ long download_error_count;
};
dictionary SessionStatsEntry {
-@@ -97,6 +99,12 @@ callback ListCallback = void(DOMString[] result);
- callback SessionStatsCallback = void(SessionStatsEntry[] result);
+@@ -99,6 +101,12 @@ callback SessionStatsCallback = void(SessionStatsEntry[] result);
+ [deprecated="Use eyeoFilteringPrivate methods instead."]
interface Functions {
+ // Start an update cycle
+ static void startUpdate();
@@ -1830,336 +1799,145 @@ diff --git a/chrome/common/extensions/api/adblock_private.idl b/chrome/common/ex
// Allows to turn Adblock on or off.
static void setEnabled(boolean enabled);
// Returns whether Adblock is on.
-diff --git a/components/adblock/android/BUILD.gn b/components/adblock/android/BUILD.gn
---- a/components/adblock/android/BUILD.gn
-+++ b/components/adblock/android/BUILD.gn
-@@ -14,6 +14,7 @@
- import("//build/config/android/rules.gni")
- import("//build/config/locales.gni")
- import("//tools/grit/grit_rule.gni")
-+import("//third_party/jni_zero/jni_zero.gni")
-
- source_set("java_bindings") {
- sources = [
-@@ -119,7 +120,7 @@ android_resources("java_ui_resources") {
- "java/res/layout/adblock_custom_item_settings.xml",
- "java/res/layout/adblock_filter_lists_list_item.xml",
- "java/res/xml/adblock_more_options.xml",
-- "java/res/xml/adblock_preferences.xml",
-+ "java/res/xml/eyeo_adblock_preferences.xml",
- ]
-
- deps = [ ":adblock_strings_grd" ]
-diff --git a/components/adblock/android/adblock_jni.cc b/components/adblock/android/adblock_jni.cc
---- a/components/adblock/android/adblock_jni.cc
-+++ b/components/adblock/android/adblock_jni.cc
-@@ -25,6 +25,8 @@
+diff --git a/components/adblock/android/adblock_controller_jni.cc b/components/adblock/android/adblock_controller_jni.cc
+--- a/components/adblock/android/adblock_controller_jni.cc
++++ b/components/adblock/android/adblock_controller_jni.cc
+@@ -23,6 +23,8 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/jni_weak_ref.h"
+#include "base/i18n/time_formatting.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/logging.h"
- #include "components/adblock/android/java_bindings_getters.h"
#include "components/adblock/android/jni_headers/AdblockController_jni.h"
-@@ -54,6 +56,10 @@ ScopedJavaLocalRef ToJava(JNIEnv* env,
+ #include "components/adblock/content/browser/factories/subscription_service_factory.h"
+@@ -48,6 +50,9 @@ 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) {
++ long download_success_count, long download_error_count,
+ const std::vector& languages,
+ const bool autoinstalled) {
ScopedJavaLocalRef url_param(
- env, env->NewObject(url_class.obj(), url_constructor,
-@@ -62,12 +68,19 @@ ScopedJavaLocalRef ToJava(JNIEnv* env,
+@@ -57,13 +62,23 @@ ScopedJavaLocalRef ToJava(JNIEnv* env,
return Java_Subscription_Constructor(env, url_param,
ConvertUTF8ToJavaString(env, title),
ConvertUTF8ToJavaString(env, version),
-+ ConvertUTF8ToJavaString(env, Subscription::SubscriptionInstallationStateToString(state)),
++ ConvertUTF8ToJavaString(env, adblock::Subscription::SubscriptionInstallationStateToString(state)),
+ ConvertUTF8ToJavaString(env, installation_time),
-+ download_success_count,
-+ download_error_count,
- ToJavaArrayOfStrings(env, languages));
++ download_success_count ? JNI_TRUE : JNI_FALSE,
++ download_error_count ? JNI_TRUE : JNI_FALSE,
+ ToJavaArrayOfStrings(env, languages),
+ autoinstalled ? JNI_TRUE : JNI_FALSE);
}
std::vector> CSubscriptionsToJObjects(
JNIEnv* env,
- const std::vector>& subscriptions) {
-+ auto* subscription_service = adblock::GetSubscriptionService();
++ const base::android::JavaParamRef& jbrowser_context_handle,
+ const std::vector>& subscriptions) {
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ content::BrowserContextFromJavaHandle(jbrowser_context_handle));
+ raw_ptr metadata =
-+ subscription_service->GetMetadata();
++ subscription_service->GetMetadata();
ScopedJavaLocalRef url_class = GetClass(env, "java/net/URL");
jmethodID url_constructor = MethodID::Get(
env, url_class.obj(), "", "(Ljava/lang/String;)V");
-@@ -76,7 +89,11 @@ std::vector> CSubscriptionsToJObjects(
+@@ -72,7 +87,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(), std::vector{},
+ sub->GetTitle(), sub->GetCurrentVersion(),
+ sub->GetInstallationState(), base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(sub->GetInstallationTime())),
+ metadata ? metadata->GetDownloadSuccessCount(sub->GetSourceUrl()) : 0,
+ metadata ? metadata->GetDownloadErrorCount(sub->GetSourceUrl()) : 0,
-+ std::vector{}));
++ std::vector{},
+ sub->GetInstallationState() ==
+ adblock::InstalledSubscription::InstallationState::AutoInstalled));
}
- return jobjects;
- }
-@@ -96,6 +113,9 @@ std::vector> CSubscriptionsToJObjects(
+@@ -93,7 +112,11 @@ std::vector> CSubscriptionsToJObjects(
+ DCHECK(sub.url.is_valid());
if (sub.url.is_valid()) {
jobjects.push_back(ToJava(env, url_class, url_constructor,
- sub.url.spec(), sub.title, "",
+- sub.url.spec(), sub.title, "", sub.languages,
++ sub.url.spec(), sub.title, /*version*/"",
+ adblock::Subscription::InstallationState::Unknown,
+ /*installation_time*/ "",
+ /*download_success_count*/ 0, /*download_error_count*/ 0,
- sub.languages));
++ sub.languages,
+ false));
}
}
-@@ -139,6 +159,37 @@ void AdblockJNI::OnSubscriptionInstalled(const GURL& url) {
+@@ -103,6 +126,52 @@ std::vector> CSubscriptionsToJObjects(
- } // namespace adblock
+ } // namespace
+static void
-+JNI_AdblockController_StartUpdate(JNIEnv* env) {
-+ adblock::GetSubscriptionService()->StartUpdate();
++JNI_AdblockController_StartUpdate(JNIEnv* env,
++ const base::android::JavaParamRef& jbrowser_context_handle) {
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ content::BrowserContextFromJavaHandle(jbrowser_context_handle));
++ subscription_service->StartUpdate();
+}
+
+static base::android::ScopedJavaLocalRef
-+JNI_AdblockController_GetCustomSubscriptions(JNIEnv* env) {
++JNI_AdblockController_GetCustomSubscriptions(JNIEnv* env,
++ const base::android::JavaParamRef& jbrowser_context_handle) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-+ auto* subscription_service = adblock::GetSubscriptionService();
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ content::BrowserContextFromJavaHandle(jbrowser_context_handle));
+ if (!subscription_service) {
+ return ToJavaArrayOfObjects(env,
+ std::vector>{});
+ }
+
+ return ToJavaArrayOfObjects(
-+ env, adblock::CSubscriptionsToJObjects(
-+ env, subscription_service->GetCustomSubscriptions(
++ env, CSubscriptionsToJObjects(
++ env, jbrowser_context_handle, subscription_service->GetCustomSubscriptions(
+ subscription_service->GetAdblockFilteringConfiguration())));
+}
+
+static jboolean JNI_AdblockController_IsPrivilegedFiltersEnabled(
-+ JNIEnv* env) {
-+ return adblock::GetSubscriptionService()->IsPrivilegedFiltersEnabled() ? JNI_TRUE : JNI_FALSE;
++ JNIEnv* env,
++ const base::android::JavaParamRef& jbrowser_context_handle) {
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ content::BrowserContextFromJavaHandle(jbrowser_context_handle));
++ return subscription_service->IsPrivilegedFiltersEnabled() ? JNI_TRUE : JNI_FALSE;
+}
+
+static void JNI_AdblockController_SetPrivilegedFiltersEnabled(
+ JNIEnv* env,
++ const base::android::JavaParamRef& jbrowser_context_handle,
+ jboolean j_enabled) {
-+ adblock::GetSubscriptionService()->SetPrivilegedFiltersEnabled(j_enabled == JNI_TRUE);
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ content::BrowserContextFromJavaHandle(jbrowser_context_handle));
++ subscription_service->SetPrivilegedFiltersEnabled(j_enabled == JNI_TRUE);
+}
+
- static void JNI_AdblockController_Bind(
+ static base::android::ScopedJavaLocalRef
+ JNI_AdblockController_GetInstalledSubscriptions(
JNIEnv* env,
- const base::android::JavaParamRef& caller) {
-diff --git a/components/adblock/android/adblock_strings.grd b/components/adblock/android/adblock_strings.grd
---- a/components/adblock/android/adblock_strings.grd
-+++ b/components/adblock/android/adblock_strings.grd
-@@ -186,10 +186,52 @@
-
-
-
-- Ad blocking
-+ Adblock Plus settings
-+
-+
-+ Enable Adblock Plus
-+
-+
-+ Check for updates now
-+
-+
-+ 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
-+https://www.cromite.org/filters/abp-filters-anti-cv.txt
-+which is activated by this setting.
-+
-+
-+ Open ABP anti-circumvention filter list repo
-+
-+
-+ Open https://gitlab.com/eyeo/anti-cv/abp-filters-anti-cv in the browser
-+
-+
-+ https://gitlab.com/eyeo/anti-cv/abp-filters-anti-cv
-+
-+
-+ Open ABP Snippets Overview
-+
-+
-+ Open https://developers.eyeo.com/snippets/snippets-overview in the browser
-+
-+
-+ https://developers.eyeo.com/snippets/snippets-overview
-+
-+
-+ Filter lists (%s selected)
-+
-+
-+ Custom ad filtering settings (%s selected)
-+
-+
-+ Custom Filters (%s selected)
-
-
-- Allow ad blocking on websites in this app
-+ Block ads on websites
-
-
- Filter lists
-@@ -216,10 +258,10 @@
- More blocking options
-
-
-- Custom ad filtering settings
-+ Custom ad filtering urls
-
-
-- Add custom filter lists
-+ Add custom filter urls
-
-
- https://example.org/myFilterList.txt
-@@ -228,10 +270,10 @@
- Custom Filters
-
-
-- Add custom filters
-+ Add custom filter commands
-
-
-- Enter filter
-+ Enter filter command
-
-
-
-diff --git a/components/adblock/android/java/res/layout/adblock_custom_item.xml b/components/adblock/android/java/res/layout/adblock_custom_item.xml
---- a/components/adblock/android/java/res/layout/adblock_custom_item.xml
-+++ b/components/adblock/android/java/res/layout/adblock_custom_item.xml
-@@ -25,14 +25,24 @@
- tools:ignore="UseCompoundDrawables">
+@@ -118,7 +187,7 @@ JNI_AdblockController_GetInstalledSubscriptions(
-
--
-+
-+
-+
-
-
-
-
-@@ -32,6 +32,43 @@
- app:iconSpaceReserved="false"
- android:summary="@string/fragment_adblock_settings_filter_lists_summary" />
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-
- GetCurrentSubscriptions(
++ env, jbrowser_context_handle, subscription_service->GetCurrentSubscriptions(
+ subscription_service->GetFilteringConfiguration(
+ adblock::kAdblockFilteringConfigurationName))));
+ }
diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/AdblockController.java b/components/adblock/android/java/src/org/chromium/components/adblock/AdblockController.java
--- a/components/adblock/android/java/src/org/chromium/components/adblock/AdblockController.java
+++ b/components/adblock/android/java/src/org/chromium/components/adblock/AdblockController.java
-@@ -50,7 +50,7 @@ public final class AdblockController extends FilteringConfiguration {
- super("adblock");
+@@ -53,7 +53,7 @@ public class AdblockController {
+ FilteringConfiguration.createConfiguration("adblock", mBrowserContextHandle);
try {
mAcceptableAds =
- new URL("https://easylist-downloads.adblockplus.org/exceptionrules.txt");
@@ -2167,10 +1945,10 @@ diff --git a/components/adblock/android/java/src/org/chromium/components/adblock
} catch (java.net.MalformedURLException e) {
mAcceptableAds = null;
}
-@@ -73,6 +73,10 @@ public final class AdblockController extends FilteringConfiguration {
- private String mTitle;
+@@ -84,6 +84,10 @@ public class AdblockController {
private String mVersion = "";
private String[] mLanguages = {};
+ private boolean mAutoInstalled;
+ private String mState;
+ private String mInstallationTime;
+ private long mDownloadSuccessCount;
@@ -2178,19 +1956,20 @@ diff --git a/components/adblock/android/java/src/org/chromium/components/adblock
public Subscription(final URL url, final String title, final String version) {
this.mUrl = url;
-@@ -82,11 +86,30 @@ public final class AdblockController extends FilteringConfiguration {
-
- @CalledByNative("Subscription")
- public Subscription(
-- final URL url, final String title, final String version, final String[] languages) {
-+ final URL url, final String title, final String version,
-+ final String state, final String installation_time,
+@@ -96,6 +100,9 @@ public class AdblockController {
+ final URL url,
+ final String title,
+ final String version,
++ final String state,
++ final String installation_time,
+ long download_success_count, long download_error_count,
-+ final String[] languages) {
+ final String[] languages,
+ boolean autoinstalled) {
this.mUrl = url;
- this.mTitle = title;
+@@ -103,6 +110,22 @@ public class AdblockController {
this.mVersion = version;
this.mLanguages = languages;
+ this.mAutoInstalled = autoinstalled;
+ this.mState = state;
+ this.mInstallationTime = installation_time;
+ this.mDownloadSuccessCount = download_success_count;
@@ -2210,363 +1989,53 @@ diff --git a/components/adblock/android/java/src/org/chromium/components/adblock
}
public String title() {
-@@ -117,6 +140,7 @@ public final class AdblockController extends FilteringConfiguration {
+@@ -137,6 +160,7 @@ public class AdblockController {
@UiThread
public void setAcceptableAdsEnabled(boolean enabled) {
+ enabled = false;
- if (enabled)
- addFilterList(mAcceptableAds);
- else
-@@ -144,6 +168,27 @@ public final class AdblockController extends FilteringConfiguration {
- removeFilterList(url);
+ if (enabled) mFilteringConfiguration.addFilterList(mAcceptableAds);
+ else mFilteringConfiguration.removeFilterList(mAcceptableAds);
+ }
+@@ -172,6 +196,27 @@ public class AdblockController {
+ mFilteringConfiguration.removeFilterList(url);
}
+ @UiThread
+ public void startUpdate() {
-+ AdblockControllerJni.get().startUpdate();
++ AdblockControllerJni.get().startUpdate(mBrowserContextHandle);
+ }
+
+ @UiThread
+ public List getCustomSubscriptions() {
+ return (List) (List>) Arrays.asList(
-+ AdblockControllerJni.get().getCustomSubscriptions());
++ AdblockControllerJni.get().getCustomSubscriptions(mBrowserContextHandle));
+ }
+
+ @UiThread
+ public void setPrivilegedFiltersEnabled(boolean enabled) {
-+ AdblockControllerJni.get().setPrivilegedFiltersEnabled(enabled);
++ AdblockControllerJni.get().setPrivilegedFiltersEnabled(mBrowserContextHandle, enabled);
+ }
+
+ @UiThread
+ public boolean isPrivilegedFiltersEnabled() {
-+ return AdblockControllerJni.get().isPrivilegedFiltersEnabled();
++ return AdblockControllerJni.get().isPrivilegedFiltersEnabled(mBrowserContextHandle);
+ }
+
@UiThread
public List getInstalledSubscriptions() {
- return (List) (List>) Arrays.asList(
-@@ -196,6 +241,10 @@ public final class AdblockController extends FilteringConfiguration {
+ return (List)
+@@ -276,6 +321,10 @@ public class AdblockController {
@NativeMethods
interface Natives {
-+ void startUpdate();
-+ boolean isPrivilegedFiltersEnabled();
-+ void setPrivilegedFiltersEnabled(boolean enabled);
-+ Object[] getCustomSubscriptions();
- void bind(AdblockController caller);
- Object[] getInstalledSubscriptions();
++ void startUpdate(BrowserContextHandle contextHandle);
++ boolean isPrivilegedFiltersEnabled(BrowserContextHandle contextHandle);
++ void setPrivilegedFiltersEnabled(BrowserContextHandle contextHandle, boolean enabled);
++ Object[] getCustomSubscriptions(BrowserContextHandle contextHandle);
+ Object[] getInstalledSubscriptions(BrowserContextHandle contextHandle);
+
Object[] getRecommendedSubscriptions();
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockAllowedDomainsFragment.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockAllowedDomainsFragment.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockAllowedDomainsFragment.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockAllowedDomainsFragment.java
-@@ -26,9 +26,14 @@ import org.chromium.components.adblock.R;
-
- import java.util.List;
-
--public class AdblockAllowedDomainsFragment extends AdblockCustomItemFragment {
-+public class AdblockAllowedDomainsFragment extends AdblockCustomItemFragment {
- public AdblockAllowedDomainsFragment() {}
-
-+ @Override
-+ protected String getItemText(String item) {
-+ return item;
-+ }
-+
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFilterListsFragment.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFilterListsFragment.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFilterListsFragment.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFilterListsFragment.java
-@@ -25,6 +25,7 @@ import android.webkit.URLUtil;
- import android.widget.Toast;
-
- import org.chromium.components.adblock.AdblockController;
-+import org.chromium.components.adblock.AdblockController.Subscription;
- import org.chromium.components.adblock.R;
-
- import java.net.MalformedURLException;
-@@ -32,7 +33,7 @@ import java.net.URL;
- import java.util.ArrayList;
- import java.util.List;
-
--public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment {
-+public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment {
- private static final String TAG = AdblockCustomFilterListsFragment.class.getSimpleName();
- public AdblockCustomFilterListsFragment() {}
-
-@@ -43,25 +44,18 @@ public class AdblockCustomFilterListsFragment extends AdblockCustomItemFragment
- }
-
- @Override
-- protected List getItems() {
-- final List installed =
-- AdblockController.getInstance().getInstalledSubscriptions();
-- final List recommended =
-- AdblockController.getInstance().getRecommendedSubscriptions();
-- final List customStrings = new ArrayList();
-- for (final AdblockController.Subscription subscription : installed) {
-- if (recommended.contains(subscription)) {
-- continue;
-- }
-- // FIXME(kzlomek): Remove this after DPD-1613
-- if (subscription.url().toString().equals(
-- "https://easylist-downloads.adblockplus.org/exceptionrules.txt")) {
-- continue;
-- }
-- customStrings.add(subscription.url().toString());
-- }
-+ protected List getItems() {
-+ return AdblockController.getInstance().getCustomSubscriptions();
-+ }
-+
-+ @Override
-+ protected String getItemText(Subscription item) {
-+ return item.url().toString();
-+ }
-
-- return customStrings;
-+ @Override
-+ protected String getItemStatus(Subscription item) {
-+ return item.getDescription();
- }
-
- @Override
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFiltersFragment.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFiltersFragment.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFiltersFragment.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomFiltersFragment.java
-@@ -25,9 +25,14 @@ import org.chromium.components.adblock.R;
-
- import java.util.List;
-
--public class AdblockCustomFiltersFragment extends AdblockCustomItemFragment {
-+public class AdblockCustomFiltersFragment extends AdblockCustomItemFragment {
- public AdblockCustomFiltersFragment() {}
-
-+ @Override
-+ protected String getItemText(String item) {
-+ return item;
-+ }
-+
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomItemFragment.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomItemFragment.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomItemFragment.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockCustomItemFragment.java
-@@ -34,7 +34,7 @@ import org.chromium.components.adblock.R;
- import java.util.ArrayList;
- import java.util.List;
-
--public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat {
-+public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat {
- private EditText mItem;
- private ImageView mAddButton;
- private ListView mListView;
-@@ -74,7 +74,7 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
-
- protected abstract void addItemImpl(String item);
- protected abstract void removeItemImpl(String item);
-- protected abstract List getItems();
-+ protected abstract List getItems();
- protected abstract String getCustomItemTextViewText();
- protected abstract String getCustomItemTextViewContentDescription();
- protected abstract String getCustomItemAddButtonContentDescription();
-@@ -84,10 +84,12 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
- // Holder for listview items
- private class Holder {
- TextView mItem;
-+ TextView mStatus;
- ImageView mRemoveButton;
-
- Holder(View rootView) {
- mItem = rootView.findViewById(R.id.fragment_adblock_custom_item_title);
-+ mStatus = rootView.findViewById(R.id.fragment_adblock_custom_item_status);
- mRemoveButton = rootView.findViewById(R.id.fragment_adblock_custom_item_remove);
- mRemoveButton.setContentDescription(
- AdblockCustomItemFragment.this.getCustomItemRemoveButtonContentDescription());
-@@ -100,6 +102,7 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
- String item = (String) v.getTag();
- removeItemImpl(item);
- mAdapter.notifyDataSetChanged();
-+ mItem.setText(item);
- }
- };
-
-@@ -127,16 +130,23 @@ public abstract class AdblockCustomItemFragment extends PreferenceFragmentCompat
- convertView.setTag(new Holder(convertView));
- }
-
-- String item = (String) getItem(position);
-+ T item = (T) getItem(position);
- Holder holder = (Holder) convertView.getTag();
-- holder.mItem.setText(item.toString());
-+ holder.mItem.setText(getItemText(item));
-+ holder.mStatus.setText(getItemStatus(item));
- holder.mRemoveButton.setOnClickListener(removeItemClickListener);
-- holder.mRemoveButton.setTag(item.toString());
-+ holder.mRemoveButton.setTag(getItemText(item));
-
- return convertView;
- }
- }
-
-+ protected abstract String getItemText(T item);
-+
-+ protected String getItemStatus(T item) {
-+ return null;
-+ }
-+
- private void initControls() {
- mAddButton.setOnClickListener(new View.OnClickListener() {
- @Override
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockFilterListsAdapter.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockFilterListsAdapter.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockFilterListsAdapter.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockFilterListsAdapter.java
-@@ -82,9 +82,12 @@ public class AdblockFilterListsAdapter extends BaseAdapter implements OnClickLis
- final List subscriptions =
- mController.getInstalledSubscriptions();
- boolean subscribed = false;
-+ TextView status = view.findViewById(R.id.status);
-+ status.setText("");
- for (final AdblockController.Subscription subscription : subscriptions) {
- if (subscription.url().equals(item.url())) {
- subscribed = true;
-+ status.setText(subscription.getDescription());
- break;
- }
- }
-@@ -94,6 +97,9 @@ public class AdblockFilterListsAdapter extends BaseAdapter implements OnClickLis
- TextView description = view.findViewById(R.id.name);
- description.setText(item.title());
- description.setContentDescription(item.title() + "filer list item title text");
-+
-+ TextView url = view.findViewById(R.id.url);
-+ url.setText(item.url().toString());
- return view;
- }
-
-diff --git a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockSettingsFragment.java b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockSettingsFragment.java
---- a/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockSettingsFragment.java
-+++ b/components/adblock/android/java/src/org/chromium/components/adblock/settings/AdblockSettingsFragment.java
-@@ -13,6 +13,7 @@
- package org.chromium.components.adblock.settings;
-
- import android.os.Bundle;
-+import android.widget.Toast;
-
- import androidx.preference.Preference;
- import androidx.preference.PreferenceFragmentCompat;
-@@ -20,6 +21,7 @@ import androidx.preference.PreferenceFragmentCompat;
- import org.chromium.build.BuildConfig;
- import org.chromium.chrome.browser.preferences.Pref;
- import org.chromium.chrome.browser.profiles.Profile;
-+import org.chromium.chrome.browser.profiles.ProfileManager;
- import org.chromium.components.adblock.AdblockController;
- import org.chromium.components.adblock.R;
- import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
-@@ -32,7 +34,19 @@ public class AdblockSettingsFragment
- private Preference mFilterLists;
- private Preference mAllowedDomains;
- private Preference mMoreOptions;
--
-+ private Preference mStartUpdate;
-+ private ChromeSwitchPreference mPrivilegedFilters;
-+
-+ private static final String START_UPDATE_KEY =
-+ "fragment_adblock_settings_start_update";
-+ private static final String PRIVILEGED_FILTERS_KEY =
-+ "fragment_adblock_privileged_filters_enabled_key";
-+ private static final String FILTER_LISTS_KEY =
-+ "fragment_adblock_settings_filter_lists_key";
-+ private static final String CUSTOM_FILTER_LISTS_KEY =
-+ "fragment_adblock_more_options_custom_filter_lists_key";
-+ private static final String CUSTOM_FILTER_KEY =
-+ "fragment_adblock_more_options_custom_filter_key";
- private static final String SETTINGS_ENABLED_KEY = "fragment_adblock_settings_enabled_key";
- private static final String SETTINGS_FILTER_LISTS_KEY =
- "fragment_adblock_settings_filter_lists_key";
-@@ -49,27 +63,48 @@ public class AdblockSettingsFragment
- private long mOnOffTogleTimestamp;
-
- private void bindPreferences() {
-+ mStartUpdate = findPreference(START_UPDATE_KEY);
-+ mStartUpdate.setOnPreferenceClickListener(preference -> {
-+ AdblockController.getInstance().startUpdate();
-+ Toast toast = Toast.makeText(getContext(),
-+ "Checking for updates in progress", Toast.LENGTH_LONG);
-+ toast.show();
-+ // handle the click so the default action isn't triggered.
-+ return true;
-+ });
-+ mPrivilegedFilters = (ChromeSwitchPreference) findPreference(PRIVILEGED_FILTERS_KEY);
- mAdblockEnabled = (ChromeSwitchPreference) findPreference(SETTINGS_ENABLED_KEY);
- mFilterLists = findPreference(SETTINGS_FILTER_LISTS_KEY);
- mAcceptableAdsEnabled = (ChromeSwitchPreference) findPreference(SETTINGS_AA_ENABLED_KEY);
-+ mAcceptableAdsEnabled.setVisible(false);
- mAllowedDomains = findPreference(SETTINGS_ALLOWED_DOMAINS_KEY);
- mMoreOptions = findPreference(SETTINGS_MORE_OPTIONS_KEY);
- }
-
- private boolean areMoreOptionsEnabled() {
-- return UserPrefs.get(Profile.getLastUsedRegularProfile())
-- .getBoolean(Pref.ADBLOCK_MORE_OPTIONS_ENABLED);
-+ return false;
- }
-
- private void applyAdblockEnabled(boolean enabledValue) {
-- mFilterLists.setEnabled(enabledValue);
-- mAcceptableAdsEnabled.setEnabled(enabledValue);
-+ mStartUpdate.setEnabled(enabledValue);
-+ mPrivilegedFilters.setEnabled(enabledValue);
- mAllowedDomains.setEnabled(enabledValue);
- mMoreOptions.setEnabled(enabledValue);
- mMoreOptions.setVisible(areMoreOptionsEnabled());
- }
-
- private void synchronizePreferences() {
-+ findPreference(FILTER_LISTS_KEY).setTitle(
-+ getContext().getString(R.string.fragment_adblock_settings_filter_lists_title_count,
-+ AdblockController.getInstance().getInstalledSubscriptions().size()));
-+ findPreference(CUSTOM_FILTER_LISTS_KEY).setTitle(
-+ getContext().getString(R.string.fragment_adblock_more_options_custom_filter_lists_title_count,
-+ AdblockController.getInstance().getCustomSubscriptions().size()));
-+ findPreference(CUSTOM_FILTER_KEY).setTitle(
-+ getContext().getString(R.string.fragment_adblock_more_options_custom_filters_title_count,
-+ AdblockController.getInstance().getCustomFilters().size()));
-+ mPrivilegedFilters.setChecked(AdblockController.getInstance().isPrivilegedFiltersEnabled());
-+ mPrivilegedFilters.setOnPreferenceChangeListener(this);
- boolean enabled = AdblockController.getInstance().isEnabled();
- mAdblockEnabled.setChecked(enabled);
- mAdblockEnabled.setOnPreferenceChangeListener(this);
-@@ -95,7 +130,7 @@ public class AdblockSettingsFragment
-
- mOnOffTogleTimestamp = now;
- if (mOnOffClickCount >= ON_OFF_TOGGLE_COUNT_TO_ENABLE_MORE_OPTIONS) {
-- UserPrefs.get(Profile.getLastUsedRegularProfile())
-+ UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
- .setBoolean(Pref.ADBLOCK_MORE_OPTIONS_ENABLED, true);
- }
- }
-@@ -107,7 +142,7 @@ public class AdblockSettingsFragment
-
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
-- addPreferencesFromResource(R.xml.adblock_preferences);
-+ addPreferencesFromResource(R.xml.eyeo_adblock_preferences);
- bindPreferences();
- synchronizePreferences();
- }
-@@ -126,6 +161,8 @@ public class AdblockSettingsFragment
- maybeEnableMoreOptions();
-
- applyAdblockEnabled((Boolean) newValue);
-+ } else if (preference.getKey().equals(PRIVILEGED_FILTERS_KEY)) {
-+ AdblockController.getInstance().setPrivilegedFiltersEnabled((Boolean) newValue);
- } else {
- assert preference.getKey().equals(SETTINGS_AA_ENABLED_KEY);
- AdblockController.getInstance().setAcceptableAdsEnabled((Boolean) newValue);
diff --git a/components/adblock/content/browser/BUILD.gn b/components/adblock/content/browser/BUILD.gn
--- a/components/adblock/content/browser/BUILD.gn
+++ b/components/adblock/content/browser/BUILD.gn
@@ -2580,23 +2049,23 @@ diff --git a/components/adblock/content/browser/BUILD.gn b/components/adblock/co
defines = []
-
- if (eyeo_intercept_debug_url) {
-- print("WARNING! Enabled intercepting eyeo debug url \"adblock.test.data\"")
+- print("WARNING! Enabled intercepting eyeo debug domain \"test.data\"")
- defines += [ "EYEO_INTERCEPT_DEBUG_URL=1" ]
- }
}
source_set("browser_impl") {
-@@ -34,8 +27,6 @@ source_set("browser_impl") {
- "adblock_controller_factory_base.cc",
- "adblock_controller_factory_base.h",
- "adblock_filter_match.h",
-- "adblock_telemetry_service_factory_base.cc",
-- "adblock_telemetry_service_factory_base.h",
- "adblock_url_loader_factory.cc",
- "adblock_url_loader_factory.h",
- "adblock_webcontents_observer.cc",
-@@ -62,15 +53,10 @@ source_set("browser_impl") {
-
+@@ -56,8 +49,6 @@ source_set("browser_impl") {
+ "eyeo_page_info.h",
+ "factories/adblock_request_throttle_factory.cc",
+ "factories/adblock_request_throttle_factory.h",
+- "factories/adblock_telemetry_service_factory.cc",
+- "factories/adblock_telemetry_service_factory.h",
+ "factories/content_security_policy_injector_factory.cc",
+ "factories/content_security_policy_injector_factory.h",
+ "factories/element_hider_factory.cc",
+@@ -89,15 +80,10 @@ source_set("browser_impl") {
+ "session_stats_impl.h",
]
- if (eyeo_intercept_debug_url) {
@@ -2610,57 +2079,476 @@ diff --git a/components/adblock/content/browser/BUILD.gn b/components/adblock/co
"//base",
+ "//components/content_settings/browser",
+ "//components/content_settings/core/browser",
+ "//components/adblock/content/browser/mojom:adblock_internals",
+ "//components/adblock/content/resources/adblock_internals:resources",
"//components/adblock/core/converter:converter",
- "//components/keyed_service/content:content",
- "//components/resources:components_resources_grit",
-diff --git a/components/adblock/content/browser/adblock_controller_factory_base.cc b/components/adblock/content/browser/adblock_controller_factory_base.cc
---- a/components/adblock/content/browser/adblock_controller_factory_base.cc
-+++ b/components/adblock/content/browser/adblock_controller_factory_base.cc
-@@ -48,10 +48,7 @@ AdblockControllerFactoryBase::BuildServiceInstanceForBrowserContext(
- std::make_unique(
- prefs, kAdblockFilteringConfigurationName);
+@@ -218,9 +204,5 @@ source_set("browser_tests") {
+ "test/adblock_web_ui_browsertest.cc",
+ ]
-- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-- adblock::switches::kDisableAcceptableAds)) {
-- adblock_filtering_configuration->RemoveFilterList(AcceptableAdsUrl());
+- if (eyeo_intercept_debug_url) {
+- sources += [ "test/adblock_debug_url_browsertest.cc" ]
- }
-+ adblock_filtering_configuration->RemoveFilterList(AcceptableAdsUrl());
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableAdblock) ||
- base::CommandLine::ForCurrentProcess()->HasSwitch(
+-
+ deps = [ ":browser_tests_support" ]
+ }
+diff --git a/components/adblock/content/browser/adblock_content_browser_client.h b/components/adblock/content/browser/adblock_content_browser_client.h
+--- a/components/adblock/content/browser/adblock_content_browser_client.h
++++ b/components/adblock/content/browser/adblock_content_browser_client.h
+@@ -27,6 +27,7 @@
+ #include "components/adblock/content/browser/request_initiator.h"
+ #include "components/adblock/content/browser/resource_classification_runner.h"
+ #include "components/adblock/core/configuration/filtering_configuration.h"
++#include "components/content_settings/core/browser/host_content_settings_map.h"
+ #include "content/public/browser/browser_context.h"
+ #include "content/public/browser/browser_thread.h"
+ #include "content/public/browser/content_browser_client.h"
+@@ -34,6 +35,7 @@
+ #include "content/public/browser/web_contents.h"
+ #include "services/network/public/cpp/url_loader_factory_builder.h"
+ #include "services/network/public/mojom/websocket.mojom.h"
++#include "services/network/public/mojom/web_transport.mojom.h"
+ #include "url/url_util.h"
+
+ #ifdef EYEO_INTERCEPT_DEBUG_URL
+@@ -76,15 +78,44 @@ class AdblockContentBrowserClient : public ContentBrowserClientBase {
+ 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,
+ content::ContentBrowserClient::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,
++ ChromeContentBrowserClient::WillCreateWebTransportCallback callback) override;
++
++ bool CanCreateWindow(
++ content::RenderFrameHost* opener,
++ const GURL& opener_url,
++ const GURL& opener_top_level_frame_url,
++ const url::Origin& source_origin,
++ content::mojom::WindowContainerType container_type,
++ const GURL& target_url,
++ const content::Referrer& referrer,
++ const std::string& frame_name,
++ WindowOpenDisposition disposition,
++ const blink::mojom::WindowFeatures& features,
++ bool user_gesture,
++ bool opener_suppressed,
++ bool* no_javascript_access) override;
++
+ void WillCreateURLLoaderFactory(
+ content::BrowserContext* browser_context,
+ content::RenderFrameHost* frame,
+@@ -108,7 +139,8 @@ class AdblockContentBrowserClient : public ContentBrowserClientBase {
+ mojo::BinderMapWithContext* map) override;
+
+ protected:
+- static bool IsFilteringNeeded(content::BrowserContext* browser_context);
++ bool IsFilteringNeeded(content::RenderFrameHost* frame);
++ bool IsFilteringNeeded(content::BrowserContext* browser_context, const GURL& embedder_url);
+
+ // current_browser_context is the BrowserContext relevant for the currently
+ // processed request. It might be an off-the-record browser context. This
+@@ -117,6 +149,8 @@ class AdblockContentBrowserClient : public ContentBrowserClientBase {
+ // "original" BrowserContext, depending on platform.
+ virtual content::BrowserContext* GetBrowserContextForEyeoFactories(
+ content::BrowserContext* current_browser_context) = 0;
++ virtual HostContentSettingsMap* GetHostContentSettingsMap(
++ content::BrowserContext* current_browser_context) = 0;
+
+ private:
+ content::BrowserContext* GetBrowserContext(content::RenderFrameHost* frame) {
+@@ -126,15 +160,27 @@ class AdblockContentBrowserClient : public ContentBrowserClientBase {
+ }
+
+ void OnWebSocketFilterCheckCompleted(
++ content::RenderProcessHost* process,
+ content::GlobalRenderFrameHostId render_frame_host_id,
+ content::ContentBrowserClient::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,
++ ChromeContentBrowserClient::WillCreateWebTransportCallback callback,
++ adblock::FilterMatchResult result);
++
+ base::WeakPtrFactory>
+ weak_factory_{this};
+
+@@ -159,41 +205,46 @@ void AdblockContentBrowserClient<
+
+ template
+ bool AdblockContentBrowserClient::
+- WillInterceptWebSocket(content::RenderFrameHost* frame) {
+- if (frame && IsFilteringNeeded(GetBrowserContext(frame))) {
++ WillInterceptWebSocket(content::RenderFrameHost* frame,
++ content::RenderProcessHost* process,
++ const url::Origin& origin) {
++ if (IsFilteringNeeded(frame)) {
+ return true;
+ }
+- return ContentBrowserClientBase::WillInterceptWebSocket(frame);
++ return ContentBrowserClientBase::WillInterceptWebSocket(frame, process, origin);
+ }
+
+ template
+ void AdblockContentBrowserClient::CreateWebSocket(
++ content::RenderProcessHost* process,
+ content::RenderFrameHost* frame,
+ content::ContentBrowserClient::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 (frame && IsFilteringNeeded(GetBrowserContext(frame))) {
++ if (IsFilteringNeeded(frame)) {
+ auto* subscription_service =
+ adblock::SubscriptionServiceFactory::GetForBrowserContext(
+ GetBrowserContext(frame));
+ auto* classification_runner =
+ adblock::ResourceClassificationRunnerFactory::GetForBrowserContext(
+ GetBrowserContext(frame));
++ std::vector dns_aliases;
+ classification_runner->CheckRequestFilterMatch(
+- subscription_service->GetCurrentSnapshot(), url, ContentType::Websocket,
++ subscription_service->GetCurrentSnapshot(), url, dns_aliases, ContentType::Websocket,
+ RequestInitiator(frame),
+ base::BindOnce(
+ &AdblockContentBrowserClient<
+ ContentBrowserClientBase>::OnWebSocketFilterCheckCompleted,
+- weak_factory_.GetWeakPtr(), frame->GetGlobalId(),
+- std::move(factory), url, site_for_cookies, user_agent,
++ weak_factory_.GetWeakPtr(), process, frame->GetGlobalId(),
++ std::move(factory), url, initiator_origin, site_for_cookies, user_agent,
+ std::move(handshake_client)));
+ } else {
+- DCHECK(ContentBrowserClientBase::WillInterceptWebSocket(frame));
+- ContentBrowserClientBase::CreateWebSocket(frame, std::move(factory), url,
++ DCHECK(ContentBrowserClientBase::WillInterceptWebSocket(frame, process, initiator_origin));
++ ContentBrowserClientBase::CreateWebSocket(process, frame, std::move(factory), url, initiator_origin,
+ site_for_cookies, user_agent,
+ std::move(handshake_client));
+ }
+@@ -211,6 +262,129 @@ void AdblockContentBrowserClient::
+ adblock::AdblockInternalsUI>(map);
+ }
+
++template
++void AdblockContentBrowserClient::
++ WillCreateWebTransport(
++ int process_id,
++ int frame_routing_id,
++ const GURL& url,
++ const url::Origin& initiator_origin,
++ mojo::PendingRemote
++ handshake_client,
++ ChromeContentBrowserClient::WillCreateWebTransportCallback callback) {
++ auto* process = content::RenderProcessHost::FromID(process_id);
++ DCHECK(process);
++
++ auto* browser_context = process->GetBrowserContext();
++ if (IsFilteringNeeded(browser_context, 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,
++ adblock::RequestInitiator(initiator_origin.GetURL().GetAsReferrer()),
++ content::GlobalRenderFrameHostId(),
++ base::BindOnce(
++ &AdblockContentBrowserClient::OnWebTransportFilterCheckCompleted,
++ weak_factory_.GetWeakPtr(),
++ process_id, frame_routing_id, url,
++ initiator_origin, std::move(handshake_client),
++ std::move(callback)));
++ return;
++ }
++
++ ChromeContentBrowserClient::WillCreateWebTransport(
++ process_id, frame_routing_id,
++ url, initiator_origin,
++ std::move(handshake_client), std::move(callback));
++}
++
++template
++void AdblockContentBrowserClient::
++ OnWebTransportFilterCheckCompleted(
++ int process_id,
++ int frame_routing_id,
++ const GURL& url,
++ const url::Origin& initiator_origin,
++ mojo::PendingRemote
++ handshake_client,
++ ChromeContentBrowserClient::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, 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));
++}
++
++template
++bool AdblockContentBrowserClient::
++ CanCreateWindow(
++ content::RenderFrameHost* opener,
++ const GURL& opener_url,
++ const GURL& opener_top_level_frame_url,
++ const url::Origin& source_origin,
++ content::mojom::WindowContainerType container_type,
++ const GURL& target_url,
++ const content::Referrer& referrer,
++ const std::string& frame_name,
++ WindowOpenDisposition disposition,
++ const blink::mojom::WindowFeatures& features,
++ bool user_gesture,
++ bool opener_suppressed,
++ bool* no_javascript_access) {
++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
++ DCHECK(opener);
++
++ if (IsFilteringNeeded(opener)) {
++ content::WebContents* web_contents =
++ content::WebContents::FromRenderFrameHost(opener);
++ auto* subscription_service =
++ adblock::SubscriptionServiceFactory::GetForBrowserContext(
++ web_contents->GetBrowserContext());
++
++ GURL popup_url(target_url);
++ web_contents->GetPrimaryMainFrame()->GetProcess()->FilterURL(false,
++ &popup_url);
++ auto* classification_runner =
++ adblock::ResourceClassificationRunnerFactory::GetForBrowserContext(
++ web_contents->GetBrowserContext());
++ const auto popup_blocking_decision =
++ classification_runner->ShouldBlockPopup(
++ subscription_service->GetCurrentSnapshot(), popup_url, opener);
++ if (popup_blocking_decision == adblock::FilterMatchResult::kAllowRule) {
++ return true;
++ }
++ if (popup_blocking_decision == adblock::FilterMatchResult::kBlockRule) {
++ return false;
++ }
++ // Otherwise, if eyeo adblocking is disabled or there is no rule that
++ // explicitly allows or blocks a popup, fall back on Chromium's built-in
++ // popup blocker.
++ DCHECK(popup_blocking_decision == adblock::FilterMatchResult::kDisabled ||
++ popup_blocking_decision == adblock::FilterMatchResult::kNoRule);
++ }
++
++ return ChromeContentBrowserClient::CanCreateWindow(
++ opener, opener_url, opener_top_level_frame_url, source_origin,
++ container_type, target_url, referrer, frame_name, disposition, features,
++ user_gesture, opener_suppressed, no_javascript_access);
++}
++
+ template
+ void AdblockContentBrowserClient::
+ WillCreateURLLoaderFactory(
+@@ -250,29 +424,8 @@ void AdblockContentBrowserClient::
+ auto* eyeo_browser_context =
+ GetBrowserContextForEyeoFactories(browser_context);
+ bool use_adblock_proxy =
+- (type == content::ContentBrowserClient::URLLoaderFactoryType::
+- kDocumentSubResource ||
+- type ==
+- content::ContentBrowserClient::URLLoaderFactoryType::kNavigation ||
+- type == content::ContentBrowserClient::URLLoaderFactoryType::
+- kServiceWorkerSubResource ||
+- type == content::ContentBrowserClient::URLLoaderFactoryType::
+- kServiceWorkerScript) &&
+- IsFilteringNeeded(eyeo_browser_context);
+-
+- bool use_test_loader = false;
+-#ifdef EYEO_INTERCEPT_DEBUG_URL
+- if (frame) {
+- content::WebContents* wc = content::WebContents::FromRenderFrameHost(frame);
+- use_test_loader =
+- (type ==
+- content::ContentBrowserClient::URLLoaderFactoryType::kNavigation) &&
+- wc->GetVisibleURL().is_valid() &&
+- url::DomainIs(wc->GetVisibleURL().host_piece(),
+- AdblockURLLoaderFactoryForTest::kEyeoDebugDataHostName);
+- use_adblock_proxy |= use_test_loader;
+- }
+-#endif
++ type != content::ContentBrowserClient::URLLoaderFactoryType::kDownload &&
++ IsFilteringNeeded(frame);
+
+ if (use_adblock_proxy) {
+ auto [proxied_receiver, target_factory_remote] = factory_builder.Append();
+@@ -282,16 +435,18 @@ void AdblockContentBrowserClient::
+ AdblockContextData::StartProxying(
+ eyeo_browser_context, initiator, std::move(proxied_receiver),
+ std::move(target_factory_remote),
+- ContentBrowserClientBase::GetUserAgent(), use_test_loader);
++ ContentBrowserClientBase::GetUserAgent(), /*use_test_loader*/ false);
+ }
+ }
+
+ template
+ void AdblockContentBrowserClient::
+ OnWebSocketFilterCheckCompleted(
++ content::RenderProcessHost* process,
+ content::GlobalRenderFrameHostId render_frame_host_id,
+ content::ContentBrowserClient::WebSocketFactory factory,
+ const GURL& url,
++ const url::Origin& initiator_origin,
+ const net::SiteForCookies& site_for_cookies,
+ const absl::optional& user_agent,
+ mojo::PendingRemote
+@@ -305,9 +460,9 @@ void AdblockContentBrowserClient::
+ result == adblock::FilterMatchResult::kBlockRule;
+ if (!has_blocking_filter) {
+ VLOG(1) << "[eyeo] Web socket allowed for " << url;
+- if (ContentBrowserClientBase::WillInterceptWebSocket(frame)) {
+- ContentBrowserClientBase::CreateWebSocket(frame, std::move(factory), url,
+- site_for_cookies, user_agent,
++ if (ContentBrowserClientBase::WillInterceptWebSocket(frame, process, initiator_origin)) {
++ ContentBrowserClientBase::CreateWebSocket(process, frame, std::move(factory), url,
++ initiator_origin, site_for_cookies, user_agent,
+ std::move(handshake_client));
+ return;
+ }
+@@ -324,16 +479,38 @@ void AdblockContentBrowserClient::
+ VLOG(1) << "[eyeo] Web socket blocked for " << url;
+ }
+
+-// static
+ template
+ bool AdblockContentBrowserClient::IsFilteringNeeded(
+- content::BrowserContext* browser_context) {
++ content::RenderFrameHost* frame) {
++ if (frame) {
++ content::RenderFrameHost* embedder = frame->GetOutermostMainFrameOrEmbedder();
++ const auto& embedder_url = embedder->GetLastCommittedURL();
++ auto* browser_context = frame->GetProcess()->GetBrowserContext();
++ return IsFilteringNeeded(browser_context, embedder_url);
++ }
++ return false;
++}
++
++template
++bool AdblockContentBrowserClient::IsFilteringNeeded(
++ content::BrowserContext* browser_context, const GURL& embedder_url) {
++ if(embedder_url.is_empty()) {
++ // in android can be empty because it was created by
++ // RenderFrameHostImpl::CreateSubresourceLoaderFactoriesForInitialEmptyDocument
++ return true;
++ }
++
++ if (embedder_url.SchemeIs(content_settings::kChromeUIScheme)) {
++ return false;
++ }
++
+ if (browser_context) {
+- return base::ranges::any_of(
+- adblock::SubscriptionServiceFactory::GetForBrowserContext(
+- browser_context)
+- ->GetInstalledFilteringConfigurations(),
+- &adblock::FilteringConfiguration::IsEnabled);
++ HostContentSettingsMap* settings_map = GetHostContentSettingsMap(browser_context);
++ if (settings_map && settings_map->GetContentSetting(embedder_url, GURL(), ContentSettingsType::ADS)
++ == CONTENT_SETTING_ALLOW) {
++ return false;
++ }
++ return true;
+ }
+ return false;
+ }
+diff --git a/components/adblock/content/browser/adblock_internals_page_handler.cc b/components/adblock/content/browser/adblock_internals_page_handler.cc
+--- a/components/adblock/content/browser/adblock_internals_page_handler.cc
++++ b/components/adblock/content/browser/adblock_internals_page_handler.cc
+@@ -19,7 +19,6 @@
+
+ #include "base/i18n/time_formatting.h"
+ #include "base/strings/utf_string_conversions.h"
+-#include "components/adblock/content/browser/factories/adblock_telemetry_service_factory.h"
+ #include "components/adblock/content/browser/factories/session_stats_factory.h"
+ #include "components/adblock/content/browser/factories/subscription_service_factory.h"
+ #include "components/adblock/core/adblock_telemetry_service.h"
+@@ -120,11 +119,9 @@ void AdblockInternalsPageHandler::GetDebugInfo(GetDebugInfoCallback callback) {
+ content += DebugLine("Total blocked", blocked[CustomFiltersUrl()], 3);
+ }
+
+- auto* telemetry_service =
+- adblock::AdblockTelemetryServiceFactory::GetForBrowserContext(context_);
+- telemetry_service->GetTopicProvidersDebugInfo(base::BindOnce(
+- &AdblockInternalsPageHandler::OnTelemetryServiceInfoArrived,
+- std::move(callback), std::move(content)));
++ std::vector topic_provider_content;
++ AdblockInternalsPageHandler::OnTelemetryServiceInfoArrived(
++ std::move(callback), std::move(content), topic_provider_content);
+ }
+
+ void AdblockInternalsPageHandler::ToggleTestpagesFLSubscription(
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
-@@ -80,7 +80,9 @@ ContentType ToAdblockResourceType(const network::ResourceRequest& request) {
- case network::mojom::RequestDestination::kWorker:
- case network::mojom::RequestDestination::kSharedWorker:
- case network::mojom::RequestDestination::kServiceWorker:
-- case network::mojom::RequestDestination::kJson:
-+ case network::mojom::RequestDestination::kSharedStorageWorklet:
-+ case network::mojom::RequestDestination::kAudioWorklet:
-+ case network::mojom::RequestDestination::kPaintWorklet:
- return ContentType::Script;
- case network::mojom::RequestDestination::kImage:
- return ContentType::Image;
-@@ -101,16 +103,14 @@ ContentType ToAdblockResourceType(const network::ResourceRequest& request) {
- return ContentType::Other;
- case network::mojom::RequestDestination::kWebBundle:
- return ContentType::WebBundle;
-+ case network::mojom::RequestDestination::kJson:
- case network::mojom::RequestDestination::kReport:
-- case network::mojom::RequestDestination::kAudioWorklet:
- case network::mojom::RequestDestination::kDictionary:
- case network::mojom::RequestDestination::kManifest:
-- case network::mojom::RequestDestination::kPaintWorklet:
+@@ -117,7 +117,6 @@ ContentType ToAdblockResourceType(const network::ResourceRequest& request) {
case network::mojom::RequestDestination::kWebIdentity:
return ContentType::Other;
}
- NOTREACHED();
- return ContentType::Other;
}
+ bool IsPopup(const RequestInitiator& initiator) {
+@@ -145,8 +144,7 @@ bool IsPopup(const RequestInitiator& initiator) {
+ // to allow any port to make this code working with our browser tests which run
+ // a custom http(s)s server.
+ bool AcceptableAdsBlockthroughFiltersHitDetected(const GURL& request_url) {
+- return request_url.host() == "btloader.com" &&
+- base::StartsWith(request_url.path(), "/recovery");
++ return false;
+ }
+
} // namespace
-@@ -184,8 +184,13 @@ class AdblockURLLoaderFactory::InProgressRequest
+@@ -220,8 +218,13 @@ class AdblockURLLoaderFactory::InProgressRequest
void OnRequestError(int error_code);
void CheckFilterMatch(CheckFilterMatchCallback callback);
void ProcessResponseHeaders(
@@ -2674,7 +2562,7 @@ diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/
void CheckRewriteFilterMatch(CheckRewriteFilterMatchCallback callback);
void OnRequestUrlClassified(CheckFilterMatchCallback callback,
FilterMatchResult result);
-@@ -293,7 +298,9 @@ void AdblockURLLoaderFactory::InProgressRequest::OnReceiveResponse(
+@@ -358,7 +361,9 @@ void AdblockURLLoaderFactory::InProgressRequest::OnReceiveResponse(
VLOG(1) << "[eyeo] Sending headers for processing: " << request_url_;
client_receiver_.Pause();
const scoped_refptr& headers = head->headers;
@@ -2684,41 +2572,26 @@ diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/
headers, base::BindOnce(&InProgressRequest::OnProcessHeadersResult,
weak_factory_.GetWeakPtr(), std::move(head),
std::move(body), std::move(cached_metadata)));
-@@ -330,12 +337,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_);
-@@ -372,9 +373,10 @@ void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch(
+@@ -420,8 +425,9 @@ void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch(
FilterMatchResult::kNoRule);
}
} else {
+ std::vector dns_aliases;
factory_->config_.resource_classifier->CheckRequestFilterMatch(
- subscription_service->GetCurrentSnapshot(), request_url_,
-- adblock_resource_type_, factory_->host_id_,
+ subscription_service->GetCurrentSnapshot(), request_url_, std::move(dns_aliases),
-+ factory_->request_initiator_, adblock_resource_type_, factory_->host_id_,
+ adblock_resource_type_, initiator,
base::BindOnce(
&AdblockURLLoaderFactory::InProgressRequest::OnRequestUrlClassified,
- weak_factory_.GetWeakPtr(),
-@@ -385,6 +387,7 @@ void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch(
+@@ -433,6 +439,7 @@ void AdblockURLLoaderFactory::InProgressRequest::CheckFilterMatch(
}
void AdblockURLLoaderFactory::InProgressRequest::ProcessResponseHeaders(
+ const std::vector& dns_aliases,
const scoped_refptr& headers,
ProcessResponseHeadersCallback callback) {
- if (!factory_->CheckHostValid()) {
-@@ -393,6 +396,36 @@ void AdblockURLLoaderFactory::InProgressRequest::ProcessResponseHeaders(
+ if (IsRequestInitiatorDestroyed()) {
+@@ -441,6 +448,37 @@ void AdblockURLLoaderFactory::InProgressRequest::ProcessResponseHeaders(
return;
}
@@ -2726,7 +2599,7 @@ diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/
+ if (dns_aliases.size() > 1) {
+ factory_->config_.resource_classifier->CheckRequestFilterMatch(
+ subscription_service->GetCurrentSnapshot(), request_url_, std::move(dns_aliases),
-+ factory_->request_initiator_, adblock_resource_type_, factory_->host_id_,
++ adblock_resource_type_, factory_->request_initiator_,
+ base::BindOnce(
+ &AdblockURLLoaderFactory::InProgressRequest::OnProcessResponseHeaders2,
+ weak_factory_.GetWeakPtr(), headers, std::move(callback)));
@@ -2734,7 +2607,8 @@ diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/
+ }
+ factory_->config_.resource_classifier->CheckResponseFilterMatch(
+ subscription_service->GetCurrentSnapshot(), request_url_,
-+ adblock_resource_type_, factory_->host_id_, headers,
++ adblock_resource_type_, factory_->request_initiator_,
++ /*factory_->host_id_,*/ headers,
+ base::BindOnce(
+ &AdblockURLLoaderFactory::InProgressRequest::
+ OnResponseHeadersClassified,
@@ -2755,73 +2629,11 @@ diff --git a/components/adblock/content/browser/adblock_url_loader_factory.cc b/
auto subscription_service = factory_->config_.subscription_service;
factory_->config_.resource_classifier->CheckResponseFilterMatch(
subscription_service->GetCurrentSnapshot(), request_url_,
-@@ -663,12 +696,13 @@ void AdblockURLLoaderFactory::InProgressRequest::OnRequestFilterMatchResult(
-
- AdblockURLLoaderFactory::AdblockURLLoaderFactory(
- AdblockURLLoaderFactoryConfig config,
-+ GURL request_initiator,
- content::GlobalRenderFrameHostId host_id,
-- mojo::PendingReceiver receiver,
-- mojo::PendingRemote target_factory,
-+ network::URLLoaderFactoryBuilder& factory_builder,
- 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)) {
-@@ -677,10 +711,12 @@ AdblockURLLoaderFactory::AdblockURLLoaderFactory(
- DCHECK(config_.element_hider);
- DCHECK(config_.sitekey_storage);
- DCHECK(config_.csp_injector);
-+ auto [loader_receiver, target_factory] = factory_builder.Append();
-+ DCHECK(!target_factory_.is_bound());
- target_factory_.Bind(std::move(target_factory));
- target_factory_.set_disconnect_handler(base::BindOnce(
- &AdblockURLLoaderFactory::OnTargetFactoryError, base::Unretained(this)));
-- proxy_receivers_.Add(this, std::move(receiver));
-+ proxy_receivers_.Add(this, std::move(loader_receiver));
- proxy_receivers_.set_disconnect_handler(base::BindRepeating(
- &AdblockURLLoaderFactory::OnProxyBindingError, base::Unretained(this)));
- }
-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,8 @@
- #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 "services/network/public/cpp/url_loader_factory_builder.h"
-+#include "url/gurl.h"
-
- namespace adblock {
-
-@@ -57,9 +59,9 @@ class AdblockURLLoaderFactory : public network::mojom::URLLoaderFactory {
-
- AdblockURLLoaderFactory(
- AdblockURLLoaderFactoryConfig config,
-+ GURL request_initiator,
- content::GlobalRenderFrameHostId host_id,
-- mojo::PendingReceiver receiver,
-- mojo::PendingRemote target_factory,
-+ network::URLLoaderFactoryBuilder& factory_builder,
- std::string user_agent_string,
- DisconnectCallback on_disconnect);
- ~AdblockURLLoaderFactory() override;
-@@ -86,6 +88,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/adblock_webcontents_observer.cc b/components/adblock/content/browser/adblock_webcontents_observer.cc
--- a/components/adblock/content/browser/adblock_webcontents_observer.cc
+++ b/components/adblock/content/browser/adblock_webcontents_observer.cc
-@@ -21,6 +21,8 @@
- #include "components/adblock/content/browser/frame_opener_info.h"
+@@ -22,6 +22,8 @@
+ #include "components/adblock/content/browser/request_initiator.h"
#include "components/adblock/core/common/sitekey.h"
#include "components/adblock/core/subscription/subscription_service.h"
+#include "components/content_settings/core/browser/host_content_settings_map.h"
@@ -2829,17 +2641,8 @@ diff --git a/components/adblock/content/browser/adblock_webcontents_observer.cc
#include "content/public/browser/navigation_handle.h"
#include "net/base/url_util.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
-@@ -56,7 +58,7 @@ const char* WindowOpenDispositionToString(WindowOpenDisposition value) {
- return "";
- }
- }
--} // namespace
-+
-
- void TraceHandleLoadComplete(
- intptr_t rfh_trace_id,
-@@ -66,18 +68,32 @@ void TraceHandleLoadComplete(
- TRACE_ID_LOCAL(rfh_trace_id));
+@@ -84,6 +86,16 @@ bool ShouldSkipElementHiding(const GURL& url) {
+ !url.IsAboutBlank();
}
+bool IsFilteringNeeded(content::RenderFrameHost* frame, HostContentSettingsMap* settings_map) {
@@ -2852,69 +2655,71 @@ diff --git a/components/adblock/content/browser/adblock_webcontents_observer.cc
+ return true;
+}
+
-+} // namespace
-+
- AdblockWebContentObserver::AdblockWebContentObserver(
- content::WebContents* web_contents,
- adblock::SubscriptionService* subscription_service,
- adblock::ElementHider* element_hider,
- adblock::SitekeyStorage* sitekey_storage,
-- std::unique_ptr frame_hierarchy_builder)
-+ std::unique_ptr frame_hierarchy_builder,
+ } // namespace
+
+ namespace adblock {
+@@ -94,14 +106,16 @@ AdblockWebContentObserver::AdblockWebContentObserver(
+ ElementHider* element_hider,
+ SitekeyStorage* sitekey_storage,
+ std::unique_ptr frame_hierarchy_builder,
+- base::RepeatingCallback navigation_counter)
++ base::RepeatingCallback navigation_counter,
+ HostContentSettingsMap* settings_map)
: content::WebContentsObserver(web_contents),
content::WebContentsUserData(*web_contents),
subscription_service_(subscription_service),
element_hider_(element_hider),
sitekey_storage_(sitekey_storage),
-- frame_hierarchy_builder_(std::move(frame_hierarchy_builder)) {}
-+ frame_hierarchy_builder_(std::move(frame_hierarchy_builder)),
+ frame_hierarchy_builder_(std::move(frame_hierarchy_builder)),
+- navigation_counter_(std::move(navigation_counter)) {}
++ navigation_counter_(std::move(navigation_counter)),
+ settings_map_(settings_map) {}
AdblockWebContentObserver::~AdblockWebContentObserver() = default;
-@@ -122,6 +138,9 @@ void AdblockWebContentObserver::DidFinishNavigation(
- if (!navigation_handle->GetRenderFrameHost()) {
- return;
- }
-+ if (!IsFilteringNeeded(navigation_handle->GetRenderFrameHost(), settings_map_)) {
-+ return;
-+ }
- if (!navigation_handle->IsErrorPage()) {
- DVLOG(3) << "[eyeo] Ready to inject JS to " << url.spec();
- HandleOnLoad(navigation_handle->GetRenderFrameHost());
+@@ -153,6 +167,9 @@ void AdblockWebContentObserver::DidFinishNavigation(
+ VLOG(1) << "[eyeo] Unsupported scheme, skipping injection.";
+ return;
+ }
++ if (!IsFilteringNeeded(frame, settings_map_)) {
++ return;
++ }
+ if (!navigation_handle->IsErrorPage()) {
+ // Element hiding for ordinary main frame (or iframe)
+ DVLOG(3) << "[eyeo] Ready to inject element hiding to " << url.spec();
diff --git a/components/adblock/content/browser/adblock_webcontents_observer.h b/components/adblock/content/browser/adblock_webcontents_observer.h
--- a/components/adblock/content/browser/adblock_webcontents_observer.h
+++ b/components/adblock/content/browser/adblock_webcontents_observer.h
-@@ -24,6 +24,7 @@
- #include "components/adblock/core/adblock_controller.h"
+@@ -23,6 +23,7 @@
+ #include "components/adblock/content/browser/frame_hierarchy_builder.h"
#include "components/adblock/core/sitekey_storage.h"
#include "components/adblock/core/subscription/subscription_service.h"
+#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-@@ -49,7 +50,8 @@ class AdblockWebContentObserver
- adblock::SubscriptionService* subscription_service,
- adblock::ElementHider* element_hider,
- adblock::SitekeyStorage* sitekey_storage,
-- std::unique_ptr frame_hierarchy_builder);
-+ std::unique_ptr frame_hierarchy_builder,
+@@ -53,7 +54,8 @@ class AdblockWebContentObserver
+ SitekeyStorage* sitekey_storage,
+ std::unique_ptr frame_hierarchy_builder,
+ base::RepeatingCallback
+- navigation_counter);
++ navigation_counter,
+ HostContentSettingsMap* settings_map);
~AdblockWebContentObserver() override;
AdblockWebContentObserver(const AdblockWebContentObserver&) = delete;
AdblockWebContentObserver& operator=(const AdblockWebContentObserver&) =
-@@ -81,5 +83,6 @@ class AdblockWebContentObserver
- raw_ptr sitekey_storage_;
+@@ -86,6 +88,7 @@ class AdblockWebContentObserver
- std::unique_ptr frame_hierarchy_builder_;
+ std::unique_ptr frame_hierarchy_builder_;
+ base::RepeatingCallback navigation_counter_;
+ raw_ptr settings_map_ = nullptr;
};
- #endif // COMPONENTS_ADBLOCK_CONTENT_BROWSER_ADBLOCK_WEBCONTENTS_OBSERVER_H_
+
+ } // namespace adblock
diff --git a/components/adblock/content/browser/element_hider_impl.cc b/components/adblock/content/browser/element_hider_impl.cc
--- a/components/adblock/content/browser/element_hider_impl.cc
+++ b/components/adblock/content/browser/element_hider_impl.cc
-@@ -211,7 +211,7 @@ void InsertUserCSSAndApplyElemHidingEmuJS(
+@@ -242,7 +242,7 @@ void InsertUserCSSAndApplyElemHidingEmuJS(
if (!frame_host) {
// Render frame host was destroyed before element hiding could be applied.
// This is not a bug, just legitimate a race condition.
@@ -2922,8 +2727,16 @@ diff --git a/components/adblock/content/browser/element_hider_impl.cc b/componen
+ std::move(on_finished).Run(ElementHider::ElemhideInjectionData{});
return;
}
- auto* info = ElementHiderInfo::GetOrCreateForCurrentDocument(frame_host);
-@@ -239,13 +239,10 @@ void InsertUserCSSAndApplyElemHidingEmuJS(
+ auto* info = EyeoDocumentInfo::GetOrCreateForCurrentDocument(frame_host);
+@@ -263,20 +263,17 @@ void InsertUserCSSAndApplyElemHidingEmuJS(
+ frame_host->ExecuteJavaScriptInIsolatedWorld(
+ base::UTF8ToUTF16(input.elemhide_js),
+ content::RenderFrameHost::JavaScriptResultCallback(),
+- content::ISOLATED_WORLD_ID_ADBLOCK);
++ content::ISOLATED_WORLD_ID_ADBLOCK_VERIFIED);
+
+ DVLOG(1) << "[eyeo] Element hiding emulation - executed JS in frame" << " '"
+ << frame_host->GetFrameName() << "'";
}
if (!input.snippet_js.empty()) {
@@ -2937,119 +2750,352 @@ diff --git a/components/adblock/content/browser/element_hider_impl.cc b/componen
- content::ISOLATED_WORLD_ID_ADBLOCK);
+ content::ISOLATED_WORLD_ID_GLOBAL);
- DVLOG(1) << "[eyeo] Snippet - executed JS in frame"
- << " '" << frame_host->GetFrameName() << "'";
+ DVLOG(1) << "[eyeo] Snippet - executed JS in frame" << " '"
+ << frame_host->GetFrameName() << "'";
+@@ -358,7 +355,7 @@ void ElementHiderImpl::HideBlockedElement(
+ render_frame_host->ExecuteJavaScriptInIsolatedWorld(
+ base::UTF8ToUTF16(js),
+ content::RenderFrameHost::JavaScriptResultCallback(),
+- content::ISOLATED_WORLD_ID_ADBLOCK);
++ content::ISOLATED_WORLD_ID_ADBLOCK_VERIFIED);
+
+ DVLOG(1) << "[eyeo] Element hiding - executed JS in frame" << " '"
+ << render_frame_host->GetFrameName() << "'";
+diff --git a/components/adblock/content/browser/factories/adblock_telemetry_service_factory.cc b/components/adblock/content/browser/factories/adblock_telemetry_service_factory.cc
+--- a/components/adblock/content/browser/factories/adblock_telemetry_service_factory.cc
++++ b/components/adblock/content/browser/factories/adblock_telemetry_service_factory.cc
+@@ -45,13 +45,6 @@ base::TimeDelta GetCheckInterval() {
+
+ } // namespace
+
+-// static
+-AdblockTelemetryService* AdblockTelemetryServiceFactory::GetForBrowserContext(
+- content::BrowserContext* context) {
+- return static_cast(
+- GetInstance()->GetServiceForBrowserContext(context, true));
+-}
+-
+ // static
+ AdblockTelemetryServiceFactory* AdblockTelemetryServiceFactory::GetInstance() {
+ static base::NoDestructor instance;
+diff --git a/components/adblock/content/browser/factories/embedding_utils.cc b/components/adblock/content/browser/factories/embedding_utils.cc
+--- a/components/adblock/content/browser/factories/embedding_utils.cc
++++ b/components/adblock/content/browser/factories/embedding_utils.cc
+@@ -20,7 +20,6 @@
+ #include
+
+ #include "components/adblock/content/browser/adblock_webcontents_observer.h"
+-#include "components/adblock/content/browser/factories/adblock_telemetry_service_factory.h"
+ #include "components/adblock/content/browser/factories/content_security_policy_injector_factory.h"
+ #include "components/adblock/content/browser/factories/element_hider_factory.h"
+ #include "components/adblock/content/browser/factories/resource_classification_runner_factory.h"
+@@ -34,7 +33,6 @@ namespace adblock {
+
+ void EnsureBackgroundServicesStarted(content::BrowserContext* browser_context) {
+ ResourceClassificationRunnerFactory::GetForBrowserContext(browser_context);
+- AdblockTelemetryServiceFactory::GetForBrowserContext(browser_context);
+ SessionStatsFactory::GetForBrowserContext(browser_context);
+ SitekeyStorageFactory::GetForBrowserContext(browser_context);
+ }
+diff --git a/components/adblock/content/browser/factories/embedding_utils.h b/components/adblock/content/browser/factories/embedding_utils.h
+--- a/components/adblock/content/browser/factories/embedding_utils.h
++++ b/components/adblock/content/browser/factories/embedding_utils.h
+@@ -23,6 +23,7 @@
+ #include "components/adblock/content/browser/factories/subscription_service_factory.h"
+ #include "components/adblock/content/browser/frame_hierarchy_builder.h"
+ #include "components/adblock/content/browser/page_view_stats.h"
++#include "components/content_settings/core/browser/host_content_settings_map.h"
+ #include "content/public/browser/browser_context.h"
+ #include "content/public/browser/web_contents.h"
+
+@@ -32,13 +33,15 @@ namespace adblock {
+ template
+ void RegisterAdblockWebContentObserver(
+ content::WebContents* web_contents,
+- content::BrowserContext* browser_context) {
++ content::BrowserContext* browser_context,
++ HostContentSettingsMap* settings_map) {
+ ObserverClass::CreateForWebContents(
+ web_contents,
+ SubscriptionServiceFactory::GetForBrowserContext(browser_context),
+ ElementHiderFactory::GetForBrowserContext(browser_context),
+ SitekeyStorageFactory::GetForBrowserContext(browser_context),
+- std::make_unique(), CountNavigationsCallback());
++ std::make_unique(), CountNavigationsCallback(),
++ settings_map);
+ }
+
+ // Ensures that all background services are started for the given browser
+diff --git a/components/adblock/content/browser/factories/subscription_service_factory.cc b/components/adblock/content/browser/factories/subscription_service_factory.cc
+--- a/components/adblock/content/browser/factories/subscription_service_factory.cc
++++ b/components/adblock/content/browser/factories/subscription_service_factory.cc
+@@ -23,6 +23,7 @@
+ #include
+
+ #include "absl/types/optional.h"
++#include "base/rand_util.h"
+ #include "base/command_line.h"
+ #include "base/files/file_util.h"
+ #include "base/functional/bind.h"
+@@ -65,7 +66,7 @@ base::TimeDelta GetUpdateCheckInterval() {
+ static base::TimeDelta kCheckInterval =
+ g_update_check_interval_for_testing
+ ? g_update_check_interval_for_testing.value()
+- : base::Hours(1);
++ : base::Hours(12) + base::Minutes(base::RandInt(-60,60));
+ return kCheckInterval;
+ }
+
+@@ -93,7 +94,8 @@ std::unique_ptr MakeSubscriptionRequest(
+ ConversionResult ConvertFilterFile(
+ const scoped_refptr& converter,
+ const GURL& subscription_url,
+- const base::FilePath& path) {
++ const base::FilePath& path,
++ bool allow_privileged_filter) {
+ TRACE_EVENT1("eyeo", "ConvertFileToFlatbuffer", "url",
+ subscription_url.spec());
+ ConversionResult result;
+@@ -105,7 +107,7 @@ ConversionResult ConvertFilterFile(
+ } else {
+ result =
+ converter->Convert(input_stream, subscription_url,
+- config::AllowPrivilegedFilters(subscription_url));
++ allow_privileged_filter && config::AllowPrivilegedFilters(subscription_url));
+ }
+ base::DeleteFile(path);
+ return result;
+@@ -167,6 +169,7 @@ void CleanupPersistedConfiguration(PrefService* prefs,
+
+ void InstallFirstRunDefaultAdblockSubscription(
+ std::unique_ptr& adblock_filtering_configuration) {
++ if ((true)) return;
+ if (std::ranges::any_of(config::GetKnownSubscriptions(),
+ [&](const KnownSubscriptionInfo& subscription) {
+ return subscription.url ==
+@@ -188,16 +191,8 @@ bool InstallFirstRunAdblockSubscriptionsCheckingLocale(
+ bool language_specific_subscription_installed = false;
+ // On first run, install additional subscriptions.
+ for (const auto& subscription : adblock::config::GetKnownSubscriptions()) {
+- if (subscription.first_run == SubscriptionFirstRunBehavior::Subscribe) {
++ if (subscription.first_run == SubscriptionFirstRunBehavior::SubscribeAtFirstRun) {
+ adblock_filtering_configuration->AddFilterList(subscription.url);
+- } else if (subscription.first_run ==
+- SubscriptionFirstRunBehavior::SubscribeIfLocaleMatch &&
+- std::find(subscription.languages.begin(),
+- subscription.languages.end(),
+- language) != subscription.languages.end()) {
+- VLOG(1) << "[eyeo] Using recommended subscription for language \""
+- << language << "\": " << subscription.title;
+- language_specific_subscription_installed = true;
+ adblock_filtering_configuration->AddFilterList(subscription.url);
+ }
+ }
+@@ -451,11 +446,12 @@ SubscriptionServiceFactory::ConvertCustomFilters(
+ void SubscriptionServiceFactory::ConvertFilterListFile(
+ const GURL& subscription_url,
+ const base::FilePath& path,
++ bool allow_privileged_filter,
+ base::OnceCallback result_callback) const {
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock()},
+ base::BindOnce(&ConvertFilterFile, flatbuffer_converter_,
+- subscription_url, path),
++ subscription_url, path, allow_privileged_filter),
+ std::move(result_callback));
+ }
+
+diff --git a/components/adblock/content/browser/factories/subscription_service_factory.h b/components/adblock/content/browser/factories/subscription_service_factory.h
+--- a/components/adblock/content/browser/factories/subscription_service_factory.h
++++ b/components/adblock/content/browser/factories/subscription_service_factory.h
+@@ -43,6 +43,7 @@ class SubscriptionServiceFactory : public BrowserContextKeyedServiceFactory,
+ void ConvertFilterListFile(
+ const GURL& subscription_url,
+ const base::FilePath& path,
++ bool allow_privileged_filter,
+ base::OnceCallback) const override;
+
+ protected:
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()) {
+@@ -66,6 +66,7 @@ GURL GetUrlAsReferrer(content::RenderFrameHost* frame_host) {
+ std::vector BuildFrameHierarchyForRenderFrameHost(
+ content::RenderFrameHost* frame_host) {
+ std::vector frame_hierarchy;
++ if (!frame_host) return frame_hierarchy;
+ for (auto* iter = frame_host; iter; iter = iter->GetParent()) {
auto last_commited_referrer = GetUrlAsReferrer(iter);
if (IsValidForFrameHierarchy(last_commited_referrer)) {
+diff --git a/components/adblock/content/browser/page_view_stats.cc b/components/adblock/content/browser/page_view_stats.cc
+--- a/components/adblock/content/browser/page_view_stats.cc
++++ b/components/adblock/content/browser/page_view_stats.cc
+@@ -57,21 +57,6 @@ const char kBlockedStatsCountKey[] = "blocked_pageviews";
+ // than AA page views.
+ const char kTotalPagesStatsCountKey[] = "pageviews";
+
+-std::string_view GetReportedNameForMetric(PageViewStats::Metric metric) {
+- switch (metric) {
+- case PageViewStats::Metric::AcceptableAds:
+- return kAcceptableAdsStatsCountKey;
+- case PageViewStats::Metric::AcceptableAdsBlockThrough:
+- return kAcceptableAdsBlockthroughStatsCountKey;
+- case PageViewStats::Metric::Allowing:
+- return kAllowedStatsCountKey;
+- case PageViewStats::Metric::Blocking:
+- return kBlockedStatsCountKey;
+- case PageViewStats::Metric::TotalPages:
+- return kTotalPagesStatsCountKey;
+- }
+-}
+-
+ base::WeakPtr g_last_used_instance;
+
+ void RegisterNavigationWithLastUsedPageViewStats(
+@@ -89,15 +74,6 @@ void RegisterAcceptableAdsBlockthroughtHitWithLastUsedPageViewStats(
+ }
+ }
+
+-inline bool WasNavigationCommitted(PageViewStats::Metric metric,
+- EyeoPageInfo* page_info) {
+- return page_info->HasMatchedPageView(PageViewStats::Metric::TotalPages);
+-}
+-
+-inline bool IsNavigationCommittingNow(PageViewStats::Metric metric) {
+- return metric == PageViewStats::Metric::TotalPages;
+-}
+-
+ } // namespace
+
+ PageViewStats::PageViewStats(
+@@ -215,22 +191,6 @@ void PageViewStats::RecordParkedMetrics(content::Page& page) {
+ }
+ // If this is the entry matching Page we are looking for...
+ if (main_frame_id == it->first) {
+- // ...and it contains some parked metrics...
+- if (!it->second.empty()) {
+- //...then record them
+- auto* page_info = EyeoPageInfo::GetOrCreateForPage(page);
+- ScopedDictPrefUpdate update(prefs_,
+- common::prefs::kTelemetryPageViewStats);
+- for (auto parked_metric : it->second) {
+- auto parked_metric_key = GetReportedNameForMetric(parked_metric);
+- const auto current_count_for_parked =
+- update->FindInt(parked_metric_key);
+- update->Set(parked_metric_key,
+- current_count_for_parked.value_or(0) + 1);
+- // Now with "final" EyeoPageInfo we can mark metric as recorded
+- page_info->SetMatchedPageView(parked_metric);
+- }
+- }
+ it = parked_metrics_before_main_navigation_.erase(it);
+ } else {
+ ++it;
+@@ -239,42 +199,13 @@ void PageViewStats::RecordParkedMetrics(content::Page& page) {
+ }
+
+ void PageViewStats::RecordPageView(content::Page& page, Metric metric) {
+- auto dict_child_key = GetReportedNameForMetric(metric);
+- auto* page_info = EyeoPageInfo::GetOrCreateForPage(page);
+- if (!IsNavigationCommittingNow(metric) &&
+- !WasNavigationCommitted(metric, page_info)) {
+- ParkMetric(page, metric);
+- return;
+- }
+- // We don't count stats metrics for individual requests but for a whole page.
+- // If this is the first request matched a metric for this page, we increment
+- // the counter. We store previous matches in EyeoPageInfo, so we can check if
+- // this is the first metric match for this page.
+- if (!page_info->SetMatchedPageView(metric)) {
+- // metric was already counted
+- return;
+- }
+- ScopedDictPrefUpdate update(prefs_, common::prefs::kTelemetryPageViewStats);
+- const auto current_count = update->FindInt(dict_child_key);
+- update->Set(dict_child_key, current_count.value_or(0) + 1);
+- // Check parked metrics and record
+- if (WasNavigationCommitted(metric, page_info)) {
+- RecordParkedMetrics(page);
+- }
+ }
+
+ int PageViewStats::GetPageViewsCount(Metric metric) const {
+- auto dict_child_key = GetReportedNameForMetric(metric);
+- const base::Value::Dict& dict =
+- prefs_->GetDict(common::prefs::kTelemetryPageViewStats);
+- const auto current_count = dict.FindInt(dict_child_key);
+- return current_count.value_or(0);
++ return 0;
+ }
+
+ void PageViewStats::ResetPageViewsCount(Metric metric) {
+- auto dict_child_key = GetReportedNameForMetric(metric);
+- ScopedDictPrefUpdate update(prefs_, common::prefs::kTelemetryPageViewStats);
+- update->Set(dict_child_key, 0);
+ }
+
+ base::RepeatingCallback
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,12 +81,21 @@ class ResourceClassificationRunner : public KeyedService {
+@@ -77,9 +77,16 @@ class ResourceClassificationRunner : public KeyedService {
+ const GURL& popup_url,
+ content::RenderFrameHost& render_frame_host,
+ CheckFilterMatchCallback callback) = 0;
++ virtual void CheckRequestFilterMatchForWebTransport(
++ SubscriptionService::Snapshot subscription_collections,
++ const GURL& request_url,
++ const RequestInitiator& request_initiator,
++ content::GlobalRenderFrameHostId render_frame_host_id,
++ CheckFilterMatchCallback callback) = 0;
virtual void CheckRequestFilterMatch(
SubscriptionService::Snapshot subscription_collections,
const GURL& request_url,
+ const std::vector& dns_aliases,
-+ const GURL& request_initiator,
ContentType adblock_resource_type,
- content::GlobalRenderFrameHostId render_frame_host_id,
+ const RequestInitiator& request_initiator,
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) = 0;
- // No callback, just notify observers
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,30 @@ 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,
-+ std::vector dns_aliases;
-+ CheckRequestFilterMatch(std::move(subscription_collections), request_url, std::move(dns_aliases), request_initiator,
- ContentType::Websocket, render_frame_host_id,
- std::move(callback));
+@@ -156,6 +156,19 @@ void ResourceClassificationRunnerImpl::CheckPopupFilterMatch(
+ render_frame_host.GetGlobalId(), std::move(callback)));
}
+void ResourceClassificationRunnerImpl::CheckRequestFilterMatchForWebTransport(
+ SubscriptionService::Snapshot subscription_collections,
+ const GURL& request_url,
-+ const GURL& request_initiator,
++ const RequestInitiator& request_initiator,
+ content::GlobalRenderFrameHostId render_frame_host_id,
+ CheckFilterMatchCallback callback) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ std::vector dns_aliases;
-+ CheckRequestFilterMatch(std::move(subscription_collections), request_url, std::move(dns_aliases), request_initiator,
-+ ContentType::Other, render_frame_host_id,
++ CheckRequestFilterMatch(std::move(subscription_collections), request_url, std::move(dns_aliases),
++ ContentType::Other, request_initiator,
+ std::move(callback));
+}
+
void ResourceClassificationRunnerImpl::CheckDocumentAllowlisted(
SubscriptionService::Snapshot subscription_collections,
const GURL& request_url,
-@@ -212,6 +227,8 @@ void ResourceClassificationRunnerImpl::ProcessDocumentAllowlistedResponse(
+@@ -208,6 +221,7 @@ void ResourceClassificationRunnerImpl::ProcessDocumentAllowlistedResponse(
void ResourceClassificationRunnerImpl::CheckRequestFilterMatch(
SubscriptionService::Snapshot subscription_collections,
const GURL& request_url,
+ const std::vector& dns_aliases,
-+ const GURL& request_initiator,
ContentType adblock_resource_type,
- content::GlobalRenderFrameHostId frame_host_id,
+ const RequestInitiator& request_initiator,
CheckFilterMatchCallback callback) {
-@@ -220,14 +237,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();
-@@ -246,7 +259,7 @@ void ResourceClassificationRunnerImpl::CheckRequestFilterMatch(
+@@ -234,7 +248,7 @@ void ResourceClassificationRunnerImpl::CheckRequestFilterMatch(
base::BindOnce(
&ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal,
resource_classifier_, std::move(subscription_collections),
-- request_url, frame_hierarchy_chain, adblock_resource_type,
-+ request_url, std::move(dns_aliases), frame_hierarchy_chain, adblock_resource_type,
+- request_url, frame_hierarchy, adblock_resource_type,
++ request_url, std::move(dns_aliases), frame_hierarchy, adblock_resource_type,
std::move(site_key)),
base::BindOnce(
&ResourceClassificationRunnerImpl::OnCheckResourceFilterMatchComplete,
-@@ -260,9 +273,16 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal(
+@@ -248,9 +262,16 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal(
const scoped_refptr& resource_classifier,
SubscriptionService::Snapshot subscription_collections,
const GURL request_url,
@@ -3066,7 +3112,7 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
TRACE_EVENT1("eyeo",
"ResourceClassificationRunnerImpl::"
"CheckRequestFilterMatchInternal",
-@@ -270,26 +290,35 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal(
+@@ -258,26 +279,35 @@ ResourceClassificationRunnerImpl::CheckRequestFilterMatchInternal(
DVLOG(1) << "[eyeo] CheckRequestFilterMatchInternal start";
@@ -3075,7 +3121,7 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
- adblock_resource_type, sitekey);
-
- if (classification_result.decision == ClassificationDecision::Allowed) {
-- VLOG(1) << "[eyeo] Document allowed due to allowing filter " << request_url;
+- VLOG(1) << "[eyeo] Resource allowed due to allowing filter " << request_url;
- return CheckResourceFilterMatchResult{
- FilterMatchResult::kAllowRule,
- classification_result.decisive_subscription,
@@ -3092,7 +3138,7 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
+ adblock_resource_type, sitekey);
+
+ if (classification_result.decision == ClassificationDecision::Allowed) {
-+ VLOG(1) << "[eyeo] Document allowed due to allowing filter " << alias_url
++ VLOG(1) << "[eyeo] Resource allowed due to allowing filter " << alias_url
+ << " " << classification_result.decisive_subscription.spec();
+ return CheckResourceFilterMatchResult{
+ FilterMatchResult::kAllowRule,
@@ -3101,13 +3147,13 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
+ }
- if (classification_result.decision == ClassificationDecision::Blocked) {
-- VLOG(1) << "[eyeo] Document blocked " << request_url;
+- VLOG(1) << "[eyeo] Resource blocked " << request_url;
- return CheckResourceFilterMatchResult{
- FilterMatchResult::kBlockRule,
- classification_result.decisive_subscription,
- classification_result.decisive_configuration_name};
+ if (classification_result.decision == ClassificationDecision::Blocked) {
-+ VLOG(1) << "[eyeo] Document blocked " << alias_url;
++ VLOG(1) << "[eyeo] Resource blocked " << alias_url;
+ return CheckResourceFilterMatchResult{
+ FilterMatchResult::kBlockRule,
+ classification_result.decisive_subscription,
@@ -3122,36 +3168,28 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
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,15 @@ class ResourceClassificationRunnerImpl final
+@@ -56,6 +56,7 @@ class ResourceClassificationRunnerImpl final
void CheckRequestFilterMatch(
SubscriptionService::Snapshot subscription_collections,
const GURL& request_url,
+ const std::vector& dns_aliases,
-+ const GURL& request_initiator,
ContentType adblock_resource_type,
- content::GlobalRenderFrameHostId render_frame_host_id,
+ const RequestInitiator& request_initiator,
CheckFilterMatchCallback callback) final;
- void CheckRequestFilterMatchForWebSocket(
+@@ -64,6 +65,12 @@ class ResourceClassificationRunnerImpl final
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 +71,12 @@ class ResourceClassificationRunnerImpl final
- SubscriptionService::Snapshot subscription_collections,
- const GURL& request_url,
- content::GlobalRenderFrameHostId render_frame_host_id) final;
+ const RequestInitiator& request_initiator) final;
+ void CheckRequestFilterMatchForWebTransport(
+ SubscriptionService::Snapshot subscription_collections,
+ const GURL& request_url,
-+ const GURL& request_initiator,
++ const RequestInitiator& request_initiator,
+ content::GlobalRenderFrameHostId render_frame_host_id,
+ CheckFilterMatchCallback callback) final;
void CheckResponseFilterMatch(
SubscriptionService::Snapshot subscription_collections,
const GURL& response_url,
-@@ -92,6 +101,7 @@ class ResourceClassificationRunnerImpl final
+@@ -88,6 +95,7 @@ class ResourceClassificationRunnerImpl final
const scoped_refptr& resource_classifier,
SubscriptionService::Snapshot subscription_collections,
const GURL request_url,
@@ -3159,69 +3197,6 @@ diff --git a/components/adblock/content/browser/resource_classification_runner_i
const std::vector frame_hierarchy,
ContentType adblock_resource_type,
const SiteKey sitekey);
-diff --git a/components/adblock/content/browser/subscription_service_factory_base.cc b/components/adblock/content/browser/subscription_service_factory_base.cc
---- a/components/adblock/content/browser/subscription_service_factory_base.cc
-+++ b/components/adblock/content/browser/subscription_service_factory_base.cc
-@@ -21,6 +21,7 @@
- #include
- #include
-
-+#include "base/rand_util.h"
- #include "base/command_line.h"
- #include "base/files/file_util.h"
- #include "base/functional/bind.h"
-@@ -65,7 +66,7 @@ base::TimeDelta GetUpdateCheckInterval() {
- static base::TimeDelta kCheckInterval =
- g_update_check_interval_for_testing
- ? g_update_check_interval_for_testing.value()
-- : base::Hours(1);
-+ : base::Hours(24) + base::Minutes(base::RandInt(-60,60));
- return kCheckInterval;
- }
-
-@@ -86,7 +87,8 @@ std::unique_ptr MakeOngoingSubscriptionRequest(
- }
-
- ConversionResult ConvertFilterFile(const GURL& subscription_url,
-- const base::FilePath& path) {
-+ const base::FilePath& path,
-+ bool allow_privileged_filter) {
- TRACE_EVENT1("eyeo", "ConvertFileToFlatbuffer", "url",
- subscription_url.spec());
- ConversionResult result;
-@@ -96,7 +98,7 @@ ConversionResult ConvertFilterFile(const GURL& subscription_url,
- } else {
- result = FlatbufferConverter::Convert(
- input_stream, subscription_url,
-- config::AllowPrivilegedFilters(subscription_url));
-+ allow_privileged_filter && config::AllowPrivilegedFilters(subscription_url));
- }
- base::DeleteFile(path);
- return result;
-@@ -202,10 +204,11 @@ SubscriptionServiceFactoryBase::ConvertCustomFilters(
- void SubscriptionServiceFactoryBase::ConvertFilterListFile(
- const GURL& subscription_url,
- const base::FilePath& path,
-+ bool allow_privileged_filter,
- base::OnceCallback result_callback) const {
- base::ThreadPool::PostTaskAndReplyWithResult(
- FROM_HERE, {base::MayBlock()},
-- base::BindOnce(&ConvertFilterFile, subscription_url, path),
-+ base::BindOnce(&ConvertFilterFile, subscription_url, path, allow_privileged_filter),
- std::move(result_callback));
- }
-
-diff --git a/components/adblock/content/browser/subscription_service_factory_base.h b/components/adblock/content/browser/subscription_service_factory_base.h
---- a/components/adblock/content/browser/subscription_service_factory_base.h
-+++ b/components/adblock/content/browser/subscription_service_factory_base.h
-@@ -39,6 +39,7 @@ class SubscriptionServiceFactoryBase : public BrowserContextKeyedServiceFactory,
- void ConvertFilterListFile(
- const GURL& subscription_url,
- const base::FilePath& path,
-+ bool allow_privileged_filter,
- base::OnceCallback) const override;
-
- protected:
diff --git a/components/adblock/core/BUILD.gn b/components/adblock/core/BUILD.gn
--- a/components/adblock/core/BUILD.gn
+++ b/components/adblock/core/BUILD.gn
@@ -3233,8 +3208,8 @@ diff --git a/components/adblock/core/BUILD.gn b/components/adblock/core/BUILD.gn
import("//third_party/flatbuffers/flatbuffer.gni")
flatbuffer("schema") {
-@@ -61,48 +60,14 @@ generate_sha256_header("schema_hash") {
- files_to_hash = [ "${target_gen_dir}/schema/filter_list_schema_generated.h" ]
+@@ -49,43 +48,9 @@ source_set("schema_hash") {
+ deps = [ ":generate_schema_hash" ]
}
-config("eyeo_telemetry_config") {
@@ -3272,17 +3247,12 @@ diff --git a/components/adblock/core/BUILD.gn b/components/adblock/core/BUILD.gn
sources = [
- "activeping_telemetry_topic_provider.cc",
- "activeping_telemetry_topic_provider.h",
- "adblock_controller.h",
- "adblock_controller_impl.cc",
- "adblock_controller_impl.h",
- "adblock_switches.cc",
- "adblock_switches.h",
- "adblock_telemetry_service.cc",
- "adblock_telemetry_service.h",
"features.cc",
"features.h",
"sitekey_storage.h",
-@@ -126,8 +91,6 @@ source_set("core") {
+@@ -109,8 +74,6 @@ source_set("core") {
"//components/prefs",
"//components/version_info",
]
@@ -3291,850 +3261,17 @@ diff --git a/components/adblock/core/BUILD.gn b/components/adblock/core/BUILD.gn
}
source_set("test_support") {
-@@ -170,6 +133,4 @@ source_set("unit_tests") {
+@@ -151,6 +114,4 @@ source_set("unit_tests") {
"//services/network:test_support",
"//testing/gtest",
]
-
- configs += [ ":eyeo_telemetry_config" ]
}
-diff --git a/components/adblock/core/activeping_telemetry_topic_provider.cc b/components/adblock/core/activeping_telemetry_topic_provider.cc
-deleted file mode 100644
---- a/components/adblock/core/activeping_telemetry_topic_provider.cc
-+++ /dev/null
-@@ -1,285 +0,0 @@
--/* This file is part of eyeo Chromium SDK,
-- * Copyright (C) 2006-present eyeo GmbH
-- *
-- * eyeo Chromium SDK is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License version 3 as
-- * published by the Free Software Foundation.
-- *
-- * eyeo Chromium SDK 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 eyeo Chromium SDK. If not, see .
-- */
--
--#include "components/adblock/core/activeping_telemetry_topic_provider.h"
--
--#include "base/json/json_reader.h"
--#include "base/json/json_writer.h"
--#include "base/system/sys_info.h"
--#include "base/time/time.h"
--#include "base/time/time_to_iso8601.h"
--#include "base/uuid.h"
--#include "components/adblock/core/common/adblock_prefs.h"
--#include "components/adblock/core/subscription/subscription_config.h"
--
--namespace adblock {
--namespace {
--int g_http_port_for_testing = 0;
--std::optional g_time_delta_for_testing;
--
--GURL GetUrl() {
-- GURL url(EYEO_TELEMETRY_SERVER_URL);
-- if (!g_http_port_for_testing) {
-- return url;
-- }
-- DCHECK_EQ(url::kHttpsScheme, url.scheme());
-- GURL::Replacements replacements;
-- replacements.SetSchemeStr(url::kHttpScheme);
-- const std::string port_str = base::NumberToString(g_http_port_for_testing);
-- replacements.SetPortStr(port_str);
-- return url.ReplaceComponents(replacements);
--}
--
--base::TimeDelta GetNormalPingInterval() {
-- static base::TimeDelta kNormalPingInterval =
-- g_time_delta_for_testing ? g_time_delta_for_testing.value()
-- : base::Hours(12);
-- return kNormalPingInterval;
--}
--
--base::TimeDelta GetRetryPingInterval() {
-- static base::TimeDelta kRetryPingInterval =
-- g_time_delta_for_testing ? g_time_delta_for_testing.value()
-- : base::Hours(1);
-- return kRetryPingInterval;
--}
--
--void AppendStringIfPresent(PrefService* pref_service,
-- const std::string& pref_name,
-- base::StringPiece payload_key,
-- base::Value::Dict& payload) {
-- auto str = pref_service->GetString(pref_name);
-- if (!str.empty()) {
-- payload.Set(payload_key, std::move(str));
-- }
--}
--} // namespace
--
--ActivepingTelemetryTopicProvider::ActivepingTelemetryTopicProvider(
-- utils::AppInfo app_info,
-- PrefService* pref_service,
-- SubscriptionService* subscription_service,
-- const GURL& base_url,
-- const std::string& auth_token)
-- : app_info_(std::move(app_info)),
-- pref_service_(pref_service),
-- subscription_service_(subscription_service),
-- base_url_(base_url),
-- auth_token_(auth_token) {}
--
--ActivepingTelemetryTopicProvider::~ActivepingTelemetryTopicProvider() = default;
--
--// static
--GURL ActivepingTelemetryTopicProvider::DefaultBaseUrl() {
--#if !defined(EYEO_TELEMETRY_CLIENT_ID)
-- LOG(WARNING)
-- << "[eyeo] Using default Telemetry server since a Telemetry client ID "
-- "was "
-- "not provided. Users will not be counted correctly by eyeo. Please "
-- "set an ID via \"eyeo_telemetry_client_id\" gn argument.";
--#endif
-- return GetUrl();
--}
--
--// static
--std::string ActivepingTelemetryTopicProvider::DefaultAuthToken() {
--#if defined(EYEO_TELEMETRY_ACTIVEPING_AUTH_TOKEN)
-- DVLOG(1) << "[eyeo] Using " << EYEO_TELEMETRY_ACTIVEPING_AUTH_TOKEN
-- << " as Telemetry authentication token";
-- return EYEO_TELEMETRY_ACTIVEPING_AUTH_TOKEN;
--#else
-- LOG(WARNING)
-- << "[eyeo] No Telemetry authentication token defined. Users will "
-- "not be counted correctly by eyeo. Please set a token via "
-- "\"eyeo_telemetry_activeping_auth_token\" gn argument.";
-- return "";
--#endif
--}
--
--GURL ActivepingTelemetryTopicProvider::GetEndpointURL() const {
-- return base_url_.Resolve("/topic/eyeochromium_activeping/version/1");
--}
--
--std::string ActivepingTelemetryTopicProvider::GetAuthToken() const {
-- return auth_token_;
--}
--
--void ActivepingTelemetryTopicProvider::GetPayload(
-- PayloadCallback callback) const {
-- std::string serialized;
-- // The only way JSONWriter::Write() can return fail is then the Value
-- // contains lists or dicts that are too deep (200 levels). We just built the
-- // payload and root objects here, they should be really shallow.
-- CHECK(base::JSONWriter::Write(GetPayloadInternal(), &serialized));
-- std::move(callback).Run(std::move(serialized));
--}
--
--base::Time ActivepingTelemetryTopicProvider::GetTimeOfNextRequest() const {
-- const auto next_ping_time =
-- pref_service_->GetTime(common::prefs::kTelemetryNextPingTime);
-- // Next ping time may be unset if this is a first run. Next request should
-- // happen ASAP.
-- if (next_ping_time.is_null()) {
-- return base::Time::Now();
-- }
--
-- return next_ping_time;
--}
--
--void ActivepingTelemetryTopicProvider::ParseResponse(
-- std::unique_ptr response_content) {
-- if (!response_content) {
-- VLOG(1) << "[eyeo] Telemetry ping failed, no response from server";
-- ScheduleNextPing(GetRetryPingInterval());
-- return;
-- }
--
-- VLOG(1) << "[eyeo] Response from Telemetry server: " << *response_content;
-- auto parsed = base::JSONReader::ReadDict(*response_content);
-- if (!parsed) {
-- VLOG(1)
-- << "[eyeo] Telemetry ping failed, response could not be parsed as JSON";
-- ScheduleNextPing(GetRetryPingInterval());
-- return;
-- }
--
-- auto* error_message = parsed->FindString("error");
-- if (error_message) {
-- VLOG(1) << "[eyeo] Telemetry ping failed, error message: "
-- << *error_message;
-- ScheduleNextPing(GetRetryPingInterval());
-- return;
-- }
--
-- // For legacy reasons, "ping_response_time" is sent to us as "token". This
-- // should be the server time of when the ping was handled, possibly truncated
-- // for anonymity. We don't parse it or interpret it, just send it back with
-- // next ping.
-- auto* ping_response_time = parsed->FindString("token");
-- if (!ping_response_time) {
-- VLOG(1) << "[eyeo] Telemetry ping failed, response did not contain a last "
-- "ping / token value";
-- ScheduleNextPing(GetRetryPingInterval());
-- return;
-- }
--
-- VLOG(1) << "[eyeo] Telemetry ping succeeded";
-- ScheduleNextPing(GetNormalPingInterval());
-- UpdatePrefs(*ping_response_time);
--}
--
--void ActivepingTelemetryTopicProvider::FetchDebugInfo(
-- DebugInfoCallback callback) const {
-- base::Value::Dict debug_info;
-- debug_info.Set("endpoint_url", GetEndpointURL().spec());
-- debug_info.Set("payload", GetPayloadInternal());
-- debug_info.Set("first_ping",
-- pref_service_->GetString(
-- adblock::common::prefs::kTelemetryFirstPingTime));
-- debug_info.Set("time_of_next_request",
-- base::TimeToISO8601(GetTimeOfNextRequest()));
-- debug_info.Set(
-- "last_ping",
-- pref_service_->GetString(adblock::common::prefs::kTelemetryLastPingTime));
-- debug_info.Set("previous_last_ping",
-- pref_service_->GetString(
-- adblock::common::prefs::kTelemetryPreviousLastPingTime));
-- debug_info.Set("next_ping",
-- base::TimeToISO8601(pref_service_->GetTime(
-- adblock::common::prefs::kTelemetryNextPingTime)));
--
-- std::string serialized;
-- // The only way JSONWriter::Write() can return fail is then the Value
-- // contains lists or dicts that are too deep (200 levels). We just built the
-- // payload and root objects here, they should be really shallow.
-- CHECK(base::JSONWriter::WriteWithOptions(
-- debug_info, base::JsonOptions::OPTIONS_PRETTY_PRINT, &serialized));
-- std::move(callback).Run(std::move(serialized));
--}
--
--void ActivepingTelemetryTopicProvider::ScheduleNextPing(base::TimeDelta delay) {
-- pref_service_->SetTime(common::prefs::kTelemetryNextPingTime,
-- base::Time::Now() + delay);
--}
--
--void ActivepingTelemetryTopicProvider::UpdatePrefs(
-- const std::string& ping_response_time) {
-- // First ping is only set once per client.
-- if (pref_service_->GetString(common::prefs::kTelemetryFirstPingTime)
-- .empty()) {
-- pref_service_->SetString(common::prefs::kTelemetryFirstPingTime,
-- ping_response_time);
-- }
-- // Previous-to-last becomes last, last becomes current.
-- pref_service_->SetString(
-- common::prefs::kTelemetryPreviousLastPingTime,
-- pref_service_->GetString(common::prefs::kTelemetryLastPingTime));
-- pref_service_->SetString(common::prefs::kTelemetryLastPingTime,
-- ping_response_time);
-- // Generate a new random tag that wil be sent along with ping times in the
-- // next request.
-- const auto tag = base::Uuid::GenerateRandomV4();
-- pref_service_->SetString(common::prefs::kTelemetryLastPingTag,
-- tag.AsLowercaseString());
--}
--
--base::Value ActivepingTelemetryTopicProvider::GetPayloadInternal() const {
-- base::Value::Dict payload;
-- bool aa_enabled = false;
-- auto* adblock_configuration =
-- subscription_service_->GetAdblockFilteringConfiguration();
-- if (adblock_configuration) {
-- aa_enabled = base::ranges::any_of(
-- adblock_configuration->GetFilterLists(),
-- [&](const auto& url) { return url == AcceptableAdsUrl(); });
-- }
-- payload.Set("addon_name", "eyeo-chromium-sdk");
-- payload.Set("addon_version", "2.0.0");
-- payload.Set("application", app_info_.name);
-- payload.Set("application_version", app_info_.version);
-- payload.Set("aa_active", aa_enabled);
-- payload.Set("platform", base::SysInfo::OperatingSystemName());
-- payload.Set("platform_version", base::SysInfo::OperatingSystemVersion());
-- // Server requires the following parameters to either have a correct,
-- // non-empty value, or not be present at all. We shall not send empty strings.
-- AppendStringIfPresent(pref_service_, common::prefs::kTelemetryLastPingTag,
-- "last_ping_tag", payload);
-- AppendStringIfPresent(pref_service_, common::prefs::kTelemetryFirstPingTime,
-- "first_ping", payload);
-- AppendStringIfPresent(pref_service_, common::prefs::kTelemetryLastPingTime,
-- "last_ping", payload);
-- AppendStringIfPresent(pref_service_,
-- common::prefs::kTelemetryPreviousLastPingTime,
-- "previous_last_ping", payload);
--
-- base::Value::Dict root;
-- root.Set("payload", std::move(payload));
-- return base::Value(std::move(root));
--}
--
--// static
--void ActivepingTelemetryTopicProvider::SetHttpPortForTesting(
-- int http_port_for_testing) {
-- g_http_port_for_testing = http_port_for_testing;
--}
--
--// static
--void ActivepingTelemetryTopicProvider::SetIntervalsForTesting(
-- base::TimeDelta time_delta) {
-- g_time_delta_for_testing = time_delta;
--}
--
--} // namespace adblock
-diff --git a/components/adblock/core/activeping_telemetry_topic_provider.h b/components/adblock/core/activeping_telemetry_topic_provider.h
-deleted file mode 100644
---- a/components/adblock/core/activeping_telemetry_topic_provider.h
-+++ /dev/null
-@@ -1,87 +0,0 @@
--/*
-- * This file is part of eyeo Chromium SDK,
-- * Copyright (C) 2006-present eyeo GmbH
-- *
-- * eyeo Chromium SDK is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License version 3 as
-- * published by the Free Software Foundation.
-- *
-- * eyeo Chromium SDK 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 eyeo Chromium SDK. If not, see .
-- */
--
--#ifndef COMPONENTS_ADBLOCK_CORE_ACTIVEPING_TELEMETRY_TOPIC_PROVIDER_H_
--#define COMPONENTS_ADBLOCK_CORE_ACTIVEPING_TELEMETRY_TOPIC_PROVIDER_H_
--
--#include "base/memory/raw_ptr.h"
--#include "base/time/time.h"
--#include "components/adblock/core/adblock_telemetry_service.h"
--#include "components/adblock/core/common/adblock_utils.h"
--#include "components/adblock/core/subscription/subscription_service.h"
--#include "components/prefs/pref_service.h"
--
--namespace adblock {
--
--// Telemetry topic provider that uploads user-counting data for periodic pings.
--// Provides the following data in Payload:
--// - Last ping time, previous-to-last ping time, first ping time
--// - Unique, non-persistent tag for disambiguating pings made by clients in
--// the same day
--// - Whether Acceptable Ads is enabled
--// - Application name & version, platform name & version
--// Note: Provides no user-identifiable information, no persistent tracking
--// data (ie. no traceable UUID) and no information about user actions.
--class ActivepingTelemetryTopicProvider final
-- : public AdblockTelemetryService::TopicProvider {
-- public:
-- ActivepingTelemetryTopicProvider(utils::AppInfo app_info,
-- PrefService* pref_service,
-- SubscriptionService* subscription_service,
-- const GURL& base_url,
-- const std::string& auth_token);
-- ~ActivepingTelemetryTopicProvider() final;
--
-- static GURL DefaultBaseUrl();
-- static std::string DefaultAuthToken();
--
-- GURL GetEndpointURL() const final;
-- std::string GetAuthToken() const final;
-- void GetPayload(PayloadCallback callback) const final;
--
-- // Normally 12 hours since last ping, 1 hour in case of retries.
-- base::Time GetTimeOfNextRequest() const final;
--
-- // Attempts to parse "token" (an opaque server description of last ping time)
-- // from |response_content|.
-- void ParseResponse(std::unique_ptr response_content) final;
--
-- void FetchDebugInfo(DebugInfoCallback callback) const final;
--
-- // Sets the port used by the embedded http server required for browser tests.
-- // Must be called before the first call to DefaultBaseUrl().
-- static void SetHttpPortForTesting(int http_port_for_testing);
--
-- // Sets the internal timing for sending pings required for browser tests.
-- // Must be called before AdblockTelemetryService::Start().
-- static void SetIntervalsForTesting(base::TimeDelta time_delta);
--
-- private:
-- void ScheduleNextPing(base::TimeDelta delay);
-- void UpdatePrefs(const std::string& ping_response_time);
-- base::Value GetPayloadInternal() const;
--
-- const utils::AppInfo app_info_;
-- raw_ptr pref_service_;
-- raw_ptr subscription_service_;
-- const GURL base_url_;
-- const std::string auth_token_;
--};
--
--} // namespace adblock
--
--#endif // COMPONENTS_ADBLOCK_CORE_ACTIVEPING_TELEMETRY_TOPIC_PROVIDER_H_
-diff --git a/components/adblock/core/adblock_controller_impl.cc b/components/adblock/core/adblock_controller_impl.cc
---- a/components/adblock/core/adblock_controller_impl.cc
-+++ b/components/adblock/core/adblock_controller_impl.cc
-@@ -102,6 +102,7 @@ bool AdblockControllerImpl::IsAdblockEnabled() const {
- }
-
- void AdblockControllerImpl::SetAcceptableAdsEnabled(bool enabled) {
-+ enabled = false;
- if (enabled) {
- InstallSubscription(AcceptableAdsUrl());
- } else {
-@@ -116,6 +117,7 @@ bool AdblockControllerImpl::IsAcceptableAdsEnabled() const {
- }
-
- void AdblockControllerImpl::InstallSubscription(const GURL& url) {
-+ if (url == AcceptableAdsUrl()) return;
- adblock_filtering_configuration_->AddFilterList(url);
- }
-
-@@ -164,10 +166,8 @@ void AdblockControllerImpl::RunFirstRunLogic(PrefService* pref_service) {
- common::prefs::kInstallFirstStartSubscriptions)) {
- // On first run, install additional subscriptions.
- for (const auto& cur : known_subscriptions_) {
-- if (cur.first_run == SubscriptionFirstRunBehavior::Subscribe) {
-- if (cur.url == AcceptableAdsUrl() &&
-- base::CommandLine::ForCurrentProcess()->HasSwitch(
-- switches::kDisableAcceptableAds)) {
-+ if (cur.first_run == SubscriptionFirstRunBehavior::SubscribeAtFirstRun) {
-+ if (cur.url == AcceptableAdsUrl()) {
- // Do not install Acceptable Ads on first run because a command line
- // switch forbids it. Mostly used for testing.
- continue;
-@@ -235,7 +235,7 @@ void AdblockControllerImpl::InstallLanguageBasedRecommendedSubscriptions() {
- SubscriptionFirstRunBehavior::SubscribeIfLocaleMatch &&
- std::find(subscription.languages.begin(), subscription.languages.end(),
- language_) != subscription.languages.end()) {
-- VLOG(1) << "[eyeo] Using recommended subscription for language \""
-+ LOG(INFO) << "[eyeo] Using recommended subscription for language \""
- << language_ << "\": " << subscription.title;
- language_specific_subscription_installed = true;
- InstallSubscription(subscription.url);
-diff --git a/components/adblock/core/adblock_switches.cc b/components/adblock/core/adblock_switches.cc
---- a/components/adblock/core/adblock_switches.cc
-+++ b/components/adblock/core/adblock_switches.cc
-@@ -19,7 +19,6 @@
-
- namespace adblock::switches {
-
--const char kDisableAcceptableAds[] = "disable-aa";
- const char kDisableAdblock[] = "disable-adblock";
- const char kDisableEyeoFiltering[] = "disable-eyeo-filtering";
-
-diff --git a/components/adblock/core/adblock_switches.h b/components/adblock/core/adblock_switches.h
---- a/components/adblock/core/adblock_switches.h
-+++ b/components/adblock/core/adblock_switches.h
-@@ -20,7 +20,6 @@
-
- namespace adblock::switches {
-
--extern const char kDisableAcceptableAds[];
- extern const char kDisableAdblock[];
- extern const char kDisableEyeoFiltering[];
-
-diff --git a/components/adblock/core/adblock_telemetry_service.cc b/components/adblock/core/adblock_telemetry_service.cc
-deleted file mode 100644
---- a/components/adblock/core/adblock_telemetry_service.cc
-+++ /dev/null
-@@ -1,258 +0,0 @@
--/*
-- * This file is part of eyeo Chromium SDK,
-- * Copyright (C) 2006-present eyeo GmbH
-- *
-- * eyeo Chromium SDK is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License version 3 as
-- * published by the Free Software Foundation.
-- *
-- * eyeo Chromium SDK 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 eyeo Chromium SDK. If not, see .
-- */
--
--#include "components/adblock/core/adblock_telemetry_service.h"
--
--#include
--
--#include "base/barrier_callback.h"
--#include "base/functional/bind.h"
--#include "base/memory/weak_ptr.h"
--#include "base/strings/string_number_conversions.h"
--#include "base/strings/string_util.h"
--#include "base/strings/stringprintf.h"
--#include "base/strings/utf_string_conversions.h"
--#include "base/time/time.h"
--#include "base/timer/timer.h"
--#include "components/adblock/core/common/adblock_prefs.h"
--#include "components/prefs/pref_service.h"
--#include "net/base/load_flags.h"
--#include "services/network/public/cpp/resource_request.h"
--#include "services/network/public/cpp/simple_url_loader.h"
--#include "services/network/public/mojom/url_response_head.mojom.h"
--
--namespace adblock {
--
--namespace {
--
--const char kDataType[] = "application/json";
--net::NetworkTrafficAnnotationTag kTrafficAnnotation =
-- net::DefineNetworkTrafficAnnotation("adblock_telemetry_request", R"(
-- semantics {
-- sender: "AdblockTelemetryService"
-- description:
-- "Messages sent to telemetry.eyeo.com to report usage statistics."
-- "Contain no user-identifiable data."
-- trigger:
-- "Periodic, several times a day."
-- data:
-- "Subject to change: "
-- "Dates of first ping, last ping and previous-to-last ping. "
-- "A non-persistent, unique ID that disambiguates pings made in the "
-- "same day. "
-- "Application name and version (ex. Chromium 86.0.4240.183). "
-- "Platform name and version (ex. Windows 10). "
-- "Whether Acceptable Ads are in use (yes/no)."
-- destination: WEBSITE
-- }
-- policy {
-- cookies_allowed: NO
-- setting:
-- "Enabled or disabled via 'Ad blocking' setting."
-- policy_exception_justification:
-- "Parent setting may be controlled by policy"
-- }
-- })");
--
--} // namespace
--
--// Represents an ongoing chain of requests relevant to a Topic.
--// A Topic is and endpoint on the Telemetry server that expects messages
--// about a domain of activity, ex. usage of Acceptable Ads or frequency of
--// filter "hits" per filter list. The browser may report on multiple topics.
--// Messages are sent periodically. The interval of communication and the
--// content of the messages is provided by a TopicProvider.
--class AdblockTelemetryService::Conversation {
-- public:
-- Conversation(
-- std::unique_ptr topic_provider,
-- scoped_refptr url_loader_factory)
-- : topic_provider_(std::move(topic_provider)),
-- url_loader_factory_(url_loader_factory) {}
--
-- bool IsRequestDue() {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- const auto due_time = topic_provider_->GetTimeOfNextRequest();
-- if (due_time > base::Time::Now()) {
-- VLOG(1) << "[eyeo] Telemetry request for "
-- << topic_provider_->GetEndpointURL()
-- << " not due yet, should run at " << due_time;
-- return false;
-- }
-- if (IsRequestInFlight()) {
-- VLOG(1) << "[eyeo] Telemetry request for "
-- << topic_provider_->GetEndpointURL() << " already in-flight";
-- return false;
-- }
-- VLOG(1) << "[eyeo] Telemetry request for "
-- << topic_provider_->GetEndpointURL() << " is due";
-- return true;
-- }
--
-- void StartRequest() {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- VLOG(1) << "[eyeo] Telemetry request for "
-- << topic_provider_->GetEndpointURL() << " starting now";
-- topic_provider_->GetPayload(base::BindOnce(&Conversation::MakeRequest,
-- weak_ptr_factory_.GetWeakPtr()));
-- }
--
-- void Stop() {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- url_loader_.reset();
-- }
--
-- const std::unique_ptr& GetTopicProvider() const {
-- return topic_provider_;
-- }
--
-- private:
-- bool IsRequestInFlight() {
-- return url_loader_ != nullptr || weak_ptr_factory_.HasWeakPtrs();
-- }
--
-- void MakeRequest(std::string payload) {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- auto request = std::make_unique();
-- request->url = topic_provider_->GetEndpointURL();
-- VLOG(1) << "[eyeo] Sending request to: " << request->url;
-- request->method = net::HttpRequestHeaders::kPostMethod;
-- // The server expects authorization via a bearer token. The token may be
-- // empty in testing builds.
-- const auto auth_token = topic_provider_->GetAuthToken();
-- if (!auth_token.empty()) {
-- request->headers.SetHeader(net::HttpRequestHeaders::kAuthorization,
-- "Bearer " + auth_token);
-- }
-- // Notify the server we're expecting a JSON response.
-- request->headers.SetHeader(net::HttpRequestHeaders::kAccept, kDataType);
-- // Disallow using cache - identical requests should be physically sent to
-- // the server.
-- request->load_flags = net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE;
-- // Omitting credentials prevents cookies from being sent. The server does
-- // not expect or parse cookies, but we want to be on the safe side,
-- // privacy-wise.
-- request->credentials_mode = network::mojom::CredentialsMode::kOmit;
--
-- // If any url_loader_ existed previously, it will be overwritten and its
-- // request will be cancelled.
-- url_loader_ = network::SimpleURLLoader::Create(std::move(request),
-- kTrafficAnnotation);
--
-- VLOG(2) << "[eyeo] Payload: " << payload;
-- url_loader_->AttachStringForUpload(payload, kDataType);
-- // The Telemetry server responds with a JSON that contains a description of
-- // any potential error. We want to parse this JSON if possible, we're not
-- // content with just an HTTP error code. Process the response content even
-- // if the code is not 200.
-- url_loader_->SetAllowHttpErrorResults(true);
--
-- url_loader_->DownloadToString(
-- url_loader_factory_.get(),
-- base::BindOnce(&Conversation::OnResponseArrived,
-- base::Unretained(this)),
-- network::SimpleURLLoader::kMaxBoundedStringDownloadSize - 1);
-- }
--
-- void OnResponseArrived(std::unique_ptr server_response) {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- topic_provider_->ParseResponse(std::move(server_response));
-- url_loader_.reset();
-- }
--
-- SEQUENCE_CHECKER(sequence_checker_);
-- std::unique_ptr topic_provider_;
-- scoped_refptr url_loader_factory_;
-- std::unique_ptr url_loader_;
-- base::WeakPtrFactory weak_ptr_factory_{this};
--};
--
--AdblockTelemetryService::AdblockTelemetryService(
-- FilteringConfiguration* filtering_configuration,
-- scoped_refptr url_loader_factory,
-- base::TimeDelta initial_delay,
-- base::TimeDelta check_interval)
-- : adblock_filtering_configuration_(filtering_configuration),
-- url_loader_factory_(url_loader_factory),
-- initial_delay_(initial_delay),
-- check_interval_(check_interval) {
-- DCHECK(adblock_filtering_configuration_);
-- adblock_filtering_configuration_->AddObserver(this);
--}
--
--AdblockTelemetryService::~AdblockTelemetryService() {
-- DCHECK(adblock_filtering_configuration_);
-- adblock_filtering_configuration_->RemoveObserver(this);
--}
--
--void AdblockTelemetryService::AddTopicProvider(
-- std::unique_ptr topic_provider) {
-- ongoing_conversations_.push_back(std::make_unique(
-- std::move(topic_provider), url_loader_factory_));
--}
--
--void AdblockTelemetryService::Start() {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- OnEnabledStateChangedInternal();
--}
--
--void AdblockTelemetryService::OnEnabledStateChanged(FilteringConfiguration*) {
-- OnEnabledStateChangedInternal();
--}
--
--void AdblockTelemetryService::GetTopicProvidersDebugInfo(
-- TopicProvidersDebugInfoCallback service_callback) const {
-- const auto barrier_callback = base::BarrierCallback(
-- ongoing_conversations_.size(), std::move(service_callback));
-- for (const auto& conversation : ongoing_conversations_) {
-- conversation->GetTopicProvider()->FetchDebugInfo(barrier_callback);
-- }
--}
--
--void AdblockTelemetryService::OnEnabledStateChangedInternal() {
-- DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-- if (adblock_filtering_configuration_->IsEnabled() && !timer_.IsRunning()) {
-- VLOG(1) << "[eyeo] Starting periodic Telemetry requests";
-- timer_.Start(FROM_HERE, initial_delay_,
-- base::BindRepeating(&AdblockTelemetryService::RunPeriodicCheck,
-- base::Unretained(this)));
-- } else if (!adblock_filtering_configuration_->IsEnabled() &&
-- timer_.IsRunning()) {
-- VLOG(1) << "[eyeo] Stopping periodic Telemetry requests";
-- Shutdown();
-- }
--}
--
--void AdblockTelemetryService::RunPeriodicCheck() {
-- for (auto& conversation : ongoing_conversations_) {
-- if (conversation->IsRequestDue()) {
-- conversation->StartRequest();
-- }
-- }
-- timer_.Start(FROM_HERE, check_interval_,
-- base::BindRepeating(&AdblockTelemetryService::RunPeriodicCheck,
-- base::Unretained(this)));
--}
--
--void AdblockTelemetryService::Shutdown() {
-- timer_.Stop();
-- for (auto& conversation : ongoing_conversations_) {
-- conversation->Stop();
-- }
--}
--
--} // namespace adblock
-diff --git a/components/adblock/core/adblock_telemetry_service.h b/components/adblock/core/adblock_telemetry_service.h
-deleted file mode 100644
---- a/components/adblock/core/adblock_telemetry_service.h
-+++ /dev/null
-@@ -1,120 +0,0 @@
--/*
-- * This file is part of eyeo Chromium SDK,
-- * Copyright (C) 2006-present eyeo GmbH
-- *
-- * eyeo Chromium SDK is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License version 3 as
-- * published by the Free Software Foundation.
-- *
-- * eyeo Chromium SDK 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 eyeo Chromium SDK. If not, see .
-- */
--
--#ifndef COMPONENTS_ADBLOCK_CORE_ADBLOCK_TELEMETRY_SERVICE_H_
--#define COMPONENTS_ADBLOCK_CORE_ADBLOCK_TELEMETRY_SERVICE_H_
--
--#include
--#include
--#include
--
--#include "base/functional/callback_forward.h"
--#include "base/memory/raw_ptr.h"
--#include "base/sequence_checker.h"
--#include "base/time/time.h"
--#include "base/timer/timer.h"
--#include "components/adblock/core/configuration/filtering_configuration.h"
--#include "components/adblock/core/subscription/subscription_service.h"
--#include "components/keyed_service/core/keyed_service.h"
--#include "services/network/public/cpp/shared_url_loader_factory.h"
--#include "url/gurl.h"
--
--namespace network {
--class SimpleURLLoader;
--} // namespace network
--
--namespace adblock {
--/**
-- * @brief Sends periodic pings to eyeo in order to count active users. Executed
-- * from Browser process UI main thread.
-- */
--class AdblockTelemetryService : public KeyedService,
-- public FilteringConfiguration::Observer {
-- public:
-- // Provides data and behavior relevant for a Telemetry "topic". A topic could
-- // be "counting users" or "reporting filter list hits" for example.
-- class TopicProvider {
-- public:
-- using PayloadCallback = base::OnceCallback;
-- using DebugInfoCallback = base::OnceCallback;
-- virtual ~TopicProvider() = default;
-- // Endpoint URL on the Telemetry server onto which requests should be sent.
-- virtual GURL GetEndpointURL() const = 0;
-- // Authorization bearer token for the endpoint defined by GetEndpointURL().
-- virtual std::string GetAuthToken() const = 0;
-- // Data uploaded with the request, should be valid for the schema
-- // present on the server. Async to allow querying asynchronous data sources.
-- virtual void GetPayload(PayloadCallback callback) const = 0;
-- // Returns the desired time when AdblockTelemetryService should make the
-- // next network request.
-- virtual base::Time GetTimeOfNextRequest() const = 0;
-- // Parses the response returned by the Telemetry server. |response_content|
-- // may be null. Implementation is free to implement a "retry" in case of
-- // response errors via GetTimeToNextRequest().
-- virtual void ParseResponse(
-- std::unique_ptr response_content) = 0;
-- // Gets debugging info to be logged on chrome://adblock-internals. Do not
-- // put any secrets here (tokens, api keys). Asynchronous to allow reusing
-- // the async logic of GetPayload, if needed.
-- virtual void FetchDebugInfo(DebugInfoCallback callback) const = 0;
-- };
-- AdblockTelemetryService(
-- FilteringConfiguration* filtering_configuration,
-- scoped_refptr url_loader_factory,
-- base::TimeDelta initial_delay,
-- base::TimeDelta check_interval);
-- ~AdblockTelemetryService() override;
-- using TopicProvidersDebugInfoCallback =
-- base::OnceCallback)>;
--
-- // Add all required topic providers before calling Start().
-- void AddTopicProvider(std::unique_ptr topic_provider);
--
-- // Starts periodic Telemetry requests, provided ad-blocking is enabled.
-- // If ad blocking is disabled, the schedule will instead start when
-- // ad blocking becomes enabled.
-- void Start();
--
-- // KeyedService:
-- void Shutdown() override;
--
-- // FilteringConfiguration::Observer
-- void OnEnabledStateChanged(FilteringConfiguration* config) override;
--
-- // Collects debug information from all topic providers. Runs |callback| once
-- // all topic providers have provided their info.
-- void GetTopicProvidersDebugInfo(
-- TopicProvidersDebugInfoCallback callback) const;
--
-- private:
-- void OnEnabledStateChangedInternal();
-- void RunPeriodicCheck();
--
-- SEQUENCE_CHECKER(sequence_checker_);
-- raw_ptr adblock_filtering_configuration_;
-- scoped_refptr url_loader_factory_;
-- base::TimeDelta initial_delay_;
-- base::TimeDelta check_interval_;
--
-- class Conversation;
-- std::vector> ongoing_conversations_;
-- base::OneShotTimer timer_;
--};
--
--} // namespace adblock
--
--#endif // COMPONENTS_ADBLOCK_CORE_ADBLOCK_TELEMETRY_SERVICE_H_
diff --git a/components/adblock/core/common/BUILD.gn b/components/adblock/core/common/BUILD.gn
--- a/components/adblock/core/common/BUILD.gn
+++ b/components/adblock/core/common/BUILD.gn
-@@ -59,14 +59,6 @@ source_set("common") {
+@@ -34,14 +34,6 @@ config("eyeo_filtering_config") {
config("eyeo_application_config") {
defines = []
@@ -4148,7 +3285,7 @@ diff --git a/components/adblock/core/common/BUILD.gn b/components/adblock/core/c
- }
}
- source_set("utils") {
+ source_set("common") {
diff --git a/components/adblock/core/common/adblock_constants.cc b/components/adblock/core/common/adblock_constants.cc
--- a/components/adblock/core/common/adblock_constants.cc
+++ b/components/adblock/core/common/adblock_constants.cc
@@ -4164,7 +3301,7 @@ diff --git a/components/adblock/core/common/adblock_constants.cc b/components/ad
diff --git a/components/adblock/core/common/adblock_constants.h b/components/adblock/core/common/adblock_constants.h
--- a/components/adblock/core/common/adblock_constants.h
+++ b/components/adblock/core/common/adblock_constants.h
-@@ -27,7 +27,6 @@ namespace flat {
+@@ -29,7 +29,6 @@ namespace flat {
enum AbpResource : int8_t;
}
@@ -4178,7 +3315,7 @@ diff --git a/components/adblock/core/common/adblock_prefs.cc b/components/adbloc
@@ -23,7 +23,9 @@
namespace adblock::common::prefs {
- // Whether to block ads
+ // Legacy: Whether to block ads
-const char kEnableAdblockLegacy[] = "adblock.enable";
+const char kEnableAdblockLegacy[] = "adblock.enabled";
+
@@ -4186,7 +3323,7 @@ diff --git a/components/adblock/core/common/adblock_prefs.cc b/components/adbloc
// Legacy: Whether to allow acceptable ads or block them all.
// Used now just to map CLI switch. Otherwise use kAdblockSubscriptionsLegacy.
-@@ -65,47 +67,11 @@ const char kLastUsedSchemaVersion[] = "adblock.last_used_schema_version";
+@@ -65,35 +67,6 @@ const char kLastUsedSchemaVersion[] = "adblock.last_used_schema_version";
// and for setting query parameters in subscription download requests.
const char kSubscriptionMetadata[] = "adblock.subscription_metadata";
@@ -4218,6 +3355,15 @@ diff --git a/components/adblock/core/common/adblock_prefs.cc b/components/adbloc
-// Not sent, used locally to ensure we don't ping too often.
-const char kTelemetryNextPingTime[] =
- "adblock.telemetry.activeping.next_ping_time";
+-
+ // FilteringConfiguration data
+ const char kConfigurationsPrefsPath[] = "filtering.configurations";
+
+@@ -106,21 +79,12 @@ const char kAutoInstalledSubscriptionsNextUpdateTime[] =
+ "adblock.auto_installed_subscriptions.last_update_time";
+
+ // Dict containing stats about acceptable ads page views
+-const char kTelemetryPageViewStats[] = "adblock.telemetry.page_view_stats";
-
-void RegisterTelemetryPrefs(PrefRegistrySimple* registry) {
- registry->RegisterStringPref(kTelemetryLastPingTag, "");
@@ -4225,8 +3371,9 @@ diff --git a/components/adblock/core/common/adblock_prefs.cc b/components/adbloc
- registry->RegisterStringPref(kTelemetryPreviousLastPingTime, "");
- registry->RegisterStringPref(kTelemetryFirstPingTime, "");
- registry->RegisterTimePref(kTelemetryNextPingTime, base::Time());
+- registry->RegisterDictionaryPref(kTelemetryPageViewStats);
-}
--
+
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(kAllowPrivilegedFilters, false);
registry->RegisterBooleanPref(kEnableAdblockLegacy, true);
@@ -4237,18 +3384,36 @@ diff --git a/components/adblock/core/common/adblock_prefs.cc b/components/adbloc
registry->RegisterListPref(kAdblockAllowedDomainsLegacy, {});
registry->RegisterListPref(kAdblockCustomFiltersLegacy, {});
registry->RegisterListPref(kAdblockSubscriptionsLegacy, {});
-@@ -114,7 +80,6 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
- registry->RegisterDictionaryPref(kSubscriptionSignatures);
+@@ -130,11 +94,10 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterStringPref(kLastUsedSchemaVersion, "");
registry->RegisterDictionaryPref(kSubscriptionMetadata);
+ registry->RegisterDictionaryPref(kConfigurationsPrefsPath);
+- registry->RegisterBooleanPref(kEnableAutoInstalledSubscriptions, true);
++ registry->RegisterBooleanPref(kEnableAutoInstalledSubscriptions, false);
+ // Set to |now| so the first update happens ASAP
+ registry->RegisterTimePref(kAutoInstalledSubscriptionsNextUpdateTime,
+ base::Time::Now());
- RegisterTelemetryPrefs(registry);
VLOG(3) << "[eyeo] Registered prefs";
}
+@@ -152,12 +115,6 @@ std::vector GetPrefs() {
+ kSubscriptionSignatures,
+ kLastUsedSchemaVersion,
+ kSubscriptionMetadata,
+- kTelemetryLastPingTag,
+- kTelemetryLastPingTime,
+- kTelemetryPreviousLastPingTime,
+- kTelemetryFirstPingTime,
+- kTelemetryNextPingTime,
+- kTelemetryPageViewStats,
+ kConfigurationsPrefsPath,
+ kEnableAutoInstalledSubscriptions,
+ kAutoInstalledSubscriptionsNextUpdateTime};
diff --git a/components/adblock/core/common/adblock_prefs.h b/components/adblock/core/common/adblock_prefs.h
--- a/components/adblock/core/common/adblock_prefs.h
+++ b/components/adblock/core/common/adblock_prefs.h
-@@ -23,6 +23,7 @@ class PrefRegistrySimple;
+@@ -26,6 +26,7 @@ class PrefRegistrySimple;
namespace adblock::common::prefs {
extern const char kEnableAdblockLegacy[];
@@ -4256,50 +3421,45 @@ diff --git a/components/adblock/core/common/adblock_prefs.h b/components/adblock
extern const char kEnableAcceptableAdsLegacy[];
extern const char kAdblockAllowedDomainsLegacy[];
extern const char kAdblockCustomFiltersLegacy[];
-diff --git a/components/adblock/core/common/adblock_utils.cc b/components/adblock/core/common/adblock_utils.cc
---- a/components/adblock/core/common/adblock_utils.cc
-+++ b/components/adblock/core/common/adblock_utils.cc
-@@ -49,16 +49,6 @@ std::string CreateDomainAllowlistingFilter(const std::string& domain) {
-
- SiteKey GetSitekeyHeader(
- const scoped_refptr& headers) {
-- size_t iterator = 0;
-- std::string name;
-- std::string value;
-- while (headers->EnumerateHeaderLines(&iterator, &name, &value)) {
-- std::transform(name.begin(), name.end(), name.begin(),
-- [](unsigned char c) { return std::tolower(c); });
-- if (name == adblock::kSiteKeyHeaderKey) {
-- return SiteKey{value};
-- }
-- }
- return {};
+@@ -36,12 +37,6 @@ extern const char kInstallFirstStartSubscriptions[];
+ extern const char kSubscriptionSignatures[];
+ extern const char kLastUsedSchemaVersion[];
+ extern const char kSubscriptionMetadata[];
+-extern const char kTelemetryLastPingTag[];
+-extern const char kTelemetryLastPingTime[];
+-extern const char kTelemetryPreviousLastPingTime[];
+-extern const char kTelemetryFirstPingTime[];
+-extern const char kTelemetryNextPingTime[];
+-extern const char kTelemetryPageViewStats[];
+ extern const char kConfigurationsPrefsPath[];
+ extern const char kEnableAutoInstalledSubscriptions[];
+ extern const char kAutoInstalledSubscriptionsNextUpdateTime[];
+diff --git a/components/adblock/core/common/app_info.cc b/components/adblock/core/common/app_info.cc
+--- a/components/adblock/core/common/app_info.cc
++++ b/components/adblock/core/common/app_info.cc
+@@ -29,18 +29,6 @@ const AppInfo& AppInfo::Get() {
}
-@@ -70,19 +60,6 @@ AppInfo::AppInfo(const AppInfo&) = default;
-
- AppInfo GetAppInfo() {
- AppInfo info;
--
+ AppInfo::AppInfo() {
-#if defined(EYEO_APPLICATION_NAME)
-- info.name = EYEO_APPLICATION_NAME;
+- name = EYEO_APPLICATION_NAME;
-#else
-- info.name = version_info::GetProductName();
+- name = version_info::GetProductName();
-#endif
-#if defined(EYEO_APPLICATION_VERSION)
-- info.version = EYEO_APPLICATION_VERSION;
+- version = EYEO_APPLICATION_VERSION;
-#else
-- info.version = version_info::GetVersionNumber();
+- version = version_info::GetVersionNumber();
-#endif
- base::ReplaceChars(version_info::GetOSType(), base::kWhitespaceASCII, "",
-- &info.client_os);
- return info;
+- &client_os);
}
+ } // namespace adblock
diff --git a/components/adblock/core/configuration/filtering_configuration.h b/components/adblock/core/configuration/filtering_configuration.h
--- a/components/adblock/core/configuration/filtering_configuration.h
+++ b/components/adblock/core/configuration/filtering_configuration.h
-@@ -65,6 +65,9 @@ class FilteringConfiguration {
+@@ -66,6 +66,9 @@ class FilteringConfiguration {
virtual void SetEnabled(bool enabled) = 0;
virtual bool IsEnabled() const = 0;
@@ -4312,15 +3472,15 @@ diff --git a/components/adblock/core/configuration/filtering_configuration.h b/c
diff --git a/components/adblock/core/configuration/persistent_filtering_configuration.cc b/components/adblock/core/configuration/persistent_filtering_configuration.cc
--- a/components/adblock/core/configuration/persistent_filtering_configuration.cc
+++ b/components/adblock/core/configuration/persistent_filtering_configuration.cc
-@@ -24,6 +24,7 @@
- #include "components/adblock/core/configuration/filtering_configuration_prefs.h"
+@@ -25,6 +25,7 @@
+ #include "components/adblock/core/common/adblock_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
+#include "components/adblock/core/common/adblock_prefs.h"
#include "base/logging.h"
-@@ -134,6 +135,7 @@ const std::string& PersistentFilteringConfiguration::GetName() const {
+@@ -133,6 +134,7 @@ const std::string& PersistentFilteringConfiguration::GetName() const {
}
void PersistentFilteringConfiguration::SetEnabled(bool enabled) {
@@ -4328,7 +3488,7 @@ diff --git a/components/adblock/core/configuration/persistent_filtering_configur
if (IsEnabled() == enabled) {
return;
}
-@@ -142,6 +144,14 @@ void PersistentFilteringConfiguration::SetEnabled(bool enabled) {
+@@ -141,6 +143,14 @@ void PersistentFilteringConfiguration::SetEnabled(bool enabled) {
NotifyEnabledStateChanged();
}
@@ -4346,7 +3506,7 @@ diff --git a/components/adblock/core/configuration/persistent_filtering_configur
diff --git a/components/adblock/core/configuration/persistent_filtering_configuration.h b/components/adblock/core/configuration/persistent_filtering_configuration.h
--- a/components/adblock/core/configuration/persistent_filtering_configuration.h
+++ b/components/adblock/core/configuration/persistent_filtering_configuration.h
-@@ -49,6 +49,9 @@ class PersistentFilteringConfiguration final : public FilteringConfiguration {
+@@ -48,6 +48,9 @@ class PersistentFilteringConfiguration final : public FilteringConfiguration {
void SetEnabled(bool enabled) final;
bool IsEnabled() const final;
@@ -4359,7 +3519,7 @@ diff --git a/components/adblock/core/configuration/persistent_filtering_configur
diff --git a/components/adblock/core/converter/flatbuffer_converter.cc b/components/adblock/core/converter/flatbuffer_converter.cc
--- a/components/adblock/core/converter/flatbuffer_converter.cc
+++ b/components/adblock/core/converter/flatbuffer_converter.cc
-@@ -124,7 +124,7 @@ void FlatbufferConverter::ConvertFilter(
+@@ -144,7 +144,7 @@ void FlatbufferConverter::ConvertFilter(
std::string(filter_str.data(), filter_str.size()))) {
flatbuffer_serializer.SerializeUrlFilter(std::move(url_filter.value()));
} else {
@@ -4371,21 +3531,7 @@ diff --git a/components/adblock/core/converter/flatbuffer_converter.cc b/compone
diff --git a/components/adblock/core/converter/parser/metadata.cc b/components/adblock/core/converter/parser/metadata.cc
--- a/components/adblock/core/converter/parser/metadata.cc
+++ b/components/adblock/core/converter/parser/metadata.cc
-@@ -57,13 +57,6 @@ std::optional Metadata::FromStream(std::istream& filter_stream) {
- if (key == "homepage") {
- homepage = value;
- } else if (key == "redirect") {
-- auto url = GURL(value);
-- if (url.is_valid()) {
-- redirect_url = url;
-- } else {
-- VLOG(1) << "[eyeo] Invalid redirect URL: " << value
-- << ". Will not redirect.";
-- }
- } else if (key == "title") {
- title = value;
- } else if (key == "version") {
-@@ -106,6 +99,7 @@ Metadata::~Metadata() = default;
+@@ -108,6 +108,7 @@ Metadata::~Metadata() = default;
// static
bool Metadata::IsValidAdblockHeader(const std::string& adblock_header) {
@@ -4393,15 +3539,6 @@ diff --git a/components/adblock/core/converter/parser/metadata.cc b/components/a
static re2::RE2 adblock_header_re("^\\[Adblock.*\\]");
std::string adblock_header_trimmed;
-@@ -130,7 +124,7 @@ base::TimeDelta Metadata::ParseExpirationTime(
-
- if (!re2::RE2::FullMatch(expiration_value, expiration_time_re,
- &expiration_time, &expiration_unit)) {
-- VLOG(1) << "[eyeo] Invalid expiration time format: " << expiration_value
-+ LOG(ERROR) << "[eyeo] Invalid expiration time format: " << expiration_value
- << ". Will use default value of "
- << kDefaultExpirationInterval.InDays() << " days.";
- return kDefaultExpirationInterval;
diff --git a/components/adblock/core/converter/parser/test/test_rules.txt b/components/adblock/core/converter/parser/test/test_rules.txt
new file mode 100644
--- /dev/null
@@ -4431,7 +3568,7 @@ new file mode 100644
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) {
+@@ -50,6 +50,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(piece, "|");
if (pattern_has_right_anchor) {
@@ -4442,7 +3579,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
piece.remove_suffix(1);
}
if (piece.find('|') == std::string_view::npos) {
-@@ -108,21 +112,21 @@ std::optional UrlFilter::FromString(std::string filter_str) {
+@@ -133,21 +137,21 @@ absl::optional UrlFilter::FromString(std::string filter_str) {
if (options->Csp().has_value() && options->Csp().value().empty() &&
!is_allowing) {
@@ -4470,9 +3607,9 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/components/adblock/core/converter/parser/url_filter_options.cc
--- a/components/adblock/core/converter/parser/url_filter_options.cc
+++ b/components/adblock/core/converter/parser/url_filter_options.cc
-@@ -88,20 +88,14 @@ std::optional UrlFilterOptions::FromString(
+@@ -92,20 +92,14 @@ absl::optional UrlFilterOptions::FromString(
+ return {};
}
- domains = DomainOption::FromString(value, kDomainOrSitekeySeparator);
} else if (key == "sitekey") {
- if (value.empty()) {
- VLOG(1) << "[eyeo] Sitekey option has to have a value.";
@@ -4497,7 +3634,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
} else {
ContentType content_type = ContentTypeFromString(key);
if (content_type != ContentType::Unknown) {
-@@ -184,6 +178,7 @@ std::optional UrlFilterOptions::ParseRewrite(
+@@ -188,6 +182,7 @@ absl::optional UrlFilterOptions::ParseRewrite(
// static
SiteKeys UrlFilterOptions::ParseSitekeys(const std::string& sitekey_value) {
SiteKeys sitekeys;
@@ -4505,7 +3642,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
for (auto& sitekey : base::SplitString(
base::ToUpperASCII(sitekey_value), kDomainOrSitekeySeparator,
base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
-@@ -195,6 +190,7 @@ SiteKeys UrlFilterOptions::ParseSitekeys(const std::string& sitekey_value) {
+@@ -199,6 +194,7 @@ SiteKeys UrlFilterOptions::ParseSitekeys(const std::string& sitekey_value) {
// static
bool UrlFilterOptions::IsValidCsp(const std::string& csp_value) {
@@ -4513,7 +3650,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
static re2::RE2 invalid_csp(
"(;|^) "
"?(base-uri|referrer|report-to|report-uri|upgrade-insecure-requests)\\b");
-@@ -205,6 +201,7 @@ bool UrlFilterOptions::IsValidCsp(const std::string& csp_value) {
+@@ -209,6 +205,7 @@ bool UrlFilterOptions::IsValidCsp(const std::string& csp_value) {
// static
void UrlFilterOptions::ParseHeaders(std::string& headers_value) {
@@ -4521,17 +3658,6 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
// replace \x2c with actual ,
static re2::RE2 r1("([^\\\\])\\\\x2c");
re2::RE2::GlobalReplace(&headers_value, r1, "\\1,");
-diff --git a/components/adblock/core/converter/parser/url_filter_options.h b/components/adblock/core/converter/parser/url_filter_options.h
---- a/components/adblock/core/converter/parser/url_filter_options.h
-+++ b/components/adblock/core/converter/parser/url_filter_options.h
-@@ -18,6 +18,7 @@
- #ifndef COMPONENTS_ADBLOCK_CORE_CONVERTER_PARSER_URL_FILTER_OPTIONS_H_
- #define COMPONENTS_ADBLOCK_CORE_CONVERTER_PARSER_URL_FILTER_OPTIONS_H_
-
-+#include
- #include
- #include