| Index: chrome/browser/extensions/api/identity/identity_api.h
|
| diff --git a/chrome/browser/extensions/api/identity/identity_api.h b/chrome/browser/extensions/api/identity/identity_api.h
|
| index 80b6cac2a7def2c6761cbbaea710e0ed8561ce9d..03e041b517eee73c30ad26715d7b74845a973d11 100644
|
| --- a/chrome/browser/extensions/api/identity/identity_api.h
|
| +++ b/chrome/browser/extensions/api/identity/identity_api.h
|
| @@ -9,11 +9,12 @@
|
|
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
|
| #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
|
| #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
|
| #include "chrome/browser/extensions/extension_function.h"
|
| #include "chrome/browser/extensions/extension_install_prompt.h"
|
| -#include "chrome/browser/ui/webui/signin/login_ui_service.h"
|
| +#include "chrome/browser/signin/signin_global_error.h"
|
| #include "google_apis/gaia/oauth2_mint_token_flow.h"
|
|
|
| class GetAuthTokenFunctionTest;
|
| @@ -36,7 +37,7 @@ extern const char kInvalidRedirect[];
|
| class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
|
| public OAuth2MintTokenFlow::Delegate,
|
| public ExtensionInstallPrompt::Delegate,
|
| - public LoginUIService::Observer {
|
| + public IdentitySigninFlow::Delegate {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("experimental.identity.getAuthToken",
|
| EXPERIMENTAL_IDENTITY_GETAUTHTOKEN)
|
| @@ -60,23 +61,17 @@ class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
|
| virtual void OnIssueAdviceSuccess(
|
| const IssueAdviceInfo& issue_advice) OVERRIDE;
|
|
|
| - // LoginUIService::Observer implementation.
|
| - virtual void OnLoginUIShown(LoginUIService::LoginUI* ui) OVERRIDE {
|
| - // Do nothing when login ui is shown.
|
| - }
|
| - virtual void OnLoginUIClosed(LoginUIService::LoginUI* ui) OVERRIDE;
|
| + // IdentitySigninFlow::Delegate implementation:
|
| + virtual void SigninSuccess(const std::string& token) OVERRIDE;
|
| + virtual void SigninFailed() OVERRIDE;
|
|
|
| // ExtensionInstallPrompt::Delegate implementation:
|
| virtual void InstallUIProceed() OVERRIDE;
|
| virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
|
|
|
| - // Shows the login UI in a browser popup.
|
| - bool StartLogin();
|
| - // Starts a MintTokenFlow with the given mode; Returns success.
|
| - bool StartFlow(OAuth2MintTokenFlow::Mode mode);
|
| + // Starts a MintTokenFlow with the given mode.
|
| + void StartFlow(OAuth2MintTokenFlow::Mode mode);
|
|
|
| - virtual void StartObservingLoginService();
|
| - virtual void StopObservingLoginService();
|
| virtual void ShowLoginPopup();
|
| virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice);
|
| // Caller owns the returned instance.
|
| @@ -86,12 +81,15 @@ class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
|
| // Checks if there is a master login token to mint tokens for the extension.
|
| virtual bool HasLoginToken() const;
|
|
|
| - bool interactive_;
|
| - scoped_ptr<OAuth2MintTokenFlow> flow_;
|
| + bool should_prompt_for_scopes_;
|
| + scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
|
| + std::string refresh_token_;
|
| + bool should_prompt_for_signin_;
|
|
|
| // When launched in interactive mode, and if there is no existing grant,
|
| // a permissions prompt will be popped up to the user.
|
| scoped_ptr<ExtensionInstallPrompt> install_ui_;
|
| + scoped_ptr<IdentitySigninFlow> signin_flow_;
|
| };
|
|
|
| class IdentityLaunchWebAuthFlowFunction : public AsyncExtensionFunction,
|
| @@ -113,14 +111,28 @@ class IdentityLaunchWebAuthFlowFunction : public AsyncExtensionFunction,
|
| scoped_ptr<WebAuthFlow> auth_flow_;
|
| };
|
|
|
| -class IdentityAPI : public ProfileKeyedAPI {
|
| +class IdentityAPI : public ProfileKeyedAPI,
|
| + public SigninGlobalError::AuthStatusProvider,
|
| + public content::NotificationObserver {
|
| public:
|
| explicit IdentityAPI(Profile* profile);
|
| virtual ~IdentityAPI();
|
| + void Initialize();
|
| +
|
| + void ReportAuthError(const GoogleServiceAuthError& error);
|
|
|
| // ProfileKeyedAPI implementation.
|
| + virtual void Shutdown() OVERRIDE;
|
| static ProfileKeyedAPIFactory<IdentityAPI>* GetFactoryInstance();
|
|
|
| + // AuthStatusProvider implementation.
|
| + virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
|
| +
|
| + // content::NotificationObserver implementation.
|
| + virtual void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) OVERRIDE;
|
| +
|
| private:
|
| friend class ProfileKeyedAPIFactory<IdentityAPI>;
|
|
|
| @@ -129,8 +141,17 @@ class IdentityAPI : public ProfileKeyedAPI {
|
| return "IdentityAPI";
|
| }
|
| static const bool kServiceIsNULLWhileTesting = true;
|
| +
|
| + Profile* profile_;
|
| + SigninManager* signin_manager_;
|
| + GoogleServiceAuthError error_;
|
| + // Used to listen to notifications from the TokenService.
|
| + content::NotificationRegistrar registrar_;
|
| };
|
|
|
| +template <>
|
| +void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies();
|
| +
|
| } // namespace extensions
|
|
|
| #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
|
|
|