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

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

Issue 385993004: Clean up Chrome OS WARNING spam (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, profile_io_data feedback Created 6 years, 5 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 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/oauth2_login_manager.h" 5 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 DCHECK(restore_strategy_ == RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN); 94 DCHECK(restore_strategy_ == RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN);
95 RestoreSessionFromSavedTokens(); 95 RestoreSessionFromSavedTokens();
96 } 96 }
97 97
98 void OAuth2LoginManager::RestoreSessionFromSavedTokens() { 98 void OAuth2LoginManager::RestoreSessionFromSavedTokens() {
99 ProfileOAuth2TokenService* token_service = GetTokenService(); 99 ProfileOAuth2TokenService* token_service = GetTokenService();
100 const std::string& primary_account_id = GetPrimaryAccountId(); 100 const std::string& primary_account_id = GetPrimaryAccountId();
101 if (token_service->RefreshTokenIsAvailable(primary_account_id)) { 101 if (token_service->RefreshTokenIsAvailable(primary_account_id)) {
102 LOG(WARNING) << "OAuth2 refresh token is already loaded."; 102 VLOG(1) << "OAuth2 refresh token is already loaded.";
103 VerifySessionCookies(); 103 VerifySessionCookies();
104 } else { 104 } else {
105 LOG(WARNING) << "Loading OAuth2 refresh token from database."; 105 VLOG(1) << "Loading OAuth2 refresh token from database.";
106 106
107 // Flag user with unknown token status in case there are no saved tokens 107 // Flag user with unknown token status in case there are no saved tokens
108 // and OnRefreshTokenAvailable is not called. Flagging it here would 108 // and OnRefreshTokenAvailable is not called. Flagging it here would
109 // cause user to go through Gaia in next login to obtain a new refresh 109 // cause user to go through Gaia in next login to obtain a new refresh
110 // token. 110 // token.
111 UserManager::Get()->SaveUserOAuthStatus(primary_account_id, 111 UserManager::Get()->SaveUserOAuthStatus(primary_account_id,
112 User::OAUTH_TOKEN_STATUS_UNKNOWN); 112 User::OAUTH_TOKEN_STATUS_UNKNOWN);
113 113
114 token_service->LoadCredentials(primary_account_id); 114 token_service->LoadCredentials(primary_account_id);
115 } 115 }
116 } 116 }
117 117
118 void OAuth2LoginManager::Stop() { 118 void OAuth2LoginManager::Stop() {
119 oauth2_token_fetcher_.reset(); 119 oauth2_token_fetcher_.reset();
120 login_verifier_.reset(); 120 login_verifier_.reset();
121 } 121 }
122 122
123 bool OAuth2LoginManager::ShouldBlockTabLoading() { 123 bool OAuth2LoginManager::ShouldBlockTabLoading() {
124 return state_ == SESSION_RESTORE_PREPARING || 124 return state_ == SESSION_RESTORE_PREPARING ||
125 state_ == SESSION_RESTORE_IN_PROGRESS; 125 state_ == SESSION_RESTORE_IN_PROGRESS;
126 } 126 }
127 127
128 void OAuth2LoginManager::OnRefreshTokenAvailable( 128 void OAuth2LoginManager::OnRefreshTokenAvailable(
129 const std::string& account_id) { 129 const std::string& account_id) {
130 LOG(WARNING) << "OnRefreshTokenAvailable"; 130 VLOG(1) << "OnRefreshTokenAvailable";
131 131
132 if (state_ == SESSION_RESTORE_NOT_STARTED) 132 if (state_ == SESSION_RESTORE_NOT_STARTED)
133 return; 133 return;
134 134
135 // TODO(fgorski): Once ProfileOAuth2TokenService supports multi-login, make 135 // TODO(fgorski): Once ProfileOAuth2TokenService supports multi-login, make
136 // sure to restore session cookies in the context of the correct account_id. 136 // sure to restore session cookies in the context of the correct account_id.
137 137
138 // Do not validate tokens for supervised users, as they don't actually have 138 // Do not validate tokens for supervised users, as they don't actually have
139 // oauth2 token. 139 // oauth2 token.
140 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) { 140 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) {
141 LOG(WARNING) << "Logged in as managed user, skip token validation."; 141 VLOG(1) << "Logged in as managed user, skip token validation.";
142 return; 142 return;
143 } 143 }
144 // Only restore session cookies for the primary account in the profile. 144 // Only restore session cookies for the primary account in the profile.
145 if (GetPrimaryAccountId() == account_id) { 145 if (GetPrimaryAccountId() == account_id) {
146 // Token is loaded. Undo the flagging before token loading. 146 // Token is loaded. Undo the flagging before token loading.
147 UserManager::Get()->SaveUserOAuthStatus(account_id, 147 UserManager::Get()->SaveUserOAuthStatus(account_id,
148 User::OAUTH2_TOKEN_STATUS_VALID); 148 User::OAUTH2_TOKEN_STATUS_VALID);
149 VerifySessionCookies(); 149 VerifySessionCookies();
150 } 150 }
151 } 151 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 FOR_EACH_OBSERVER(Observer, observer_list_, 394 FOR_EACH_OBSERVER(Observer, observer_list_,
395 OnSessionRestoreStateChanged(user_profile_, state_)); 395 OnSessionRestoreStateChanged(user_profile_, state_));
396 } 396 }
397 397
398 void OAuth2LoginManager::SetSessionRestoreStartForTesting( 398 void OAuth2LoginManager::SetSessionRestoreStartForTesting(
399 const base::Time& time) { 399 const base::Time& time) {
400 session_restore_start_ = time; 400 session_restore_start_ = time;
401 } 401 }
402 402
403 } // namespace chromeos 403 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698