OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 // static | 153 // static |
154 string16 TemplateURLModel::CleanUserInputKeyword(const string16& keyword) { | 154 string16 TemplateURLModel::CleanUserInputKeyword(const string16& keyword) { |
155 // Remove the scheme. | 155 // Remove the scheme. |
156 string16 result(l10n_util::ToLower(keyword)); | 156 string16 result(l10n_util::ToLower(keyword)); |
157 url_parse::Component scheme_component; | 157 url_parse::Component scheme_component; |
158 if (url_parse::ExtractScheme(UTF16ToUTF8(keyword).c_str(), | 158 if (url_parse::ExtractScheme(UTF16ToUTF8(keyword).c_str(), |
159 static_cast<int>(keyword.length()), | 159 static_cast<int>(keyword.length()), |
160 &scheme_component)) { | 160 &scheme_component)) { |
161 // If the scheme isn't "http" or "https", bail. The user isn't trying to | 161 // If the scheme isn't "http", "https", or "httpsv", bail. The user isn't |
162 // type a web address, but rather an FTP, file:, or other scheme URL, or a | 162 // trying to type a web address, but rather an FTP, file:, or other scheme |
163 // search query with some sort of initial operator (e.g. "site:"). | 163 // URL, or a search query with some sort of initial operator |
| 164 // (e.g. "site:"). |
164 if (result.compare(0, scheme_component.end(), | 165 if (result.compare(0, scheme_component.end(), |
165 ASCIIToUTF16(chrome::kHttpScheme)) && | 166 ASCIIToUTF16(chrome::kHttpScheme)) && |
166 result.compare(0, scheme_component.end(), | 167 result.compare(0, scheme_component.end(), |
167 ASCIIToUTF16(chrome::kHttpsScheme))) | 168 ASCIIToUTF16(chrome::kHttpsScheme)) && |
| 169 result.compare(0, scheme_component.end(), |
| 170 ASCIIToUTF16(chrome::kHttpsvScheme))) |
168 return string16(); | 171 return string16(); |
169 | 172 |
170 // Include trailing ':'. | 173 // Include trailing ':'. |
171 result.erase(0, scheme_component.end() + 1); | 174 result.erase(0, scheme_component.end() + 1); |
172 // Many schemes usually have "//" after them, so strip it too. | 175 // Many schemes usually have "//" after them, so strip it too. |
173 const string16 after_scheme(ASCIIToUTF16("//")); | 176 const string16 after_scheme(ASCIIToUTF16("//")); |
174 if (result.compare(0, after_scheme.length(), after_scheme) == 0) | 177 if (result.compare(0, after_scheme.length(), after_scheme) == 0) |
175 result.erase(0, after_scheme.length()); | 178 result.erase(0, after_scheme.length()); |
176 } | 179 } |
177 | 180 |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 delete template_url; | 1265 delete template_url; |
1263 } | 1266 } |
1264 | 1267 |
1265 void TemplateURLModel::NotifyObservers() { | 1268 void TemplateURLModel::NotifyObservers() { |
1266 if (!loaded_) | 1269 if (!loaded_) |
1267 return; | 1270 return; |
1268 | 1271 |
1269 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, | 1272 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, |
1270 OnTemplateURLModelChanged()); | 1273 OnTemplateURLModelChanged()); |
1271 } | 1274 } |
OLD | NEW |