| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | 13 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
| 13 #include "chrome/browser/extensions/app_notify_channel_setup.h" | 14 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
| 14 #include "chrome/browser/extensions/extension_function.h" | 15 #include "chrome/browser/extensions/extension_function.h" |
| 15 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" | 16 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
| 16 | 17 |
| 17 class GoogleServiceAuthError; | 18 class GoogleServiceAuthError; |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 class GetAuthTokenFunction : public AsyncExtensionFunction, | 22 class GetAuthTokenFunction : public AsyncExtensionFunction, |
| 22 public OAuth2MintTokenFlow::Delegate { | 23 public OAuth2MintTokenFlow::Delegate { |
| 23 public: | 24 public: |
| 24 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); | 25 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); |
| 25 | 26 |
| 26 GetAuthTokenFunction(); | 27 GetAuthTokenFunction(); |
| 27 | 28 |
| 28 private: | 29 private: |
| 29 virtual ~GetAuthTokenFunction(); | 30 virtual ~GetAuthTokenFunction(); |
| 30 | 31 |
| 31 // ExtensionFunction: | 32 // ExtensionFunction: |
| 32 virtual bool RunImpl() OVERRIDE; | 33 virtual bool RunImpl() OVERRIDE; |
| 33 | 34 |
| 34 // OAuth2MintTokenFlow::Delegate implementation: | 35 // OAuth2MintTokenFlow::Delegate implementation: |
| 35 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; | 36 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; |
| 36 virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 37 virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| 38 virtual void OnIssueAdviceSuccess( |
| 39 const IssueAdviceInfo& issue_advice) OVERRIDE; |
| 37 | 40 |
| 38 scoped_ptr<OAuth2MintTokenFlow> flow_; | 41 scoped_ptr<OAuth2MintTokenFlow> flow_; |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 class LaunchWebAuthFlowFunction : public AsyncExtensionFunction, | 44 class LaunchWebAuthFlowFunction : public AsyncExtensionFunction, |
| 42 public WebAuthFlow::Delegate { | 45 public WebAuthFlow::Delegate { |
| 43 public: | 46 public: |
| 44 LaunchWebAuthFlowFunction(); | 47 LaunchWebAuthFlowFunction(); |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 virtual ~LaunchWebAuthFlowFunction(); | 50 virtual ~LaunchWebAuthFlowFunction(); |
| 48 virtual bool RunImpl() OVERRIDE; | 51 virtual bool RunImpl() OVERRIDE; |
| 49 | 52 |
| 50 // WebAuthFlow::Delegate implementation. | 53 // WebAuthFlow::Delegate implementation. |
| 51 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE; | 54 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE; |
| 52 virtual void OnAuthFlowFailure() OVERRIDE; | 55 virtual void OnAuthFlowFailure() OVERRIDE; |
| 53 | 56 |
| 54 scoped_ptr<WebAuthFlow> auth_flow_; | 57 scoped_ptr<WebAuthFlow> auth_flow_; |
| 55 | 58 |
| 56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.launchWebAuthFlow"); | 59 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.launchWebAuthFlow"); |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 } // namespace extensions | 62 } // namespace extensions |
| 60 | 63 |
| 61 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 64 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
| OLD | NEW |