| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/signin/about_signin_internals_factory.h" | 5 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 7 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile_dependency_manager.h" | 9 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 9 #include "chrome/browser/signin/about_signin_internals.h" | 10 #include "chrome/browser/signin/about_signin_internals.h" |
| 10 #include "chrome/browser/signin/signin_internals_util.h" | 11 #include "chrome/browser/signin/signin_internals_util.h" |
| 11 #include "chrome/browser/signin/token_service_factory.h" | 12 #include "chrome/browser/signin/token_service_factory.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "google_apis/gaia/gaia_constants.h" | 14 #include "google_apis/gaia/gaia_constants.h" |
| 14 | 15 |
| 15 using namespace signin_internals_util; | 16 using namespace signin_internals_util; |
| 16 | 17 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 return static_cast<AboutSigninInternals*>( | 30 return static_cast<AboutSigninInternals*>( |
| 30 GetInstance()->GetServiceForProfile(profile, true)); | 31 GetInstance()->GetServiceForProfile(profile, true)); |
| 31 } | 32 } |
| 32 | 33 |
| 33 // static | 34 // static |
| 34 AboutSigninInternalsFactory* AboutSigninInternalsFactory::GetInstance() { | 35 AboutSigninInternalsFactory* AboutSigninInternalsFactory::GetInstance() { |
| 35 return Singleton<AboutSigninInternalsFactory>::get(); | 36 return Singleton<AboutSigninInternalsFactory>::get(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void AboutSigninInternalsFactory::RegisterUserPrefs( | 39 void AboutSigninInternalsFactory::RegisterUserPrefs( |
| 39 PrefServiceSyncable* user_prefs) { | 40 PrefRegistrySyncable* user_prefs) { |
| 40 // SigninManager information for about:signin-internals. | 41 // SigninManager information for about:signin-internals. |
| 41 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) { | 42 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) { |
| 42 const std::string pref_path = SigninStatusFieldToString( | 43 const std::string pref_path = SigninStatusFieldToString( |
| 43 static_cast<UntimedSigninStatusField>(i)); | 44 static_cast<UntimedSigninStatusField>(i)); |
| 44 user_prefs->RegisterStringPref(pref_path.c_str(), "", | 45 user_prefs->RegisterStringPref(pref_path.c_str(), "", |
| 45 PrefServiceSyncable::UNSYNCABLE_PREF); | 46 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 46 } | 47 } |
| 47 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { | 48 for (int i = TIMED_FIELDS_BEGIN; i < TIMED_FIELDS_END; ++i) { |
| 48 const std::string value = SigninStatusFieldToString( | 49 const std::string value = SigninStatusFieldToString( |
| 49 static_cast<TimedSigninStatusField>(i)) + ".value"; | 50 static_cast<TimedSigninStatusField>(i)) + ".value"; |
| 50 const std::string time = SigninStatusFieldToString( | 51 const std::string time = SigninStatusFieldToString( |
| 51 static_cast<TimedSigninStatusField>(i)) + ".time"; | 52 static_cast<TimedSigninStatusField>(i)) + ".time"; |
| 52 user_prefs->RegisterStringPref(value.c_str(), "", | 53 user_prefs->RegisterStringPref(value.c_str(), "", |
| 53 PrefServiceSyncable::UNSYNCABLE_PREF); | 54 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 54 user_prefs->RegisterStringPref(time.c_str(), "", | 55 user_prefs->RegisterStringPref(time.c_str(), "", |
| 55 PrefServiceSyncable::UNSYNCABLE_PREF); | 56 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 56 } | 57 } |
| 57 // TokenService information for about:signin-internals. | 58 // TokenService information for about:signin-internals. |
| 58 for (size_t i = 0; i < kNumTokenPrefs; i++) { | 59 for (size_t i = 0; i < kNumTokenPrefs; i++) { |
| 59 const std::string pref = TokenPrefPath(kTokenPrefsArray[i]); | 60 const std::string pref = TokenPrefPath(kTokenPrefsArray[i]); |
| 60 const std::string value = pref + ".value"; | 61 const std::string value = pref + ".value"; |
| 61 const std::string status = pref + ".status"; | 62 const std::string status = pref + ".status"; |
| 62 const std::string time = pref + ".time"; | 63 const std::string time = pref + ".time"; |
| 63 user_prefs->RegisterStringPref(value.c_str(), "", | 64 user_prefs->RegisterStringPref(value.c_str(), "", |
| 64 PrefServiceSyncable::UNSYNCABLE_PREF); | 65 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 65 user_prefs->RegisterStringPref(status.c_str(), "", | 66 user_prefs->RegisterStringPref(status.c_str(), "", |
| 66 PrefServiceSyncable::UNSYNCABLE_PREF); | 67 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 67 user_prefs->RegisterStringPref(time.c_str(), "", | 68 user_prefs->RegisterStringPref(time.c_str(), "", |
| 68 PrefServiceSyncable::UNSYNCABLE_PREF); | 69 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 ProfileKeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor( | 73 ProfileKeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor( |
| 73 Profile* profile) const { | 74 Profile* profile) const { |
| 74 AboutSigninInternals* service = new AboutSigninInternals(); | 75 AboutSigninInternals* service = new AboutSigninInternals(); |
| 75 service->Initialize(profile); | 76 service->Initialize(profile); |
| 76 return service; | 77 return service; |
| 77 } | 78 } |
| OLD | NEW |