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