OLD | NEW |
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/string16.h" | 11 #include "base/string16.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/google/google_url_tracker.h" | 17 #include "chrome/browser/google/google_url_tracker.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/net/url_util.h" | |
20 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
21 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 22 #include "net/base/url_util.h" |
23 | 23 |
24 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
25 #include "chrome/browser/mac/keystone_glue.h" | 25 #include "chrome/browser/mac/keystone_glue.h" |
26 #elif defined(OS_CHROMEOS) | 26 #elif defined(OS_CHROMEOS) |
27 #include "chrome/browser/google/google_util_chromeos.h" | 27 #include "chrome/browser/google/google_util_chromeos.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(GOOGLE_CHROME_BUILD) | 30 #if defined(GOOGLE_CHROME_BUILD) |
31 #include "chrome/browser/google/linkdoctor_internal/linkdoctor_internal.h" | 31 #include "chrome/browser/google/linkdoctor_internal/linkdoctor_internal.h" |
32 #endif | 32 #endif |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 BrandForTesting::~BrandForTesting() { | 79 BrandForTesting::~BrandForTesting() { |
80 brand_for_testing = NULL; | 80 brand_for_testing = NULL; |
81 } | 81 } |
82 | 82 |
83 GURL AppendGoogleLocaleParam(const GURL& url) { | 83 GURL AppendGoogleLocaleParam(const GURL& url) { |
84 // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses | 84 // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses |
85 // 'no' for that. | 85 // 'no' for that. |
86 std::string locale = g_browser_process->GetApplicationLocale(); | 86 std::string locale = g_browser_process->GetApplicationLocale(); |
87 if (locale == "nb") | 87 if (locale == "nb") |
88 locale = "no"; | 88 locale = "no"; |
89 return chrome_common_net::AppendQueryParameter(url, "hl", locale); | 89 return net::AppendQueryParameter(url, "hl", locale); |
90 } | 90 } |
91 | 91 |
92 std::string StringAppendGoogleLocaleParam(const std::string& url) { | 92 std::string StringAppendGoogleLocaleParam(const std::string& url) { |
93 GURL original_url(url); | 93 GURL original_url(url); |
94 DCHECK(original_url.is_valid()); | 94 DCHECK(original_url.is_valid()); |
95 GURL localized_url = AppendGoogleLocaleParam(original_url); | 95 GURL localized_url = AppendGoogleLocaleParam(original_url); |
96 return localized_url.spec(); | 96 return localized_url.spec(); |
97 } | 97 } |
98 | 98 |
99 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { | 99 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { |
100 const std::string google_domain( | 100 const std::string google_domain( |
101 net::RegistryControlledDomainService::GetDomainAndRegistry( | 101 net::RegistryControlledDomainService::GetDomainAndRegistry( |
102 GoogleURLTracker::GoogleURL(profile))); | 102 GoogleURLTracker::GoogleURL(profile))); |
103 const size_t first_dot = google_domain.find('.'); | 103 const size_t first_dot = google_domain.find('.'); |
104 if (first_dot == std::string::npos) { | 104 if (first_dot == std::string::npos) { |
105 NOTREACHED(); | 105 NOTREACHED(); |
106 return url; | 106 return url; |
107 } | 107 } |
108 return chrome_common_net::AppendQueryParameter( | 108 return net::AppendQueryParameter(url, "sd", |
109 url, "sd", google_domain.substr(first_dot + 1)); | 109 google_domain.substr(first_dot + 1)); |
110 } | 110 } |
111 | 111 |
112 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
113 | 113 |
114 bool GetBrand(std::string* brand) { | 114 bool GetBrand(std::string* brand) { |
115 if (brand_for_testing) { | 115 if (brand_for_testing) { |
116 brand->assign(brand_for_testing); | 116 brand->assign(brand_for_testing); |
117 return true; | 117 return true; |
118 } | 118 } |
119 | 119 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 const char* const kBrands[] = { | 320 const char* const kBrands[] = { |
321 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", | 321 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", |
322 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", | 322 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", |
323 }; | 323 }; |
324 const char* const* end = &kBrands[arraysize(kBrands)]; | 324 const char* const* end = &kBrands[arraysize(kBrands)]; |
325 const char* const* found = std::find(&kBrands[0], end, brand); | 325 const char* const* found = std::find(&kBrands[0], end, brand); |
326 return found != end; | 326 return found != end; |
327 } | 327 } |
328 | 328 |
329 } // namespace google_util | 329 } // namespace google_util |
OLD | NEW |