| 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_EXPERIMENTAL_IDENTITY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/extensions/api/identity/experimental_web_auth_flow.h" |
| 13 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h" | 14 #include "chrome/browser/extensions/api/identity/identity_mint_queue.h" |
| 14 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h" | 15 #include "chrome/browser/extensions/api/identity/identity_signin_flow.h" |
| 15 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | |
| 16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "chrome/browser/extensions/extension_install_prompt.h" | 17 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 18 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 18 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 // TODO(courage): These functions exist to support some apps that were | 22 // TODO(courage): These functions exist to support some apps that were |
| 23 // whitelisted to use the experimental API. Remove them once those | 23 // whitelisted to use the experimental API. Remove them once those |
| 24 // apps have migrated. | 24 // apps have migrated. |
| 25 | 25 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // When launched in interactive mode, and if there is no existing grant, | 104 // When launched in interactive mode, and if there is no existing grant, |
| 105 // a permissions prompt will be popped up to the user. | 105 // a permissions prompt will be popped up to the user. |
| 106 IssueAdviceInfo issue_advice_; | 106 IssueAdviceInfo issue_advice_; |
| 107 scoped_ptr<ExtensionInstallPrompt> install_ui_; | 107 scoped_ptr<ExtensionInstallPrompt> install_ui_; |
| 108 scoped_ptr<IdentitySigninFlow> signin_flow_; | 108 scoped_ptr<IdentitySigninFlow> signin_flow_; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 class ExperimentalIdentityLaunchWebAuthFlowFunction | 111 class ExperimentalIdentityLaunchWebAuthFlowFunction |
| 112 : public AsyncExtensionFunction, | 112 : public AsyncExtensionFunction, |
| 113 public WebAuthFlow::Delegate { | 113 public ExperimentalWebAuthFlow::Delegate { |
| 114 public: | 114 public: |
| 115 DECLARE_EXTENSION_FUNCTION("experimental.identity.launchWebAuthFlow", | 115 DECLARE_EXTENSION_FUNCTION("experimental.identity.launchWebAuthFlow", |
| 116 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); | 116 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); |
| 117 ExperimentalIdentityLaunchWebAuthFlowFunction(); | 117 ExperimentalIdentityLaunchWebAuthFlowFunction(); |
| 118 | 118 |
| 119 // URL checking helpers. Public for testing. | 119 // URL checking helpers. Public for testing. |
| 120 // Checks to see if the current URL ends the flow. | 120 // Checks to see if the current URL ends the flow. |
| 121 bool IsFinalRedirectURL(const GURL& url) const; | 121 bool IsFinalRedirectURL(const GURL& url) const; |
| 122 | 122 |
| 123 // Unit tests may override extension_id. | 123 // Unit tests may override extension_id. |
| 124 void InitFinalRedirectURLPrefixesForTest(const std::string& extension_id); | 124 void InitFinalRedirectURLPrefixesForTest(const std::string& extension_id); |
| 125 | 125 |
| 126 protected: | 126 protected: |
| 127 virtual ~ExperimentalIdentityLaunchWebAuthFlowFunction(); | 127 virtual ~ExperimentalIdentityLaunchWebAuthFlowFunction(); |
| 128 virtual bool RunImpl() OVERRIDE; | 128 virtual bool RunImpl() OVERRIDE; |
| 129 | 129 |
| 130 // Helper to initialize final URLs vector. | 130 // Helper to initialize final URLs vector. |
| 131 void InitFinalRedirectURLPrefixes(const std::string& extension_id); | 131 void InitFinalRedirectURLPrefixes(const std::string& extension_id); |
| 132 | 132 |
| 133 scoped_ptr<WebAuthFlow> auth_flow_; | 133 scoped_ptr<ExperimentalWebAuthFlow> auth_flow_; |
| 134 std::vector<GURL> final_prefixes_; | 134 std::vector<GURL> final_prefixes_; |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 // WebAuthFlow::Delegate implementation. | 137 // ExperimentalWebAuthFlow::Delegate implementation. |
| 138 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE; | 138 virtual void OnAuthFlowFailure(ExperimentalWebAuthFlow::Failure failure) |
| 139 OVERRIDE; |
| 139 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; | 140 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace extensions | 143 } // namespace extensions |
| 143 | 144 |
| 144 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ | 145 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXPERIMENTAL_IDENTITY_API_H_ |
| OLD | NEW |