[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / chrome / browser / signin / about_signin_internals_factory.cc
blob5d77ec827792fedf9d902961335b2694d37e8c93
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
3 // found in the LICENSE file.
5 #include "chrome/browser/signin/about_signin_internals_factory.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/account_tracker_service_factory.h"
10 #include "chrome/browser/signin/chrome_signin_client_factory.h"
11 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/browser/signin/signin_error_controller_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/common/pref_names.h"
16 #include "components/keyed_service/content/browser_context_dependency_manager.h"
17 #include "components/pref_registry/pref_registry_syncable.h"
18 #include "components/signin/core/browser/about_signin_internals.h"
19 #include "components/signin/core/browser/signin_internals_util.h"
20 #include "components/signin/core/browser/signin_manager.h"
21 #include "google_apis/gaia/gaia_constants.h"
23 using namespace signin_internals_util;
25 AboutSigninInternalsFactory::AboutSigninInternalsFactory()
26 : BrowserContextKeyedServiceFactory(
27 "AboutSigninInternals",
28 BrowserContextDependencyManager::GetInstance()) {
29 DependsOn(AccountTrackerServiceFactory::GetInstance());
30 DependsOn(ChromeSigninClientFactory::GetInstance());
31 DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
32 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
33 DependsOn(SigninErrorControllerFactory::GetInstance());
34 DependsOn(SigninManagerFactory::GetInstance());
37 AboutSigninInternalsFactory::~AboutSigninInternalsFactory() {}
39 // static
40 AboutSigninInternals* AboutSigninInternalsFactory::GetForProfile(
41 Profile* profile) {
42 return static_cast<AboutSigninInternals*>(
43 GetInstance()->GetServiceForBrowserContext(profile, true));
46 // static
47 AboutSigninInternalsFactory* AboutSigninInternalsFactory::GetInstance() {
48 return Singleton<AboutSigninInternalsFactory>::get();
51 void AboutSigninInternalsFactory::RegisterProfilePrefs(
52 user_prefs::PrefRegistrySyncable* user_prefs) {
53 // SigninManager information for about:signin-internals.
55 // TODO(rogerta): leaving untimed fields here for now because legacy
56 // profiles still have these prefs. In three or four version from M43
57 // we can probably remove them.
58 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) {
59 const std::string pref_path = SigninStatusFieldToString(
60 static_cast<UntimedSigninStatusField>(i));
61 user_prefs->RegisterStringPref(pref_path.c_str(), std::string());
64 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) {
65 const std::string value = SigninStatusFieldToString(
66 static_cast<TimedSigninStatusField>(i)) + ".value";
67 const std::string time = SigninStatusFieldToString(
68 static_cast<TimedSigninStatusField>(i)) + ".time";
69 user_prefs->RegisterStringPref(value.c_str(), std::string());
70 user_prefs->RegisterStringPref(time.c_str(), std::string());
74 KeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor(
75 content::BrowserContext* context) const {
76 Profile* profile = Profile::FromBrowserContext(context);
77 AboutSigninInternals* service = new AboutSigninInternals(
78 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
79 AccountTrackerServiceFactory::GetForProfile(profile),
80 SigninManagerFactory::GetForProfile(profile),
81 SigninErrorControllerFactory::GetForProfile(profile),
82 GaiaCookieManagerServiceFactory::GetForProfile(profile));
83 service->Initialize(ChromeSigninClientFactory::GetForProfile(profile));
84 return service;