| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 base::string16 result(base::i18n::ToLower(keyword)); | 511 base::string16 result(base::i18n::ToLower(keyword)); |
| 512 base::TrimWhitespace(result, base::TRIM_ALL, &result); | 512 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
| 513 url::Component scheme_component; | 513 url::Component scheme_component; |
| 514 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), | 514 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), |
| 515 static_cast<int>(keyword.length()), | 515 static_cast<int>(keyword.length()), |
| 516 &scheme_component)) { | 516 &scheme_component)) { |
| 517 // If the scheme isn't "http" or "https", bail. The user isn't trying to | 517 // If the scheme isn't "http" or "https", bail. The user isn't trying to |
| 518 // type a web address, but rather an FTP, file:, or other scheme URL, or a | 518 // type a web address, but rather an FTP, file:, or other scheme URL, or a |
| 519 // search query with some sort of initial operator (e.g. "site:"). | 519 // search query with some sort of initial operator (e.g. "site:"). |
| 520 if (result.compare(0, scheme_component.end(), | 520 if (result.compare(0, scheme_component.end(), |
| 521 base::ASCIIToUTF16(content::kHttpScheme)) && | 521 base::ASCIIToUTF16(url::kHttpScheme)) && |
| 522 result.compare(0, scheme_component.end(), | 522 result.compare(0, scheme_component.end(), |
| 523 base::ASCIIToUTF16(content::kHttpsScheme))) | 523 base::ASCIIToUTF16(url::kHttpsScheme))) |
| 524 return base::string16(); | 524 return base::string16(); |
| 525 | 525 |
| 526 // Include trailing ':'. | 526 // Include trailing ':'. |
| 527 result.erase(0, scheme_component.end() + 1); | 527 result.erase(0, scheme_component.end() + 1); |
| 528 // Many schemes usually have "//" after them, so strip it too. | 528 // Many schemes usually have "//" after them, so strip it too. |
| 529 const base::string16 after_scheme(base::ASCIIToUTF16("//")); | 529 const base::string16 after_scheme(base::ASCIIToUTF16("//")); |
| 530 if (result.compare(0, after_scheme.length(), after_scheme) == 0) | 530 if (result.compare(0, after_scheme.length(), after_scheme) == 0) |
| 531 result.erase(0, after_scheme.length()); | 531 result.erase(0, after_scheme.length()); |
| 532 } | 532 } |
| 533 | 533 |
| (...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 new_dse = *i; | 2756 new_dse = *i; |
| 2757 break; | 2757 break; |
| 2758 } | 2758 } |
| 2759 } | 2759 } |
| 2760 } | 2760 } |
| 2761 } | 2761 } |
| 2762 if (!new_dse) | 2762 if (!new_dse) |
| 2763 new_dse = FindNewDefaultSearchProvider(); | 2763 new_dse = FindNewDefaultSearchProvider(); |
| 2764 SetDefaultSearchProviderNoNotify(new_dse); | 2764 SetDefaultSearchProviderNoNotify(new_dse); |
| 2765 } | 2765 } |
| OLD | NEW |