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