| OLD | NEW |
| 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> |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 private: | 177 private: |
| 178 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 178 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
| 179 ComponentWithChromeClientId); | 179 ComponentWithChromeClientId); |
| 180 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 180 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
| 181 ComponentWithNormalClientId); | 181 ComponentWithNormalClientId); |
| 182 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); | 182 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); |
| 183 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); | 183 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); |
| 184 friend class MockGetAuthTokenFunction; | 184 friend class MockGetAuthTokenFunction; |
| 185 | 185 |
| 186 // ExtensionFunction: | 186 // ExtensionFunction: |
| 187 virtual bool RunImpl() OVERRIDE; | 187 virtual bool RunSync() OVERRIDE; |
| 188 | 188 |
| 189 // Helpers to report async function results to the caller. | 189 // Helpers to report async function results to the caller. |
| 190 void StartAsyncRun(); | 190 void StartAsyncRun(); |
| 191 void CompleteAsyncRun(bool success); | 191 void CompleteAsyncRun(bool success); |
| 192 void CompleteFunctionWithResult(const std::string& access_token); | 192 void CompleteFunctionWithResult(const std::string& access_token); |
| 193 void CompleteFunctionWithError(const std::string& error); | 193 void CompleteFunctionWithError(const std::string& error); |
| 194 | 194 |
| 195 // Initiate/complete the sub-flows. | 195 // Initiate/complete the sub-flows. |
| 196 void StartSigninFlow(); | 196 void StartSigninFlow(); |
| 197 void StartMintTokenFlow(IdentityMintRequestQueue::MintType type); | 197 void StartMintTokenFlow(IdentityMintRequestQueue::MintType type); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 : public ChromeSyncExtensionFunction { | 277 : public ChromeSyncExtensionFunction { |
| 278 public: | 278 public: |
| 279 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", | 279 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", |
| 280 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) | 280 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) |
| 281 IdentityRemoveCachedAuthTokenFunction(); | 281 IdentityRemoveCachedAuthTokenFunction(); |
| 282 | 282 |
| 283 protected: | 283 protected: |
| 284 virtual ~IdentityRemoveCachedAuthTokenFunction(); | 284 virtual ~IdentityRemoveCachedAuthTokenFunction(); |
| 285 | 285 |
| 286 // SyncExtensionFunction implementation: | 286 // SyncExtensionFunction implementation: |
| 287 virtual bool RunImpl() OVERRIDE; | 287 virtual bool RunSync() OVERRIDE; |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction, | 290 class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction, |
| 291 public WebAuthFlow::Delegate { | 291 public WebAuthFlow::Delegate { |
| 292 public: | 292 public: |
| 293 DECLARE_EXTENSION_FUNCTION("identity.launchWebAuthFlow", | 293 DECLARE_EXTENSION_FUNCTION("identity.launchWebAuthFlow", |
| 294 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); | 294 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); |
| 295 | 295 |
| 296 IdentityLaunchWebAuthFlowFunction(); | 296 IdentityLaunchWebAuthFlowFunction(); |
| 297 | 297 |
| 298 // Tests may override extension_id. | 298 // Tests may override extension_id. |
| 299 void InitFinalRedirectURLPrefixForTest(const std::string& extension_id); | 299 void InitFinalRedirectURLPrefixForTest(const std::string& extension_id); |
| 300 | 300 |
| 301 private: | 301 private: |
| 302 virtual ~IdentityLaunchWebAuthFlowFunction(); | 302 virtual ~IdentityLaunchWebAuthFlowFunction(); |
| 303 virtual bool RunImpl() OVERRIDE; | 303 virtual bool RunSync() OVERRIDE; |
| 304 | 304 |
| 305 // WebAuthFlow::Delegate implementation. | 305 // WebAuthFlow::Delegate implementation. |
| 306 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE; | 306 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE; |
| 307 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; | 307 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; |
| 308 virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE {} | 308 virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE {} |
| 309 | 309 |
| 310 // Helper to initialize final URL prefix. | 310 // Helper to initialize final URL prefix. |
| 311 void InitFinalRedirectURLPrefix(const std::string& extension_id); | 311 void InitFinalRedirectURLPrefix(const std::string& extension_id); |
| 312 | 312 |
| 313 scoped_ptr<WebAuthFlow> auth_flow_; | 313 scoped_ptr<WebAuthFlow> auth_flow_; |
| 314 GURL final_url_prefix_; | 314 GURL final_url_prefix_; |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 } // namespace extensions | 317 } // namespace extensions |
| 318 | 318 |
| 319 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 319 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
| OLD | NEW |