OLD | NEW |
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 #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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Whether or not the keywords have been loaded. | 187 // Whether or not the keywords have been loaded. |
188 bool loaded() { return loaded_; } | 188 bool loaded() { return loaded_; } |
189 | 189 |
190 // Notification that the keywords have been loaded. | 190 // Notification that the keywords have been loaded. |
191 // This is invoked from WebDataService, and should not be directly | 191 // This is invoked from WebDataService, and should not be directly |
192 // invoked. | 192 // invoked. |
193 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | 193 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
194 const WDTypedResult* result); | 194 const WDTypedResult* result); |
195 | 195 |
196 // Removes (and deletes) TemplateURLs from |urls| that have duplicate | |
197 // prepopulate ids. Duplicate prepopulate ids are not allowed, but due to a | |
198 // bug it was possible get dups. This step is only called when the version | |
199 // number changes. | |
200 void RemoveDuplicatePrepopulateIDs(std::vector<const TemplateURL*>* urls); | |
201 | |
202 // Returns the locale-direction-adjusted short name for the given keyword. | 196 // Returns the locale-direction-adjusted short name for the given keyword. |
203 // Also sets the out param to indicate whether the keyword belongs to an | 197 // Also sets the out param to indicate whether the keyword belongs to an |
204 // extension. | 198 // extension. |
205 std::wstring GetKeywordShortName(const std::wstring& keyword, | 199 std::wstring GetKeywordShortName(const std::wstring& keyword, |
206 bool* is_extension_keyword); | 200 bool* is_extension_keyword); |
207 | 201 |
208 // NotificationObserver method. TemplateURLModel listens for three | 202 // NotificationObserver method. TemplateURLModel listens for three |
209 // notification types: | 203 // notification types: |
210 // . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit | 204 // . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit |
211 // corresponds to a keyword. | 205 // corresponds to a keyword. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 253 |
260 // Removes the supplied template_url from the maps. This searches through all | 254 // Removes the supplied template_url from the maps. This searches through all |
261 // entries in the maps and does not generate the host or keyword. | 255 // entries in the maps and does not generate the host or keyword. |
262 // This is used when the cached content of the TemplateURL changes. | 256 // This is used when the cached content of the TemplateURL changes. |
263 void RemoveFromMapsByPointer(const TemplateURL* template_url); | 257 void RemoveFromMapsByPointer(const TemplateURL* template_url); |
264 | 258 |
265 void AddToMaps(const TemplateURL* template_url); | 259 void AddToMaps(const TemplateURL* template_url); |
266 | 260 |
267 // Sets the keywords. This is used once the keywords have been loaded. | 261 // Sets the keywords. This is used once the keywords have been loaded. |
268 // This does NOT notify the delegate or the database. | 262 // This does NOT notify the delegate or the database. |
269 void SetTemplateURLs(const std::vector<const TemplateURL*>& urls); | 263 void SetTemplateURLs(const std::vector<TemplateURL*>& urls); |
270 | 264 |
271 void DeleteGeneratedKeywordsMatchingHost(const std::wstring& host); | 265 void DeleteGeneratedKeywordsMatchingHost(const std::wstring& host); |
272 | 266 |
273 // If there is a notification service, sends TEMPLATE_URL_MODEL_LOADED | 267 // If there is a notification service, sends TEMPLATE_URL_MODEL_LOADED |
274 // notification. | 268 // notification. |
275 void NotifyLoaded(); | 269 void NotifyLoaded(); |
276 | 270 |
277 // Loads engines from prepopulate data and merges them in with the existing | |
278 // engines. This is invoked when the version of the prepopulate data changes. | |
279 void MergeEnginesFromPrepopulateData(); | |
280 | |
281 // Saves enough of url to preferences so that it can be loaded from | 271 // Saves enough of url to preferences so that it can be loaded from |
282 // preferences on start up. | 272 // preferences on start up. |
283 void SaveDefaultSearchProviderToPrefs(const TemplateURL* url); | 273 void SaveDefaultSearchProviderToPrefs(const TemplateURL* url); |
284 | 274 |
285 // Creates a TemplateURL that was previously saved to prefs via | 275 // Creates a TemplateURL that was previously saved to prefs via |
286 // SaveDefaultSearchProviderToPrefs. Returns true if successful, false | 276 // SaveDefaultSearchProviderToPrefs. Returns true if successful, false |
287 // otherwise. This is used if GetDefaultSearchProvider is invoked before the | 277 // otherwise. This is used if GetDefaultSearchProvider is invoked before the |
288 // TemplateURL has loaded. If the user has opted for no default search, this | 278 // TemplateURL has loaded. If the user has opted for no default search, this |
289 // returns true but default_provider is set to NULL. | 279 // returns true but default_provider is set to NULL. |
290 bool LoadDefaultSearchProviderFromPrefs(TemplateURL** default_provider); | 280 bool LoadDefaultSearchProviderFromPrefs(TemplateURL** default_provider); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // increasing integer that is initialized from the database. | 372 // increasing integer that is initialized from the database. |
383 TemplateURL::IDType next_id_; | 373 TemplateURL::IDType next_id_; |
384 | 374 |
385 // List of extension IDs waiting for Load to have keywords registered. | 375 // List of extension IDs waiting for Load to have keywords registered. |
386 std::vector<std::string> pending_extension_ids_; | 376 std::vector<std::string> pending_extension_ids_; |
387 | 377 |
388 DISALLOW_COPY_AND_ASSIGN(TemplateURLModel); | 378 DISALLOW_COPY_AND_ASSIGN(TemplateURLModel); |
389 }; | 379 }; |
390 | 380 |
391 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_ | 381 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_ |
OLD | NEW |