Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/extensions/api/identity/experimental_identity_api.h

Issue 17009016: Wire up the identity API for enterprise Kiosk Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/api/identity/experimental_web_auth_flow.h" 13 #include "chrome/browser/extensions/api/identity/experimental_web_auth_flow.h"
14 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h" 14 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h"
15 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h" 15 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
16 #include "chrome/browser/extensions/extension_function.h" 16 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/extensions/extension_install_prompt.h" 17 #include "chrome/browser/extensions/extension_install_prompt.h"
18 #include "chrome/browser/signin/oauth2_token_service.h"
18 #include "google_apis/gaia/oauth2_mint_token_flow.h" 19 #include "google_apis/gaia/oauth2_mint_token_flow.h"
19 20
20 namespace extensions { 21 namespace extensions {
21 22
22 // TODO(courage): These functions exist to support some apps that were 23 // TODO(courage): These functions exist to support some apps that were
23 // whitelisted to use the experimental API. Remove them once those 24 // whitelisted to use the experimental API. Remove them once those
24 // apps have migrated. 25 // apps have migrated.
25 26
26 // experimental.identity.getAuthToken fetches an OAuth 2 function for 27 // experimental.identity.getAuthToken fetches an OAuth 2 function for
27 // the caller. The request has three sub-flows: non-interactive, 28 // the caller. The request has three sub-flows: non-interactive,
28 // interactive, and sign-in. 29 // interactive, and sign-in.
29 // 30 //
30 // In the non-interactive flow, getAuthToken requests a token from 31 // In the non-interactive flow, getAuthToken requests a token from
31 // GAIA. GAIA may respond with a token, an error, or "consent 32 // GAIA. GAIA may respond with a token, an error, or "consent
32 // required". In the consent required cases, getAuthToken proceeds to 33 // required". In the consent required cases, getAuthToken proceeds to
33 // the second, interactive phase. 34 // the second, interactive phase.
34 // 35 //
35 // The interactive flow presents a scope approval dialog to the 36 // The interactive flow presents a scope approval dialog to the
36 // user. If the user approves the request, a grant will be recorded on 37 // user. If the user approves the request, a grant will be recorded on
37 // the server, and an access token will be returned to the caller. 38 // the server, and an access token will be returned to the caller.
38 // 39 //
39 // In some cases we need to display a sign-in dialog. Normally the 40 // In some cases we need to display a sign-in dialog. Normally the
40 // profile will be signed in already, but if it turns out we need a 41 // profile will be signed in already, but if it turns out we need a
41 // new login token, there is a sign-in flow. If that flow completes 42 // new login token, there is a sign-in flow. If that flow completes
42 // successfully, getAuthToken proceeds to the non-interactive flow. 43 // successfully, getAuthToken proceeds to the non-interactive flow.
43 class ExperimentalIdentityGetAuthTokenFunction 44 class ExperimentalIdentityGetAuthTokenFunction
44 : public AsyncExtensionFunction, 45 : public AsyncExtensionFunction,
45 public ExtensionInstallPrompt::Delegate, 46 public ExtensionInstallPrompt::Delegate,
46 public OAuth2MintTokenFlow::Delegate, 47 public OAuth2MintTokenFlow::Delegate,
47 public IdentitySigninFlow::Delegate { 48 public IdentitySigninFlow::Delegate,
49 public OAuth2TokenService::Consumer {
Michael Courage 2013/06/20 00:19:42 chrome.experimental.identity is only around for a
Mattias Nissler (ping if slow) 2013/06/21 02:44:46 OK, reverted the experimental changes.
48 public: 50 public:
49 DECLARE_EXTENSION_FUNCTION("experimental.identity.getAuthToken", 51 DECLARE_EXTENSION_FUNCTION("experimental.identity.getAuthToken",
50 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN); 52 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN);
51 53
52 ExperimentalIdentityGetAuthTokenFunction(); 54 ExperimentalIdentityGetAuthTokenFunction();
53 virtual bool RunImpl() OVERRIDE; 55 virtual bool RunImpl() OVERRIDE;
54 56
55 protected: 57 protected:
56 virtual ~ExperimentalIdentityGetAuthTokenFunction(); 58 virtual ~ExperimentalIdentityGetAuthTokenFunction();
57 59
(...skipping 18 matching lines...) Expand all
76 const IssueAdviceInfo& issue_advice) OVERRIDE; 78 const IssueAdviceInfo& issue_advice) OVERRIDE;
77 79
78 // IdentitySigninFlow::Delegate implementation: 80 // IdentitySigninFlow::Delegate implementation:
79 virtual void SigninSuccess(const std::string& token) OVERRIDE; 81 virtual void SigninSuccess(const std::string& token) OVERRIDE;
80 virtual void SigninFailed() OVERRIDE; 82 virtual void SigninFailed() OVERRIDE;
81 83
82 // ExtensionInstallPrompt::Delegate implementation: 84 // ExtensionInstallPrompt::Delegate implementation:
83 virtual void InstallUIProceed() OVERRIDE; 85 virtual void InstallUIProceed() OVERRIDE;
84 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 86 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
85 87
88 // OAuth2TokenService::Consumer implementation:
89 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
90 const std::string& access_token,
91 const base::Time& expiration_time) OVERRIDE;
92 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
93 const GoogleServiceAuthError& error) OVERRIDE;
94
86 // Starts a mint token request to GAIA. 95 // Starts a mint token request to GAIA.
87 void StartGaiaRequest(OAuth2MintTokenFlow::Mode mode); 96 void StartGaiaRequest(OAuth2MintTokenFlow::Mode mode);
88 97
89 // Methods for invoking UI. Overridable for testing. 98 // Methods for invoking UI. Overridable for testing.
90 virtual void ShowLoginPopup(); 99 virtual void ShowLoginPopup();
91 virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice); 100 virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice);
92 // Caller owns the returned instance. 101 // Caller owns the returned instance.
93 virtual OAuth2MintTokenFlow* CreateMintTokenFlow( 102 virtual OAuth2MintTokenFlow* CreateMintTokenFlow(
94 OAuth2MintTokenFlow::Mode mode); 103 OAuth2MintTokenFlow::Mode mode);
95 104
96 // Checks if there is a master login token to mint tokens for the extension. 105 // Checks if there is a master login token to mint tokens for the extension.
97 virtual bool HasLoginToken() const; 106 virtual bool HasLoginToken() const;
98 107
99 bool should_prompt_for_scopes_; 108 bool should_prompt_for_scopes_;
100 scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_; 109 scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
101 std::string refresh_token_; 110 std::string refresh_token_;
102 bool should_prompt_for_signin_; 111 bool should_prompt_for_signin_;
103 112
104 // When launched in interactive mode, and if there is no existing grant, 113 // When launched in interactive mode, and if there is no existing grant,
105 // a permissions prompt will be popped up to the user. 114 // a permissions prompt will be popped up to the user.
106 IssueAdviceInfo issue_advice_; 115 IssueAdviceInfo issue_advice_;
107 scoped_ptr<ExtensionInstallPrompt> install_ui_; 116 scoped_ptr<ExtensionInstallPrompt> install_ui_;
108 scoped_ptr<IdentitySigninFlow> signin_flow_; 117 scoped_ptr<IdentitySigninFlow> signin_flow_;
118 scoped_ptr<OAuth2TokenService::Request> device_token_request_;
109 }; 119 };
110 120
111 class ExperimentalIdentityLaunchWebAuthFlowFunction 121 class ExperimentalIdentityLaunchWebAuthFlowFunction
112 : public AsyncExtensionFunction, 122 : public AsyncExtensionFunction,
113 public ExperimentalWebAuthFlow::Delegate { 123 public ExperimentalWebAuthFlow::Delegate {
114 public: 124 public:
115 DECLARE_EXTENSION_FUNCTION("experimental.identity.launchWebAuthFlow", 125 DECLARE_EXTENSION_FUNCTION("experimental.identity.launchWebAuthFlow",
116 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); 126 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW);
117 ExperimentalIdentityLaunchWebAuthFlowFunction(); 127 ExperimentalIdentityLaunchWebAuthFlowFunction();
118 128
(...skipping 17 matching lines...) Expand all
136 private: 146 private:
137 // ExperimentalWebAuthFlow::Delegate implementation. 147 // ExperimentalWebAuthFlow::Delegate implementation.
138 virtual void OnAuthFlowFailure(ExperimentalWebAuthFlow::Failure failure) 148 virtual void OnAuthFlowFailure(ExperimentalWebAuthFlow::Failure failure)
139 OVERRIDE; 149 OVERRIDE;
140 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; 150 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE;
141 }; 151 };
142 152
143 } // namespace extensions 153 } // namespace extensions
144 154
145 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ 155 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698