| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/google/core/browser/google_util.h" | 5 #include "components/google/core/browser/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" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Catalonia does not have a CLDR country code, since it's a region in Spain, | 125 // Catalonia does not have a CLDR country code, since it's a region in Spain, |
| 126 // so use Spain instead. | 126 // so use Spain instead. |
| 127 if (country_code == "cat") | 127 if (country_code == "cat") |
| 128 return "es"; | 128 return "es"; |
| 129 return country_code; | 129 return country_code; |
| 130 } | 130 } |
| 131 | 131 |
| 132 GURL GetGoogleSearchURL(GURL google_homepage_url) { | 132 GURL GetGoogleSearchURL(GURL google_homepage_url) { |
| 133 // To transform the homepage URL into the corresponding search URL, add the | 133 // To transform the homepage URL into the corresponding search URL, add the |
| 134 // "search" and the "q=" query string. | 134 // "search" and the "q=" query string. |
| 135 std::string search_path = "search"; | |
| 136 std::string query_string = "q="; | |
| 137 GURL::Replacements replacements; | 135 GURL::Replacements replacements; |
| 138 replacements.SetPathStr(search_path); | 136 replacements.SetPathStr("search"); |
| 139 replacements.SetQueryStr(query_string); | 137 replacements.SetQueryStr("q="); |
| 140 return google_homepage_url.ReplaceComponents(replacements); | 138 return google_homepage_url.ReplaceComponents(replacements); |
| 141 } | 139 } |
| 142 | 140 |
| 143 GURL CommandLineGoogleBaseURL() { | 141 GURL CommandLineGoogleBaseURL() { |
| 144 // Unit tests may add command-line flags after the first call to this | 142 // Unit tests may add command-line flags after the first call to this |
| 145 // function, so we don't simply initialize a static |base_url| directly and | 143 // function, so we don't simply initialize a static |base_url| directly and |
| 146 // then unconditionally return it. | 144 // then unconditionally return it. |
| 147 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); | 145 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); |
| 148 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); | 146 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); |
| 149 std::string current_switch_value( | 147 std::string current_switch_value( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 206 } |
| 209 | 207 |
| 210 bool IsYoutubeDomainUrl(const GURL& url, | 208 bool IsYoutubeDomainUrl(const GURL& url, |
| 211 SubdomainPermission subdomain_permission, | 209 SubdomainPermission subdomain_permission, |
| 212 PortPermission port_permission) { | 210 PortPermission port_permission) { |
| 213 return IsValidURL(url, port_permission) && | 211 return IsValidURL(url, port_permission) && |
| 214 IsValidHostName(url.host(), "youtube", subdomain_permission); | 212 IsValidHostName(url.host(), "youtube", subdomain_permission); |
| 215 } | 213 } |
| 216 | 214 |
| 217 } // namespace google_util | 215 } // namespace google_util |
| OLD | NEW |