Chromium Code Reviews| 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..02ef8fe27c6db6be1781297860ab2ac5475f9ffb 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. |
| @@ -88,10 +83,13 @@ class IdentityGetAuthTokenFunction : public AsyncExtensionFunction, |
| bool interactive_; |
| scoped_ptr<OAuth2MintTokenFlow> flow_; |
|
Pete Williamson
2013/03/27 18:03:55
Since we have multiple flows, it might be nice to
Michael Courage
2013/03/27 18:40:11
Done.
|
| + std::string refresh_token_; |
| + bool should_retry_with_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_ |