OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_GAIA_WEB_AUTH_FLOW_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/extensions/api/identity/extension_token_key.h" | 9 #include "chrome/browser/extensions/api/identity/extension_token_key.h" |
10 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | 10 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
| 11 #include "chrome/browser/profiles/profile_io_data.h" |
11 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" | 12 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" |
12 #include "google_apis/gaia/ubertoken_fetcher.h" | 13 #include "google_apis/gaia/ubertoken_fetcher.h" |
13 | 14 |
| 15 namespace net { |
| 16 class TrivialURLRequestContextGetter; |
| 17 } |
| 18 |
14 namespace extensions { | 19 namespace extensions { |
15 | 20 |
16 // Implements a web-based OAuth2 scope approval dialog. This flow has | 21 // Implements a web-based OAuth2 scope approval dialog. This flow has |
17 // four parts: | 22 // four parts: |
18 // 1. Fetch an ubertoken for a signed-in user. | 23 // 1. Fetch an ubertoken for a signed-in user. |
19 // 2. Use the ubertoken to get session cookies using MergeSession. | 24 // 2. Use the ubertoken to get session cookies using MergeSession. |
20 // 3. Start the OAuth flow and wait for final redirect. | 25 // 3. Start the OAuth flow and wait for final redirect. |
21 // 4. Parse results from the fragment component of the final redirect URI. | 26 // 4. Parse results from the fragment component of the final redirect URI. |
22 // | 27 // |
23 // The OAuth flow is a special version of the OAuth2 out-of-band flow | 28 // The OAuth flow is a special version of the OAuth2 out-of-band flow |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // WebAuthFlow::Delegate implementation. | 81 // WebAuthFlow::Delegate implementation. |
77 void OnAuthFlowFailure(WebAuthFlow::Failure failure) override; | 82 void OnAuthFlowFailure(WebAuthFlow::Failure failure) override; |
78 void OnAuthFlowURLChange(const GURL& redirect_url) override; | 83 void OnAuthFlowURLChange(const GURL& redirect_url) override; |
79 void OnAuthFlowTitleChange(const std::string& title) override; | 84 void OnAuthFlowTitleChange(const std::string& title) override; |
80 | 85 |
81 private: | 86 private: |
82 // Creates a WebAuthFlow, which will navigate to |url|. Can override | 87 // Creates a WebAuthFlow, which will navigate to |url|. Can override |
83 // for testing. Used to kick off the MergeSession (step #2). | 88 // for testing. Used to kick off the MergeSession (step #2). |
84 virtual std::unique_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url); | 89 virtual std::unique_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url); |
85 | 90 |
| 91 void StartOnIOThread(); |
| 92 void StartUberTokenFetch(); |
| 93 void CleanupRequestContextOnIOThread(); |
| 94 |
86 Delegate* delegate_; | 95 Delegate* delegate_; |
87 Profile* profile_; | 96 Profile* profile_; |
88 std::string account_id_; | 97 std::string account_id_; |
89 std::string redirect_scheme_; | 98 std::string redirect_scheme_; |
90 std::string redirect_path_prefix_; | 99 std::string redirect_path_prefix_; |
91 GURL auth_url_; | 100 GURL auth_url_; |
92 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_; | 101 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_; |
93 std::unique_ptr<WebAuthFlow> web_flow_; | 102 std::unique_ptr<WebAuthFlow> web_flow_; |
| 103 std::unique_ptr<net::URLRequestContext> ubertoken_request_context_; |
| 104 scoped_refptr<net::TrivialURLRequestContextGetter> context_getter_; |
| 105 net::URLRequestContextGetter* main_context_; |
94 | 106 |
95 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow); | 107 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow); |
96 }; | 108 }; |
97 | 109 |
98 } // namespace extensions | 110 } // namespace extensions |
99 | 111 |
100 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
OLD | NEW |