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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/google_url_tracker.h" 12 #include "chrome/browser/google_url_tracker.h"
13 #include "chrome/browser/history/history.h" 13 #include "chrome/browser/history/history.h"
14 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
15 #include "chrome/browser/rlz/rlz.h" 15 #include "chrome/browser/rlz/rlz.h"
16 #include "chrome/browser/search_engines/template_url.h" 16 #include "chrome/browser/search_engines/template_url.h"
17 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 17 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
18 #include "chrome/common/l10n_util.h" 18 #include "chrome/common/l10n_util.h"
19 #include "chrome/common/notification_service.h" 19 #include "chrome/common/notification_service.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/pref_service.h" 21 #include "chrome/common/pref_service.h"
22 #include "chrome/common/stl_util-inl.h" 22 #include "chrome/common/stl_util-inl.h"
23 #include "chrome/common/url_constants.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
24 #include "googleurl/src/url_parse.h" 25 #include "googleurl/src/url_parse.h"
25 #include "grit/locale_settings.h" 26 #include "grit/locale_settings.h"
26 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
27 #include "unicode/rbbi.h" 28 #include "unicode/rbbi.h"
28 #include "unicode/uchar.h" 29 #include "unicode/uchar.h"
29 30
30 using base::Time; 31 using base::Time;
31 32
32 // String in the URL that is replaced by the search term. 33 // String in the URL that is replaced by the search term.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Don't autogenerate keywords for referrers that are the result of a form 153 // Don't autogenerate keywords for referrers that are the result of a form
153 // submission (TODO: right now we approximate this by checking for the URL 154 // submission (TODO: right now we approximate this by checking for the URL
154 // having a query, but we should replace this with a call to WebCore to see if 155 // having a query, but we should replace this with a call to WebCore to see if
155 // the originating page was actually a form submission), anything other than 156 // the originating page was actually a form submission), anything other than
156 // http, or referrers with a path. 157 // http, or referrers with a path.
157 // 158 //
158 // If we relax the path constraint, we need to be sure to sanitize the path 159 // If we relax the path constraint, we need to be sure to sanitize the path
159 // elements and update AutocompletePopup to look for keywords using the path. 160 // elements and update AutocompletePopup to look for keywords using the path.
160 // See http://b/issue?id=863583. 161 // See http://b/issue?id=863583.
161 if (!url.is_valid() || 162 if (!url.is_valid() ||
162 (autodetected && (url.has_query() || (url.scheme() != "http") || 163 (autodetected && (url.has_query() || !url.SchemeIs(chrome::kHttpScheme) ||
163 ((url.path() != "") && (url.path() != "/"))))) 164 ((url.path() != "") && (url.path() != "/")))))
164 return std::wstring(); 165 return std::wstring();
165 166
166 // Strip "www." off the front of the keyword; otherwise the keyword won't work 167 // Strip "www." off the front of the keyword; otherwise the keyword won't work
167 // properly. See http://b/issue?id=1205573. 168 // properly. See http://b/issue?id=1205573.
168 return net::StripWWW(UTF8ToWide(url.host())); 169 return net::StripWWW(UTF8ToWide(url.host()));
169 } 170 }
170 171
171 // static 172 // static
172 std::wstring TemplateURLModel::CleanUserInputKeyword( 173 std::wstring TemplateURLModel::CleanUserInputKeyword(
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 AddToMaps(t_url); 974 AddToMaps(t_url);
974 something_changed = true; 975 something_changed = true;
975 } 976 }
976 } 977 }
977 978
978 if (something_changed && loaded_) { 979 if (something_changed && loaded_) {
979 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, 980 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_,
980 OnTemplateURLModelChanged()); 981 OnTemplateURLModelChanged());
981 } 982 }
982 } 983 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | chrome/browser/search_engines/template_url_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698