| 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_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // least don't return the empty string. | 329 // least don't return the empty string. |
| 330 base::string16 keyword(net::StripWWWFromHost(url)); | 330 base::string16 keyword(net::StripWWWFromHost(url)); |
| 331 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; | 331 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; |
| 332 } | 332 } |
| 333 | 333 |
| 334 // static | 334 // static |
| 335 base::string16 TemplateURLService::CleanUserInputKeyword( | 335 base::string16 TemplateURLService::CleanUserInputKeyword( |
| 336 const base::string16& keyword) { | 336 const base::string16& keyword) { |
| 337 // Remove the scheme. | 337 // Remove the scheme. |
| 338 base::string16 result(base::i18n::ToLower(keyword)); | 338 base::string16 result(base::i18n::ToLower(keyword)); |
| 339 TrimWhitespace(result, TRIM_ALL, &result); | 339 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
| 340 url_parse::Component scheme_component; | 340 url_parse::Component scheme_component; |
| 341 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), | 341 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), |
| 342 static_cast<int>(keyword.length()), | 342 static_cast<int>(keyword.length()), |
| 343 &scheme_component)) { | 343 &scheme_component)) { |
| 344 // If the scheme isn't "http" or "https", bail. The user isn't trying to | 344 // If the scheme isn't "http" or "https", bail. The user isn't trying to |
| 345 // type a web address, but rather an FTP, file:, or other scheme URL, or a | 345 // type a web address, but rather an FTP, file:, or other scheme URL, or a |
| 346 // search query with some sort of initial operator (e.g. "site:"). | 346 // search query with some sort of initial operator (e.g. "site:"). |
| 347 if (result.compare(0, scheme_component.end(), | 347 if (result.compare(0, scheme_component.end(), |
| 348 base::ASCIIToUTF16(content::kHttpScheme)) && | 348 base::ASCIIToUTF16(content::kHttpScheme)) && |
| 349 result.compare(0, scheme_component.end(), | 349 result.compare(0, scheme_component.end(), |
| (...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 new_dse = *i; | 2732 new_dse = *i; |
| 2733 break; | 2733 break; |
| 2734 } | 2734 } |
| 2735 } | 2735 } |
| 2736 } | 2736 } |
| 2737 } | 2737 } |
| 2738 if (!new_dse) | 2738 if (!new_dse) |
| 2739 new_dse = FindNewDefaultSearchProvider(); | 2739 new_dse = FindNewDefaultSearchProvider(); |
| 2740 SetDefaultSearchProviderNoNotify(new_dse); | 2740 SetDefaultSearchProviderNoNotify(new_dse); |
| 2741 } | 2741 } |
| OLD | NEW |