| Index: chrome/browser/chromeos/login/oauth_login_manager.h
|
| diff --git a/chrome/browser/chromeos/login/oauth_login_manager.h b/chrome/browser/chromeos/login/oauth_login_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..561e0276c217816efc1ef3ae0ec7738f64866aff
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/login/oauth_login_manager.h
|
| @@ -0,0 +1,95 @@
|
| +// Copyright (c) 2013 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.
|
| +
|
| +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/chromeos/login/oauth2_login_verifier.h"
|
| +#include "chrome/browser/chromeos/login/oauth2_token_fetcher.h"
|
| +#include "content/public/browser/notification_observer.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +
|
| +class GaiaAuthFetcher;
|
| +class GoogleServiceAuthError;
|
| +class Profile;
|
| +class TokenService;
|
| +
|
| +namespace chromeos {
|
| +
|
| +// Observes token change events in TokenService and coordinates appropriate
|
| +// response from ChromeOS login flow.
|
| +class OAuthLoginManager : public content::NotificationObserver,
|
| + public OAuth2LoginVerifier::Delegate,
|
| + public OAuth2TokenFetcher::Delegate {
|
| + public:
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| + // Raised when cookie jar authentication is successfully completed.
|
| + virtual void OnCompletedAuthentication(Profile* user_profile) = 0;
|
| + };
|
| +
|
| + OAuthLoginManager(Delegate* delegate,
|
| + Profile* user_profile,
|
| + Profile* auth_profile,
|
| + bool has_web_auth_cookies);
|
| +
|
| + // Restores and verified OAuth tokens either from TokenService or
|
| + void RestoreOAuth2Tokens();
|
| +
|
| + 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;
|
| +
|
| + // OAuth2TokenFetcher::Delegate overrides.
|
| + virtual void OnOAuth2TokenAvailable(
|
| + const GaiaAuthConsumer::ClientLoginResult& gaia_credentials,
|
| + const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) OVERRIDE;
|
| + virtual void OnOAuth2TokenFetchFailed() OVERRIDE;
|
| +
|
| +
|
| + // Retrieves TokenService for |user_profile_| and sets up notification
|
| + // observer events.
|
| + TokenService* SetupTokenService();
|
| + // Loads previously stored OAuth2 tokens and kicks off its validation.
|
| + void LoadAndVerifyOAuth2Tokens();
|
| + // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from
|
| + // provided |auth_profile|.
|
| + void FetchOAuth2Tokens();
|
| + // Reports when all tokens are loaded.
|
| + void ReportTokenLoaded();
|
| + // Issue GAIA cookie recovery (MergeSession) from |uber_token_|.
|
| + void RestoreSessionCookies();
|
| + // Checks GAIA error and figures out whether the request should be
|
| + // re-attempted.
|
| + bool RetryOnError(const GoogleServiceAuthError& error);
|
| +
|
| + Delegate* delegate_;
|
| + Profile* user_profile_;
|
| + Profile* auth_profile_;
|
| + bool has_web_auth_cookies_;
|
| + // 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<OAuth2TokenFetcher> oauth2_token_fetcher_;
|
| + scoped_ptr<OAuth2LoginVerifier> login_verifier_;
|
| + std::string refresh_token_;
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
|
|
|