| 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 #include "chrome/browser/search_engines/template_url_service_factory.h" | 5 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/google/google_url_tracker_factory.h" | 7 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 8 #include "chrome/browser/history/history_service_factory.h" | 8 #include "chrome/browser/history/history_service_factory.h" |
| 9 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile_dependency_manager.h" | 11 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 11 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
| 12 #include "chrome/browser/webdata/web_data_service_factory.h" | 13 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 | 15 |
| 15 // static | 16 // static |
| 16 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { | 17 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { |
| 17 return static_cast<TemplateURLService*>( | 18 return static_cast<TemplateURLService*>( |
| 18 GetInstance()->GetServiceForProfile(profile, true)); | 19 GetInstance()->GetServiceForProfile(profile, true)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 DependsOn(WebDataServiceFactory::GetInstance()); | 38 DependsOn(WebDataServiceFactory::GetInstance()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} | 41 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} |
| 41 | 42 |
| 42 ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( | 43 ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( |
| 43 Profile* profile) const { | 44 Profile* profile) const { |
| 44 return BuildInstanceFor(profile); | 45 return BuildInstanceFor(profile); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void TemplateURLServiceFactory::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 48 void TemplateURLServiceFactory::RegisterUserPrefs( |
| 48 prefs->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, | 49 PrefRegistrySyncable* registry) { |
| 49 std::string(), | 50 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, |
| 50 PrefServiceSyncable::SYNCABLE_PREF); | 51 std::string(), |
| 51 prefs->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, | 52 PrefRegistrySyncable::SYNCABLE_PREF); |
| 52 true, | 53 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, |
| 53 PrefServiceSyncable::UNSYNCABLE_PREF); | 54 true, |
| 54 prefs->RegisterStringPref(prefs::kDefaultSearchProviderName, | 55 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 55 std::string(), | 56 registry->RegisterStringPref(prefs::kDefaultSearchProviderName, |
| 56 PrefServiceSyncable::UNSYNCABLE_PREF); | 57 std::string(), |
| 57 prefs->RegisterStringPref(prefs::kDefaultSearchProviderID, | 58 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 58 std::string(), | 59 registry->RegisterStringPref(prefs::kDefaultSearchProviderID, |
| 59 PrefServiceSyncable::UNSYNCABLE_PREF); | 60 std::string(), |
| 60 prefs->RegisterStringPref(prefs::kDefaultSearchProviderPrepopulateID, | 61 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 61 std::string(), | 62 registry->RegisterStringPref(prefs::kDefaultSearchProviderPrepopulateID, |
| 62 PrefServiceSyncable::UNSYNCABLE_PREF); | 63 std::string(), |
| 63 prefs->RegisterStringPref(prefs::kDefaultSearchProviderSuggestURL, | 64 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 64 std::string(), | 65 registry->RegisterStringPref(prefs::kDefaultSearchProviderSuggestURL, |
| 65 PrefServiceSyncable::UNSYNCABLE_PREF); | 66 std::string(), |
| 66 prefs->RegisterStringPref(prefs::kDefaultSearchProviderSearchURL, | 67 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 67 std::string(), | 68 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURL, |
| 68 PrefServiceSyncable::UNSYNCABLE_PREF); | 69 std::string(), |
| 69 prefs->RegisterStringPref(prefs::kDefaultSearchProviderInstantURL, | 70 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 70 std::string(), | 71 registry->RegisterStringPref(prefs::kDefaultSearchProviderInstantURL, |
| 71 PrefServiceSyncable::UNSYNCABLE_PREF); | 72 std::string(), |
| 72 prefs->RegisterStringPref(prefs::kDefaultSearchProviderKeyword, | 73 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 73 std::string(), | 74 registry->RegisterStringPref(prefs::kDefaultSearchProviderKeyword, |
| 74 PrefServiceSyncable::UNSYNCABLE_PREF); | 75 std::string(), |
| 75 prefs->RegisterStringPref(prefs::kDefaultSearchProviderIconURL, | 76 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 76 std::string(), | 77 registry->RegisterStringPref(prefs::kDefaultSearchProviderIconURL, |
| 77 PrefServiceSyncable::UNSYNCABLE_PREF); | 78 std::string(), |
| 78 prefs->RegisterStringPref(prefs::kDefaultSearchProviderEncodings, | 79 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 79 std::string(), | 80 registry->RegisterStringPref(prefs::kDefaultSearchProviderEncodings, |
| 80 PrefServiceSyncable::UNSYNCABLE_PREF); | 81 std::string(), |
| 81 prefs->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, | 82 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 82 PrefServiceSyncable::UNSYNCABLE_PREF); | 83 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, |
| 83 prefs->RegisterStringPref( | 84 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 85 registry->RegisterStringPref( |
| 84 prefs::kDefaultSearchProviderSearchTermsReplacementKey, | 86 prefs::kDefaultSearchProviderSearchTermsReplacementKey, |
| 85 std::string(), | 87 std::string(), |
| 86 PrefServiceSyncable::UNSYNCABLE_PREF); | 88 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 87 } | 89 } |
| 88 | 90 |
| 89 bool TemplateURLServiceFactory::ServiceRedirectedInIncognito() const { | 91 bool TemplateURLServiceFactory::ServiceRedirectedInIncognito() const { |
| 90 return true; | 92 return true; |
| 91 } | 93 } |
| 92 | 94 |
| 93 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 95 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 94 return true; | 96 return true; |
| 95 } | 97 } |
| 96 | 98 |
| 97 void TemplateURLServiceFactory::ProfileShutdown(Profile* profile) { | 99 void TemplateURLServiceFactory::ProfileShutdown(Profile* profile) { |
| 98 // We shutdown AND destroy the TemplateURLService during this pass. | 100 // We shutdown AND destroy the TemplateURLService during this pass. |
| 99 // TemplateURLService schedules a task on the WebDataService from its | 101 // TemplateURLService schedules a task on the WebDataService from its |
| 100 // destructor. Delete it first to ensure the task gets scheduled before we | 102 // destructor. Delete it first to ensure the task gets scheduled before we |
| 101 // shut down the database. | 103 // shut down the database. |
| 102 ProfileKeyedServiceFactory::ProfileShutdown(profile); | 104 ProfileKeyedServiceFactory::ProfileShutdown(profile); |
| 103 ProfileKeyedServiceFactory::ProfileDestroyed(profile); | 105 ProfileKeyedServiceFactory::ProfileDestroyed(profile); |
| 104 } | 106 } |
| 105 | 107 |
| 106 void TemplateURLServiceFactory::ProfileDestroyed(Profile* profile) { | 108 void TemplateURLServiceFactory::ProfileDestroyed(Profile* profile) { |
| 107 // Don't double delete. | 109 // Don't double delete. |
| 108 } | 110 } |
| OLD | NEW |