| 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" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 bool GetReactivationBrand(std::string* brand) { | 148 bool GetReactivationBrand(std::string* brand) { |
| 149 brand->clear(); | 149 brand->clear(); |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 #endif | 153 #endif |
| 154 | 154 |
| 155 bool IsGoogleDomainUrl(const std::string& url, | 155 bool IsGoogleDomainUrl(const std::string& url, |
| 156 SubdomainPermission subdomain_permission, | 156 SubdomainPermission subdomain_permission, |
| 157 PortPermission port_permission) { | 157 PortPermission port_permission) { |
| 158 GURL original_url(url); | 158 GURL gurl(url); |
| 159 if (!original_url.is_valid() || | 159 return gurl.is_valid() && (gurl.SchemeIs("http") || gurl.SchemeIs("https")) && |
| 160 !(original_url.SchemeIs("http") || original_url.SchemeIs("https"))) | 160 (gurl.port().empty() || (port_permission == ALLOW_NON_STANDARD_PORTS)) && |
| 161 return false; | 161 google_util::IsGoogleHostname(gurl.host(), subdomain_permission); |
| 162 | |
| 163 // If we have the Instant URL overridden with a command line flag, accept | |
| 164 // its domain/port combination as well. | |
| 165 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 166 if (command_line.HasSwitch(switches::kInstantURL)) { | |
| 167 GURL custom_instant_url( | |
| 168 command_line.GetSwitchValueASCII(switches::kInstantURL)); | |
| 169 if (original_url.host() == custom_instant_url.host() && | |
| 170 original_url.port() == custom_instant_url.port()) | |
| 171 return true; | |
| 172 } | |
| 173 | |
| 174 return (original_url.port().empty() || | |
| 175 port_permission == ALLOW_NON_STANDARD_PORTS) && | |
| 176 google_util::IsGoogleHostname(original_url.host(), subdomain_permission); | |
| 177 } | 162 } |
| 178 | 163 |
| 179 bool IsGoogleHostname(const std::string& host, | 164 bool IsGoogleHostname(const std::string& host, |
| 180 SubdomainPermission subdomain_permission) { | 165 SubdomainPermission subdomain_permission) { |
| 181 size_t tld_length = net::registry_controlled_domains::GetRegistryLength( | 166 size_t tld_length = net::registry_controlled_domains::GetRegistryLength( |
| 182 host, | 167 host, |
| 183 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 168 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 184 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 169 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 185 if ((tld_length == 0) || (tld_length == std::string::npos)) | 170 if ((tld_length == 0) || (tld_length == std::string::npos)) |
| 186 return false; | 171 return false; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 const char* const kBrands[] = { | 279 const char* const kBrands[] = { |
| 295 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", | 280 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", |
| 296 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", | 281 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", |
| 297 }; | 282 }; |
| 298 const char* const* end = &kBrands[arraysize(kBrands)]; | 283 const char* const* end = &kBrands[arraysize(kBrands)]; |
| 299 const char* const* found = std::find(&kBrands[0], end, brand); | 284 const char* const* found = std::find(&kBrands[0], end, brand); |
| 300 return found != end; | 285 return found != end; |
| 301 } | 286 } |
| 302 | 287 |
| 303 } // namespace google_util | 288 } // namespace google_util |
| OLD | NEW |