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

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

Issue 110373007: Delay loading the NTP after sign in until MergeSession has been performed in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in chromeos 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
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/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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 : OAuth2TokenService::Consumer("account_reconcilor"), 79 : OAuth2TokenService::Consumer("account_reconcilor"),
81 profile_(profile), 80 profile_(profile),
81 merge_session_helper_(profile, NULL),
82 registered_with_token_service_(false), 82 registered_with_token_service_(false),
83 are_gaia_accounts_set_(false), 83 are_gaia_accounts_set_(false),requests_(NULL) {
84 requests_(NULL) {
85 DVLOG(1) << "AccountReconcilor::AccountReconcilor"; 84 DVLOG(1) << "AccountReconcilor::AccountReconcilor";
86 RegisterWithSigninManager(); 85 RegisterWithSigninManager();
87 RegisterWithCookieMonster(); 86 RegisterWithCookieMonster();
88 87
89 // If this profile is not connected, the reconcilor should do nothing but 88 // If this profile is not connected, the reconcilor should do nothing but
90 // wait for the connection. 89 // wait for the connection.
91 if (IsProfileConnected()) { 90 if (IsProfileConnected()) {
92 RegisterWithTokenService(); 91 RegisterWithTokenService();
93 StartPeriodicReconciliation(); 92 StartPeriodicReconciliation();
94 } 93 }
95 } 94 }
96 95
97 AccountReconcilor::~AccountReconcilor() { 96 AccountReconcilor::~AccountReconcilor() {
98 // Make sure shutdown was called first. 97 // Make sure shutdown was called first.
99 DCHECK(!registered_with_token_service_); 98 DCHECK(!registered_with_token_service_);
100 DCHECK(registrar_.IsEmpty()); 99 DCHECK(registrar_.IsEmpty());
101 DCHECK(!reconciliation_timer_.IsRunning()); 100 DCHECK(!reconciliation_timer_.IsRunning());
102 DCHECK(!requests_); 101 DCHECK(!requests_);
103 DCHECK_EQ(0u, user_id_fetchers_.size()); 102 DCHECK_EQ(0u, user_id_fetchers_.size());
104 } 103 }
105 104
106 void AccountReconcilor::Shutdown() { 105 void AccountReconcilor::Shutdown() {
107 DVLOG(1) << "AccountReconcilor::Shutdown"; 106 DVLOG(1) << "AccountReconcilor::Shutdown";
107 merge_session_helper_.CancelAll();
108 DeleteAccessTokenRequestsAndUserIdFetchers(); 108 DeleteAccessTokenRequestsAndUserIdFetchers();
109 UnregisterWithSigninManager(); 109 UnregisterWithSigninManager();
110 UnregisterWithTokenService(); 110 UnregisterWithTokenService();
111 UnregisterWithCookieMonster(); 111 UnregisterWithCookieMonster();
112 StopPeriodicReconciliation(); 112 StopPeriodicReconciliation();
113 } 113 }
114 114
115 void AccountReconcilor::AddMergeSessionObserver(
116 GoogleAutoLoginHelper::Observer* observer) {
117 merge_session_helper_.AddObserver(observer);
118 }
119
120 void AccountReconcilor::RemoveMergeSessionObserver(
121 GoogleAutoLoginHelper::Observer* observer) {
122 merge_session_helper_.RemoveObserver(observer);
123 }
124
115 void AccountReconcilor::DeleteAccessTokenRequestsAndUserIdFetchers() { 125 void AccountReconcilor::DeleteAccessTokenRequestsAndUserIdFetchers() {
116 delete[] requests_; 126 delete[] requests_;
117 requests_ = NULL; 127 requests_ = NULL;
118 128
119 user_id_fetchers_.clear(); 129 user_id_fetchers_.clear();
120 } 130 }
121 131
122 bool AccountReconcilor::AreAllRefreshTokensChecked() const { 132 bool AccountReconcilor::AreAllRefreshTokensChecked() const {
123 return chrome_accounts_.size() == 133 return chrome_accounts_.size() ==
124 (valid_chrome_accounts_.size() + invalid_chrome_accounts_.size()); 134 (valid_chrome_accounts_.size() + invalid_chrome_accounts_.size());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 240 }
231 241
232 void AccountReconcilor::OnRefreshTokenRevoked(const std::string& account_id) { 242 void AccountReconcilor::OnRefreshTokenRevoked(const std::string& account_id) {
233 DVLOG(1) << "AccountReconcilor::OnRefreshTokenRevoked: " << account_id; 243 DVLOG(1) << "AccountReconcilor::OnRefreshTokenRevoked: " << account_id;
234 PerformRemoveAction(account_id); 244 PerformRemoveAction(account_id);
235 } 245 }
236 246
237 void AccountReconcilor::OnRefreshTokensLoaded() {} 247 void AccountReconcilor::OnRefreshTokensLoaded() {}
238 248
239 void AccountReconcilor::PerformMergeAction(const std::string& account_id) { 249 void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
240 // GoogleAutoLoginHelper deletes itself upon success / failure. 250 merge_session_helper_.LogIn(account_id);
241 GoogleAutoLoginHelper* helper = new GoogleAutoLoginHelper(profile_);
242 helper->LogIn(account_id);
243 } 251 }
244 252
245 void AccountReconcilor::PerformRemoveAction(const std::string& account_id) { 253 void AccountReconcilor::PerformRemoveAction(const std::string& account_id) {
246 // TODO(acleung): Implement this: 254 // TODO(acleung): Implement this:
247 } 255 }
248 256
249 void AccountReconcilor::StartReconcileAction() { 257 void AccountReconcilor::StartReconcileAction() {
250 if (!IsProfileConnected()) 258 if (!IsProfileConnected())
251 return; 259 return;
252 260
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 const std::string& account_id) { 400 const std::string& account_id) {
393 valid_chrome_accounts_.insert(account_id); 401 valid_chrome_accounts_.insert(account_id);
394 FinishReconcileAction(); 402 FinishReconcileAction();
395 } 403 }
396 404
397 void AccountReconcilor::HandleFailedAccountIdCheck( 405 void AccountReconcilor::HandleFailedAccountIdCheck(
398 const std::string& account_id) { 406 const std::string& account_id) {
399 invalid_chrome_accounts_.insert(account_id); 407 invalid_chrome_accounts_.insert(account_id);
400 FinishReconcileAction(); 408 FinishReconcileAction();
401 } 409 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/account_reconcilor.h ('k') | chrome/browser/signin/account_reconcilor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698