Identity API: web-based scope approval dialogs for getAuthToken
When getAuthToken needs to prompt a user for permissions, it now uses
a web-based authorization flow instead of native dialogs.
BUG=228908
(step #4 of the bug description)
Review URL: https://chromiumcodereview.appspot.com/15148007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200683 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/api/identity/identity_api.h b/chrome/browser/extensions/api/identity/identity_api.h
index 9fb6ddc..ed99871 100644
--- a/chrome/browser/extensions/api/identity/identity_api.h
+++ b/chrome/browser/extensions/api/identity/identity_api.h
@@ -11,23 +11,24 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h"
#include "chrome/browser/extensions/api/identity/identity_mint_queue.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/signin/signin_global_error.h"
#include "google_apis/gaia/oauth2_mint_token_flow.h"
-class GetAuthTokenFunctionTest;
-class MockGetAuthTokenFunction;
class GoogleServiceAuthError;
class Profile;
class SigninManagerBase;
namespace extensions {
+class GetAuthTokenFunctionTest;
+class MockGetAuthTokenFunction;
+
namespace identity_constants {
extern const char kInvalidClientId[];
extern const char kInvalidScopes[];
@@ -58,7 +59,7 @@
// new login token, there is a sign-in flow. If that flow completes
// successfully, getAuthToken proceeds to the non-interactive flow.
class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
- public ExtensionInstallPrompt::Delegate,
+ public GaiaWebAuthFlow::Delegate,
public IdentityMintRequestQueue::Request,
public OAuth2MintTokenFlow::Delegate,
public IdentitySigninFlow::Delegate {
@@ -102,9 +103,12 @@
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;
+ // GaiaWebAuthFlow::Delegate implementation:
+ virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure,
+ GoogleServiceAuthError service_error,
+ const std::string& oauth_error) OVERRIDE;
+ virtual void OnGaiaFlowCompleted(const std::string& access_token,
+ const std::string& expiration) OVERRIDE;
// Starts a mint token request to GAIA.
void StartGaiaRequest(OAuth2MintTokenFlow::Mode mode);
@@ -119,6 +123,10 @@
// Checks if there is a master login token to mint tokens for the extension.
virtual bool HasLoginToken() const;
+ // Maps OAuth2 protocol errors to an error message returned to the
+ // developer in chrome.runtime.lastError.
+ std::string MapOAuth2ErrorToDescription(const std::string& error);
+
bool should_prompt_for_scopes_;
IdentityMintRequestQueue::MintType mint_token_flow_type_;
scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
@@ -128,7 +136,7 @@
// When launched in interactive mode, and if there is no existing grant,
// a permissions prompt will be popped up to the user.
IssueAdviceInfo issue_advice_;
- scoped_ptr<ExtensionInstallPrompt> install_ui_;
+ scoped_ptr<GaiaWebAuthFlow> gaia_web_auth_flow_;
scoped_ptr<IdentitySigninFlow> signin_flow_;
};
@@ -163,6 +171,7 @@
// WebAuthFlow::Delegate implementation.
virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE;
virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE;
+ virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE {}
// Helper to initialize final URL prefix.
void InitFinalRedirectURLPrefix(const std::string& extension_id);