| 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/signin_manager_base.h" | 5 #include "chrome/browser/signin/signin_manager_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // clear their login info also (not valid to be logged in without any | 48 // clear their login info also (not valid to be logged in without any |
| 49 // tokens). | 49 // tokens). |
| 50 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 50 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 51 if (cmd_line->HasSwitch(switches::kClearTokenService)) | 51 if (cmd_line->HasSwitch(switches::kClearTokenService)) |
| 52 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); | 52 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
| 53 | 53 |
| 54 std::string user = profile_->GetPrefs()->GetString( | 54 std::string user = profile_->GetPrefs()->GetString( |
| 55 prefs::kGoogleServicesUsername); | 55 prefs::kGoogleServicesUsername); |
| 56 if (!user.empty()) | 56 if (!user.empty()) |
| 57 SetAuthenticatedUsername(user); | 57 SetAuthenticatedUsername(user); |
| 58 | |
| 59 InitTokenService(); | |
| 60 } | |
| 61 | |
| 62 void SigninManagerBase::InitTokenService() { | |
| 63 // TokenService can be null for unit tests. | |
| 64 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | |
| 65 if (token_service) | |
| 66 token_service->Initialize(GaiaConstants::kChromeSource, profile_); | |
| 67 // Note: ChromeOS will kick off TokenService::LoadTokensFromDB from | |
| 68 // OAuthLoginManager once the rest of the Profile is fully initialized. | |
| 69 } | 58 } |
| 70 | 59 |
| 71 bool SigninManagerBase::IsInitialized() const { | 60 bool SigninManagerBase::IsInitialized() const { |
| 72 return profile_ != NULL; | 61 return profile_ != NULL; |
| 73 } | 62 } |
| 74 | 63 |
| 75 bool SigninManagerBase::IsSigninAllowed() const { | 64 bool SigninManagerBase::IsSigninAllowed() const { |
| 76 return profile_->GetPrefs()->GetBoolean(prefs::kSigninAllowed); | 65 return profile_->GetPrefs()->GetBoolean(prefs::kSigninAllowed); |
| 77 } | 66 } |
| 78 | 67 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 NotifySigninValueChanged(field, value)); | 131 NotifySigninValueChanged(field, value)); |
| 143 } | 132 } |
| 144 | 133 |
| 145 void SigninManagerBase::NotifyDiagnosticsObservers( | 134 void SigninManagerBase::NotifyDiagnosticsObservers( |
| 146 const TimedSigninStatusField& field, | 135 const TimedSigninStatusField& field, |
| 147 const std::string& value) { | 136 const std::string& value) { |
| 148 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 137 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
| 149 signin_diagnostics_observers_, | 138 signin_diagnostics_observers_, |
| 150 NotifySigninValueChanged(field, value)); | 139 NotifySigninValueChanged(field, value)); |
| 151 } | 140 } |
| OLD | NEW |