| 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/chromeos/login/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); | 395 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); |
| 396 oauth_status_update->SetWithoutPathExpansion(username, | 396 oauth_status_update->SetWithoutPathExpansion(username, |
| 397 new base::FundamentalValue(static_cast<int>(oauth_token_status))); | 397 new base::FundamentalValue(static_cast<int>(oauth_token_status))); |
| 398 } | 398 } |
| 399 | 399 |
| 400 User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus( | 400 User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus( |
| 401 const std::string& username) const { | 401 const std::string& username) const { |
| 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 403 | 403 |
| 404 if (CommandLine::ForCurrentProcess()->HasSwitch( | 404 PrefService* local_state = g_browser_process->local_state(); |
| 405 switches::kSkipOAuthLogin)) { | 405 const DictionaryValue* prefs_oauth_status = |
| 406 // Use OAUTH_TOKEN_STATUS_VALID flag if kSkipOAuthLogin is present. | 406 local_state->GetDictionary(kUserOAuthTokenStatus); |
| 407 return User::OAUTH_TOKEN_STATUS_VALID; | 407 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; |
| 408 } else { | 408 if (prefs_oauth_status && |
| 409 PrefService* local_state = g_browser_process->local_state(); | 409 prefs_oauth_status->GetIntegerWithoutPathExpansion( |
| 410 const DictionaryValue* prefs_oauth_status = | 410 username, &oauth_token_status)) { |
| 411 local_state->GetDictionary(kUserOAuthTokenStatus); | 411 return static_cast<User::OAuthTokenStatus>(oauth_token_status); |
| 412 | |
| 413 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; | |
| 414 if (prefs_oauth_status && | |
| 415 prefs_oauth_status->GetIntegerWithoutPathExpansion(username, | |
| 416 &oauth_token_status)) { | |
| 417 return static_cast<User::OAuthTokenStatus>(oauth_token_status); | |
| 418 } | |
| 419 } | 412 } |
| 420 | |
| 421 return User::OAUTH_TOKEN_STATUS_UNKNOWN; | 413 return User::OAUTH_TOKEN_STATUS_UNKNOWN; |
| 422 } | 414 } |
| 423 | 415 |
| 424 void UserManagerImpl::SaveUserDisplayName(const std::string& username, | 416 void UserManagerImpl::SaveUserDisplayName(const std::string& username, |
| 425 const string16& display_name) { | 417 const string16& display_name) { |
| 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 427 | 419 |
| 428 User* user = const_cast<User*>(FindUser(username)); | 420 User* user = const_cast<User*>(FindUser(username)); |
| 429 if (!user) | 421 if (!user) |
| 430 return; // Ignore if there is no such user. | 422 return; // Ignore if there is no such user. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 observed_sync_service_->GetAuthError().state(); | 515 observed_sync_service_->GetAuthError().state(); |
| 524 if (state != GoogleServiceAuthError::NONE && | 516 if (state != GoogleServiceAuthError::NONE && |
| 525 state != GoogleServiceAuthError::CONNECTION_FAILED && | 517 state != GoogleServiceAuthError::CONNECTION_FAILED && |
| 526 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && | 518 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && |
| 527 state != GoogleServiceAuthError::REQUEST_CANCELED) { | 519 state != GoogleServiceAuthError::REQUEST_CANCELED) { |
| 528 // Invalidate OAuth token to force Gaia sign-in flow. This is needed | 520 // Invalidate OAuth token to force Gaia sign-in flow. This is needed |
| 529 // because sign-out/sign-in solution is suggested to the user. | 521 // because sign-out/sign-in solution is suggested to the user. |
| 530 // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is | 522 // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is |
| 531 // implemented. | 523 // implemented. |
| 532 DVLOG(1) << "Invalidate OAuth token because of a sync error."; | 524 DVLOG(1) << "Invalidate OAuth token because of a sync error."; |
| 533 SaveUserOAuthStatus(logged_in_user_->email(), | 525 SaveUserOAuthStatus( |
| 534 User::OAUTH_TOKEN_STATUS_INVALID); | 526 logged_in_user_->email(), |
| 527 CommandLine::ForCurrentProcess()->HasSwitch(::switches::kForceOAuth1) ? |
| 528 User::OAUTH1_TOKEN_STATUS_INVALID : |
| 529 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 535 } | 530 } |
| 536 } | 531 } |
| 537 | 532 |
| 538 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { | 533 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { |
| 539 UpdatePublicAccountDisplayName(account_id); | 534 UpdatePublicAccountDisplayName(account_id); |
| 540 } | 535 } |
| 541 | 536 |
| 542 void UserManagerImpl::OnDeviceLocalAccountsChanged() { | 537 void UserManagerImpl::OnDeviceLocalAccountsChanged() { |
| 543 // No action needed here, changes to the list of device-local accounts get | 538 // No action needed here, changes to the list of device-local accounts get |
| 544 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. | 539 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 device_local_account_policy_service_->GetBrokerForAccount(username); | 950 device_local_account_policy_service_->GetBrokerForAccount(username); |
| 956 if (broker) | 951 if (broker) |
| 957 display_name = broker->GetDisplayName(); | 952 display_name = broker->GetDisplayName(); |
| 958 } | 953 } |
| 959 | 954 |
| 960 // Set or clear the display name. | 955 // Set or clear the display name. |
| 961 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); | 956 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); |
| 962 } | 957 } |
| 963 | 958 |
| 964 } // namespace chromeos | 959 } // namespace chromeos |
| OLD | NEW |