1
Description: Add Ubuntu id into search queries to get credit.
2
Author: Chad Miller <chad.miller@canonical.com>
4
--- a/components/search_engines/prepopulated_engines.json
5
+++ b/components/search_engines/prepopulated_engines.json
7
"name": "\u767e\u5ea6",
8
"keyword": "baidu.com",
9
"favicon_url": "https://www.baidu.com/favicon.ico",
10
- "search_url": "https://www.baidu.com/#ie={inputEncoding}&wd={searchTerms}",
11
+ "search_url": "https://www.baidu.com/#ie={inputEncoding}&tn=ubuntuu_cb&wd={searchTerms}",
13
"https://www.baidu.com/s?ie={inputEncoding}&wd={searchTerms}",
14
"https://www.baidu.com/s?ie={inputEncoding}&word={searchTerms}",
17
"keyword": "duckduckgo.com",
18
"favicon_url": "https://duckduckgo.com/favicon.ico",
19
- "search_url": "https://duckduckgo.com/?q={searchTerms}",
20
+ "search_url": "https://duckduckgo.com/?q={searchTerms}&t=canonical",
21
"suggest_url": "https://duckduckgo.com/ac/?q={searchTerms}&type=list",
22
"type": "SEARCH_ENGINE_DUCKDUCKGO",
24
--- a/components/search_engines/template_url.cc
25
+++ b/components/search_engines/template_url.cc
26
@@ -953,6 +953,9 @@ std::string TemplateURLRef::HandleReplac
28
std::string url = parsed_url_;
30
+ bool is_google_search = false;
31
+ bool ubuntu_credit_for_search = false;
33
// replacements_ is ordered in ascending order, as such we need to iterate
35
for (auto i = replacements_.rbegin(); i != replacements_.rend(); ++i) {
36
@@ -981,6 +984,7 @@ std::string TemplateURLRef::HandleReplac
39
DCHECK(!i->is_post_param);
40
+ is_google_search = true;
42
std::string(), search_terms_data.GoogleBaseURLValue(), *i, &url);
44
@@ -1100,7 +1104,8 @@ std::string TemplateURLRef::HandleReplac
46
case GOOGLE_SEARCH_CLIENT: {
47
DCHECK(!i->is_post_param);
48
- std::string client = search_terms_data.GetSearchClient();
49
+ ubuntu_credit_for_search = true;
50
+ std::string client = "ubuntu";
52
HandleReplacement("client", client, *i, &url);
54
@@ -1229,6 +1234,13 @@ std::string TemplateURLRef::HandleReplac
58
+ /* Google search template from prefs might not have a client token. */
59
+ if (is_google_search && !ubuntu_credit_for_search) {
60
+ if (url.find_first_of('?', 8) != std::string::npos) { // perhaps no GET params
61
+ url.append("&client=ubuntu");
65
if (!post_params_.empty())
66
EncodeFormData(post_params_, post_content);