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

Side by Side Diff: chrome/browser/extensions/api/identity/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: Stop mint queue request on completion. 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IDENTITY_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" 16 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h"
17 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h" 17 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h"
18 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h" 18 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h"
19 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" 19 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
20 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 20 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
21 #include "chrome/browser/extensions/extension_function.h" 21 #include "chrome/browser/extensions/extension_function.h"
22 #include "chrome/browser/signin/oauth2_token_service.h"
22 #include "chrome/browser/signin/signin_global_error.h" 23 #include "chrome/browser/signin/signin_global_error.h"
23 #include "google_apis/gaia/oauth2_mint_token_flow.h" 24 #include "google_apis/gaia/oauth2_mint_token_flow.h"
24 25
25 class GoogleServiceAuthError; 26 class GoogleServiceAuthError;
27 class MockGetAuthTokenFunction;
26 class Profile; 28 class Profile;
27 class SigninManagerBase; 29 class SigninManagerBase;
28 30
29 namespace extensions { 31 namespace extensions {
30 32
31 class GetAuthTokenFunctionTest; 33 class GetAuthTokenFunctionTest;
32 class MockGetAuthTokenFunction; 34 class MockGetAuthTokenFunction;
33 35
34 namespace identity_constants { 36 namespace identity_constants {
35 extern const char kInvalidClientId[]; 37 extern const char kInvalidClientId[];
(...skipping 22 matching lines...) Expand all
58 // the server, and an access token will be returned to the caller. 60 // the server, and an access token will be returned to the caller.
59 // 61 //
60 // In some cases we need to display a sign-in dialog. Normally the 62 // In some cases we need to display a sign-in dialog. Normally the
61 // profile will be signed in already, but if it turns out we need a 63 // profile will be signed in already, but if it turns out we need a
62 // new login token, there is a sign-in flow. If that flow completes 64 // new login token, there is a sign-in flow. If that flow completes
63 // successfully, getAuthToken proceeds to the non-interactive flow. 65 // successfully, getAuthToken proceeds to the non-interactive flow.
64 class IdentityGetAuthTokenFunction : public AsyncExtensionFunction, 66 class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
65 public GaiaWebAuthFlow::Delegate, 67 public GaiaWebAuthFlow::Delegate,
66 public IdentityMintRequestQueue::Request, 68 public IdentityMintRequestQueue::Request,
67 public OAuth2MintTokenFlow::Delegate, 69 public OAuth2MintTokenFlow::Delegate,
68 public IdentitySigninFlow::Delegate { 70 public IdentitySigninFlow::Delegate,
71 public OAuth2TokenService::Consumer {
69 public: 72 public:
70 DECLARE_EXTENSION_FUNCTION("identity.getAuthToken", 73 DECLARE_EXTENSION_FUNCTION("identity.getAuthToken",
71 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN); 74 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN);
72 75
73 IdentityGetAuthTokenFunction(); 76 IdentityGetAuthTokenFunction();
74 77
75 protected: 78 protected:
76 virtual ~IdentityGetAuthTokenFunction(); 79 virtual ~IdentityGetAuthTokenFunction();
77 80
78 private: 81 private:
(...skipping 30 matching lines...) Expand all
109 virtual void SigninSuccess(const std::string& token) OVERRIDE; 112 virtual void SigninSuccess(const std::string& token) OVERRIDE;
110 virtual void SigninFailed() OVERRIDE; 113 virtual void SigninFailed() OVERRIDE;
111 114
112 // GaiaWebAuthFlow::Delegate implementation: 115 // GaiaWebAuthFlow::Delegate implementation:
113 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure, 116 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure,
114 GoogleServiceAuthError service_error, 117 GoogleServiceAuthError service_error,
115 const std::string& oauth_error) OVERRIDE; 118 const std::string& oauth_error) OVERRIDE;
116 virtual void OnGaiaFlowCompleted(const std::string& access_token, 119 virtual void OnGaiaFlowCompleted(const std::string& access_token,
117 const std::string& expiration) OVERRIDE; 120 const std::string& expiration) OVERRIDE;
118 121
122 // OAuth2TokenService::Consumer implementation:
123 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
124 const std::string& access_token,
125 const base::Time& expiration_time) OVERRIDE;
126 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
127 const GoogleServiceAuthError& error) OVERRIDE;
128
119 // Starts a mint token request to GAIA. 129 // Starts a mint token request to GAIA.
120 void StartGaiaRequest(OAuth2MintTokenFlow::Mode mode); 130 void StartGaiaRequest(OAuth2MintTokenFlow::Mode mode);
121 131
122 // Methods for invoking UI. Overridable for testing. 132 // Methods for invoking UI. Overridable for testing.
123 virtual void ShowLoginPopup(); 133 virtual void ShowLoginPopup();
124 virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice); 134 virtual void ShowOAuthApprovalDialog(const IssueAdviceInfo& issue_advice);
125 // Caller owns the returned instance. 135 // Caller owns the returned instance.
126 virtual OAuth2MintTokenFlow* CreateMintTokenFlow( 136 virtual OAuth2MintTokenFlow* CreateMintTokenFlow(
127 OAuth2MintTokenFlow::Mode mode); 137 OAuth2MintTokenFlow::Mode mode);
128 138
(...skipping 11 matching lines...) Expand all
140 scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_; 150 scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
141 std::string refresh_token_; 151 std::string refresh_token_;
142 bool should_prompt_for_signin_; 152 bool should_prompt_for_signin_;
143 153
144 std::string oauth2_client_id_; 154 std::string oauth2_client_id_;
145 // When launched in interactive mode, and if there is no existing grant, 155 // When launched in interactive mode, and if there is no existing grant,
146 // a permissions prompt will be popped up to the user. 156 // a permissions prompt will be popped up to the user.
147 IssueAdviceInfo issue_advice_; 157 IssueAdviceInfo issue_advice_;
148 scoped_ptr<GaiaWebAuthFlow> gaia_web_auth_flow_; 158 scoped_ptr<GaiaWebAuthFlow> gaia_web_auth_flow_;
149 scoped_ptr<IdentitySigninFlow> signin_flow_; 159 scoped_ptr<IdentitySigninFlow> signin_flow_;
160 scoped_ptr<OAuth2TokenService::Request> device_token_request_;
150 }; 161 };
151 162
152 class IdentityRemoveCachedAuthTokenFunction : public SyncExtensionFunction { 163 class IdentityRemoveCachedAuthTokenFunction : public SyncExtensionFunction {
153 public: 164 public:
154 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", 165 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken",
155 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) 166 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN)
156 IdentityRemoveCachedAuthTokenFunction(); 167 IdentityRemoveCachedAuthTokenFunction();
157 168
158 protected: 169 protected:
159 virtual ~IdentityRemoveCachedAuthTokenFunction(); 170 virtual ~IdentityRemoveCachedAuthTokenFunction();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 IdentityMintRequestQueue mint_queue_; 295 IdentityMintRequestQueue mint_queue_;
285 CachedTokens token_cache_; 296 CachedTokens token_cache_;
286 }; 297 };
287 298
288 template <> 299 template <>
289 void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies(); 300 void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies();
290 301
291 } // namespace extensions 302 } // namespace extensions
292 303
293 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 304 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698