| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/search_engines/template_url_service_factory.h" | 5 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 10 #include "components/keyed_service/core/service_access_type.h" | 11 #include "components/keyed_service/core/service_access_type.h" |
| 11 #include "components/keyed_service/ios/browser_state_dependency_manager.h" | 12 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
| 12 #include "components/search_engines/default_search_manager.h" | 13 #include "components/search_engines/default_search_manager.h" |
| 13 #include "components/search_engines/template_url_service.h" | 14 #include "components/search_engines/template_url_service.h" |
| 14 #include "ios/chrome/browser/application_context.h" | 15 #include "ios/chrome/browser/application_context.h" |
| 15 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" | 16 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
| 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 17 #include "ios/chrome/browser/google/google_url_tracker_factory.h" | 18 #include "ios/chrome/browser/google/google_url_tracker_factory.h" |
| 18 #include "ios/chrome/browser/history/history_service_factory.h" | 19 #include "ios/chrome/browser/history/history_service_factory.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 base::Closure GetDefaultSearchProviderChangedCallback() { | 31 base::Closure GetDefaultSearchProviderChangedCallback() { |
| 31 #if defined(ENABLE_RLZ) | 32 #if defined(ENABLE_RLZ) |
| 32 return base::Bind(base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), | 33 return base::Bind(base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), |
| 33 rlz_lib::CHROME, rlz::RLZTracker::ChromeOmnibox(), | 34 rlz_lib::CHROME, rlz::RLZTracker::ChromeOmnibox(), |
| 34 rlz_lib::SET_TO_GOOGLE); | 35 rlz_lib::SET_TO_GOOGLE); |
| 35 #else | 36 #else |
| 36 return base::Closure(); | 37 return base::Closure(); |
| 37 #endif | 38 #endif |
| 38 } | 39 } |
| 39 | 40 |
| 40 scoped_ptr<KeyedService> BuildTemplateURLService(web::BrowserState* context) { | 41 std::unique_ptr<KeyedService> BuildTemplateURLService( |
| 42 web::BrowserState* context) { |
| 41 ios::ChromeBrowserState* browser_state = | 43 ios::ChromeBrowserState* browser_state = |
| 42 ios::ChromeBrowserState::FromBrowserState(context); | 44 ios::ChromeBrowserState::FromBrowserState(context); |
| 43 return make_scoped_ptr(new TemplateURLService( | 45 return base::WrapUnique(new TemplateURLService( |
| 44 browser_state->GetPrefs(), | 46 browser_state->GetPrefs(), |
| 45 make_scoped_ptr(new ios::UIThreadSearchTermsData(browser_state)), | 47 base::WrapUnique(new ios::UIThreadSearchTermsData(browser_state)), |
| 46 ios::WebDataServiceFactory::GetKeywordWebDataForBrowserState( | 48 ios::WebDataServiceFactory::GetKeywordWebDataForBrowserState( |
| 47 browser_state, ServiceAccessType::EXPLICIT_ACCESS), | 49 browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
| 48 make_scoped_ptr(new ios::TemplateURLServiceClientImpl( | 50 base::WrapUnique(new ios::TemplateURLServiceClientImpl( |
| 49 ios::HistoryServiceFactory::GetForBrowserState( | 51 ios::HistoryServiceFactory::GetForBrowserState( |
| 50 browser_state, ServiceAccessType::EXPLICIT_ACCESS))), | 52 browser_state, ServiceAccessType::EXPLICIT_ACCESS))), |
| 51 ios::GoogleURLTrackerFactory::GetForBrowserState(browser_state), | 53 ios::GoogleURLTrackerFactory::GetForBrowserState(browser_state), |
| 52 GetApplicationContext()->GetRapporService(), | 54 GetApplicationContext()->GetRapporService(), |
| 53 GetDefaultSearchProviderChangedCallback())); | 55 GetDefaultSearchProviderChangedCallback())); |
| 54 } | 56 } |
| 55 | 57 |
| 56 } // namespace | 58 } // namespace |
| 57 | 59 |
| 58 // static | 60 // static |
| (...skipping 24 matching lines...) Expand all Loading... |
| 83 } | 85 } |
| 84 | 86 |
| 85 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} | 87 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} |
| 86 | 88 |
| 87 void TemplateURLServiceFactory::RegisterBrowserStatePrefs( | 89 void TemplateURLServiceFactory::RegisterBrowserStatePrefs( |
| 88 user_prefs::PrefRegistrySyncable* registry) { | 90 user_prefs::PrefRegistrySyncable* registry) { |
| 89 DefaultSearchManager::RegisterProfilePrefs(registry); | 91 DefaultSearchManager::RegisterProfilePrefs(registry); |
| 90 TemplateURLService::RegisterProfilePrefs(registry); | 92 TemplateURLService::RegisterProfilePrefs(registry); |
| 91 } | 93 } |
| 92 | 94 |
| 93 scoped_ptr<KeyedService> TemplateURLServiceFactory::BuildServiceInstanceFor( | 95 std::unique_ptr<KeyedService> |
| 96 TemplateURLServiceFactory::BuildServiceInstanceFor( |
| 94 web::BrowserState* context) const { | 97 web::BrowserState* context) const { |
| 95 return BuildTemplateURLService(context); | 98 return BuildTemplateURLService(context); |
| 96 } | 99 } |
| 97 | 100 |
| 98 web::BrowserState* TemplateURLServiceFactory::GetBrowserStateToUse( | 101 web::BrowserState* TemplateURLServiceFactory::GetBrowserStateToUse( |
| 99 web::BrowserState* context) const { | 102 web::BrowserState* context) const { |
| 100 return GetBrowserStateRedirectedInIncognito(context); | 103 return GetBrowserStateRedirectedInIncognito(context); |
| 101 } | 104 } |
| 102 | 105 |
| 103 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 106 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 104 return true; | 107 return true; |
| 105 } | 108 } |
| 106 | 109 |
| 107 } // namespace ios | 110 } // namespace ios |
| OLD | NEW |