| OLD | NEW |
| 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/account_reconcilor.h" | 5 #include "chrome/browser/signin/account_reconcilor.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 11 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/signin/google_auto_login_helper.h" | |
| 14 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager.h" | 15 #include "chrome/browser/signin/signin_manager.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 20 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 21 #include "google_apis/gaia/gaia_auth_fetcher.h" | 20 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 22 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
| 23 #include "google_apis/gaia/gaia_constants.h" | 22 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 DVLOG(1) << "AccountReconcilor::OnNetworkError: " << account_id_ | 70 DVLOG(1) << "AccountReconcilor::OnNetworkError: " << account_id_ |
| 72 << " response_code=" << response_code; | 71 << " response_code=" << response_code; |
| 73 | 72 |
| 74 // TODO(rogerta): some response error should not be treated like | 73 // TODO(rogerta): some response error should not be treated like |
| 75 // permanent errors. Figure out appropriate ones. | 74 // permanent errors. Figure out appropriate ones. |
| 76 reconcilor_->HandleFailedAccountIdCheck(account_id_); | 75 reconcilor_->HandleFailedAccountIdCheck(account_id_); |
| 77 } | 76 } |
| 78 | 77 |
| 79 AccountReconcilor::AccountReconcilor(Profile* profile) | 78 AccountReconcilor::AccountReconcilor(Profile* profile) |
| 80 : profile_(profile), | 79 : profile_(profile), |
| 80 merge_session_helper_(profile), |
| 81 registered_with_token_service_(false), | 81 registered_with_token_service_(false), |
| 82 are_gaia_accounts_set_(false), | 82 are_gaia_accounts_set_(false), |
| 83 requests_(NULL) { | 83 requests_(NULL) { |
| 84 DVLOG(1) << "AccountReconcilor::AccountReconcilor"; | 84 DVLOG(1) << "AccountReconcilor::AccountReconcilor"; |
| 85 merge_session_helper_.disable_auto_delete_when_done(); |
| 85 RegisterWithSigninManager(); | 86 RegisterWithSigninManager(); |
| 86 RegisterWithCookieMonster(); | 87 RegisterWithCookieMonster(); |
| 87 | 88 |
| 88 // If this profile is not connected, the reconcilor should do nothing but | 89 // If this profile is not connected, the reconcilor should do nothing but |
| 89 // wait for the connection. | 90 // wait for the connection. |
| 90 if (IsProfileConnected()) { | 91 if (IsProfileConnected()) { |
| 91 RegisterWithTokenService(); | 92 RegisterWithTokenService(); |
| 92 StartPeriodicReconciliation(); | 93 StartPeriodicReconciliation(); |
| 93 } | 94 } |
| 94 } | 95 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 230 } |
| 230 | 231 |
| 231 void AccountReconcilor::OnRefreshTokenRevoked(const std::string& account_id) { | 232 void AccountReconcilor::OnRefreshTokenRevoked(const std::string& account_id) { |
| 232 DVLOG(1) << "AccountReconcilor::OnRefreshTokenRevoked: " << account_id; | 233 DVLOG(1) << "AccountReconcilor::OnRefreshTokenRevoked: " << account_id; |
| 233 PerformRemoveAction(account_id); | 234 PerformRemoveAction(account_id); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void AccountReconcilor::OnRefreshTokensLoaded() {} | 237 void AccountReconcilor::OnRefreshTokensLoaded() {} |
| 237 | 238 |
| 238 void AccountReconcilor::PerformMergeAction(const std::string& account_id) { | 239 void AccountReconcilor::PerformMergeAction(const std::string& account_id) { |
| 239 // GoogleAutoLoginHelper deletes itself upon success / failure. | 240 merge_session_helper_.LogIn(account_id); |
| 240 GoogleAutoLoginHelper* helper = new GoogleAutoLoginHelper(profile_); | |
| 241 helper->LogIn(account_id); | |
| 242 } | 241 } |
| 243 | 242 |
| 244 void AccountReconcilor::PerformRemoveAction(const std::string& account_id) { | 243 void AccountReconcilor::PerformRemoveAction(const std::string& account_id) { |
| 245 // TODO(acleung): Implement this: | 244 // TODO(acleung): Implement this: |
| 246 } | 245 } |
| 247 | 246 |
| 248 void AccountReconcilor::StartReconcileAction() { | 247 void AccountReconcilor::StartReconcileAction() { |
| 249 if (!IsProfileConnected()) | 248 if (!IsProfileConnected()) |
| 250 return; | 249 return; |
| 251 | 250 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 const std::string& account_id) { | 390 const std::string& account_id) { |
| 392 valid_chrome_accounts_.insert(account_id); | 391 valid_chrome_accounts_.insert(account_id); |
| 393 FinishReconcileAction(); | 392 FinishReconcileAction(); |
| 394 } | 393 } |
| 395 | 394 |
| 396 void AccountReconcilor::HandleFailedAccountIdCheck( | 395 void AccountReconcilor::HandleFailedAccountIdCheck( |
| 397 const std::string& account_id) { | 396 const std::string& account_id) { |
| 398 invalid_chrome_accounts_.insert(account_id); | 397 invalid_chrome_accounts_.insert(account_id); |
| 399 FinishReconcileAction(); | 398 FinishReconcileAction(); |
| 400 } | 399 } |
| OLD | NEW |