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

Side by Side Diff: chrome/browser/search_engines/template_url_service.h

Issue 343823002: Move GenerateSearchURL() and GenerateKeyword() from TemplateURLService to TemplateURL (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 6 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
OLDNEW
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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // SaveDefaultSearchProviderToPrefs or set via policy. 106 // SaveDefaultSearchProviderToPrefs or set via policy.
107 // Returns true if successful, false otherwise. 107 // Returns true if successful, false otherwise.
108 // If the user or the policy has opted for no default search, this 108 // If the user or the policy has opted for no default search, this
109 // returns true but default_provider is set to NULL. 109 // returns true but default_provider is set to NULL.
110 // |*is_managed| specifies whether the default is managed via policy. 110 // |*is_managed| specifies whether the default is managed via policy.
111 static bool LoadDefaultSearchProviderFromPrefs( 111 static bool LoadDefaultSearchProviderFromPrefs(
112 PrefService* prefs, 112 PrefService* prefs,
113 scoped_ptr<TemplateURLData>* default_provider_data, 113 scoped_ptr<TemplateURLData>* default_provider_data,
114 bool* is_managed); 114 bool* is_managed);
115 115
116 // Generates a suitable keyword for the specified url, which must be valid.
117 // This is guaranteed not to return an empty string, since TemplateURLs should
118 // never have an empty keyword.
119 static base::string16 GenerateKeyword(const GURL& url);
120
121 // Removes any unnecessary characters from a user input keyword. 116 // Removes any unnecessary characters from a user input keyword.
122 // This removes the leading scheme, "www." and any trailing slash. 117 // This removes the leading scheme, "www." and any trailing slash.
123 static base::string16 CleanUserInputKeyword(const base::string16& keyword); 118 static base::string16 CleanUserInputKeyword(const base::string16& keyword);
124 119
125 // Returns the search url for t_url. Returns an empty GURL if t_url has no
126 // url().
127 static GURL GenerateSearchURL(const TemplateURL* t_url,
128 const SearchTermsData& search_terms_data);
129
130 // Saves enough of url to |prefs| so that it can be loaded from preferences on 120 // Saves enough of url to |prefs| so that it can be loaded from preferences on
131 // start up. 121 // start up.
132 static void SaveDefaultSearchProviderToPrefs(const TemplateURL* url, 122 static void SaveDefaultSearchProviderToPrefs(const TemplateURL* url,
133 PrefService* prefs); 123 PrefService* prefs);
134 124
135 // Returns true if there is no TemplateURL that conflicts with the 125 // Returns true if there is no TemplateURL that conflicts with the
136 // keyword/url pair, or there is one but it can be replaced. If there is an 126 // keyword/url pair, or there is one but it can be replaced. If there is an
137 // existing keyword that can be replaced and template_url_to_replace is 127 // existing keyword that can be replaced and template_url_to_replace is
138 // non-NULL, template_url_to_replace is set to the keyword to replace. 128 // non-NULL, template_url_to_replace is set to the keyword to replace.
139 // 129 //
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 761
772 // Helper class to manage the default search engine. 762 // Helper class to manage the default search engine.
773 DefaultSearchManager default_search_manager_; 763 DefaultSearchManager default_search_manager_;
774 764
775 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; 765 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_;
776 766
777 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 767 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
778 }; 768 };
779 769
780 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 770 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_parser.cc ('k') | chrome/browser/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698