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

Side by Side Diff: chrome/browser/signin/profile_oauth2_token_service.cc

Issue 138603002: Merge r245242: Gracefully handle being signed out of a supervised profile. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1700/src
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/signin/profile_oauth2_token_service.h" 5 #include "chrome/browser/signin/profile_oauth2_token_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void ProfileOAuth2TokenService::UpdateAuthError( 140 void ProfileOAuth2TokenService::UpdateAuthError(
141 const std::string& account_id, 141 const std::string& account_id,
142 const GoogleServiceAuthError& error) { 142 const GoogleServiceAuthError& error) {
143 // Do not report connection errors as these are not actually auth errors. 143 // Do not report connection errors as these are not actually auth errors.
144 // We also want to avoid masking a "real" auth error just because we 144 // We also want to avoid masking a "real" auth error just because we
145 // subsequently get a transient network error. 145 // subsequently get a transient network error.
146 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) 146 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED)
147 return; 147 return;
148 148
149 DCHECK_GT(refresh_tokens_.count(account_id), 0u); 149 if (refresh_tokens_.count(account_id) == 0) {
150 // This could happen if the preferences have been corrupted (see
151 // http://crbug.com/321370). In a Debug build that would be a bug, but in a
152 // Release build we want to deal with it gracefully.
153 NOTREACHED();
154 return;
155 }
150 refresh_tokens_[account_id]->SetLastAuthError(error); 156 refresh_tokens_[account_id]->SetLastAuthError(error);
151 } 157 }
152 158
153 void ProfileOAuth2TokenService::Observe( 159 void ProfileOAuth2TokenService::Observe(
154 int type, 160 int type,
155 const content::NotificationSource& source, 161 const content::NotificationSource& source,
156 const content::NotificationDetails& details) { 162 const content::NotificationDetails& details) {
157 const std::string& account_id = GetPrimaryAccountId(); 163 const std::string& account_id = GetPrimaryAccountId();
158 switch (type) { 164 switch (type) {
159 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { 165 case chrome::NOTIFICATION_TOKEN_AVAILABLE: {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 374 }
369 } 375 }
370 376
371 if (!old_login_token.empty() && 377 if (!old_login_token.empty() &&
372 refresh_tokens_.count(GetPrimaryAccountId()) == 0) { 378 refresh_tokens_.count(GetPrimaryAccountId()) == 0) {
373 UpdateCredentials(GetPrimaryAccountId(), old_login_token); 379 UpdateCredentials(GetPrimaryAccountId(), old_login_token);
374 } 380 }
375 381
376 FireRefreshTokensLoaded(); 382 FireRefreshTokensLoaded();
377 } 383 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698