| 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 "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/google/google_url_tracker_factory.h" | 8 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} | 42 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} |
| 43 | 43 |
| 44 ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( | 44 ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* profile) const { | 45 content::BrowserContext* profile) const { |
| 46 return BuildInstanceFor(static_cast<Profile*>(profile)); | 46 return BuildInstanceFor(static_cast<Profile*>(profile)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TemplateURLServiceFactory::RegisterUserPrefs( | 49 void TemplateURLServiceFactory::RegisterUserPrefs( |
| 50 PrefRegistrySyncable* registry) { | 50 user_prefs::PrefRegistrySyncable* registry) { |
| 51 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, | 51 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, |
| 52 std::string(), | 52 std::string(), |
| 53 PrefRegistrySyncable::SYNCABLE_PREF); | 53 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 54 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, | 54 registry->RegisterBooleanPref( |
| 55 true, | 55 prefs::kDefaultSearchProviderEnabled, |
| 56 PrefRegistrySyncable::UNSYNCABLE_PREF); | 56 true, |
| 57 registry->RegisterStringPref(prefs::kDefaultSearchProviderName, | 57 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 58 std::string(), | 58 registry->RegisterStringPref( |
| 59 PrefRegistrySyncable::UNSYNCABLE_PREF); | 59 prefs::kDefaultSearchProviderName, |
| 60 registry->RegisterStringPref(prefs::kDefaultSearchProviderID, | 60 std::string(), |
| 61 std::string(), | 61 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 62 PrefRegistrySyncable::UNSYNCABLE_PREF); | 62 registry->RegisterStringPref( |
| 63 registry->RegisterStringPref(prefs::kDefaultSearchProviderPrepopulateID, | 63 prefs::kDefaultSearchProviderID, |
| 64 std::string(), | 64 std::string(), |
| 65 PrefRegistrySyncable::UNSYNCABLE_PREF); | 65 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 66 registry->RegisterStringPref(prefs::kDefaultSearchProviderSuggestURL, | 66 registry->RegisterStringPref( |
| 67 std::string(), | 67 prefs::kDefaultSearchProviderPrepopulateID, |
| 68 PrefRegistrySyncable::UNSYNCABLE_PREF); | 68 std::string(), |
| 69 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURL, | 69 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 70 std::string(), | 70 registry->RegisterStringPref( |
| 71 PrefRegistrySyncable::UNSYNCABLE_PREF); | 71 prefs::kDefaultSearchProviderSuggestURL, |
| 72 registry->RegisterStringPref(prefs::kDefaultSearchProviderInstantURL, | 72 std::string(), |
| 73 std::string(), | 73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 74 PrefRegistrySyncable::UNSYNCABLE_PREF); | 74 registry->RegisterStringPref( |
| 75 registry->RegisterStringPref(prefs::kDefaultSearchProviderKeyword, | 75 prefs::kDefaultSearchProviderSearchURL, |
| 76 std::string(), | 76 std::string(), |
| 77 PrefRegistrySyncable::UNSYNCABLE_PREF); | 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 78 registry->RegisterStringPref(prefs::kDefaultSearchProviderIconURL, | 78 registry->RegisterStringPref( |
| 79 std::string(), | 79 prefs::kDefaultSearchProviderInstantURL, |
| 80 PrefRegistrySyncable::UNSYNCABLE_PREF); | 80 std::string(), |
| 81 registry->RegisterStringPref(prefs::kDefaultSearchProviderEncodings, | 81 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 82 std::string(), | 82 registry->RegisterStringPref( |
| 83 PrefRegistrySyncable::UNSYNCABLE_PREF); | 83 prefs::kDefaultSearchProviderKeyword, |
| 84 std::string(), |
| 85 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 86 registry->RegisterStringPref( |
| 87 prefs::kDefaultSearchProviderIconURL, |
| 88 std::string(), |
| 89 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 90 registry->RegisterStringPref( |
| 91 prefs::kDefaultSearchProviderEncodings, |
| 92 std::string(), |
| 93 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 84 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, | 94 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, |
| 85 PrefRegistrySyncable::UNSYNCABLE_PREF); | 95 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 86 registry->RegisterStringPref( | 96 registry->RegisterStringPref( |
| 87 prefs::kDefaultSearchProviderSearchTermsReplacementKey, | 97 prefs::kDefaultSearchProviderSearchTermsReplacementKey, |
| 88 std::string(), | 98 std::string(), |
| 89 PrefRegistrySyncable::UNSYNCABLE_PREF); | 99 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 90 } | 100 } |
| 91 | 101 |
| 92 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 102 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 93 content::BrowserContext* context) const { | 103 content::BrowserContext* context) const { |
| 94 return chrome::GetBrowserContextRedirectedInIncognito(context); | 104 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 95 } | 105 } |
| 96 | 106 |
| 97 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 107 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 98 return true; | 108 return true; |
| 99 } | 109 } |
| 100 | 110 |
| 101 void TemplateURLServiceFactory::ProfileShutdown( | 111 void TemplateURLServiceFactory::ProfileShutdown( |
| 102 content::BrowserContext* profile) { | 112 content::BrowserContext* profile) { |
| 103 // We shutdown AND destroy the TemplateURLService during this pass. | 113 // We shutdown AND destroy the TemplateURLService during this pass. |
| 104 // TemplateURLService schedules a task on the WebDataService from its | 114 // TemplateURLService schedules a task on the WebDataService from its |
| 105 // destructor. Delete it first to ensure the task gets scheduled before we | 115 // destructor. Delete it first to ensure the task gets scheduled before we |
| 106 // shut down the database. | 116 // shut down the database. |
| 107 ProfileKeyedServiceFactory::ProfileShutdown(profile); | 117 ProfileKeyedServiceFactory::ProfileShutdown(profile); |
| 108 ProfileKeyedServiceFactory::ProfileDestroyed(profile); | 118 ProfileKeyedServiceFactory::ProfileDestroyed(profile); |
| 109 } | 119 } |
| 110 | 120 |
| 111 void TemplateURLServiceFactory::ProfileDestroyed( | 121 void TemplateURLServiceFactory::ProfileDestroyed( |
| 112 content::BrowserContext* profile) { | 122 content::BrowserContext* profile) { |
| 113 // Don't double delete. | 123 // Don't double delete. |
| 114 } | 124 } |
| OLD | NEW |