OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define COMPONENTS_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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 TemplateURLService( | 90 TemplateURLService( |
91 PrefService* prefs, | 91 PrefService* prefs, |
92 scoped_ptr<SearchTermsData> search_terms_data, | 92 scoped_ptr<SearchTermsData> search_terms_data, |
93 const scoped_refptr<KeywordWebDataService>& web_data_service, | 93 const scoped_refptr<KeywordWebDataService>& web_data_service, |
94 scoped_ptr<TemplateURLServiceClient> client, | 94 scoped_ptr<TemplateURLServiceClient> client, |
95 GoogleURLTracker* google_url_tracker, | 95 GoogleURLTracker* google_url_tracker, |
96 rappor::RapporService* rappor_service, | 96 rappor::RapporService* rappor_service, |
97 const base::Closure& dsp_change_callback); | 97 const base::Closure& dsp_change_callback); |
98 // The following is for testing. | 98 // The following is for testing. |
99 TemplateURLService(const Initializer* initializers, const int count); | 99 TemplateURLService(const Initializer* initializers, const int count); |
100 virtual ~TemplateURLService(); | 100 ~TemplateURLService() override; |
101 | 101 |
102 // Creates a TemplateURLData that was previously saved to |prefs| via | 102 // Creates a TemplateURLData that was previously saved to |prefs| via |
103 // SaveDefaultSearchProviderToPrefs or set via policy. | 103 // SaveDefaultSearchProviderToPrefs or set via policy. |
104 // Returns true if successful, false otherwise. | 104 // Returns true if successful, false otherwise. |
105 // If the user or the policy has opted for no default search, this | 105 // If the user or the policy has opted for no default search, this |
106 // returns true but default_provider is set to NULL. | 106 // returns true but default_provider is set to NULL. |
107 // |*is_managed| specifies whether the default is managed via policy. | 107 // |*is_managed| specifies whether the default is managed via policy. |
108 static bool LoadDefaultSearchProviderFromPrefs( | 108 static bool LoadDefaultSearchProviderFromPrefs( |
109 PrefService* prefs, | 109 PrefService* prefs, |
110 scoped_ptr<TemplateURLData>* default_provider_data, | 110 scoped_ptr<TemplateURLData>* default_provider_data, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 #if defined(UNIT_TEST) | 283 #if defined(UNIT_TEST) |
284 void set_loaded(bool value) { loaded_ = value; } | 284 void set_loaded(bool value) { loaded_ = value; } |
285 #endif | 285 #endif |
286 | 286 |
287 // Whether or not the keywords have been loaded. | 287 // Whether or not the keywords have been loaded. |
288 bool loaded() { return loaded_; } | 288 bool loaded() { return loaded_; } |
289 | 289 |
290 // Notification that the keywords have been loaded. | 290 // Notification that the keywords have been loaded. |
291 // This is invoked from WebDataService, and should not be directly | 291 // This is invoked from WebDataService, and should not be directly |
292 // invoked. | 292 // invoked. |
293 virtual void OnWebDataServiceRequestDone( | 293 void OnWebDataServiceRequestDone(KeywordWebDataService::Handle h, |
294 KeywordWebDataService::Handle h, | 294 const WDTypedResult* result) override; |
295 const WDTypedResult* result) override; | |
296 | 295 |
297 // Returns the locale-direction-adjusted short name for the given keyword. | 296 // Returns the locale-direction-adjusted short name for the given keyword. |
298 // Also sets the out param to indicate whether the keyword belongs to an | 297 // Also sets the out param to indicate whether the keyword belongs to an |
299 // Omnibox extension. | 298 // Omnibox extension. |
300 base::string16 GetKeywordShortName(const base::string16& keyword, | 299 base::string16 GetKeywordShortName(const base::string16& keyword, |
301 bool* is_omnibox_api_extension_keyword); | 300 bool* is_omnibox_api_extension_keyword); |
302 | 301 |
303 // Called by the history service when a URL is visited. | 302 // Called by the history service when a URL is visited. |
304 void OnHistoryURLVisited(const URLVisitedDetails& details); | 303 void OnHistoryURLVisited(const URLVisitedDetails& details); |
305 | 304 |
306 // KeyedService implementation. | 305 // KeyedService implementation. |
307 virtual void Shutdown() override; | 306 void Shutdown() override; |
308 | 307 |
309 // syncer::SyncableService implementation. | 308 // syncer::SyncableService implementation. |
310 | 309 |
311 // Returns all syncable TemplateURLs from this model as SyncData. This should | 310 // Returns all syncable TemplateURLs from this model as SyncData. This should |
312 // include every search engine and no Extension keywords. | 311 // include every search engine and no Extension keywords. |
313 virtual syncer::SyncDataList GetAllSyncData( | 312 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
314 syncer::ModelType type) const override; | |
315 // Process new search engine changes from Sync, merging them into our local | 313 // Process new search engine changes from Sync, merging them into our local |
316 // data. This may send notifications if local search engines are added, | 314 // data. This may send notifications if local search engines are added, |
317 // updated or removed. | 315 // updated or removed. |
318 virtual syncer::SyncError ProcessSyncChanges( | 316 syncer::SyncError ProcessSyncChanges( |
319 const tracked_objects::Location& from_here, | 317 const tracked_objects::Location& from_here, |
320 const syncer::SyncChangeList& change_list) override; | 318 const syncer::SyncChangeList& change_list) override; |
321 // Merge initial search engine data from Sync and push any local changes up | 319 // Merge initial search engine data from Sync and push any local changes up |
322 // to Sync. This may send notifications if local search engines are added, | 320 // to Sync. This may send notifications if local search engines are added, |
323 // updated or removed. | 321 // updated or removed. |
324 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 322 syncer::SyncMergeResult MergeDataAndStartSyncing( |
325 syncer::ModelType type, | 323 syncer::ModelType type, |
326 const syncer::SyncDataList& initial_sync_data, | 324 const syncer::SyncDataList& initial_sync_data, |
327 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 325 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
328 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) override; | 326 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) override; |
329 virtual void StopSyncing(syncer::ModelType type) override; | 327 void StopSyncing(syncer::ModelType type) override; |
330 | 328 |
331 // Processes a local TemplateURL change for Sync. |turl| is the TemplateURL | 329 // Processes a local TemplateURL change for Sync. |turl| is the TemplateURL |
332 // that has been modified, and |type| is the Sync ChangeType that took place. | 330 // that has been modified, and |type| is the Sync ChangeType that took place. |
333 // This may send a new SyncChange to the cloud. If our model has not yet been | 331 // This may send a new SyncChange to the cloud. If our model has not yet been |
334 // associated with Sync, or if this is triggered by a Sync change, then this | 332 // associated with Sync, or if this is triggered by a Sync change, then this |
335 // does nothing. | 333 // does nothing. |
336 void ProcessTemplateURLChange(const tracked_objects::Location& from_here, | 334 void ProcessTemplateURLChange(const tracked_objects::Location& from_here, |
337 const TemplateURL* turl, | 335 const TemplateURL* turl, |
338 syncer::SyncChange::SyncChangeType type); | 336 syncer::SyncChange::SyncChangeType type); |
339 | 337 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 740 |
743 // Helper class to manage the default search engine. | 741 // Helper class to manage the default search engine. |
744 DefaultSearchManager default_search_manager_; | 742 DefaultSearchManager default_search_manager_; |
745 | 743 |
746 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; | 744 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; |
747 | 745 |
748 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 746 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
749 }; | 747 }; |
750 | 748 |
751 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 749 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |