Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / chrome / browser / signin / account_consistency_service_factory.mm
blob699e752ca2f4e78847366bf69d3bbb39523185b4
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
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/signin/account_consistency_service_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/signin/ios/browser/account_consistency_service.h"
10 #include "ios/chrome/browser/content_settings/cookie_settings_factory.h"
11 #include "ios/chrome/browser/experimental_flags.h"
12 #include "ios/chrome/browser/signin/gaia_cookie_manager_service_factory.h"
13 #include "ios/chrome/browser/signin/signin_client_factory.h"
14 #include "ios/chrome/browser/signin/signin_manager_factory.h"
15 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
17 namespace ios {
19 AccountConsistencyServiceFactory::AccountConsistencyServiceFactory()
20     : BrowserStateKeyedServiceFactory(
21           "AccountConsistencyService",
22           BrowserStateDependencyManager::GetInstance()) {
23   DependsOn(ios::CookieSettingsFactory::GetInstance());
24   DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
25   DependsOn(SigninClientFactory::GetInstance());
26   DependsOn(ios::SigninManagerFactory::GetInstance());
29 AccountConsistencyServiceFactory::~AccountConsistencyServiceFactory() {}
31 // static
32 AccountConsistencyService* AccountConsistencyServiceFactory::GetForBrowserState(
33     ios::ChromeBrowserState* browser_state) {
34   if (!experimental_flags::IsWKWebViewEnabled()) {
35     return nullptr;
36   }
37   return static_cast<AccountConsistencyService*>(
38       GetInstance()->GetServiceForBrowserState(browser_state, true));
41 // static
42 AccountConsistencyServiceFactory*
43 AccountConsistencyServiceFactory::GetInstance() {
44   return Singleton<AccountConsistencyServiceFactory>::get();
47 void AccountConsistencyServiceFactory::RegisterBrowserStatePrefs(
48     user_prefs::PrefRegistrySyncable* registry) {
49   AccountConsistencyService::RegisterPrefs(registry);
52 scoped_ptr<KeyedService>
53 AccountConsistencyServiceFactory::BuildServiceInstanceFor(
54     web::BrowserState* context) const {
55   ios::ChromeBrowserState* chrome_browser_state =
56       ios::ChromeBrowserState::FromBrowserState(context);
57   return make_scoped_ptr(new AccountConsistencyService(
58       chrome_browser_state,
59       ios::CookieSettingsFactory::GetForBrowserState(chrome_browser_state),
60       GaiaCookieManagerServiceFactory::GetForBrowserState(chrome_browser_state),
61       SigninClientFactory::GetForBrowserState(chrome_browser_state),
62       ios::SigninManagerFactory::GetForBrowserState(chrome_browser_state)));
65 bool AccountConsistencyServiceFactory::ServiceIsCreatedWithBrowserState()
66     const {
67   return true;
70 }  // namespace ios