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

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

Issue 2078021: First pass at experimental omnibox API. There are plenty of rough edges and (Closed)
Patch Set: no prefer_keyword Created 10 years, 7 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) 2009 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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "chrome/browser/webdata/web_data_service.h" 12 #include "chrome/browser/webdata/web_data_service.h"
13 #include "chrome/common/notification_registrar.h" 13 #include "chrome/common/notification_registrar.h"
14 #include "testing/gtest/include/gtest/gtest_prod.h" 14 #include "testing/gtest/include/gtest/gtest_prod.h"
15 15
16 class Extension;
16 class PrefService; 17 class PrefService;
17 class Profile; 18 class Profile;
18 19
19 namespace history { 20 namespace history {
20 struct URLVisitedDetails; 21 struct URLVisitedDetails;
21 } 22 }
22 23
23 // TemplateURLModel is the backend for keywords. It's used by 24 // TemplateURLModel is the backend for keywords. It's used by
24 // KeywordAutocomplete. 25 // KeywordAutocomplete.
25 // 26 //
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // existing_turl. If existing_turl was the default, new_turl is made the 130 // existing_turl. If existing_turl was the default, new_turl is made the
130 // default. After this call existing_turl is deleted. As with Add, 131 // default. After this call existing_turl is deleted. As with Add,
131 // TemplateURLModel takes ownership of existing_turl. 132 // TemplateURLModel takes ownership of existing_turl.
132 void Replace(const TemplateURL* existing_turl, 133 void Replace(const TemplateURL* existing_turl,
133 TemplateURL* new_turl); 134 TemplateURL* new_turl);
134 135
135 // Removes all auto-generated keywords that were created on or after the 136 // Removes all auto-generated keywords that were created on or after the
136 // date passed in. 137 // date passed in.
137 void RemoveAutoGeneratedSince(base::Time created_after); 138 void RemoveAutoGeneratedSince(base::Time created_after);
138 139
140 // If the given extension has an omnibox keyword, adds a TemplateURL for that
141 // keyword. Only 1 keyword is allowed for a given extension. If the keyword
142 // already exists for this extension, does nothing.
143 void RegisterExtensionKeyword(Extension* extension);
144
145 // Removes the TemplateURL containing the keyword for the given extension,
146 // if any.
147 void UnregisterExtensionKeyword(Extension* extension);
148
149 // Returns the TemplateURL associated with the keyword for this extension.
150 // This works by checking the extension ID, not the keyword, so it will work
151 // even if the user changed the keyword.
152 const TemplateURL* GetTemplateURLForExtension(Extension* extension) const;
153
139 // Returns the set of URLs describing the keywords. The elements are owned 154 // Returns the set of URLs describing the keywords. The elements are owned
140 // by TemplateURLModel and should not be deleted. 155 // by TemplateURLModel and should not be deleted.
141 std::vector<const TemplateURL*> GetTemplateURLs() const; 156 std::vector<const TemplateURL*> GetTemplateURLs() const;
142 157
143 // Increment the usage count of a keyword. 158 // Increment the usage count of a keyword.
144 // Called when a URL is loaded that was generated from a keyword. 159 // Called when a URL is loaded that was generated from a keyword.
145 void IncrementUsageCount(const TemplateURL* url); 160 void IncrementUsageCount(const TemplateURL* url);
146 161
147 // Resets the title, keyword and search url of the specified TemplateURL. 162 // Resets the title, keyword and search url of the specified TemplateURL.
148 // The TemplateURL is marked as not replaceable. 163 // The TemplateURL is marked as not replaceable.
(...skipping 30 matching lines...) Expand all
179 // invoked. 194 // invoked.
180 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, 195 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
181 const WDTypedResult* result); 196 const WDTypedResult* result);
182 197
183 // Removes (and deletes) TemplateURLs from |urls| that have duplicate 198 // Removes (and deletes) TemplateURLs from |urls| that have duplicate
184 // prepopulate ids. Duplicate prepopulate ids are not allowed, but due to a 199 // prepopulate ids. Duplicate prepopulate ids are not allowed, but due to a
185 // bug it was possible get dups. This step is only called when the version 200 // bug it was possible get dups. This step is only called when the version
186 // number changes. 201 // number changes.
187 void RemoveDuplicatePrepopulateIDs(std::vector<const TemplateURL*>* urls); 202 void RemoveDuplicatePrepopulateIDs(std::vector<const TemplateURL*>* urls);
188 203
204 // Returns the locale-direction-adjusted short name for the given keyword.
205 // Also sets the out param to indicate whether the keyword belongs to an
206 // extension.
207 std::wstring GetKeywordShortName(const std::wstring& keyword,
208 bool* is_extension_keyword);
209
189 // NotificationObserver method. TemplateURLModel listens for three 210 // NotificationObserver method. TemplateURLModel listens for three
190 // notification types: 211 // notification types:
191 // . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit 212 // . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit
192 // corresponds to a keyword. 213 // corresponds to a keyword.
193 // . NOTIFY_GOOGLE_URL_UPDATED: updates mapping for any keywords containing 214 // . NOTIFY_GOOGLE_URL_UPDATED: updates mapping for any keywords containing
194 // a google base url replacement term. 215 // a google base url replacement term.
195 virtual void Observe(NotificationType type, 216 virtual void Observe(NotificationType type,
196 const NotificationSource& source, 217 const NotificationSource& source,
197 const NotificationDetails& details); 218 const NotificationDetails& details);
198 219
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 365
345 // The default search provider from preferences. This is only valid if 366 // The default search provider from preferences. This is only valid if
346 // GetDefaultSearchProvider is invoked and we haven't been loaded or loading 367 // GetDefaultSearchProvider is invoked and we haven't been loaded or loading
347 // failed. If loading was successful this is not used. 368 // failed. If loading was successful this is not used.
348 scoped_ptr<TemplateURL> prefs_default_search_provider_; 369 scoped_ptr<TemplateURL> prefs_default_search_provider_;
349 370
350 // ID assigned to next TemplateURL added to this model. This is an ever 371 // ID assigned to next TemplateURL added to this model. This is an ever
351 // increasing integer that is initialized from the database. 372 // increasing integer that is initialized from the database.
352 TemplateURL::IDType next_id_; 373 TemplateURL::IDType next_id_;
353 374
375 // List of extension IDs waiting for Load to have keywords registered.
376 std::vector<std::string> pending_extension_ids_;
377
354 DISALLOW_EVIL_CONSTRUCTORS(TemplateURLModel); 378 DISALLOW_EVIL_CONSTRUCTORS(TemplateURLModel);
355 }; 379 };
356 380
357 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_ 381 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | chrome/browser/search_engines/template_url_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698