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

Side by Side Diff: chrome/browser/signin/google_auto_login_helper.h

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: rebased Created 7 years 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 #ifndef CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ 6 #define CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "chrome/browser/signin/ubertoken_fetcher.h" 10 #include "chrome/browser/signin/ubertoken_fetcher.h"
11 #include "google_apis/gaia/gaia_auth_consumer.h" 11 #include "google_apis/gaia/gaia_auth_consumer.h"
12 12
13 class GaiaAuthFetcher; 13 class GaiaAuthFetcher;
14 class Profile; 14 class Profile;
15 15
16 // Logs in the current signed in user into Google services. Populates the cookie 16 // Merges a Google account known to Chrome into the cookie jar. Once the
17 // jar with Google credentials of the signed in user. 17 // account is merged, successfully or not, a NOTIFICATION_MERGE_SESSION_COMPLETE
18 // notification is sent out. When mergin multiple accounts, once instance of
guohui 2013/12/18 22:27:10 nit: mergin->merging, once->one
Roger Tawa OOO till Jul 10th 2013/12/19 02:43:42 Done.
19 // the helper is better than multiple instances if there is the possibility
20 // that then run concurrently, since changes to the cookie must be serialized.
guohui 2013/12/18 22:27:10 nit: then->they
Roger Tawa OOO till Jul 10th 2013/12/19 02:43:42 Done.
21 //
22 // By default instances of GoogleAutoLoginHelper delete themselves when done.
18 class GoogleAutoLoginHelper : public GaiaAuthConsumer, 23 class GoogleAutoLoginHelper : public GaiaAuthConsumer,
19 public UbertokenConsumer { 24 public UbertokenConsumer {
20 public: 25 public:
26 struct MergeSessionDetails {
27 MergeSessionDetails(const std::string& account_id,
28 const GoogleServiceAuthError& error);
29
30 std::string account_id;
31 GoogleServiceAuthError error;
32 };
33
21 explicit GoogleAutoLoginHelper(Profile* profile); 34 explicit GoogleAutoLoginHelper(Profile* profile);
22 virtual ~GoogleAutoLoginHelper(); 35 virtual ~GoogleAutoLoginHelper();
23 36
24 void LogIn(); 37 void LogIn();
25 void LogIn(const std::string& account_id); 38 void LogIn(const std::string& account_id);
26 39
40 // Tells this helper to not delete itself when its done with all accounts.
41 void disable_auto_delete_when_done() { auto_delete_when_done_ = false; }
42
43 protected:
44 Profile* profile() { return profile_; }
45
46 // Overridden from UbertokenConsumer.
47 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE;
48 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
49
27 // Overridden from GaiaAuthConsumer. 50 // Overridden from GaiaAuthConsumer.
28 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE; 51 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE;
29 virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) 52 virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error)
30 OVERRIDE; 53 OVERRIDE;
31 54
32 // Overridden from UbertokenConsumer. 55 private:
33 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; 56 // Starts the proess of fetching the uber token and performing a merge session
34 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; 57 // for the next account. Virtual so that it can be overriden in tests.
58 virtual void StartFetching();
35 59
36 // For testing. 60 // Send out notification when merge session completes.
37 virtual UbertokenFetcher* CreateNewUbertokenFetcher(); 61 // Virtual so that it can be overriden in tests.
38 virtual GaiaAuthFetcher* CreateNewGaiaAuthFetcher(); 62 virtual void SignalComplete(const GoogleServiceAuthError& error);
39 63
40 private: 64 // Start the next merge session, if needed.
65 void MergeNextAccount();
66
67 // Delete |this| if the auto delete when done is enabled.
68 void AutoDeleteIfNeeded();
69
41 Profile* profile_; 70 Profile* profile_;
42 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; 71 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
43 scoped_ptr<UbertokenFetcher> uber_token_fetcher_; 72 scoped_ptr<UbertokenFetcher> uber_token_fetcher_;
44 std::deque<std::string> accounts_; 73 std::deque<std::string> accounts_;
74 bool auto_delete_when_done_;
45 75
46 DISALLOW_COPY_AND_ASSIGN(GoogleAutoLoginHelper); 76 DISALLOW_COPY_AND_ASSIGN(GoogleAutoLoginHelper);
47 }; 77 };
48 78
49 #endif // CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ 79 #endif // CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/signin/account_reconcilor.cc ('k') | chrome/browser/signin/google_auto_login_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698