Chromium Code Reviews| Index: chrome/browser/chromeos/login/login_manager.h |
| diff --git a/chrome/browser/chromeos/login/login_manager.h b/chrome/browser/chromeos/login/login_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..04458e738d52bac6759d026ebafba47f2691f1fa |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/login_manager.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
|
xiyuan
2013/01/07 23:07:55
nit: insert an empty line
zel
2013/01/08 02:05:41
Done.
|
| +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/chromeos/login/oauth2_login_verifier.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| + |
| +class GaiaAuthFetcher; |
| +class GoogleServiceAuthError; |
| +class Profile; |
| + |
| +namespace chromeos { |
| + |
| +// Observes token change events in TokenService and coordinates appropriate |
| +// response from ChromeOS login flow. |
| +class LoginManager : public base::SupportsWeakPtr<LoginManager>, |
|
xiyuan
2013/01/07 23:07:55
It seems we never get a weak ptr of the LoginManag
zel
2013/01/08 02:05:41
Done.
zel
2013/01/08 02:05:41
I've called it TokenServiceObserver originally, bu
|
| + public content::NotificationObserver, |
| + public OAuth2LoginVerifier::Delegate { |
| + public: |
| + class Delegate { |
| + public: |
| + virtual ~Delegate() {} |
| + // Reports when tokens are loaded from the database. |
|
xiyuan
2013/01/07 23:07:55
nit: alignment
zel
2013/01/08 02:05:41
Done.
|
| + virtual void OnOAuth2RefreshTokenLoaded( |
| + Profile* profile, |
| + const std::string& oauth2_refresh_token) = 0; |
| + // Reports when key auth-related tokens failed to be fetched. |
| + virtual void OnOAuth2RefreshTokenFetchFailed( |
| + Profile* profile, const std::string& service) = 0; |
| + // Reports when GAIA cookies have been successfully restored in the cookie |
| + // jar of the |profile| (through /MergeSession GAIA call). |
| + virtual void OnCookiesRestoreSuccess(Profile* profile) = 0; |
| + // Reports when GAIA cookies have been successfully restored in the cookie |
| + // jar of the |profile| (through /MergeSession GAIA call). |
| + virtual void OnCookiesRestoreFailure(Profile* profile) = 0; |
| + }; |
| + |
| + LoginManager(Delegate* delegate, Profile* user_profile); |
| + |
| + private: |
| + // content::NotificationObserver overrides. |
| + void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + // OAuth2LoginVerifier::Delegate overrides. |
| + virtual void OnOAuth2LoginVerifierSuccess(const std::string& sid, |
| + const std::string& lsid, |
| + const std::string& auth) OVERRIDE; |
| + virtual void OnOAuth2LoginVerifierFaulure() OVERRIDE; |
| + |
| + // Reports when all tokens are loaded. |
| + void ReportTokenLoaded(); |
| + // Issue GAIA cookie recovery (MergeSession) from |uber_token_|. |
| + void RestoreSessionCookies(); |
| + // Checks GAIA error and figures out of the request should be reattempted |
|
xiyuan
2013/01/07 23:07:55
nit: Checks GAIA error and figures out whether the
zel
2013/01/08 02:05:41
Done.
|
| + // |
| + bool RetryOnError(const GoogleServiceAuthError& error); |
| + |
| + Delegate* delegate_; |
| + Profile* user_profile_; |
| + // Keeps the track if we have already reported OAuth2 token being loaded |
| + // by TokenService. |
| + bool loading_reported_; |
| + int restore_attempt_count_; |
| + content::NotificationRegistrar registrar_; |
| + scoped_ptr<OAuth2LoginVerifier> login_verifier_; |
| + std::string refresh_token_; |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_H_ |