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

Side by Side Diff: chrome/browser/chromeos/login/user_manager_impl.cc

Issue 11991002: Merge 176800 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/preferences.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); 399 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus);
400 oauth_status_update->SetWithoutPathExpansion(username, 400 oauth_status_update->SetWithoutPathExpansion(username,
401 new base::FundamentalValue(static_cast<int>(oauth_token_status))); 401 new base::FundamentalValue(static_cast<int>(oauth_token_status)));
402 } 402 }
403 403
404 User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus( 404 User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus(
405 const std::string& username) const { 405 const std::string& username) const {
406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
407 407
408 if (CommandLine::ForCurrentProcess()->HasSwitch( 408 PrefService* local_state = g_browser_process->local_state();
409 switches::kSkipOAuthLogin)) { 409 const DictionaryValue* prefs_oauth_status =
410 // Use OAUTH_TOKEN_STATUS_VALID flag if kSkipOAuthLogin is present. 410 local_state->GetDictionary(kUserOAuthTokenStatus);
411 return User::OAUTH_TOKEN_STATUS_VALID; 411 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN;
412 } else { 412 if (prefs_oauth_status &&
413 PrefService* local_state = g_browser_process->local_state(); 413 prefs_oauth_status->GetIntegerWithoutPathExpansion(
414 const DictionaryValue* prefs_oauth_status = 414 username, &oauth_token_status)) {
415 local_state->GetDictionary(kUserOAuthTokenStatus); 415 return static_cast<User::OAuthTokenStatus>(oauth_token_status);
416
417 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN;
418 if (prefs_oauth_status &&
419 prefs_oauth_status->GetIntegerWithoutPathExpansion(username,
420 &oauth_token_status)) {
421 return static_cast<User::OAuthTokenStatus>(oauth_token_status);
422 }
423 } 416 }
424
425 return User::OAUTH_TOKEN_STATUS_UNKNOWN; 417 return User::OAUTH_TOKEN_STATUS_UNKNOWN;
426 } 418 }
427 419
428 void UserManagerImpl::SaveUserDisplayName(const std::string& username, 420 void UserManagerImpl::SaveUserDisplayName(const std::string& username,
429 const string16& display_name) { 421 const string16& display_name) {
430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
431 423
432 User* user = const_cast<User*>(FindUser(username)); 424 User* user = const_cast<User*>(FindUser(username));
433 if (!user) 425 if (!user)
434 return; // Ignore if there is no such user. 426 return; // Ignore if there is no such user.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 observed_sync_service_->GetAuthError().state(); 519 observed_sync_service_->GetAuthError().state();
528 if (state != GoogleServiceAuthError::NONE && 520 if (state != GoogleServiceAuthError::NONE &&
529 state != GoogleServiceAuthError::CONNECTION_FAILED && 521 state != GoogleServiceAuthError::CONNECTION_FAILED &&
530 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && 522 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE &&
531 state != GoogleServiceAuthError::REQUEST_CANCELED) { 523 state != GoogleServiceAuthError::REQUEST_CANCELED) {
532 // Invalidate OAuth token to force Gaia sign-in flow. This is needed 524 // Invalidate OAuth token to force Gaia sign-in flow. This is needed
533 // because sign-out/sign-in solution is suggested to the user. 525 // because sign-out/sign-in solution is suggested to the user.
534 // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is 526 // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is
535 // implemented. 527 // implemented.
536 DVLOG(1) << "Invalidate OAuth token because of a sync error."; 528 DVLOG(1) << "Invalidate OAuth token because of a sync error.";
537 SaveUserOAuthStatus(logged_in_user_->email(), 529 SaveUserOAuthStatus(
538 User::OAUTH_TOKEN_STATUS_INVALID); 530 logged_in_user_->email(),
531 CommandLine::ForCurrentProcess()->HasSwitch(::switches::kForceOAuth1) ?
532 User::OAUTH1_TOKEN_STATUS_INVALID :
533 User::OAUTH2_TOKEN_STATUS_INVALID);
539 } 534 }
540 } 535 }
541 536
542 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { 537 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) {
543 UpdatePublicAccountDisplayName(account_id); 538 UpdatePublicAccountDisplayName(account_id);
544 } 539 }
545 540
546 void UserManagerImpl::OnDeviceLocalAccountsChanged() { 541 void UserManagerImpl::OnDeviceLocalAccountsChanged() {
547 // No action needed here, changes to the list of device-local accounts get 542 // No action needed here, changes to the list of device-local accounts get
548 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. 543 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 device_local_account_policy_service_->GetBrokerForAccount(username); 954 device_local_account_policy_service_->GetBrokerForAccount(username);
960 if (broker) 955 if (broker)
961 display_name = broker->GetDisplayName(); 956 display_name = broker->GetDisplayName();
962 } 957 }
963 958
964 // Set or clear the display name. 959 // Set or clear the display name.
965 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); 960 SaveUserDisplayName(username, UTF8ToUTF16(display_name));
966 } 961 }
967 962
968 } // namespace chromeos 963 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698