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 3263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3274 // and thus won't ever string-compare successfully against |url|. | 3274 // and thus won't ever string-compare successfully against |url|. |
3275 return (url == google.search_url) ? &google : NULL; | 3275 return (url == google.search_url) ? &google : NULL; |
3276 } | 3276 } |
3277 | 3277 |
3278 // For all other cases, check using origins, in order to more aggressively | 3278 // For all other cases, check using origins, in order to more aggressively |
3279 // match search engine types for data imported from other browsers. | 3279 // match search engine types for data imported from other browsers. |
3280 // | 3280 // |
3281 // First special-case Google, because the prepopulate URL for it will not | 3281 // First special-case Google, because the prepopulate URL for it will not |
3282 // convert to a GURL and thus won't have an origin. Instead see if the | 3282 // convert to a GURL and thus won't have an origin. Instead see if the |
3283 // incoming URL's host is "[*.]google.<TLD>". | 3283 // incoming URL's host is "[*.]google.<TLD>". |
3284 if (google_util::IsGoogleHostname(as_gurl.host())) | 3284 if (google_util::IsGoogleHostname(as_gurl.host(), |
| 3285 google_util::DISALLOW_SUBDOMAIN)) { |
3285 return &google; | 3286 return &google; |
| 3287 } |
3286 | 3288 |
3287 // Now check the rest of the prepopulate data. | 3289 // Now check the rest of the prepopulate data. |
3288 GURL origin(as_gurl.GetOrigin()); | 3290 GURL origin(as_gurl.GetOrigin()); |
3289 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { | 3291 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { |
3290 GURL engine_url(kAllEngines[i]->search_url); | 3292 GURL engine_url(kAllEngines[i]->search_url); |
3291 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) | 3293 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) |
3292 return kAllEngines[i]; | 3294 return kAllEngines[i]; |
3293 } | 3295 } |
3294 | 3296 |
3295 return NULL; | 3297 return NULL; |
3296 } | 3298 } |
3297 | 3299 |
3298 string16 GetEngineName(const std::string& url) { | 3300 string16 GetEngineName(const std::string& url) { |
3299 const PrepopulatedEngine* engine = GetEngineForURL(url); | 3301 const PrepopulatedEngine* engine = GetEngineForURL(url); |
3300 if (engine) | 3302 if (engine) |
3301 return WideToUTF16(engine->name); | 3303 return WideToUTF16(engine->name); |
3302 GURL as_gurl(url); | 3304 GURL as_gurl(url); |
3303 return (as_gurl.is_valid() && !as_gurl.host().empty()) ? | 3305 return (as_gurl.is_valid() && !as_gurl.host().empty()) ? |
3304 UTF8ToUTF16(as_gurl.host()) : | 3306 UTF8ToUTF16(as_gurl.host()) : |
3305 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME); | 3307 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME); |
3306 } | 3308 } |
3307 | 3309 |
3308 SearchEngineType GetEngineType(const std::string& url) { | 3310 SearchEngineType GetEngineType(const std::string& url) { |
3309 const PrepopulatedEngine* engine = GetEngineForURL(url); | 3311 const PrepopulatedEngine* engine = GetEngineForURL(url); |
3310 return engine ? engine->type : SEARCH_ENGINE_OTHER; | 3312 return engine ? engine->type : SEARCH_ENGINE_OTHER; |
3311 } | 3313 } |
3312 | 3314 |
3313 } // namespace TemplateURLPrepopulateData | 3315 } // namespace TemplateURLPrepopulateData |
OLD | NEW |