Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/search_engines/template_url_model.cc

Issue 3259010: Don't treat input with a scheme that's not "http" or "https" as a potential k... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 // static 125 // static
126 std::wstring TemplateURLModel::CleanUserInputKeyword( 126 std::wstring TemplateURLModel::CleanUserInputKeyword(
127 const std::wstring& keyword) { 127 const std::wstring& keyword) {
128 // Remove the scheme. 128 // Remove the scheme.
129 std::wstring result(UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword)))); 129 std::wstring result(UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword))));
130 url_parse::Component scheme_component; 130 url_parse::Component scheme_component;
131 if (url_parse::ExtractScheme(WideToUTF8(keyword).c_str(), 131 if (url_parse::ExtractScheme(WideToUTF8(keyword).c_str(),
132 static_cast<int>(keyword.length()), 132 static_cast<int>(keyword.length()),
133 &scheme_component)) { 133 &scheme_component)) {
134 // If the scheme isn't "http" or "https", bail. The user isn't trying to
135 // type a web address, but rather an FTP, file:, or other scheme URL, or a
136 // search query with some sort of initial operator (e.g. "site:").
137 if (result.compare(0, scheme_component.end(),
138 ASCIIToWide(chrome::kHttpScheme)) &&
139 result.compare(0, scheme_component.end(),
140 ASCIIToWide(chrome::kHttpsScheme)))
141 return std::wstring();
142
134 // Include trailing ':'. 143 // Include trailing ':'.
135 result.erase(0, scheme_component.end() + 1); 144 result.erase(0, scheme_component.end() + 1);
136 // Many schemes usually have "//" after them, so strip it too. 145 // Many schemes usually have "//" after them, so strip it too.
137 const std::wstring after_scheme(L"//"); 146 const std::wstring after_scheme(L"//");
138 if (result.compare(0, after_scheme.length(), after_scheme) == 0) 147 if (result.compare(0, after_scheme.length(), after_scheme) == 0)
139 result.erase(0, after_scheme.length()); 148 result.erase(0, after_scheme.length());
140 } 149 }
141 150
142 // Remove leading "www.". 151 // Remove leading "www.".
143 result = net::StripWWW(result); 152 result = net::StripWWW(result);
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 something_changed = true; 1011 something_changed = true;
1003 } 1012 }
1004 } 1013 }
1005 1014
1006 if (something_changed && loaded_) { 1015 if (something_changed && loaded_) {
1007 provider_map_.UpdateGoogleBaseURLs(); 1016 provider_map_.UpdateGoogleBaseURLs();
1008 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, 1017 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_,
1009 OnTemplateURLModelChanged()); 1018 OnTemplateURLModelChanged());
1010 } 1019 }
1011 } 1020 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698