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_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/google/google_url_tracker.h" | 16 #include "chrome/browser/google/google_url_tracker.h" |
17 #include "chrome/browser/net/browser_url_util.h" | |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/net/url_util.h" |
19 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
21 #include "net/base/registry_controlled_domain.h" | 21 #include "net/base/registry_controlled_domain.h" |
22 | 22 |
23 #if defined(OS_MACOSX) | 23 #if defined(OS_MACOSX) |
24 #include "chrome/browser/mac/keystone_glue.h" | 24 #include "chrome/browser/mac/keystone_glue.h" |
25 #endif | 25 #endif |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 30 matching lines...) Expand all Loading... |
59 BrandForTesting::~BrandForTesting() { | 59 BrandForTesting::~BrandForTesting() { |
60 brand_for_testing = NULL; | 60 brand_for_testing = NULL; |
61 } | 61 } |
62 | 62 |
63 GURL AppendGoogleLocaleParam(const GURL& url) { | 63 GURL AppendGoogleLocaleParam(const GURL& url) { |
64 // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses | 64 // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses |
65 // 'no' for that. | 65 // 'no' for that. |
66 std::string locale = g_browser_process->GetApplicationLocale(); | 66 std::string locale = g_browser_process->GetApplicationLocale(); |
67 if (locale == "nb") | 67 if (locale == "nb") |
68 locale = "no"; | 68 locale = "no"; |
69 return chrome_browser_net::AppendQueryParameter(url, "hl", locale); | 69 return chrome_common_net::AppendQueryParameter(url, "hl", locale); |
70 } | 70 } |
71 | 71 |
72 std::string StringAppendGoogleLocaleParam(const std::string& url) { | 72 std::string StringAppendGoogleLocaleParam(const std::string& url) { |
73 GURL original_url(url); | 73 GURL original_url(url); |
74 DCHECK(original_url.is_valid()); | 74 DCHECK(original_url.is_valid()); |
75 GURL localized_url = AppendGoogleLocaleParam(original_url); | 75 GURL localized_url = AppendGoogleLocaleParam(original_url); |
76 return localized_url.spec(); | 76 return localized_url.spec(); |
77 } | 77 } |
78 | 78 |
79 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { | 79 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { |
80 const std::string google_domain( | 80 const std::string google_domain( |
81 net::RegistryControlledDomainService::GetDomainAndRegistry( | 81 net::RegistryControlledDomainService::GetDomainAndRegistry( |
82 GoogleURLTracker::GoogleURL(profile))); | 82 GoogleURLTracker::GoogleURL(profile))); |
83 const size_t first_dot = google_domain.find('.'); | 83 const size_t first_dot = google_domain.find('.'); |
84 if (first_dot == std::string::npos) { | 84 if (first_dot == std::string::npos) { |
85 NOTREACHED(); | 85 NOTREACHED(); |
86 return url; | 86 return url; |
87 } | 87 } |
88 return chrome_browser_net::AppendQueryParameter( | 88 return chrome_common_net::AppendQueryParameter( |
89 url, "sd", google_domain.substr(first_dot + 1)); | 89 url, "sd", google_domain.substr(first_dot + 1)); |
90 } | 90 } |
91 | 91 |
92 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
93 | 93 |
94 bool GetBrand(std::string* brand) { | 94 bool GetBrand(std::string* brand) { |
95 if (brand_for_testing) { | 95 if (brand_for_testing) { |
96 brand->assign(brand_for_testing); | 96 brand->assign(brand_for_testing); |
97 return true; | 97 return true; |
98 } | 98 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 const char* const kBrands[] = { | 258 const char* const kBrands[] = { |
259 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", | 259 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", |
260 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", | 260 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", |
261 }; | 261 }; |
262 const char* const* end = &kBrands[arraysize(kBrands)]; | 262 const char* const* end = &kBrands[arraysize(kBrands)]; |
263 const char* const* found = std::find(&kBrands[0], end, brand); | 263 const char* const* found = std::find(&kBrands[0], end, brand); |
264 return found != end; | 264 return found != end; |
265 } | 265 } |
266 | 266 |
267 } // namespace google_util | 267 } // namespace google_util |
OLD | NEW |