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

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

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 GoogleServiceAuthError::State state = 514 GoogleServiceAuthError::State state =
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.";
Nikita (slow) 2013/01/11 22:02:03 LOG(WARNING) << OAuth1
zel 2013/01/12 02:07:37 The comment was good, the code below wasn't.
533 SaveUserOAuthStatus(logged_in_user_->email(), 525 SaveUserOAuthStatus(logged_in_user_->email(),
534 User::OAUTH_TOKEN_STATUS_INVALID); 526 User::OAUTH1_TOKEN_STATUS_INVALID);
535 } 527 }
536 } 528 }
537 529
538 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { 530 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) {
539 UpdatePublicAccountDisplayName(account_id); 531 UpdatePublicAccountDisplayName(account_id);
540 } 532 }
541 533
542 void UserManagerImpl::OnDeviceLocalAccountsChanged() { 534 void UserManagerImpl::OnDeviceLocalAccountsChanged() {
543 // No action needed here, changes to the list of device-local accounts get 535 // No action needed here, changes to the list of device-local accounts get
544 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. 536 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 device_local_account_policy_service_->GetBrokerForAccount(username); 947 device_local_account_policy_service_->GetBrokerForAccount(username);
956 if (broker) 948 if (broker)
957 display_name = broker->GetDisplayName(); 949 display_name = broker->GetDisplayName();
958 } 950 }
959 951
960 // Set or clear the display name. 952 // Set or clear the display name.
961 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); 953 SaveUserDisplayName(username, UTF8ToUTF16(display_name));
962 } 954 }
963 955
964 } // namespace chromeos 956 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698