#553 activates the pop-up blocking management present in adblockplus
but not active in upstream. added "enable-stricter-popup-blocker" flag for the global deactivation of all pop-ups (default disabled)
This commit is contained in:
@@ -290,3 +290,4 @@ eyeo-beta-118.0.5993.48-android_settings.patch
|
||||
eyeo-beta-118.0.5993.48-extension_api.patch
|
||||
00Eyeo-Adblock-Remove-Privacy-Issues.patch
|
||||
00AdblockPlus-add-blocking-in-service-workers.patch
|
||||
00AdblockPlus-connect-popup-blocker.patch
|
||||
@@ -0,0 +1,170 @@
|
||||
From: uazo <uazo@users.noreply.github.com>
|
||||
Date: Tue, 9 Jan 2024 13:37:05 +0000
|
||||
Subject: AdblockPlus connect popup blocker
|
||||
|
||||
activates the pop-up blocking management present in adblockplus
|
||||
but not active in upstream.
|
||||
added "enable-stricter-popup-blocker" flag for the global
|
||||
deactivation of all pop-ups (default disabled)
|
||||
---
|
||||
.../adblock/adblock_content_browser_client.cc | 52 +++++++++++++++++++
|
||||
.../adblock/adblock_content_browser_client.h | 14 +++++
|
||||
components/blocked_content/popup_blocker.cc | 9 +++-
|
||||
components/blocked_content/popup_blocker.h | 3 ++
|
||||
.../about_flags_cc/Stricter-popup-blocker.inc | 14 +++++
|
||||
5 files changed, 91 insertions(+), 1 deletion(-)
|
||||
create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Stricter-popup-blocker.inc
|
||||
|
||||
diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/browser/adblock/adblock_content_browser_client.cc
|
||||
--- a/chrome/browser/adblock/adblock_content_browser_client.cc
|
||||
+++ b/chrome/browser/adblock/adblock_content_browser_client.cc
|
||||
@@ -330,6 +330,58 @@ void AdblockContentBrowserClient::OnWebTransportFilterCheckCompleted(
|
||||
"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);
|
||||
+}
|
||||
+
|
||||
bool AdblockContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
content::BrowserContext* browser_context,
|
||||
content::RenderFrameHost* frame,
|
||||
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
|
||||
@@ -82,6 +82,20 @@ class AdblockContentBrowserClient : public ChromeContentBrowserClient {
|
||||
scoped_refptr<base::SequencedTaskRunner> 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;
|
||||
+
|
||||
private:
|
||||
void CreateWebSocketInternal(
|
||||
content::RenderProcessHost* process,
|
||||
diff --git a/components/blocked_content/popup_blocker.cc b/components/blocked_content/popup_blocker.cc
|
||||
--- a/components/blocked_content/popup_blocker.cc
|
||||
+++ b/components/blocked_content/popup_blocker.cc
|
||||
@@ -20,6 +20,11 @@
|
||||
#include "third_party/blink/public/mojom/frame/frame.mojom-shared.h"
|
||||
|
||||
namespace blocked_content {
|
||||
+
|
||||
+CROMITE_FEATURE(kStrictPopupBlocker,
|
||||
+ "StrictPopupBlocker",
|
||||
+ base::FEATURE_DISABLED_BY_DEFAULT);
|
||||
+
|
||||
namespace {
|
||||
|
||||
content::Page& GetSourcePageForPopup(
|
||||
@@ -88,7 +93,9 @@ PopupBlockType ShouldBlockPopup(content::WebContents* web_contents,
|
||||
GetSourcePageForPopup(open_url_params, web_contents))) {
|
||||
return PopupBlockType::kAbusive;
|
||||
}
|
||||
- return PopupBlockType::kNotBlocked;
|
||||
+ return base::FeatureList::IsEnabled(kStrictPopupBlocker)
|
||||
+ ? PopupBlockType::kAbusive
|
||||
+ : PopupBlockType::kNotBlocked;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
diff --git a/components/blocked_content/popup_blocker.h b/components/blocked_content/popup_blocker.h
|
||||
--- a/components/blocked_content/popup_blocker.h
|
||||
+++ b/components/blocked_content/popup_blocker.h
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef COMPONENTS_BLOCKED_CONTENT_POPUP_BLOCKER_H_
|
||||
#define COMPONENTS_BLOCKED_CONTENT_POPUP_BLOCKER_H_
|
||||
|
||||
+#include "base/feature_list.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "third_party/blink/public/mojom/window_features/window_features.mojom-forward.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
@@ -18,6 +19,8 @@ struct OpenURLParams;
|
||||
} // namespace content
|
||||
|
||||
namespace blocked_content {
|
||||
+BASE_DECLARE_FEATURE(kStrictPopupBlocker);
|
||||
+
|
||||
class PopupNavigationDelegate;
|
||||
|
||||
// Classifies what caused a popup to be blocked.
|
||||
diff --git a/cromite_flags/chrome/browser/about_flags_cc/Stricter-popup-blocker.inc b/cromite_flags/chrome/browser/about_flags_cc/Stricter-popup-blocker.inc
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/cromite_flags/chrome/browser/about_flags_cc/Stricter-popup-blocker.inc
|
||||
@@ -0,0 +1,14 @@
|
||||
+#ifdef ABOUT_FLAG_INCLUDE_SECTION
|
||||
+
|
||||
+#include "components/blocked_content/popup_blocker.h"
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+#ifdef FLAG_SECTION
|
||||
+
|
||||
+ {"enable-stricter-popup-blocker",
|
||||
+ "Enable Stricter popup blocker",
|
||||
+ "Blocks all pop-ups, even those with user gestures.", kOsAll,
|
||||
+ FEATURE_VALUE_TYPE(blocked_content::kStrictPopupBlocker)},
|
||||
+
|
||||
+#endif // ifdef FLAG_SECTION
|
||||
--
|
||||
2.25.1
|
||||
Reference in New Issue
Block a user