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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | 12 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
13 #include "chrome/browser/extensions/app_notify_channel_setup.h" | 13 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
14 #include "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
15 #include "chrome/browser/extensions/extension_function.h" | 15 #include "chrome/browser/extensions/extension_function.h" |
16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | |
16 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" | 17 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
17 | 18 |
18 class GoogleServiceAuthError; | 19 class GoogleServiceAuthError; |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 class GetAuthTokenFunction : public AsyncExtensionFunction, | 23 class GetAuthTokenFunction : public AsyncExtensionFunction, |
23 public OAuth2MintTokenFlow::Delegate, | 24 public OAuth2MintTokenFlow::Delegate, |
24 public ExtensionInstallPrompt::Delegate { | 25 public ExtensionInstallPrompt::Delegate, |
26 public LoginUIService::Observer { | |
25 public: | 27 public: |
26 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); | 28 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); |
27 | 29 |
28 GetAuthTokenFunction(); | 30 GetAuthTokenFunction(); |
29 | 31 |
30 private: | 32 private: |
31 virtual ~GetAuthTokenFunction(); | 33 virtual ~GetAuthTokenFunction(); |
32 | 34 |
33 // ExtensionFunction: | 35 // ExtensionFunction: |
34 virtual bool RunImpl() OVERRIDE; | 36 virtual bool RunImpl() OVERRIDE; |
35 | 37 |
36 // OAuth2MintTokenFlow::Delegate implementation: | 38 // OAuth2MintTokenFlow::Delegate implementation: |
37 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; | 39 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; |
38 virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 40 virtual void OnMintTokenFailure( |
41 const GoogleServiceAuthError& error) OVERRIDE; | |
39 virtual void OnIssueAdviceSuccess( | 42 virtual void OnIssueAdviceSuccess( |
40 const IssueAdviceInfo& issue_advice) OVERRIDE; | 43 const IssueAdviceInfo& issue_advice) OVERRIDE; |
41 | 44 |
45 // LoginUIService::Observer implementation. | |
46 virtual void OnLoginUIShown(LoginUIService::LoginUI* ui) OVERRIDE; | |
Evan Stade
2012/07/13 08:57:33
I can't find this interface in code search, was it
Munjal (Google)
2012/07/16 20:13:30
Yeah, that change was landed recently. But now it
| |
47 virtual void OnLoginUIClosed(LoginUIService::LoginUI* ui) OVERRIDE; | |
48 | |
42 // ExtensionInstallPrompt::Delegate implementation: | 49 // ExtensionInstallPrompt::Delegate implementation: |
43 virtual void InstallUIProceed() OVERRIDE; | 50 virtual void InstallUIProceed() OVERRIDE; |
44 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 51 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
45 | 52 |
53 // Shows the login UI in a browser popup. | |
54 bool StartLogin(); | |
46 // Starts a MintTokenFlow with the given mode; Returns success. | 55 // Starts a MintTokenFlow with the given mode; Returns success. |
47 bool StartFlow(OAuth2MintTokenFlow::Mode mode); | 56 bool StartFlow(OAuth2MintTokenFlow::Mode mode); |
48 | 57 |
58 // Checks if there is a master login token to mint token for the extension. | |
Mihai Parparita -not on Chrome
2012/07/12 23:31:32
"to mint tokens" sounds more correct.
Munjal (Google)
2012/07/16 20:13:30
Done.
| |
59 bool HasLoginToken() const; | |
60 | |
61 // Gets the token mint flow mode based on a command-line flag. | |
62 OAuth2MintTokenFlow::Mode GetTokenFlowMode() const; | |
63 | |
49 bool interactive_; | 64 bool interactive_; |
50 scoped_ptr<OAuth2MintTokenFlow> flow_; | 65 scoped_ptr<OAuth2MintTokenFlow> flow_; |
51 | 66 |
52 // When launched in interactive mode, and if there is no existing grant, | 67 // When launched in interactive mode, and if there is no existing grant, |
53 // a permissions prompt will be popped up to the user. | 68 // a permissions prompt will be popped up to the user. |
54 scoped_ptr<ExtensionInstallPrompt> install_ui_; | 69 scoped_ptr<ExtensionInstallPrompt> install_ui_; |
55 }; | 70 }; |
56 | 71 |
57 class LaunchWebAuthFlowFunction : public AsyncExtensionFunction, | 72 class LaunchWebAuthFlowFunction : public AsyncExtensionFunction, |
58 public WebAuthFlow::Delegate { | 73 public WebAuthFlow::Delegate { |
59 public: | 74 public: |
60 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.launchWebAuthFlow"); | 75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.launchWebAuthFlow"); |
61 | 76 |
62 LaunchWebAuthFlowFunction(); | 77 LaunchWebAuthFlowFunction(); |
63 | 78 |
64 private: | 79 private: |
65 virtual ~LaunchWebAuthFlowFunction(); | 80 virtual ~LaunchWebAuthFlowFunction(); |
66 virtual bool RunImpl() OVERRIDE; | 81 virtual bool RunImpl() OVERRIDE; |
67 | 82 |
68 // WebAuthFlow::Delegate implementation. | 83 // WebAuthFlow::Delegate implementation. |
69 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE; | 84 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE; |
70 virtual void OnAuthFlowFailure() OVERRIDE; | 85 virtual void OnAuthFlowFailure() OVERRIDE; |
71 | 86 |
72 scoped_ptr<WebAuthFlow> auth_flow_; | 87 scoped_ptr<WebAuthFlow> auth_flow_; |
73 }; | 88 }; |
74 | 89 |
75 } // namespace extensions | 90 } // namespace extensions |
76 | 91 |
77 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 92 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
OLD | NEW |