OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/oauth1_login_manager.h" | 5 #include "chrome/browser/chromeos/login/oauth1_login_manager.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/login/user_manager.h" | 9 #include "chrome/browser/chromeos/login/user_manager.h" |
10 #include "chrome/browser/policy/browser_policy_connector.h" | |
11 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/signin/token_service.h" | 12 #include "chrome/browser/signin/token_service.h" |
14 #include "chrome/browser/signin/token_service_factory.h" | 13 #include "chrome/browser/signin/token_service_factory.h" |
15 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
18 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
19 #include "google_apis/gaia/gaia_auth_fetcher.h" | 18 #include "google_apis/gaia/gaia_auth_fetcher.h" |
20 #include "google_apis/gaia/gaia_constants.h" | 19 #include "google_apis/gaia/gaia_constants.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 StoreOAuth1Tokens(); | 132 StoreOAuth1Tokens(); |
134 // Verify OAuth1 token by doing OAuthLogin and fetching credentials. If we | 133 // Verify OAuth1 token by doing OAuthLogin and fetching credentials. If we |
135 // have just transfered auth cookies out of authenticated cookie jar, there | 134 // have just transfered auth cookies out of authenticated cookie jar, there |
136 // is no need to try to mint them from OAuth token again. | 135 // is no need to try to mint them from OAuth token again. |
137 VerifyOAuth1AccessToken(); | 136 VerifyOAuth1AccessToken(); |
138 } | 137 } |
139 | 138 |
140 void OAuth1LoginManager::OnOAuth1AccessTokenFetchFailed() { | 139 void OAuth1LoginManager::OnOAuth1AccessTokenFetchFailed() { |
141 LOG(ERROR) << "OAuth1 access token fetch failed!"; | 140 LOG(ERROR) << "OAuth1 access token fetch failed!"; |
142 state_ = OAuthLoginManager::SESSION_RESTORE_DONE; | 141 state_ = OAuthLoginManager::SESSION_RESTORE_DONE; |
143 g_browser_process->browser_policy_connector()->RegisterForUserPolicy( | |
144 EmptyString()); | |
145 } | 142 } |
146 | 143 |
147 void OAuth1LoginManager::OnOAuth1VerificationSucceeded( | 144 void OAuth1LoginManager::OnOAuth1VerificationSucceeded( |
148 const std::string& user_name, const std::string& sid, | 145 const std::string& user_name, const std::string& sid, |
149 const std::string& lsid, const std::string& auth) { | 146 const std::string& lsid, const std::string& auth) { |
150 LOG(INFO) << "OAuth1 token verification succeeded"; | 147 LOG(INFO) << "OAuth1 token verification succeeded"; |
151 // Kick off sync engine. | 148 // Kick off sync engine. |
152 GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth, | 149 GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth, |
153 std::string()); | 150 std::string()); |
154 TokenService* token_service = | 151 TokenService* token_service = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } else { | 211 } else { |
215 LOG(INFO) << "Failed to get OAuth1 token/secret encrypted."; | 212 LOG(INFO) << "Failed to get OAuth1 token/secret encrypted."; |
216 // Set the OAuth status invalid so that the user will go through full | 213 // Set the OAuth status invalid so that the user will go through full |
217 // GAIA login next time. | 214 // GAIA login next time. |
218 UserManager::Get()->SaveUserOAuthStatus( | 215 UserManager::Get()->SaveUserOAuthStatus( |
219 user->email(), User::OAUTH1_TOKEN_STATUS_INVALID); | 216 user->email(), User::OAUTH1_TOKEN_STATUS_INVALID); |
220 } | 217 } |
221 } | 218 } |
222 | 219 |
223 } // namespace chromeos | 220 } // namespace chromeos |
OLD | NEW |