Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: chrome/browser/google/google_util.cc

Issue 327793005: Change google_util::AppendGoogleLocaleParam to take in the application locale (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ChromeOS fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/google/google_util.h" 5 #include "chrome/browser/google/google_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h"
17 #include "components/google/core/browser/google_switches.h" 16 #include "components/google/core/browser/google_switches.h"
18 #include "components/google/core/browser/google_url_tracker.h" 17 #include "components/google/core/browser/google_url_tracker.h"
19 #include "components/url_fixer/url_fixer.h" 18 #include "components/url_fixer/url_fixer.h"
20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
21 #include "net/base/url_util.h" 20 #include "net/base/url_util.h"
22 #include "url/gurl.h" 21 #include "url/gurl.h"
23 22
24 // Only use Link Doctor on official builds. It uses an API key, too, but 23 // Only use Link Doctor on official builds. It uses an API key, too, but
25 // seems best to just disable it, for more responsive error pages and to reduce 24 // seems best to just disable it, for more responsive error pages and to reduce
26 // server load. 25 // server load.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 64
66 void SetMockLinkDoctorBaseURLForTesting() { 65 void SetMockLinkDoctorBaseURLForTesting() {
67 gUseMockLinkDoctorBaseURLForTesting = true; 66 gUseMockLinkDoctorBaseURLForTesting = true;
68 } 67 }
69 68
70 std::string GetGoogleLocale(const std::string& application_locale) { 69 std::string GetGoogleLocale(const std::string& application_locale) {
71 // Google does not recognize "nb" for Norwegian Bokmal; it uses "no". 70 // Google does not recognize "nb" for Norwegian Bokmal; it uses "no".
72 return (application_locale == "nb") ? "no" : application_locale; 71 return (application_locale == "nb") ? "no" : application_locale;
73 } 72 }
74 73
75 GURL AppendGoogleLocaleParam(const GURL& url) { 74 GURL AppendGoogleLocaleParam(const GURL& url,
75 const std::string& application_locale) {
76 return net::AppendQueryParameter( 76 return net::AppendQueryParameter(
77 url, "hl", GetGoogleLocale(g_browser_process->GetApplicationLocale())); 77 url, "hl", GetGoogleLocale(application_locale));
78 }
79
80 std::string StringAppendGoogleLocaleParam(const std::string& url) {
81 GURL original_url(url);
82 DCHECK(original_url.is_valid());
83 GURL localized_url = AppendGoogleLocaleParam(original_url);
84 return localized_url.spec();
85 } 78 }
86 79
87 std::string GetGoogleCountryCode(GURL google_homepage_url) { 80 std::string GetGoogleCountryCode(GURL google_homepage_url) {
88 const std::string google_hostname = google_homepage_url.host(); 81 const std::string google_hostname = google_homepage_url.host();
89 const size_t last_dot = google_hostname.find_last_of('.'); 82 const size_t last_dot = google_hostname.find_last_of('.');
90 if (last_dot == std::string::npos) { 83 if (last_dot == std::string::npos) {
91 NOTREACHED(); 84 NOTREACHED();
92 } 85 }
93 std::string country_code = google_hostname.substr(last_dot + 1); 86 std::string country_code = google_hostname.substr(last_dot + 1);
94 // Assume the com TLD implies the US. 87 // Assume the com TLD implies the US.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (!is_home_page_base && (path != "/search")) 182 if (!is_home_page_base && (path != "/search"))
190 return false; 183 return false;
191 184
192 // Check for query parameter in URL parameter and hash fragment, depending on 185 // Check for query parameter in URL parameter and hash fragment, depending on
193 // the path type. 186 // the path type.
194 return HasGoogleSearchQueryParam(url.ref()) || 187 return HasGoogleSearchQueryParam(url.ref()) ||
195 (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); 188 (!is_home_page_base && HasGoogleSearchQueryParam(url.query()));
196 } 189 }
197 190
198 } // namespace google_util 191 } // namespace google_util
OLDNEW
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698