1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/signin/about_signin_internals.h"
#include "chrome/browser/signin/signin_internals_util.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "google_apis/gaia/gaia_constants.h"
using namespace signin_internals_util;
AboutSigninInternalsFactory::AboutSigninInternalsFactory()
: BrowserContextKeyedServiceFactory(
"AboutSigninInternals",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(TokenServiceFactory::GetInstance());
}
AboutSigninInternalsFactory::~AboutSigninInternalsFactory() {}
// static
AboutSigninInternals* AboutSigninInternalsFactory::GetForProfile(
Profile* profile) {
return static_cast<AboutSigninInternals*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
AboutSigninInternalsFactory* AboutSigninInternalsFactory::GetInstance() {
return Singleton<AboutSigninInternalsFactory>::get();
}
void AboutSigninInternalsFactory::RegisterUserPrefs(
user_prefs::PrefRegistrySyncable* user_prefs) {
// SigninManager information for about:signin-internals.
for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) {
const std::string pref_path = SigninStatusFieldToString(
static_cast<UntimedSigninStatusField>(i));
user_prefs->RegisterStringPref(
pref_path.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) {
const std::string value = SigninStatusFieldToString(
static_cast<TimedSigninStatusField>(i)) + ".value";
const std::string time = SigninStatusFieldToString(
static_cast<TimedSigninStatusField>(i)) + ".time";
user_prefs->RegisterStringPref(
value.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
user_prefs->RegisterStringPref(
time.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// TokenService information for about:signin-internals.
for (size_t i = 0; i < kNumTokenPrefs; i++) {
const std::string pref = TokenPrefPath(kTokenPrefsArray[i]);
const std::string value = pref + ".value";
const std::string status = pref + ".status";
const std::string time = pref + ".time";
const std::string time_internal = pref + ".time_internal";
user_prefs->RegisterStringPref(
value.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
user_prefs->RegisterStringPref(
status.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
user_prefs->RegisterStringPref(
time.c_str(),
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
user_prefs->RegisterInt64Pref(
time_internal.c_str(),
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
}
BrowserContextKeyedService*
AboutSigninInternalsFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
AboutSigninInternals* service = new AboutSigninInternals();
service->Initialize(static_cast<Profile*>(profile));
return service;
}
|