| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/google/google_url_tracker_factory.h" | 13 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 14 #include "chrome/browser/history/history_service_factory.h" | 14 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/profiles/incognito_helpers.h" | 15 #include "chrome/browser/profiles/incognito_helpers.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 17 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
| 18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 19 #include "chrome/browser/web_data_service_factory.h" | 19 #include "chrome/browser/web_data_service_factory.h" |
| 20 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 20 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 21 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 22 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 23 #include "components/search_engines/default_search_manager.h" | 23 #include "components/search_engines/default_search_manager.h" |
| 24 #include "components/search_engines/search_engines_pref_names.h" | 24 #include "components/search_engines/search_engines_pref_names.h" |
| 25 #include "components/search_engines/template_url_service.h" | 25 #include "components/search_engines/template_url_service.h" |
| 26 #include "extensions/browser/extension_pref_value_map_factory.h" |
| 26 #include "rlz/features/features.h" | 27 #include "rlz/features/features.h" |
| 27 | 28 |
| 28 #if BUILDFLAG(ENABLE_RLZ) | 29 #if BUILDFLAG(ENABLE_RLZ) |
| 29 #include "components/rlz/rlz_tracker.h" | 30 #include "components/rlz/rlz_tracker.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 // static | 33 // static |
| 33 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { | 34 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { |
| 34 return static_cast<TemplateURLService*>( | 35 return static_cast<TemplateURLService*>( |
| 35 GetInstance()->GetServiceForBrowserContext(profile, true)); | 36 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 #endif | 52 #endif |
| 52 Profile* profile = static_cast<Profile*>(context); | 53 Profile* profile = static_cast<Profile*>(context); |
| 53 return base::MakeUnique<TemplateURLService>( | 54 return base::MakeUnique<TemplateURLService>( |
| 54 profile->GetPrefs(), | 55 profile->GetPrefs(), |
| 55 std::unique_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), | 56 std::unique_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), |
| 56 WebDataServiceFactory::GetKeywordWebDataForProfile( | 57 WebDataServiceFactory::GetKeywordWebDataForProfile( |
| 57 profile, ServiceAccessType::EXPLICIT_ACCESS), | 58 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 58 std::unique_ptr<TemplateURLServiceClient>( | 59 std::unique_ptr<TemplateURLServiceClient>( |
| 59 new ChromeTemplateURLServiceClient( | 60 new ChromeTemplateURLServiceClient( |
| 60 HistoryServiceFactory::GetForProfile( | 61 HistoryServiceFactory::GetForProfile( |
| 61 profile, ServiceAccessType::EXPLICIT_ACCESS))), | 62 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 63 ExtensionPrefValueMapFactory::GetForBrowserContext(context))), |
| 62 GoogleURLTrackerFactory::GetForProfile(profile), | 64 GoogleURLTrackerFactory::GetForProfile(profile), |
| 63 g_browser_process->rappor_service(), dsp_change_callback); | 65 g_browser_process->rappor_service(), dsp_change_callback); |
| 64 } | 66 } |
| 65 | 67 |
| 66 TemplateURLServiceFactory::TemplateURLServiceFactory() | 68 TemplateURLServiceFactory::TemplateURLServiceFactory() |
| 67 : BrowserContextKeyedServiceFactory( | 69 : BrowserContextKeyedServiceFactory( |
| 68 "TemplateURLServiceFactory", | 70 "TemplateURLServiceFactory", |
| 69 BrowserContextDependencyManager::GetInstance()) { | 71 BrowserContextDependencyManager::GetInstance()) { |
| 70 DependsOn(GoogleURLTrackerFactory::GetInstance()); | 72 DependsOn(GoogleURLTrackerFactory::GetInstance()); |
| 71 DependsOn(HistoryServiceFactory::GetInstance()); | 73 DependsOn(HistoryServiceFactory::GetInstance()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 86 } | 88 } |
| 87 | 89 |
| 88 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 90 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 89 content::BrowserContext* context) const { | 91 content::BrowserContext* context) const { |
| 90 return chrome::GetBrowserContextRedirectedInIncognito(context); | 92 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 91 } | 93 } |
| 92 | 94 |
| 93 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 95 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 94 return true; | 96 return true; |
| 95 } | 97 } |
| OLD | NEW |