Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/signin/about_signin_internals.cc

Issue 196783002: Export a private webstore API to call into the new inline sign-in flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add API tests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 5 #include "chrome/browser/signin/about_signin_internals.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Also persist these values in the prefs. 150 // Also persist these values in the prefs.
151 const std::string value_pref = SigninStatusFieldToString(field) + ".value"; 151 const std::string value_pref = SigninStatusFieldToString(field) + ".value";
152 const std::string time_pref = SigninStatusFieldToString(field) + ".time"; 152 const std::string time_pref = SigninStatusFieldToString(field) + ".time";
153 profile_->GetPrefs()->SetString(value_pref.c_str(), value); 153 profile_->GetPrefs()->SetString(value_pref.c_str(), value);
154 profile_->GetPrefs()->SetString(time_pref.c_str(), time_as_str); 154 profile_->GetPrefs()->SetString(time_pref.c_str(), time_as_str);
155 155
156 NotifyObservers(); 156 NotifyObservers();
157 } 157 }
158 158
159 void AboutSigninInternals::SigninManagerCreated(SigninManagerBase* manager) {
160 manager->AddSigninDiagnosticsObserver(this);
161 }
162
163 void AboutSigninInternals::SigninManagerShutdown(SigninManagerBase* manager) {
164 manager->RemoveSigninDiagnosticsObserver(this);
165 }
166
159 void AboutSigninInternals::RefreshSigninPrefs() { 167 void AboutSigninInternals::RefreshSigninPrefs() {
160 // Return if no profile exists. Can occur in unit tests. 168 // Return if no profile exists. Can occur in unit tests.
161 if (!profile_) 169 if (!profile_)
162 return; 170 return;
163 171
164 PrefService* pref_service = profile_->GetPrefs(); 172 PrefService* pref_service = profile_->GetPrefs();
165 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) { 173 for (int i = UNTIMED_FIELDS_BEGIN; i < UNTIMED_FIELDS_END; ++i) {
166 const std::string pref_path = 174 const std::string pref_path =
167 SigninStatusFieldToString(static_cast<UntimedSigninStatusField>(i)); 175 SigninStatusFieldToString(static_cast<UntimedSigninStatusField>(i));
168 176
(...skipping 15 matching lines...) Expand all
184 192
185 NotifyObservers(); 193 NotifyObservers();
186 } 194 }
187 195
188 void AboutSigninInternals::Initialize(Profile* profile) { 196 void AboutSigninInternals::Initialize(Profile* profile) {
189 DCHECK(!profile_); 197 DCHECK(!profile_);
190 profile_ = profile; 198 profile_ = profile;
191 199
192 RefreshSigninPrefs(); 200 RefreshSigninPrefs();
193 201
202 SigninManagerFactory::GetInstance()->AddObserver(this);
194 SigninManagerFactory::GetForProfile(profile)-> 203 SigninManagerFactory::GetForProfile(profile)->
195 AddSigninDiagnosticsObserver(this); 204 AddSigninDiagnosticsObserver(this);
196 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> 205 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
197 AddDiagnosticsObserver(this); 206 AddDiagnosticsObserver(this);
198 } 207 }
199 208
200 void AboutSigninInternals::Shutdown() { 209 void AboutSigninInternals::Shutdown() {
210 SigninManagerFactory::GetInstance()->RemoveObserver(this);
201 SigninManagerFactory::GetForProfile(profile_)-> 211 SigninManagerFactory::GetForProfile(profile_)->
202 RemoveSigninDiagnosticsObserver(this); 212 RemoveSigninDiagnosticsObserver(this);
203 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> 213 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
204 RemoveDiagnosticsObserver(this); 214 RemoveDiagnosticsObserver(this);
205 215
206 } 216 }
207 217
208 void AboutSigninInternals::NotifyObservers() { 218 void AboutSigninInternals::NotifyObservers() {
209 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, 219 FOR_EACH_OBSERVER(AboutSigninInternals::Observer,
210 signin_observers_, 220 signin_observers_,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 const std::vector<TokenInfo*>& tokens = it->second; 405 const std::vector<TokenInfo*>& tokens = it->second;
396 for (size_t i = 0; i < tokens.size(); ++i) { 406 for (size_t i = 0; i < tokens.size(); ++i) {
397 base::DictionaryValue* token_info = tokens[i]->ToValue(); 407 base::DictionaryValue* token_info = tokens[i]->ToValue();
398 token_details->Append(token_info); 408 token_details->Append(token_info);
399 } 409 }
400 } 410 }
401 411
402 return signin_status.Pass(); 412 return signin_status.Pass();
403 } 413 }
404 414
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698