| OLD | NEW |
| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/prefs/public/pref_change_registrar.h" | 17 #include "base/prefs/public/pref_change_registrar.h" |
| 18 #include "base/prefs/public/pref_observer.h" |
| 18 #include "chrome/browser/profiles/profile_keyed_service.h" | 19 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 19 #include "chrome/browser/search_engines/template_url_id.h" | 20 #include "chrome/browser/search_engines/template_url_id.h" |
| 20 #include "chrome/browser/webdata/web_data_service.h" | 21 #include "chrome/browser/webdata/web_data_service.h" |
| 21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 23 #include "sync/api/sync_change.h" | 24 #include "sync/api/sync_change.h" |
| 24 #include "sync/api/syncable_service.h" | 25 #include "sync/api/syncable_service.h" |
| 25 | 26 |
| 26 class GURL; | 27 class GURL; |
| 27 class PrefService; | 28 class PrefService; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // OnTemplateURLServiceChanged as well as the TEMPLATE_URL_SERVICE_LOADED | 61 // OnTemplateURLServiceChanged as well as the TEMPLATE_URL_SERVICE_LOADED |
| 61 // notification message. | 62 // notification message. |
| 62 // | 63 // |
| 63 // TemplateURLService takes ownership of any TemplateURL passed to it. If there | 64 // TemplateURLService takes ownership of any TemplateURL passed to it. If there |
| 64 // is a WebDataService, deletion is handled by WebDataService, otherwise | 65 // is a WebDataService, deletion is handled by WebDataService, otherwise |
| 65 // TemplateURLService handles deletion. | 66 // TemplateURLService handles deletion. |
| 66 | 67 |
| 67 class TemplateURLService : public WebDataServiceConsumer, | 68 class TemplateURLService : public WebDataServiceConsumer, |
| 68 public ProfileKeyedService, | 69 public ProfileKeyedService, |
| 69 public content::NotificationObserver, | 70 public content::NotificationObserver, |
| 71 public PrefObserver, |
| 70 public syncer::SyncableService { | 72 public syncer::SyncableService { |
| 71 public: | 73 public: |
| 72 typedef std::map<std::string, std::string> QueryTerms; | 74 typedef std::map<std::string, std::string> QueryTerms; |
| 73 typedef std::vector<TemplateURL*> TemplateURLVector; | 75 typedef std::vector<TemplateURL*> TemplateURLVector; |
| 74 // Type for a static function pointer that acts as a time source. | 76 // Type for a static function pointer that acts as a time source. |
| 75 typedef base::Time(TimeProvider)(); | 77 typedef base::Time(TimeProvider)(); |
| 76 typedef std::map<std::string, syncer::SyncData> SyncDataMap; | 78 typedef std::map<std::string, syncer::SyncData> SyncDataMap; |
| 77 | 79 |
| 78 // Struct used for initializing the data store with fake data. | 80 // Struct used for initializing the data store with fake data. |
| 79 // Each initializer is mapped to a TemplateURL. | 81 // Each initializer is mapped to a TemplateURL. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Returns the locale-direction-adjusted short name for the given keyword. | 259 // Returns the locale-direction-adjusted short name for the given keyword. |
| 258 // Also sets the out param to indicate whether the keyword belongs to an | 260 // Also sets the out param to indicate whether the keyword belongs to an |
| 259 // extension. | 261 // extension. |
| 260 string16 GetKeywordShortName(const string16& keyword, | 262 string16 GetKeywordShortName(const string16& keyword, |
| 261 bool* is_extension_keyword); | 263 bool* is_extension_keyword); |
| 262 | 264 |
| 263 virtual void Observe(int type, | 265 virtual void Observe(int type, |
| 264 const content::NotificationSource& source, | 266 const content::NotificationSource& source, |
| 265 const content::NotificationDetails& details) OVERRIDE; | 267 const content::NotificationDetails& details) OVERRIDE; |
| 266 | 268 |
| 269 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 270 const std::string& pref_name) OVERRIDE; |
| 271 |
| 267 // syncer::SyncableService implementation. | 272 // syncer::SyncableService implementation. |
| 268 | 273 |
| 269 // Returns all syncable TemplateURLs from this model as SyncData. This should | 274 // Returns all syncable TemplateURLs from this model as SyncData. This should |
| 270 // include every search engine and no Extension keywords. | 275 // include every search engine and no Extension keywords. |
| 271 virtual syncer::SyncDataList GetAllSyncData( | 276 virtual syncer::SyncDataList GetAllSyncData( |
| 272 syncer::ModelType type) const OVERRIDE; | 277 syncer::ModelType type) const OVERRIDE; |
| 273 // Process new search engine changes from Sync, merging them into our local | 278 // Process new search engine changes from Sync, merging them into our local |
| 274 // data. This may send notifications if local search engines are added, | 279 // data. This may send notifications if local search engines are added, |
| 275 // updated or removed. | 280 // updated or removed. |
| 276 virtual syncer::SyncError ProcessSyncChanges( | 281 virtual syncer::SyncError ProcessSyncChanges( |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 676 |
| 672 // This is used to log the origin of changes to the default search provider. | 677 // This is used to log the origin of changes to the default search provider. |
| 673 // We set this value to increasingly specific values when we know what is the | 678 // We set this value to increasingly specific values when we know what is the |
| 674 // cause/origin of a default search change. | 679 // cause/origin of a default search change. |
| 675 DefaultSearchChangeOrigin dsp_change_origin_; | 680 DefaultSearchChangeOrigin dsp_change_origin_; |
| 676 | 681 |
| 677 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 682 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 678 }; | 683 }; |
| 679 | 684 |
| 680 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 685 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |