1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
Description: Add Ubuntu id into search queries to get credit.
Author: Chad Miller <chad.miller@canonical.com>
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -79,7 +79,7 @@
"name": "\u767e\u5ea6",
"keyword": "baidu.com",
"favicon_url": "http://www.baidu.com/favicon.ico",
- "search_url": "http://www.baidu.com/#ie={inputEncoding}&wd={searchTerms}",
+ "search_url": "http://www.baidu.com/#ie={inputEncoding}&tn=ubuntuu_cb&wd={searchTerms}",
"type": "SEARCH_ENGINE_BAIDU",
"id": 21
},
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -898,6 +898,9 @@ std::string TemplateURLRef::HandleReplac
std::string url = parsed_url_;
+ bool is_google_search = false;
+ bool ubuntu_credit_for_search = false;
+
// replacements_ is ordered in ascending order, as such we need to iterate
// from the back.
for (Replacements::reverse_iterator i = replacements_.rbegin();
@@ -927,6 +930,7 @@ std::string TemplateURLRef::HandleReplac
case GOOGLE_BASE_URL:
DCHECK(!i->is_post_param);
+ is_google_search = true;
HandleReplacement(
std::string(), search_terms_data.GoogleBaseURLValue(), *i, &url);
break;
@@ -1102,7 +1106,8 @@ std::string TemplateURLRef::HandleReplac
case GOOGLE_SEARCH_CLIENT: {
DCHECK(!i->is_post_param);
- std::string client = search_terms_data.GetSearchClient();
+ ubuntu_credit_for_search = true;
+ std::string client = "ubuntu";
if (!client.empty())
HandleReplacement("client", client, *i, &url);
break;
@@ -1200,6 +1205,11 @@ std::string TemplateURLRef::HandleReplac
}
}
+ /* Google search template from prefs might not have a client token. */
+ if (is_google_search && !ubuntu_credit_for_search) {
+ url.append("&client=ubuntu");
+ }
+
if (!post_params_.empty())
EncodeFormData(post_params_, post_content);
|