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

Side by Side Diff: chrome/browser/chromeos/login/signin/auth_sync_observer.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/signin/auth_sync_observer.h" 5 #include "chrome/browser/chromeos/login/signin/auth_sync_observer.h"
6 6
7 #include "base/metrics/user_metrics.h" 7 #include "base/metrics/user_metrics.h"
8 #include "base/metrics/user_metrics_action.h" 8 #include "base/metrics/user_metrics_action.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/chromeos/login/reauth_stats.h" 10 #include "chrome/browser/chromeos/login/reauth_stats.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 sync_service->GetAuthError().state(); 55 sync_service->GetAuthError().state();
56 if (state != GoogleServiceAuthError::NONE && 56 if (state != GoogleServiceAuthError::NONE &&
57 state != GoogleServiceAuthError::CONNECTION_FAILED && 57 state != GoogleServiceAuthError::CONNECTION_FAILED &&
58 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && 58 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE &&
59 state != GoogleServiceAuthError::REQUEST_CANCELED) { 59 state != GoogleServiceAuthError::REQUEST_CANCELED) {
60 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is 60 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is
61 // needed because sign-out/sign-in solution is suggested to the user. 61 // needed because sign-out/sign-in solution is suggested to the user.
62 // TODO(nkostylev): Remove after crosbug.com/25978 is implemented. 62 // TODO(nkostylev): Remove after crosbug.com/25978 is implemented.
63 LOG(WARNING) << "Invalidate OAuth token because of a sync error: " 63 LOG(WARNING) << "Invalidate OAuth token because of a sync error: "
64 << sync_service->GetAuthError().ToString(); 64 << sync_service->GetAuthError().ToString();
65 std::string email = user->email(); 65 const AccountId& account_id = user->GetAccountId();
66 DCHECK(!email.empty()); 66 DCHECK(account_id.is_valid());
67 // TODO(nkostyelv): Change observer after active user has changed. 67 // TODO(nkostyelv): Change observer after active user has changed.
68 user_manager::User::OAuthTokenStatus old_status = 68 user_manager::User::OAuthTokenStatus old_status =
69 user->oauth_token_status(); 69 user->oauth_token_status();
70 user_manager::UserManager::Get()->SaveUserOAuthStatus( 70 user_manager::UserManager::Get()->SaveUserOAuthStatus(
71 email, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); 71 account_id, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID);
72 RecordReauthReason(email, ReauthReason::SYNC_FAILED); 72 RecordReauthReason(account_id, ReauthReason::SYNC_FAILED);
73 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && 73 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED &&
74 old_status != user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { 74 old_status != user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) {
75 // Attempt to restore token from file. 75 // Attempt to restore token from file.
76 ChromeUserManager::Get() 76 ChromeUserManager::Get()
77 ->GetSupervisedUserManager() 77 ->GetSupervisedUserManager()
78 ->LoadSupervisedUserToken( 78 ->LoadSupervisedUserToken(
79 profile_, 79 profile_,
80 base::Bind(&AuthSyncObserver::OnSupervisedTokenLoaded, 80 base::Bind(&AuthSyncObserver::OnSupervisedTokenLoaded,
81 base::Unretained(this))); 81 base::Unretained(this)));
82 content::RecordAction( 82 content::RecordAction(
83 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Invalidated")); 83 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Invalidated"));
84 } 84 }
85 } else if (state == GoogleServiceAuthError::NONE) { 85 } else if (state == GoogleServiceAuthError::NONE) {
86 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && 86 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED &&
87 user->oauth_token_status() == 87 user->oauth_token_status() ==
88 user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { 88 user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) {
89 LOG(ERROR) << 89 LOG(ERROR) <<
90 "Got an incorrectly invalidated token case, restoring token status."; 90 "Got an incorrectly invalidated token case, restoring token status.";
91 user_manager::UserManager::Get()->SaveUserOAuthStatus( 91 user_manager::UserManager::Get()->SaveUserOAuthStatus(
92 user->email(), user_manager::User::OAUTH2_TOKEN_STATUS_VALID); 92 user->GetAccountId(), user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
93 content::RecordAction( 93 content::RecordAction(
94 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Recovered")); 94 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Recovered"));
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) { 99 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) {
100 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( 100 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken(
101 profile_, token); 101 profile_, token);
102 } 102 }
103 103
104 } // namespace chromeos 104 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698