Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / signin / about_signin_internals_factory.cc
blobbd17a0046d54c76472572d4fd1db9b5a762a44d0
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/signin/about_signin_internals.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/signin/signin_internals_util.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
13 #include "components/user_prefs/pref_registry_syncable.h"
14 #include "google_apis/gaia/gaia_constants.h"
16 using namespace signin_internals_util;
18 AboutSigninInternalsFactory::AboutSigninInternalsFactory()
19 : BrowserContextKeyedServiceFactory(
20 "AboutSigninInternals",
21 BrowserContextDependencyManager::GetInstance()) {
22 DependsOn(SigninManagerFactory::GetInstance());
23 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
26 AboutSigninInternalsFactory::~AboutSigninInternalsFactory() {}
28 // static
29 AboutSigninInternals* AboutSigninInternalsFactory::GetForProfile(
30 Profile* profile) {
31 return static_cast<AboutSigninInternals*>(
32 GetInstance()->GetServiceForBrowserContext(profile, true));
35 // static
36 AboutSigninInternalsFactory* AboutSigninInternalsFactory::GetInstance() {
37 return Singleton<AboutSigninInternalsFactory>::get();
40 void AboutSigninInternalsFactory::RegisterProfilePrefs(
41 user_prefs::PrefRegistrySyncable* user_prefs) {
42 // SigninManager information for about:signin-internals.
43 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) {
44 const std::string pref_path = SigninStatusFieldToString(
45 static_cast<UntimedSigninStatusField>(i));
46 user_prefs->RegisterStringPref(
47 pref_path.c_str(),
48 std::string(),
49 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
51 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) {
52 const std::string value = SigninStatusFieldToString(
53 static_cast<TimedSigninStatusField>(i)) + ".value";
54 const std::string time = SigninStatusFieldToString(
55 static_cast<TimedSigninStatusField>(i)) + ".time";
56 user_prefs->RegisterStringPref(
57 value.c_str(),
58 std::string(),
59 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
60 user_prefs->RegisterStringPref(
61 time.c_str(),
62 std::string(),
63 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
67 BrowserContextKeyedService*
68 AboutSigninInternalsFactory::BuildServiceInstanceFor(
69 content::BrowserContext* profile) const {
70 AboutSigninInternals* service = new AboutSigninInternals();
71 service->Initialize(static_cast<Profile*>(profile));
72 return service;