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

Side by Side Diff: chrome/browser/signin/signin_tracker.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/signin_tracker.h" 5 #include "chrome/browser/signin/signin_tracker.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/account_reconcilor_factory.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service.h" 10 #include "chrome/browser/signin/profile_oauth2_token_service.h"
10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
11 #include "chrome/browser/signin/signin_manager.h" 12 #include "chrome/common/profile_management_switches.h"
12 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "content/public/browser/notification_details.h" 13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
15 #include "google_apis/gaia/gaia_constants.h" 15 #include "google_apis/gaia/gaia_constants.h"
16 16
17 #if !defined(OS_CHROMEOS)
18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #endif
21
17 SigninTracker::SigninTracker(Profile* profile, Observer* observer) 22 SigninTracker::SigninTracker(Profile* profile, Observer* observer)
18 : profile_(profile), observer_(observer) { 23 : profile_(profile), observer_(observer) {
19 DCHECK(profile_); 24 DCHECK(profile_);
20 Initialize(); 25 Initialize();
21 } 26 }
22 27
23 SigninTracker::~SigninTracker() { 28 SigninTracker::~SigninTracker() {
24 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> 29 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
25 RemoveObserver(this); 30 RemoveObserver(this);
31
32 if (!switches::IsEnableWebBasedSignin()) {
33 if (switches::IsNewProfileManagement()) {
34 AccountReconcilorFactory::GetForProfile(profile_)->
35 RemoveMergeSessionObserver(this);
36 #if !defined(OS_CHROMEOS)
37 } else {
38 SigninManagerFactory::GetForProfile(profile_)->
39 RemoveMergeSessionObserver(this);
40 #endif
41 }
42 }
26 } 43 }
27 44
28 void SigninTracker::Initialize() { 45 void SigninTracker::Initialize() {
29 DCHECK(observer_); 46 DCHECK(observer_);
30 47
31 // Register for notifications from the SigninManager. 48 // Register for notifications from the SigninManager.
32 registrar_.Add(this, 49 registrar_.Add(this,
33 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, 50 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
34 content::Source<Profile>(profile_)); 51 content::Source<Profile>(profile_));
35 52
36 OAuth2TokenService* token_service = 53 OAuth2TokenService* token_service =
37 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 54 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
38 token_service->AddObserver(this); 55 token_service->AddObserver(this);
39 } 56 }
40 57
41 void SigninTracker::Observe(int type, 58 void SigninTracker::Observe(int type,
42 const content::NotificationSource& source, 59 const content::NotificationSource& source,
43 const content::NotificationDetails& details) { 60 const content::NotificationDetails& details) {
44 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, type); 61 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, type);
45 62
46 // We should not get more than one of these notifications. 63 // We should not get more than one of these notifications.
47 const GoogleServiceAuthError& error = 64 const GoogleServiceAuthError& error =
48 *(content::Details<const GoogleServiceAuthError>(details).ptr()); 65 *(content::Details<const GoogleServiceAuthError>(details).ptr());
49 observer_->SigninFailed(error); 66 observer_->SigninFailed(error);
50 } 67 }
51 68
52 void SigninTracker::OnRefreshTokenAvailable(const std::string& account_id) { 69 void SigninTracker::OnRefreshTokenAvailable(const std::string& account_id) {
53 // TODO: when OAuth2TokenService handles multi-login, this should check 70 // TODO: when OAuth2TokenService handles multi-login, this should check
54 // that |account_id| is the primary account before signalling success. 71 // that |account_id| is the primary account before signalling success.
72 if (!switches::IsEnableWebBasedSignin()) {
73 if (switches::IsNewProfileManagement()) {
74 AccountReconcilorFactory::GetForProfile(profile_)->
75 AddMergeSessionObserver(this);
76 #if !defined(OS_CHROMEOS)
77 } else {
78 SigninManagerFactory::GetForProfile(profile_)->
79 AddMergeSessionObserver(this);
80 #endif
81 }
82 }
83
55 observer_->SigninSuccess(); 84 observer_->SigninSuccess();
56 } 85 }
57 86
58 void SigninTracker::OnRefreshTokenRevoked(const std::string& account_id) { 87 void SigninTracker::OnRefreshTokenRevoked(const std::string& account_id) {
59 NOTREACHED(); 88 NOTREACHED();
60 } 89 }
90
91 void SigninTracker::MergeSessionCompleted(
92 const std::string& account_id,
93 const GoogleServiceAuthError& error) {
94 observer_->MergeSessionComplete(error);
95 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_tracker.h ('k') | chrome/browser/signin/signin_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698