Chromium Code Reviews| 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/search_engines/template_url_prepopulate_data.h" | 5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 8 #include <locale.h> | 8 #include <locale.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3277 // and thus won't ever string-compare successfully against |url|. | 3277 // and thus won't ever string-compare successfully against |url|. |
| 3278 return (url == google.search_url) ? &google : NULL; | 3278 return (url == google.search_url) ? &google : NULL; |
| 3279 } | 3279 } |
| 3280 | 3280 |
| 3281 // For all other cases, check using origins, in order to more aggressively | 3281 // For all other cases, check using origins, in order to more aggressively |
| 3282 // match search engine types for data imported from other browsers. | 3282 // match search engine types for data imported from other browsers. |
| 3283 // | 3283 // |
| 3284 // First special-case Google, because the prepopulate URL for it will not | 3284 // First special-case Google, because the prepopulate URL for it will not |
| 3285 // convert to a GURL and thus won't have an origin. Instead see if the | 3285 // convert to a GURL and thus won't have an origin. Instead see if the |
| 3286 // incoming URL's host is "[*.]google.<TLD>". | 3286 // incoming URL's host is "[*.]google.<TLD>". |
| 3287 if (google_util::IsGoogleHostname(as_gurl.host())) | 3287 if (google_util::IsGoogleHostname(as_gurl.host(), |
| 3288 google_util::DISALLOW_SUBDOMAIN)) { | |
|
Peter Kasting
2012/04/30 18:13:34
Nit: {} not necessary
SteveT
2012/04/30 21:15:44
Done.
| |
| 3288 return &google; | 3289 return &google; |
| 3290 } | |
| 3289 | 3291 |
| 3290 // Now check the rest of the prepopulate data. | 3292 // Now check the rest of the prepopulate data. |
| 3291 GURL origin(as_gurl.GetOrigin()); | 3293 GURL origin(as_gurl.GetOrigin()); |
| 3292 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { | 3294 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { |
| 3293 GURL engine_url(kAllEngines[i]->search_url); | 3295 GURL engine_url(kAllEngines[i]->search_url); |
| 3294 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) | 3296 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) |
| 3295 return kAllEngines[i]; | 3297 return kAllEngines[i]; |
| 3296 } | 3298 } |
| 3297 | 3299 |
| 3298 return NULL; | 3300 return NULL; |
| 3299 } | 3301 } |
| 3300 | 3302 |
| 3301 string16 GetEngineName(const std::string& url) { | 3303 string16 GetEngineName(const std::string& url) { |
| 3302 const PrepopulatedEngine* engine = GetEngineForURL(url); | 3304 const PrepopulatedEngine* engine = GetEngineForURL(url); |
| 3303 if (engine) | 3305 if (engine) |
| 3304 return WideToUTF16(engine->name); | 3306 return WideToUTF16(engine->name); |
| 3305 GURL as_gurl(url); | 3307 GURL as_gurl(url); |
| 3306 return (as_gurl.is_valid() && !as_gurl.host().empty()) ? | 3308 return (as_gurl.is_valid() && !as_gurl.host().empty()) ? |
| 3307 UTF8ToUTF16(as_gurl.host()) : | 3309 UTF8ToUTF16(as_gurl.host()) : |
| 3308 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME); | 3310 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME); |
| 3309 } | 3311 } |
| 3310 | 3312 |
| 3311 SearchEngineType GetEngineType(const std::string& url) { | 3313 SearchEngineType GetEngineType(const std::string& url) { |
| 3312 const PrepopulatedEngine* engine = GetEngineForURL(url); | 3314 const PrepopulatedEngine* engine = GetEngineForURL(url); |
| 3313 return engine ? engine->type : SEARCH_ENGINE_OTHER; | 3315 return engine ? engine->type : SEARCH_ENGINE_OTHER; |
| 3314 } | 3316 } |
| 3315 | 3317 |
| 3316 } // namespace TemplateURLPrepopulateData | 3318 } // namespace TemplateURLPrepopulateData |
| OLD | NEW |