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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { 499 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) {
500 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; 500 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed.";
501 // REVIEW: why does this call OnClientLoginFailure? 501 // REVIEW: why does this call OnClientLoginFailure?
502 OnClientLoginFailure(error); 502 OnClientLoginFailure(error);
503 } 503 }
504 504
505 void SigninManager::Observe(int type, 505 void SigninManager::Observe(int type,
506 const content::NotificationSource& source, 506 const content::NotificationSource& source,
507 const content::NotificationDetails& details) { 507 const content::NotificationDetails& details) {
508 switch (type) { 508 switch (type) {
509 case chrome::NOTIFICATION_PREF_CHANGED:
510 DCHECK(*content::Details<std::string>(details).ptr() ==
511 prefs::kGoogleServicesUsernamePattern);
512 if (!authenticated_username_.empty() &&
513 !IsAllowedUsername(authenticated_username_)) {
514 // Signed in user is invalid according to the current policy so sign
515 // the user out.
516 SignOut();
517 }
518 break;
519
520 #if !defined(OS_CHROMEOS) 509 #if !defined(OS_CHROMEOS)
521 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { 510 case chrome::NOTIFICATION_TOKEN_AVAILABLE: {
522 TokenService::TokenAvailableDetails* tok_details = 511 TokenService::TokenAvailableDetails* tok_details =
523 content::Details<TokenService::TokenAvailableDetails>( 512 content::Details<TokenService::TokenAvailableDetails>(
524 details).ptr(); 513 details).ptr();
525 514
526 // If a GAIA service token has become available, use it to pre-login the 515 // If a GAIA service token has become available, use it to pre-login the
527 // user to other services that depend on GAIA credentials. 516 // user to other services that depend on GAIA credentials.
528 if (tok_details->service() == GaiaConstants::kGaiaService) { 517 if (tok_details->service() == GaiaConstants::kGaiaService) {
529 if (client_login_.get() == NULL) { 518 if (client_login_.get() == NULL) {
530 client_login_.reset( 519 client_login_.reset(
531 new GaiaAuthFetcher(this, 520 new GaiaAuthFetcher(this,
532 GaiaConstants::kChromeSource, 521 GaiaConstants::kChromeSource,
533 profile_->GetRequestContext())); 522 profile_->GetRequestContext()));
534 } 523 }
535 524
536 client_login_->StartMergeSession(tok_details->token()); 525 client_login_->StartMergeSession(tok_details->token());
537 526
538 // We only want to do this once per sign-in. 527 // We only want to do this once per sign-in.
539 CleanupNotificationRegistration(); 528 CleanupNotificationRegistration();
540 } 529 }
541 break; 530 break;
542 } 531 }
543 #endif 532 #endif
544 default: 533 default:
545 NOTREACHED(); 534 NOTREACHED();
546 } 535 }
547 } 536 }
548 537
538 void SigninManager::OnPreferenceChanged(PrefServiceBase* service,
539 const std::string& pref_name) {
540 DCHECK_EQ(std::string(prefs::kGoogleServicesUsernamePattern), pref_name);
541 if (!authenticated_username_.empty() &&
542 !IsAllowedUsername(authenticated_username_)) {
543 // Signed in user is invalid according to the current policy so sign
544 // the user out.
545 SignOut();
546 }
547 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/speech/chrome_speech_recognition_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698