Index: chrome/browser/extensions/api/identity/identity_api.h |
=================================================================== |
--- chrome/browser/extensions/api/identity/identity_api.h (revision 147566) |
+++ chrome/browser/extensions/api/identity/identity_api.h (working copy) |
@@ -13,39 +13,77 @@ |
#include "chrome/browser/extensions/app_notify_channel_setup.h" |
#include "chrome/browser/extensions/extension_install_prompt.h" |
#include "chrome/browser/extensions/extension_function.h" |
+#include "chrome/browser/ui/webui/signin/login_ui_service.h" |
#include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
+class GetAuthTokenFunctionTest; |
+class MockGetAuthTokenFunction; |
class GoogleServiceAuthError; |
namespace extensions { |
class IdentityGetAuthTokenFunction : public AsyncExtensionFunction, |
public OAuth2MintTokenFlow::Delegate, |
- public ExtensionInstallPrompt::Delegate { |
+ public ExtensionInstallPrompt::Delegate, |
+ public LoginUIService::Observer { |
public: |
DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); |
IdentityGetAuthTokenFunction(); |
- private: |
+ static const char kInvalidClientId[]; |
+ static const char kInvalidScopes[]; |
+ static const char kAuthFailure[]; |
+ static const char kNoGrant[]; |
+ static const char kUserRejected[]; |
+ static const char kUserNotSignedIn[]; |
+ |
+ protected: |
virtual ~IdentityGetAuthTokenFunction(); |
+ private: |
+ friend class ::GetAuthTokenFunctionTest; |
+ friend class ::MockGetAuthTokenFunction; |
+ |
// ExtensionFunction: |
virtual bool RunImpl() OVERRIDE; |
// OAuth2MintTokenFlow::Delegate implementation: |
virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; |
- virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
+ virtual void OnMintTokenFailure( |
+ const GoogleServiceAuthError& error) OVERRIDE; |
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; |
+ |
// 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); |
+ virtual void StartObservingLoginService(); |
+ virtual void StopObservingLoginService(); |
+ virtual void ShowLoginPopup(); |
+ virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice); |
+ // Caller owns the returned instance. |
+ virtual OAuth2MintTokenFlow* CreateMintTokenFlow( |
+ OAuth2MintTokenFlow::Mode mode); |
+ |
+ // Checks if there is a master login token to mint tokens for the extension. |
+ virtual bool HasLoginToken() const; |
+ |
+ // Gets the token mint flow mode based on a command-line flag. |
+ OAuth2MintTokenFlow::Mode GetTokenFlowMode() const; |
+ |
bool interactive_; |
scoped_ptr<OAuth2MintTokenFlow> flow_; |
@@ -59,6 +97,8 @@ |
public: |
DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.launchWebAuthFlow"); |
+ static const char kInvalidRedirect[]; |
+ |
IdentityLaunchWebAuthFlowFunction(); |
private: |