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

Side by Side Diff: components/signin/core/browser/signin_manager.cc

Issue 2422943002: Remove usage of FOR_EACH_OBSERVER macro in components/signin (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/signin/core/browser/signin_manager.h" 5 #include "components/signin/core/browser/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 possibly_invalid_gaia_id_.clear(); 134 possibly_invalid_gaia_id_.clear();
135 possibly_invalid_email_.clear(); 135 possibly_invalid_email_.clear();
136 password_.clear(); 136 password_.clear();
137 type_ = SIGNIN_TYPE_NONE; 137 type_ = SIGNIN_TYPE_NONE;
138 temp_refresh_token_.clear(); 138 temp_refresh_token_.clear();
139 } 139 }
140 140
141 void SigninManager::HandleAuthError(const GoogleServiceAuthError& error) { 141 void SigninManager::HandleAuthError(const GoogleServiceAuthError& error) {
142 ClearTransientSigninData(); 142 ClearTransientSigninData();
143 143
144 FOR_EACH_OBSERVER(SigninManagerBase::Observer, 144 for (auto& observer : observer_list_)
145 observer_list_, 145 observer.GoogleSigninFailed(error);
146 GoogleSigninFailed(error));
147 } 146 }
148 147
149 void SigninManager::SignOut( 148 void SigninManager::SignOut(
150 signin_metrics::ProfileSignout signout_source_metric, 149 signin_metrics::ProfileSignout signout_source_metric,
151 signin_metrics::SignoutDelete signout_delete_metric) { 150 signin_metrics::SignoutDelete signout_delete_metric) {
152 DCHECK(IsInitialized()); 151 DCHECK(IsInitialized());
153 152
154 signin_metrics::LogSignout(signout_source_metric, signout_delete_metric); 153 signin_metrics::LogSignout(signout_source_metric, signout_delete_metric);
155 if (!IsAuthenticated()) { 154 if (!IsAuthenticated()) {
156 if (AuthInProgress()) { 155 if (AuthInProgress()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 signed_in_duration.InMinutes()); 193 signed_in_duration.InMinutes());
195 } 194 }
196 195
197 // Revoke all tokens before sending signed_out notification, because there 196 // Revoke all tokens before sending signed_out notification, because there
198 // may be components that don't listen for token service events when the 197 // may be components that don't listen for token service events when the
199 // profile is not connected to an account. 198 // profile is not connected to an account.
200 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, " 199 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, "
201 << "IsSigninAllowed: " << IsSigninAllowed(); 200 << "IsSigninAllowed: " << IsSigninAllowed();
202 token_service_->RevokeAllCredentials(); 201 token_service_->RevokeAllCredentials();
203 202
204 FOR_EACH_OBSERVER(SigninManagerBase::Observer, 203 for (auto& observer : observer_list_)
205 observer_list_, 204 observer.GoogleSignedOut(account_id, username);
206 GoogleSignedOut(account_id, username));
207 } 205 }
208 206
209 void SigninManager::Initialize(PrefService* local_state) { 207 void SigninManager::Initialize(PrefService* local_state) {
210 SigninManagerBase::Initialize(local_state); 208 SigninManagerBase::Initialize(local_state);
211 209
212 // local_state can be null during unit tests. 210 // local_state can be null during unit tests.
213 if (local_state) { 211 if (local_state) {
214 local_state_pref_registrar_.Init(local_state); 212 local_state_pref_registrar_.Init(local_state);
215 local_state_pref_registrar_.Add( 213 local_state_pref_registrar_.Add(
216 prefs::kGoogleServicesUsernamePattern, 214 prefs::kGoogleServicesUsernamePattern,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 base::Time::Now().ToInternalValue()); 366 base::Time::Now().ToInternalValue());
369 SetAuthenticatedAccountInfo(possibly_invalid_gaia_id_, 367 SetAuthenticatedAccountInfo(possibly_invalid_gaia_id_,
370 possibly_invalid_email_); 368 possibly_invalid_email_);
371 const std::string gaia_id = possibly_invalid_gaia_id_; 369 const std::string gaia_id = possibly_invalid_gaia_id_;
372 370
373 possibly_invalid_account_id_.clear(); 371 possibly_invalid_account_id_.clear();
374 possibly_invalid_gaia_id_.clear(); 372 possibly_invalid_gaia_id_.clear();
375 possibly_invalid_email_.clear(); 373 possibly_invalid_email_.clear();
376 signin_manager_signed_in_ = true; 374 signin_manager_signed_in_ = true;
377 375
378 FOR_EACH_OBSERVER( 376 for (auto& observer : observer_list_) {
379 SigninManagerBase::Observer, observer_list_, 377 observer.GoogleSigninSucceeded(GetAuthenticatedAccountId(),
380 GoogleSigninSucceeded(GetAuthenticatedAccountId(), 378 GetAuthenticatedAccountInfo().email,
381 GetAuthenticatedAccountInfo().email, password_)); 379 password_);
380 }
382 381
383 client_->OnSignedIn(GetAuthenticatedAccountId(), gaia_id, 382 client_->OnSignedIn(GetAuthenticatedAccountId(), gaia_id,
384 GetAuthenticatedAccountInfo().email, password_); 383 GetAuthenticatedAccountInfo().email, password_);
385 384
386 signin_metrics::LogSigninProfile(client_->IsFirstRun(), 385 signin_metrics::LogSigninProfile(client_->IsFirstRun(),
387 client_->GetInstallDate()); 386 client_->GetInstallDate());
388 387
389 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. 388 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again.
390 389
391 PostSignedIn(); 390 PostSignedIn();
(...skipping 24 matching lines...) Expand all
416 account_tracker_service()->SetMigrationDone(); 415 account_tracker_service()->SetMigrationDone();
417 token_service_->RemoveObserver(this); 416 token_service_->RemoveObserver(this);
418 } 417 }
419 } 418 }
420 419
421 void SigninManager::ProhibitSignout(bool prohibit_signout) { 420 void SigninManager::ProhibitSignout(bool prohibit_signout) {
422 prohibit_signout_ = prohibit_signout; 421 prohibit_signout_ = prohibit_signout;
423 } 422 }
424 423
425 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } 424 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; }
OLDNEW
« no previous file with comments | « components/signin/core/browser/signin_error_controller.cc ('k') | components/signin/core/browser/signin_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698