Chromium Code Reviews| Index: chrome/browser/signin/google_auto_login_helper.h |
| diff --git a/chrome/browser/signin/google_auto_login_helper.h b/chrome/browser/signin/google_auto_login_helper.h |
| index 914f49d25bd453006cf8872a7f73d031f9382f08..07d210cd427e274eae781517c53f9809599eeea5 100644 |
| --- a/chrome/browser/signin/google_auto_login_helper.h |
| +++ b/chrome/browser/signin/google_auto_login_helper.h |
| @@ -2,8 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |
| -#define CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |
| +#ifndef CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |
| +#define CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |
| #include <deque> |
| @@ -13,37 +13,67 @@ |
| class GaiaAuthFetcher; |
| class Profile; |
| -// Logs in the current signed in user into Google services. Populates the cookie |
| -// jar with Google credentials of the signed in user. |
| +// Merges a Google account known to Chrome into the cookie jar. Once the |
| +// account is merged, successfully or not, a NOTIFICATION_MERGE_SESSION_COMPLETE |
| +// 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.
|
| +// the helper is better than multiple instances if there is the possibility |
| +// 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.
|
| +// |
| +// By default instances of GoogleAutoLoginHelper delete themselves when done. |
| class GoogleAutoLoginHelper : public GaiaAuthConsumer, |
| public UbertokenConsumer { |
| public: |
| + struct MergeSessionDetails { |
| + MergeSessionDetails(const std::string& account_id, |
| + const GoogleServiceAuthError& error); |
| + |
| + std::string account_id; |
| + GoogleServiceAuthError error; |
| + }; |
| + |
| explicit GoogleAutoLoginHelper(Profile* profile); |
| virtual ~GoogleAutoLoginHelper(); |
| void LogIn(); |
| void LogIn(const std::string& account_id); |
| - // Overridden from GaiaAuthConsumer. |
| - virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE; |
| - virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) |
| - OVERRIDE; |
| + // Tells this helper to not delete itself when its done with all accounts. |
| + void disable_auto_delete_when_done() { auto_delete_when_done_ = false; } |
| + |
| + protected: |
| + Profile* profile() { return profile_; } |
| // Overridden from UbertokenConsumer. |
| virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; |
| virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| - // For testing. |
| - virtual UbertokenFetcher* CreateNewUbertokenFetcher(); |
| - virtual GaiaAuthFetcher* CreateNewGaiaAuthFetcher(); |
| + // Overridden from GaiaAuthConsumer. |
| + virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE; |
| + virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) |
| + OVERRIDE; |
| private: |
| + // Starts the proess of fetching the uber token and performing a merge session |
| + // for the next account. Virtual so that it can be overriden in tests. |
| + virtual void StartFetching(); |
| + |
| + // Send out notification when merge session completes. |
| + // Virtual so that it can be overriden in tests. |
| + virtual void SignalComplete(const GoogleServiceAuthError& error); |
| + |
| + // Start the next merge session, if needed. |
| + void MergeNextAccount(); |
| + |
| + // Delete |this| if the auto delete when done is enabled. |
| + void AutoDeleteIfNeeded(); |
| + |
| Profile* profile_; |
| scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
| scoped_ptr<UbertokenFetcher> uber_token_fetcher_; |
| std::deque<std::string> accounts_; |
| + bool auto_delete_when_done_; |
| DISALLOW_COPY_AND_ASSIGN(GoogleAutoLoginHelper); |
| }; |
| -#endif // CHROME_BROWSER_ANDROID_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |
| +#endif // CHROME_BROWSER_SIGNIN_GOOGLE_AUTO_LOGIN_HELPER_H_ |