| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, | 95 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, |
| 96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 97 registry->RegisterStringPref( | 97 registry->RegisterStringPref( |
| 98 prefs::kDefaultSearchProviderSearchTermsReplacementKey, | 98 prefs::kDefaultSearchProviderSearchTermsReplacementKey, |
| 99 std::string(), | 99 std::string(), |
| 100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 101 } | 101 } |
| 102 | 102 |
| 103 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 103 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 104 content::BrowserContext* context) const { | 104 content::BrowserContext* context) const { |
| 105 // TODO(dougw): We need a separate instance of TemplateURLService in | 105 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 106 // incognito profiles so that search-term-replacement can be disabled in | |
| 107 // incognito (see crbug.com/232065). Switch back to a shared instance once | |
| 108 // this is no longer necessary. | |
| 109 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
| 110 } | 106 } |
| 111 | 107 |
| 112 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 108 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 113 return true; | 109 return true; |
| 114 } | 110 } |
| 115 | 111 |
| 116 void TemplateURLServiceFactory::BrowserContextShutdown( | 112 void TemplateURLServiceFactory::BrowserContextShutdown( |
| 117 content::BrowserContext* profile) { | 113 content::BrowserContext* profile) { |
| 118 // We shutdown AND destroy the TemplateURLService during this pass. | 114 // We shutdown AND destroy the TemplateURLService during this pass. |
| 119 // TemplateURLService schedules a task on the WebDataService from its | 115 // TemplateURLService schedules a task on the WebDataService from its |
| 120 // destructor. Delete it first to ensure the task gets scheduled before we | 116 // destructor. Delete it first to ensure the task gets scheduled before we |
| 121 // shut down the database. | 117 // shut down the database. |
| 122 BrowserContextKeyedServiceFactory::BrowserContextShutdown(profile); | 118 BrowserContextKeyedServiceFactory::BrowserContextShutdown(profile); |
| 123 BrowserContextKeyedServiceFactory::BrowserContextDestroyed(profile); | 119 BrowserContextKeyedServiceFactory::BrowserContextDestroyed(profile); |
| 124 } | 120 } |
| 125 | 121 |
| 126 void TemplateURLServiceFactory::BrowserContextDestroyed( | 122 void TemplateURLServiceFactory::BrowserContextDestroyed( |
| 127 content::BrowserContext* profile) { | 123 content::BrowserContext* profile) { |
| 128 // Don't double delete. | 124 // Don't double delete. |
| 129 } | 125 } |
| OLD | NEW |