| 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.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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { | 490 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { |
| 491 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; | 491 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; |
| 492 // REVIEW: why does this call OnClientLoginFailure? | 492 // REVIEW: why does this call OnClientLoginFailure? |
| 493 OnClientLoginFailure(error); | 493 OnClientLoginFailure(error); |
| 494 } | 494 } |
| 495 | 495 |
| 496 void SigninManager::Observe(int type, | 496 void SigninManager::Observe(int type, |
| 497 const content::NotificationSource& source, | 497 const content::NotificationSource& source, |
| 498 const content::NotificationDetails& details) { | 498 const content::NotificationDetails& details) { |
| 499 switch (type) { | 499 switch (type) { |
| 500 case chrome::NOTIFICATION_PREF_CHANGED: | |
| 501 DCHECK(*content::Details<std::string>(details).ptr() == | |
| 502 prefs::kGoogleServicesUsernamePattern); | |
| 503 if (!authenticated_username_.empty() && | |
| 504 !IsAllowedUsername(authenticated_username_)) { | |
| 505 // Signed in user is invalid according to the current policy so sign | |
| 506 // the user out. | |
| 507 SignOut(); | |
| 508 } | |
| 509 break; | |
| 510 | |
| 511 #if !defined(OS_CHROMEOS) | 500 #if !defined(OS_CHROMEOS) |
| 512 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 501 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
| 513 TokenService::TokenAvailableDetails* tok_details = | 502 TokenService::TokenAvailableDetails* tok_details = |
| 514 content::Details<TokenService::TokenAvailableDetails>( | 503 content::Details<TokenService::TokenAvailableDetails>( |
| 515 details).ptr(); | 504 details).ptr(); |
| 516 | 505 |
| 517 // If a GAIA service token has become available, use it to pre-login the | 506 // If a GAIA service token has become available, use it to pre-login the |
| 518 // user to other services that depend on GAIA credentials. | 507 // user to other services that depend on GAIA credentials. |
| 519 if (tok_details->service() == GaiaConstants::kGaiaService) { | 508 if (tok_details->service() == GaiaConstants::kGaiaService) { |
| 520 if (client_login_.get() == NULL) { | 509 if (client_login_.get() == NULL) { |
| 521 client_login_.reset( | 510 client_login_.reset( |
| 522 new GaiaAuthFetcher(this, | 511 new GaiaAuthFetcher(this, |
| 523 GaiaConstants::kChromeSource, | 512 GaiaConstants::kChromeSource, |
| 524 profile_->GetRequestContext())); | 513 profile_->GetRequestContext())); |
| 525 } | 514 } |
| 526 | 515 |
| 527 client_login_->StartMergeSession(tok_details->token()); | 516 client_login_->StartMergeSession(tok_details->token()); |
| 528 | 517 |
| 529 // We only want to do this once per sign-in. | 518 // We only want to do this once per sign-in. |
| 530 CleanupNotificationRegistration(); | 519 CleanupNotificationRegistration(); |
| 531 } | 520 } |
| 532 break; | 521 break; |
| 533 } | 522 } |
| 534 #endif | 523 #endif |
| 535 default: | 524 default: |
| 536 NOTREACHED(); | 525 NOTREACHED(); |
| 537 } | 526 } |
| 538 } | 527 } |
| 539 | 528 |
| 529 void SigninManager::OnPreferenceChanged(PrefServiceBase* service, |
| 530 const std::string& pref_name) { |
| 531 DCHECK_EQ(prefs::kGoogleServicesUsernamePattern, pref_name); |
| 532 if (!authenticated_username_.empty() && |
| 533 !IsAllowedUsername(authenticated_username_)) { |
| 534 // Signed in user is invalid according to the current policy so sign |
| 535 // the user out. |
| 536 SignOut(); |
| 537 } |
| 538 } |
| OLD | NEW |