summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch')
-rw-r--r--www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch461
1 files changed, 461 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch b/www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch
new file mode 100644
index 0000000..9ff8cfa
--- /dev/null
+++ b/www/chromium-uc/patches/extra/ungoogled-chromium/add-suggestions-url-field.patch
@@ -0,0 +1,461 @@
1# Add suggestions URL text field to the search engine editing dialog
2# (chrome://settings/searchEngines).
3
4--- chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html.orig
5+++ chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html
6@@ -20,6 +20,13 @@
7 value="{{queryUrl_}}" on-focus="validate_" on-input="validate_"
8 disabled$="[[model.urlLocked]]">
9 </cr-input>
10+ <cr-input id="suggestionsUrl"
11+ label="Suggestions URL with %s in place of query"
12+ error-message="$i18n{notValid}"
13+ value="{{suggestionsUrl_}}"
14+ on-focus="validate_" on-input="validate_"
15+ disabled$="[[model.urlLocked]]">
16+ </cr-input>
17 </div>
18 <div slot="button-container">
19 <cr-button class="cancel-button" on-click="cancel_" id="cancel">
20--- chrome/browser/resources/settings/search_engines_page/search_engine_dialog.ts.orig
21+++ chrome/browser/resources/settings/search_engines_page/search_engine_dialog.ts
22@@ -26,6 +26,7 @@ interface SettingsSearchEngineDialogElem
23 dialog: CrDialogElement,
24 keyword: CrInputElement,
25 queryUrl: CrInputElement,
26+ suggestionsUrl: CrInputElement,
27 searchEngine: CrInputElement,
28 };
29 }
30@@ -54,6 +55,7 @@ class SettingsSearchEngineDialogElement
31 searchEngine_: String,
32 keyword_: String,
33 queryUrl_: String,
34+ suggestionsUrl_: String,
35 dialogTitle_: String,
36 actionButtonText_: String,
37 };
38@@ -63,6 +65,7 @@ class SettingsSearchEngineDialogElement
39 private searchEngine_: string;
40 private keyword_: string;
41 private queryUrl_: string;
42+ private suggestionsUrl_: string;
43 private dialogTitle_: string;
44 private actionButtonText_: string;
45 private browserProxy_: SearchEnginesBrowserProxy =
46@@ -92,6 +95,7 @@ class SettingsSearchEngineDialogElement
47 this.searchEngine_ = this.model.name;
48 this.keyword_ = this.model.keyword;
49 this.queryUrl_ = this.model.url;
50+ this.suggestionsUrl_ = this.model.suggestionsUrl;
51 } else {
52 this.dialogTitle_ =
53 loadTimeData.getString('searchEnginesAddSearchEngine');
54@@ -127,8 +131,12 @@ class SettingsSearchEngineDialogElement
55 }
56 }
57
58- [this.$.searchEngine, this.$.keyword, this.$.queryUrl].forEach(
59- element => this.validateElement_(element));
60+ [
61+ this.$.searchEngine,
62+ this.$.keyword,
63+ this.$.queryUrl,
64+ this.$.suggestionsUrl
65+ ].forEach(element => this.validateElement_(element));
66 }
67
68 private cancel_() {
69@@ -137,7 +145,8 @@ class SettingsSearchEngineDialogElement
70
71 private onActionButtonTap_() {
72 this.browserProxy_.searchEngineEditCompleted(
73- this.searchEngine_, this.keyword_, this.queryUrl_);
74+ this.searchEngine_, this.keyword_, this.queryUrl_,
75+ this.suggestionsUrl_);
76 this.$.dialog.close();
77 }
78
79@@ -165,9 +174,11 @@ class SettingsSearchEngineDialogElement
80
81 private updateActionButtonState_() {
82 const allValid = [
83- this.$.searchEngine, this.$.keyword, this.$.queryUrl
84+ this.$.searchEngine, this.$.keyword, this.$.queryUrl,
85+ this.$.suggestionsUrl
86 ].every(function(inputElement) {
87- return !inputElement.invalid && inputElement.value.length > 0;
88+ return !inputElement.invalid && (inputElement.value.length > 0 ||
89+ inputElement.id == 'suggestionsUrl');
90 });
91 this.$.actionButton.disabled = !allValid;
92 }
93--- chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.ts.orig
94+++ chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.ts
95@@ -30,6 +30,7 @@ export type SearchEngine = {
96 modelIndex: number,
97 name: string,
98 url: string,
99+ suggestionsUrl: string,
100 urlLocked: boolean,
101 };
102
103@@ -53,7 +54,7 @@ export interface SearchEnginesBrowserPro
104 searchEngineEditCancelled(): void;
105
106 searchEngineEditCompleted(
107- searchEngine: string, keyword: string, queryUrl: string): void;
108+ searchEngine: string, keyword: string, queryUrl: string, suggestionsUrl: string): void;
109
110 getSearchEnginesList(): Promise<SearchEnginesInfo>;
111
112@@ -84,11 +85,12 @@ export class SearchEnginesBrowserProxyIm
113 }
114
115 searchEngineEditCompleted(
116- searchEngine: string, keyword: string, queryUrl: string) {
117+ searchEngine: string, keyword: string, queryUrl: string, suggestionsUrl: string) {
118 chrome.send('searchEngineEditCompleted', [
119 searchEngine,
120 keyword,
121 queryUrl,
122+ suggestionsUrl,
123 ]);
124 }
125
126--- chrome/browser/ui/search_engines/edit_search_engine_controller.cc.orig
127+++ chrome/browser/ui/search_engines/edit_search_engine_controller.cc
128@@ -67,6 +67,15 @@ bool EditSearchEngineController::IsURLVa
129 .is_valid();
130 }
131
132+bool EditSearchEngineController::IsSuggestionsURLValid(
133+ const std::string& suggestions_url_input) const {
134+ std::string suggestions_url = GetFixedUpURL(suggestions_url_input);
135+ if (suggestions_url.empty())
136+ return true;
137+
138+ return IsURLValid(suggestions_url);
139+}
140+
141 bool EditSearchEngineController::IsKeywordValid(
142 const std::u16string& keyword_input) const {
143 std::u16string keyword_input_trimmed(
144@@ -89,10 +98,12 @@ bool EditSearchEngineController::IsKeywo
145 void EditSearchEngineController::AcceptAddOrEdit(
146 const std::u16string& title_input,
147 const std::u16string& keyword_input,
148- const std::string& url_input) {
149+ const std::string& url_input,
150+ const std::string& suggestions_url_input) {
151 DCHECK(!keyword_input.empty());
152 std::string url_string = GetFixedUpURL(url_input);
153 DCHECK(!url_string.empty());
154+ std::string suggestions_url = GetFixedUpURL(suggestions_url_input);
155
156 TemplateURLService* template_url_service =
157 TemplateURLServiceFactory::GetForProfile(profile_);
158@@ -120,7 +131,8 @@ void EditSearchEngineController::AcceptA
159 } else {
160 // Adding or modifying an entry via the Delegate.
161 edit_keyword_delegate_->OnEditedKeyword(template_url_, title_input,
162- keyword_input, url_string);
163+ keyword_input, url_string,
164+ suggestions_url);
165 }
166 }
167
168--- chrome/browser/ui/search_engines/edit_search_engine_controller.h.orig
169+++ chrome/browser/ui/search_engines/edit_search_engine_controller.h
170@@ -23,7 +23,8 @@ class EditSearchEngineControllerDelegate
171 virtual void OnEditedKeyword(TemplateURL* template_url,
172 const std::u16string& title,
173 const std::u16string& keyword,
174- const std::string& url) = 0;
175+ const std::string& url,
176+ const std::string& suggestions_url) = 0;
177
178 protected:
179 virtual ~EditSearchEngineControllerDelegate() {}
180@@ -54,6 +55,8 @@ class EditSearchEngineController {
181 // character results in a valid url.
182 bool IsURLValid(const std::string& url_input) const;
183
184+ bool IsSuggestionsURLValid(const std::string& suggestions_url_input) const;
185+
186 // Returns true if the value of |keyword_input| represents a valid keyword.
187 // The keyword is valid if it is non-empty and does not conflict with an
188 // existing entry. NOTE: this is just the keyword, not the title and url.
189@@ -62,7 +65,8 @@ class EditSearchEngineController {
190 // Completes the add or edit of a search engine.
191 void AcceptAddOrEdit(const std::u16string& title_input,
192 const std::u16string& keyword_input,
193- const std::string& url_input);
194+ const std::string& url_input,
195+ const std::string& suggestions_url_input);
196
197 // Deletes an unused TemplateURL, if its add was cancelled and it's not
198 // already owned by the TemplateURLService.
199--- chrome/browser/ui/search_engines/keyword_editor_controller.cc.orig
200+++ chrome/browser/ui/search_engines/keyword_editor_controller.cc
201@@ -21,23 +21,27 @@ KeywordEditorController::KeywordEditorCo
202 KeywordEditorController::~KeywordEditorController() {
203 }
204
205-int KeywordEditorController::AddTemplateURL(const std::u16string& title,
206- const std::u16string& keyword,
207- const std::string& url) {
208+int KeywordEditorController::AddTemplateURL(
209+ const std::u16string& title,
210+ const std::u16string& keyword,
211+ const std::string& url,
212+ const std::string& suggestions_url) {
213 DCHECK(!url.empty());
214
215 base::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword"));
216
217 const int new_index = table_model_->last_other_engine_index();
218- table_model_->Add(new_index, title, keyword, url);
219+ table_model_->Add(new_index, title, keyword, url, suggestions_url);
220
221 return new_index;
222 }
223
224-void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url,
225- const std::u16string& title,
226- const std::u16string& keyword,
227- const std::string& url) {
228+void KeywordEditorController::ModifyTemplateURL(
229+ TemplateURL* template_url,
230+ const std::u16string& title,
231+ const std::u16string& keyword,
232+ const std::string& url,
233+ const std::string& suggestions_url) {
234 DCHECK(!url.empty());
235 const int index = table_model_->IndexOfTemplateURL(template_url);
236 if (index == -1) {
237@@ -48,10 +52,12 @@ void KeywordEditorController::ModifyTemp
238
239 // Don't do anything if the entry didn't change.
240 if ((template_url->short_name() == title) &&
241- (template_url->keyword() == keyword) && (template_url->url() == url))
242+ (template_url->keyword() == keyword) &&
243+ (template_url->url() == url) &&
244+ (template_url->suggestions_url() == suggestions_url))
245 return;
246
247- table_model_->ModifyTemplateURL(index, title, keyword, url);
248+ table_model_->ModifyTemplateURL(index, title, keyword, url, suggestions_url);
249
250 base::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword"));
251 }
252--- chrome/browser/ui/search_engines/keyword_editor_controller.h.orig
253+++ chrome/browser/ui/search_engines/keyword_editor_controller.h
254@@ -29,14 +29,16 @@ class KeywordEditorController {
255 // model. Returns the index of the added URL.
256 int AddTemplateURL(const std::u16string& title,
257 const std::u16string& keyword,
258- const std::string& url);
259+ const std::string& url,
260+ const std::string& suggestions_url);
261
262 // Invoked when the user modifies a TemplateURL. Updates the
263 // TemplateURLService and table model appropriately.
264 void ModifyTemplateURL(TemplateURL* template_url,
265 const std::u16string& title,
266 const std::u16string& keyword,
267- const std::string& url);
268+ const std::string& url,
269+ const std::string& suggestions_url);
270
271 // Return true if the given |url| can be edited.
272 bool CanEdit(const TemplateURL* url) const;
273--- chrome/browser/ui/search_engines/template_url_table_model.cc.orig
274+++ chrome/browser/ui/search_engines/template_url_table_model.cc
275@@ -109,21 +109,25 @@ void TemplateURLTableModel::Remove(int i
276 void TemplateURLTableModel::Add(int index,
277 const std::u16string& short_name,
278 const std::u16string& keyword,
279- const std::string& url) {
280+ const std::string& url,
281+ const std::string& suggestions_url) {
282 DCHECK(index >= 0 && index <= RowCount());
283 DCHECK(!url.empty());
284 TemplateURLData data;
285 data.SetShortName(short_name);
286 data.SetKeyword(keyword);
287 data.SetURL(url);
288+ data.suggestions_url = suggestions_url;
289 data.is_active = TemplateURLData::ActiveStatus::kTrue;
290 template_url_service_->Add(std::make_unique<TemplateURL>(data));
291 }
292
293-void TemplateURLTableModel::ModifyTemplateURL(int index,
294- const std::u16string& title,
295- const std::u16string& keyword,
296- const std::string& url) {
297+void TemplateURLTableModel::ModifyTemplateURL(
298+ int index,
299+ const std::u16string& title,
300+ const std::u16string& keyword,
301+ const std::string& url,
302+ const std::string& suggestions_url) {
303 DCHECK(index >= 0 && index <= RowCount());
304 DCHECK(!url.empty());
305 TemplateURL* template_url = GetTemplateURL(index);
306@@ -132,7 +136,8 @@ void TemplateURLTableModel::ModifyTempla
307 DCHECK(template_url_service_->GetDefaultSearchProvider() != template_url ||
308 template_url->SupportsReplacement(
309 template_url_service_->search_terms_data()));
310- template_url_service_->ResetTemplateURL(template_url, title, keyword, url);
311+ template_url_service_->ResetTemplateURL(template_url, title, keyword, url,
312+ suggestions_url);
313 }
314
315 TemplateURL* TemplateURLTableModel::GetTemplateURL(int index) {
316--- chrome/browser/ui/search_engines/template_url_table_model.h.orig
317+++ chrome/browser/ui/search_engines/template_url_table_model.h
318@@ -54,13 +54,15 @@ class TemplateURLTableModel : public ui:
319 void Add(int index,
320 const std::u16string& short_name,
321 const std::u16string& keyword,
322- const std::string& url);
323+ const std::string& url,
324+ const std::string& suggestions_url);
325
326 // Update the entry at the specified index.
327 void ModifyTemplateURL(int index,
328 const std::u16string& title,
329 const std::u16string& keyword,
330- const std::string& url);
331+ const std::string& url,
332+ const std::string& suggestions_url);
333
334 // Reloads the icon at the specified index.
335 void ReloadIcon(int index);
336--- chrome/browser/ui/webui/settings/search_engines_handler.cc.orig
337+++ chrome/browser/ui/webui/settings/search_engines_handler.cc
338@@ -37,6 +37,7 @@ namespace {
339 const char kSearchEngineField[] = "searchEngine";
340 const char kKeywordField[] = "keyword";
341 const char kQueryUrlField[] = "queryUrl";
342+const char kSuggestionsUrlField[] = "suggestionsUrl";
343
344 // Dummy number used for indicating that a new search engine is added.
345 const int kNewSearchEngineIndex = -1;
346@@ -212,6 +213,9 @@ SearchEnginesHandler::CreateDictionaryFo
347 Profile* profile = Profile::FromWebUI(web_ui());
348 dict->SetString(
349 "url", template_url->url_ref().DisplayURL(UIThreadSearchTermsData()));
350+ dict->SetString("suggestionsUrl",
351+ template_url->suggestions_url_ref().DisplayURL(
352+ UIThreadSearchTermsData()));
353 dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0);
354 GURL icon_url = template_url->favicon_url();
355 if (icon_url.is_valid())
356@@ -325,12 +329,14 @@ void SearchEnginesHandler::HandleSearchE
357 void SearchEnginesHandler::OnEditedKeyword(TemplateURL* template_url,
358 const std::u16string& title,
359 const std::u16string& keyword,
360- const std::string& url) {
361+ const std::string& url,
362+ const std::string& suggestions_url) {
363 DCHECK(!url.empty());
364 if (template_url)
365- list_controller_.ModifyTemplateURL(template_url, title, keyword, url);
366+ list_controller_.ModifyTemplateURL(template_url, title, keyword, url,
367+ suggestions_url);
368 else
369- list_controller_.AddTemplateURL(title, keyword, url);
370+ list_controller_.AddTemplateURL(title, keyword, url, suggestions_url);
371
372 edit_controller_.reset();
373 }
374@@ -361,6 +367,8 @@ bool SearchEnginesHandler::CheckFieldVal
375 is_valid = edit_controller_->IsKeywordValid(base::UTF8ToUTF16(field_value));
376 else if (field_name.compare(kQueryUrlField) == 0)
377 is_valid = edit_controller_->IsURLValid(field_value);
378+ else if (field_name.compare(kSuggestionsUrlField) == 0)
379+ is_valid = edit_controller_->IsSuggestionsURLValid(field_value);
380 else
381 NOTREACHED();
382
383@@ -382,17 +390,21 @@ void SearchEnginesHandler::HandleSearchE
384 std::string search_engine;
385 std::string keyword;
386 std::string query_url;
387+ std::string suggestions_url;
388 CHECK(args->GetString(0, &search_engine));
389 CHECK(args->GetString(1, &keyword));
390 CHECK(args->GetString(2, &query_url));
391+ CHECK(args->GetString(3, &suggestions_url));
392
393 // Recheck validity. It's possible to get here with invalid input if e.g. the
394 // user calls the right JS functions directly from the web inspector.
395 if (CheckFieldValidity(kSearchEngineField, search_engine) &&
396 CheckFieldValidity(kKeywordField, keyword) &&
397- CheckFieldValidity(kQueryUrlField, query_url)) {
398+ CheckFieldValidity(kQueryUrlField, query_url) &&
399+ CheckFieldValidity(kSuggestionsUrlField, suggestions_url)) {
400 edit_controller_->AcceptAddOrEdit(base::UTF8ToUTF16(search_engine),
401- base::UTF8ToUTF16(keyword), query_url);
402+ base::UTF8ToUTF16(keyword),
403+ query_url, suggestions_url);
404 }
405 }
406
407--- chrome/browser/ui/webui/settings/search_engines_handler.h.orig
408+++ chrome/browser/ui/webui/settings/search_engines_handler.h
409@@ -50,7 +50,8 @@ class SearchEnginesHandler : public Sett
410 void OnEditedKeyword(TemplateURL* template_url,
411 const std::u16string& title,
412 const std::u16string& keyword,
413- const std::string& url) override;
414+ const std::string& url,
415+ const std::string& suggestions_url) override;
416
417 // SettingsPageUIHandler implementation.
418 void RegisterMessages() override;
419@@ -82,8 +83,8 @@ class SearchEnginesHandler : public Sett
420 // to WebUI. Called from WebUI.
421 void HandleValidateSearchEngineInput(const base::ListValue* args);
422
423- // Checks whether the given user input field (searchEngine, keyword, queryUrl)
424- // is populated with a valid value.
425+ // Checks whether the given user input field (searchEngine, keyword, queryUrl,
426+ // suggestionsUrl) is populated with a valid value.
427 bool CheckFieldValidity(const std::string& field_name,
428 const std::string& field_value);
429
430--- components/search_engines/template_url_service.cc.orig
431+++ components/search_engines/template_url_service.cc
432@@ -641,7 +641,8 @@ void TemplateURLService::IncrementUsageC
433 void TemplateURLService::ResetTemplateURL(TemplateURL* url,
434 const std::u16string& title,
435 const std::u16string& keyword,
436- const std::string& search_url) {
437+ const std::string& search_url,
438+ const std::string& suggestions_url) {
439 DCHECK(!IsCreatedByExtension(url));
440 DCHECK(!keyword.empty());
441 DCHECK(!search_url.empty());
442@@ -656,6 +657,7 @@ void TemplateURLService::ResetTemplateUR
443 data.safe_for_autoreplace = false;
444 data.last_modified = clock_->Now();
445 data.is_active = TemplateURLData::ActiveStatus::kTrue;
446+ data.suggestions_url = suggestions_url;
447
448 Update(url, TemplateURL(data));
449 }
450--- components/search_engines/template_url_service.h.orig
451+++ components/search_engines/template_url_service.h
452@@ -253,7 +253,8 @@ class TemplateURLService : public WebDat
453 void ResetTemplateURL(TemplateURL* url,
454 const std::u16string& title,
455 const std::u16string& keyword,
456- const std::string& search_url);
457+ const std::string& search_url,
458+ const std::string& suggestions_url);
459
460 // Sets the `is_active` field of the specified TemplateURL to `kTrue` or
461 // `kFalse`. Called when a user explicitly activates/deactivates the search