| 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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 if (default_search_index < loaded_urls.size()) { | 1279 if (default_search_index < loaded_urls.size()) { |
| 1280 default_search_provider = loaded_urls[default_search_index]; | 1280 default_search_provider = loaded_urls[default_search_index]; |
| 1281 loaded_urls.weak_erase(loaded_urls.begin() + default_search_index); | 1281 loaded_urls.weak_erase(loaded_urls.begin() + default_search_index); |
| 1282 } | 1282 } |
| 1283 return default_search_provider; | 1283 return default_search_provider; |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 SearchEngineType GetEngineType(const std::string& url) { | 1286 SearchEngineType GetEngineType(const std::string& url) { |
| 1287 // Restricted to UI thread because ReplaceSearchTerms() is so restricted. | 1287 // Restricted to UI thread because ReplaceSearchTerms() is so restricted. |
| 1288 using content::BrowserThread; | 1288 using content::BrowserThread; |
| 1289 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 1289 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 1290 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1290 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1291 | 1291 |
| 1292 // We may get a valid URL, or we may get the Google prepopulate URL which | 1292 // We may get a valid URL, or we may get the Google prepopulate URL which |
| 1293 // can't be converted directly to a GURL. To handle the latter, we first | 1293 // can't be converted directly to a GURL. To handle the latter, we first |
| 1294 // construct a TemplateURL from the provided |url|, then call | 1294 // construct a TemplateURL from the provided |url|, then call |
| 1295 // ReplaceSearchTerms(). This should return a valid URL even when the input | 1295 // ReplaceSearchTerms(). This should return a valid URL even when the input |
| 1296 // has Google base URLs. | 1296 // has Google base URLs. |
| 1297 TemplateURLData data; | 1297 TemplateURLData data; |
| 1298 data.SetURL(url); | 1298 data.SetURL(url); |
| 1299 TemplateURL turl(NULL, data); | 1299 TemplateURL turl(NULL, data); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1326 GURL GetLogoURL(const TemplateURL& template_url, LogoSize size) { | 1326 GURL GetLogoURL(const TemplateURL& template_url, LogoSize size) { |
| 1327 if (GetEngineType(template_url.url()) == SEARCH_ENGINE_GOOGLE) { | 1327 if (GetEngineType(template_url.url()) == SEARCH_ENGINE_GOOGLE) { |
| 1328 return GURL((size == LOGO_200_PERCENT) ? | 1328 return GURL((size == LOGO_200_PERCENT) ? |
| 1329 google_logos.logo_200_percent_url : | 1329 google_logos.logo_200_percent_url : |
| 1330 google_logos.logo_100_percent_url); | 1330 google_logos.logo_100_percent_url); |
| 1331 } | 1331 } |
| 1332 return GURL(); | 1332 return GURL(); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 } // namespace TemplateURLPrepopulateData | 1335 } // namespace TemplateURLPrepopulateData |
| OLD | NEW |