~chromium-team/chromium-browser/focal-stable

« back to all changes in this revision

Viewing changes to debian/patches/search-credit.patch

  • Committer: Olivier Tilloy
  • Date: 2019-06-12 07:56:52 UTC
  • mfrom: (1494.1.4 eoan-snap)
  • Revision ID: olivier.tilloy@canonical.com-20190612075652-2mej8weep7syq5j9
* Upstream release: 75.0.3770.80
  - CVE-2019-5828: Use after free in ServiceWorker.
  - CVE-2019-5829: Use after free in Download Manager.
  - CVE-2019-5830: Incorrectly credentialed requests in CORS.
  - CVE-2019-5831: Incorrect map processing in V8.
  - CVE-2019-5832: Incorrect CORS handling in XHR.
  - CVE-2019-5833: Inconsistent security UI placement.
  - CVE-2019-5834: URL spoof in Omnibox on iOS.
  - CVE-2019-5835: Out of bounds read in Swiftshader.
  - CVE-2019-5836: Heap buffer overflow in Angle.
  - CVE-2019-5837: Cross-origin resources size disclosure in Appcache.
  - CVE-2019-5838: Overly permissive tab access in Extensions.
  - CVE-2019-5839: Incorrect handling of certain code points in Blink.
  - CVE-2019-5840: Popup blocker bypass.
* Install the chromium snap in place of the debian packages, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Add Ubuntu id into search queries to get credit.
2
 
Author: Chad Miller <chad.miller@canonical.com>
3
 
 
4
 
--- a/components/search_engines/prepopulated_engines.json
5
 
+++ b/components/search_engines/prepopulated_engines.json
6
 
@@ -52,7 +52,7 @@
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}",
12
 
       "alternate_urls": [
13
 
         "https://www.baidu.com/s?ie={inputEncoding}&wd={searchTerms}",
14
 
         "https://www.baidu.com/s?ie={inputEncoding}&word={searchTerms}",
15
 
@@ -99,7 +99,7 @@
16
 
       "name": "DuckDuckGo",
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",
23
 
       "id": 92
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
27
 
 
28
 
   std::string url = parsed_url_;
29
 
 
30
 
+  bool is_google_search = false;
31
 
+  bool ubuntu_credit_for_search = false;
32
 
+
33
 
   // replacements_ is ordered in ascending order, as such we need to iterate
34
 
   // from the back.
35
 
   for (auto i = replacements_.rbegin(); i != replacements_.rend(); ++i) {
36
 
@@ -981,6 +984,7 @@ std::string TemplateURLRef::HandleReplac
37
 
 
38
 
       case GOOGLE_BASE_URL:
39
 
         DCHECK(!i->is_post_param);
40
 
+        is_google_search = true;
41
 
         HandleReplacement(
42
 
             std::string(), search_terms_data.GoogleBaseURLValue(), *i, &url);
43
 
         break;
44
 
@@ -1100,7 +1104,8 @@ std::string TemplateURLRef::HandleReplac
45
 
 
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";
51
 
         if (!client.empty())
52
 
           HandleReplacement("client", client, *i, &url);
53
 
         break;
54
 
@@ -1229,6 +1234,13 @@ std::string TemplateURLRef::HandleReplac
55
 
     }
56
 
   }
57
 
 
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");
62
 
+    }
63
 
+  }
64
 
+
65
 
   if (!post_params_.empty())
66
 
     EncodeFormData(post_params_, post_content);
67