Index: chrome/browser/google/google_util.cc |
=================================================================== |
--- chrome/browser/google/google_util.cc (revision 248295) |
+++ chrome/browser/google/google_util.cc (working copy) |
@@ -27,15 +27,16 @@ |
#include "chrome/browser/google/google_util_chromeos.h" |
#endif |
+// Only use Link Doctor on official builds. It uses an API key, too, but |
+// seems best to just disable it, for more responsive error pages and to reduce |
+// server load. |
#if defined(GOOGLE_CHROME_BUILD) |
-#include "chrome/browser/google/linkdoctor_internal/linkdoctor_internal.h" |
+#define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" |
+#else |
+#define LINKDOCTOR_SERVER_REQUEST_URL "" |
#endif |
-#ifndef LINKDOCTOR_SERVER_REQUEST_URL |
-#define LINKDOCTOR_SERVER_REQUEST_URL std::string() |
-#endif |
- |
// Helpers -------------------------------------------------------------------- |
namespace { |
@@ -74,15 +75,17 @@ |
gUseMockLinkDoctorBaseURLForTesting = true; |
} |
-GURL AppendGoogleLocaleParam(const GURL& url) { |
- // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses |
- // 'no' for that. |
Peter Kasting
2014/02/04 22:49:04
Why did you remove this comment?
mmenke
2014/02/04 23:52:02
Mistake, thanks for catching that.
|
+std::string GetGoogleLocale() { |
std::string locale = g_browser_process->GetApplicationLocale(); |
if (locale == "nb") |
- locale = "no"; |
- return net::AppendQueryParameter(url, "hl", locale); |
+ return "no"; |
+ return locale; |
} |
+GURL AppendGoogleLocaleParam(const GURL& url) { |
+ return net::AppendQueryParameter(url, "hl", GetGoogleLocale()); |
+} |
+ |
std::string StringAppendGoogleLocaleParam(const std::string& url) { |
GURL original_url(url); |
DCHECK(original_url.is_valid()); |
@@ -90,20 +93,39 @@ |
return localized_url.spec(); |
} |
-GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { |
+std::string GetGoogleCountryCodeCode(Profile* profile) { |
const std::string google_domain( |
net::registry_controlled_domains::GetDomainAndRegistry( |
GoogleURLTracker::GoogleURL(profile), |
net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)); |
- const size_t first_dot = google_domain.find('.'); |
- if (first_dot == std::string::npos) { |
+ const size_t last_dot = google_domain.find_last_of('.'); |
+ if (last_dot == std::string::npos) { |
NOTREACHED(); |
Peter Kasting
2014/02/04 22:49:04
Do not handle DCHECK failure. Instead of "if (...
mmenke
2014/02/04 23:52:02
Done. Looks like GoogleURLTracker is smart enough
Peter Kasting
2014/02/05 00:01:39
If that were the case, we wouldn't want NOTREACHED
mmenke
2014/02/05 00:04:56
Makes sense.
|
- return url; |
+ return ""; |
} |
- return net::AppendQueryParameter(url, "sd", |
- google_domain.substr(first_dot + 1)); |
+ std::string tld = google_domain.substr(last_dot + 1); |
Peter Kasting
2014/02/04 22:49:04
Nit: I'm uneasy calling this the "tld", since it's
mmenke
2014/02/04 23:52:02
Done, though per IANA, uk is a TLD: http://data.ia
|
+ // Assume the com TLD implies the US. |
+ if (tld == "com") |
+ return "us"; |
+ // The CLDR code for the UK is "GB". |
Peter Kasting
2014/02/04 22:49:04
What does "CLDR" mean? Explain it or don't use th
mmenke
2014/02/04 23:52:02
Done.
|
+ if (tld == "uk") |
+ return "gb"; |
+ // Catalonia does not have a CLDR country code, so use Spain instead. |
+ if (tld == "cat") |
+ return "es"; |
+ return tld; |
} |
+GURL GetGoogleSearchURL(Profile* profile) { |
+ GURL url = GoogleURLTracker::GoogleURL(profile); |
Peter Kasting
2014/02/04 22:49:04
Nit: This can just be inlined into the last line o
mmenke
2014/02/04 23:52:02
Done.
|
+ |
+ // The url returned by the tracker does not include search path. |
Peter Kasting
2014/02/04 22:49:04
Nit: search path -> the "/search" path
mmenke
2014/02/04 23:52:02
Done.
|
+ std::string search_path = "search"; |
+ GURL::Replacements replace_path; |
+ replace_path.SetPathStr(search_path); |
+ return url.ReplaceComponents(replace_path); |
+} |
+ |
#if defined(OS_WIN) |
bool GetBrand(std::string* brand) { |