| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_model.h" | 5 #include "chrome/browser/search_engines/template_url_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Strip "www." off the front of the keyword; otherwise the keyword won't work | 155 // Strip "www." off the front of the keyword; otherwise the keyword won't work |
| 156 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . | 156 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . |
| 157 return net::StripWWW(UTF8ToWide(url.host())); | 157 return net::StripWWW(UTF8ToWide(url.host())); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // static | 160 // static |
| 161 std::wstring TemplateURLModel::CleanUserInputKeyword( | 161 std::wstring TemplateURLModel::CleanUserInputKeyword( |
| 162 const std::wstring& keyword) { | 162 const std::wstring& keyword) { |
| 163 // Remove the scheme. | 163 // Remove the scheme. |
| 164 std::wstring result(l10n_util::ToLower(keyword)); | 164 std::wstring result(UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword)))); |
| 165 url_parse::Component scheme_component; | 165 url_parse::Component scheme_component; |
| 166 if (url_parse::ExtractScheme(WideToUTF8(keyword).c_str(), | 166 if (url_parse::ExtractScheme(WideToUTF8(keyword).c_str(), |
| 167 static_cast<int>(keyword.length()), | 167 static_cast<int>(keyword.length()), |
| 168 &scheme_component)) { | 168 &scheme_component)) { |
| 169 // Include trailing ':'. | 169 // Include trailing ':'. |
| 170 result.erase(0, scheme_component.end() + 1); | 170 result.erase(0, scheme_component.end() + 1); |
| 171 // Many schemes usually have "//" after them, so strip it too. | 171 // Many schemes usually have "//" after them, so strip it too. |
| 172 const std::wstring after_scheme(L"//"); | 172 const std::wstring after_scheme(L"//"); |
| 173 if (result.compare(0, after_scheme.length(), after_scheme) == 0) | 173 if (result.compare(0, after_scheme.length(), after_scheme) == 0) |
| 174 result.erase(0, after_scheme.length()); | 174 result.erase(0, after_scheme.length()); |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 const TemplateURL* TemplateURLModel::GetTemplateURLForExtension( | 1106 const TemplateURL* TemplateURLModel::GetTemplateURLForExtension( |
| 1107 Extension* extension) const { | 1107 Extension* extension) const { |
| 1108 for (TemplateURLVector::const_iterator i = template_urls_.begin(); | 1108 for (TemplateURLVector::const_iterator i = template_urls_.begin(); |
| 1109 i != template_urls_.end(); ++i) { | 1109 i != template_urls_.end(); ++i) { |
| 1110 if ((*i)->IsExtensionKeyword() && (*i)->url()->GetHost() == extension->id()) | 1110 if ((*i)->IsExtensionKeyword() && (*i)->url()->GetHost() == extension->id()) |
| 1111 return *i; | 1111 return *i; |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 return NULL; | 1114 return NULL; |
| 1115 } | 1115 } |
| OLD | NEW |