summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch')
-rw-r--r--www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch134
1 files changed, 134 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch b/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch
new file mode 100644
index 0000000..b80101e
--- /dev/null
+++ b/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch
@@ -0,0 +1,134 @@
1# Add flag to disable automatic search engine collection
2
3--- chrome/browser/ungoogled_flag_entries.h.orig
4+++ chrome/browser/ungoogled_flag_entries.h
5@@ -16,4 +16,8 @@
6 "Handling of extension MIME type requests",
7 "Used when deciding how to handle a request for a CRX or User Script MIME type. ungoogled-chromium flag.",
8 kOsAll, MULTI_VALUE_TYPE(kExtensionHandlingChoices)},
9+ {"disable-search-engine-collection",
10+ "Disable search engine collection",
11+ "Prevents search engines from being added automatically. ungoogled-chromium flag.",
12+ kOsAll, SINGLE_VALUE_TYPE("disable-search-engine-collection")},
13 #endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
14--- chrome/renderer/chrome_render_frame_observer.cc.orig
15+++ chrome/renderer/chrome_render_frame_observer.cc
16@@ -139,9 +139,10 @@ ChromeRenderFrameObserver::ChromeRenderF
17 if (!render_frame->IsMainFrame())
18 return;
19
20-#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
21 const base::CommandLine& command_line =
22 *base::CommandLine::ForCurrentProcess();
23+ should_autocollect_ = !command_line.HasSwitch("disable-search-engine-collection");
24+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
25 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection))
26 SetClientSidePhishingDetection();
27 #endif
28@@ -201,14 +202,16 @@ void ChromeRenderFrameObserver::DidFinis
29 if (frame->Parent())
30 return;
31
32- GURL osdd_url = frame->GetDocument().OpenSearchDescriptionURL();
33- if (!osdd_url.is_empty()) {
34- mojo::AssociatedRemote<chrome::mojom::OpenSearchDescriptionDocumentHandler>
35- osdd_handler;
36- render_frame()->GetRemoteAssociatedInterfaces()->GetInterface(
37- &osdd_handler);
38- osdd_handler->PageHasOpenSearchDescriptionDocument(
39- frame->GetDocument().Url(), osdd_url);
40+ if (should_autocollect_) {
41+ GURL osdd_url = frame->GetDocument().OpenSearchDescriptionURL();
42+ if (!osdd_url.is_empty()) {
43+ mojo::AssociatedRemote<chrome::mojom::OpenSearchDescriptionDocumentHandler>
44+ osdd_handler;
45+ render_frame()->GetRemoteAssociatedInterfaces()->GetInterface(
46+ &osdd_handler);
47+ osdd_handler->PageHasOpenSearchDescriptionDocument(
48+ frame->GetDocument().Url(), osdd_url);
49+ }
50 }
51 }
52
53--- chrome/renderer/chrome_render_frame_observer.h.orig
54+++ chrome/renderer/chrome_render_frame_observer.h
55@@ -139,6 +139,7 @@ class ChromeRenderFrameObserver : public
56 #if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
57 safe_browsing::PhishingClassifierDelegate* phishing_classifier_ = nullptr;
58 #endif
59+ bool should_autocollect_; // Whether to autocollect search engines
60
61 // Owned by ChromeContentRendererClient and outlive us.
62 web_cache::WebCacheImpl* web_cache_impl_;
63--- components/search_engines/template_url_service.cc.orig
64+++ components/search_engines/template_url_service.cc
65@@ -12,6 +12,7 @@
66 #include "base/bind.h"
67 #include "base/callback.h"
68 #include "base/callback_helpers.h"
69+#include "base/command_line.h"
70 #include "base/containers/contains.h"
71 #include "base/debug/crash_logging.h"
72 #include "base/format_macros.h"
73@@ -197,6 +198,12 @@ bool IsCreatedByExtension(const Template
74 template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION;
75 }
76
77+bool ShouldAutocollect() {
78+ const base::CommandLine& command_line =
79+ *base::CommandLine::ForCurrentProcess();
80+ return !command_line.HasSwitch("disable-search-engine-collection");
81+}
82+
83 } // namespace
84
85 // TemplateURLService::LessWithPrefix -----------------------------------------
86@@ -282,6 +289,7 @@ TemplateURLService::TemplateURLService(
87 std::unique_ptr<TemplateURLServiceClient> client,
88 const base::RepeatingClosure& dsp_change_callback)
89 : prefs_(prefs),
90+ should_autocollect_(true),
91 search_terms_data_(std::move(search_terms_data)),
92 web_data_service_(web_data_service),
93 client_(std::move(client)),
94@@ -363,8 +371,8 @@ bool TemplateURLService::CanAddAutogener
95 // that may interfere with search queries). An easy heuristic for this is
96 // whether the user has a TemplateURL that has been manually modified (e.g.,
97 // renamed) connected to the same host.
98- return !url.is_valid() || url.host().empty() ||
99- CanAddAutogeneratedKeywordForHost(url.host());
100+ return should_autocollect_ && (!url.is_valid() || url.host().empty() ||
101+ CanAddAutogeneratedKeywordForHost(url.host()));
102 }
103
104 bool TemplateURLService::IsPrepopulatedOrCreatedByPolicy(
105@@ -1496,6 +1504,8 @@ SyncDataMap TemplateURLService::CreateGU
106
107 void TemplateURLService::Init(const Initializer* initializers,
108 int num_initializers) {
109+ should_autocollect_ = ShouldAutocollect();
110+
111 if (client_)
112 client_->SetOwner(this);
113
114@@ -1632,6 +1642,9 @@ void TemplateURLService::ChangeToLoadedS
115
116 bool TemplateURLService::CanAddAutogeneratedKeywordForHost(
117 const std::string& host) const {
118+ if (!should_autocollect_)
119+ return false;
120+
121 const TemplateURLSet* urls = provider_map_->GetURLsForHost(host);
122 if (!urls)
123 return true;
124--- components/search_engines/template_url_service.h.orig
125+++ components/search_engines/template_url_service.h
126@@ -706,6 +706,8 @@ class TemplateURLService : public WebDat
127 // ---------- Browser state related members ---------------------------------
128 PrefService* prefs_ = nullptr;
129
130+ bool should_autocollect_; // Whether search engines should be auto-collected
131+
132 std::unique_ptr<SearchTermsData> search_terms_data_ =
133 std::make_unique<SearchTermsData>();
134