| 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 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" | 5 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 auth_url_ = GaiaUrls::GetInstance()->oauth2_auth_url().Resolve( | 88 auth_url_ = GaiaUrls::GetInstance()->oauth2_auth_url().Resolve( |
| 89 oauth2_authorize_params); | 89 oauth2_authorize_params); |
| 90 } | 90 } |
| 91 | 91 |
| 92 GaiaWebAuthFlow::~GaiaWebAuthFlow() { | 92 GaiaWebAuthFlow::~GaiaWebAuthFlow() { |
| 93 TRACE_EVENT_ASYNC_END0("identity", "GaiaWebAuthFlow", this); | 93 TRACE_EVENT_ASYNC_END0("identity", "GaiaWebAuthFlow", this); |
| 94 | 94 |
| 95 if (io_helper_) { | 95 if (io_helper_) { |
| 96 content::BrowserThread::PostTask( | 96 content::BrowserThread::PostTask( |
| 97 content::BrowserThread::IO, | 97 content::BrowserThread::IO, FROM_HERE, |
| 98 FROM_HERE, | 98 base::BindOnce(&GaiaWebAuthFlow::IOHelper::Cleanup, |
| 99 base::Bind(&GaiaWebAuthFlow::IOHelper::Cleanup, | 99 base::Unretained(io_helper_.release()))); |
| 100 base::Unretained(io_helper_.release()))); | |
| 101 } | 100 } |
| 102 | 101 |
| 103 if (web_flow_) | 102 if (web_flow_) |
| 104 web_flow_.release()->DetachDelegateAndDelete(); | 103 web_flow_.release()->DetachDelegateAndDelete(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void GaiaWebAuthFlow::Start() { | 106 void GaiaWebAuthFlow::Start() { |
| 108 io_helper_.reset(new IOHelper(weak_ptr_factory_.GetWeakPtr(), | 107 io_helper_.reset(new IOHelper(weak_ptr_factory_.GetWeakPtr(), |
| 109 profile_->GetRequestContext())); | 108 profile_->GetRequestContext())); |
| 110 content::BrowserThread::PostTask( | 109 content::BrowserThread::PostTask( |
| 111 content::BrowserThread::IO, | 110 content::BrowserThread::IO, FROM_HERE, |
| 112 FROM_HERE, | 111 base::BindOnce(&GaiaWebAuthFlow::IOHelper::PrepareRequestContext, |
| 113 base::Bind(&GaiaWebAuthFlow::IOHelper::PrepareRequestContext, | 112 base::Unretained(io_helper_.get()))); |
| 114 base::Unretained(io_helper_.get()))); | |
| 115 } | 113 } |
| 116 | 114 |
| 117 void GaiaWebAuthFlow::StartUberTokenFetch() { | 115 void GaiaWebAuthFlow::StartUberTokenFetch() { |
| 118 ProfileOAuth2TokenService* token_service = | 116 ProfileOAuth2TokenService* token_service = |
| 119 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 117 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 120 context_getter_ = new net::TrivialURLRequestContextGetter( | 118 context_getter_ = new net::TrivialURLRequestContextGetter( |
| 121 io_helper_->ubertoken_request_context(), | 119 io_helper_->ubertoken_request_context(), |
| 122 profile_->GetRequestContext()->GetNetworkTaskRunner()); | 120 profile_->GetRequestContext()->GetNetworkTaskRunner()); |
| 123 ubertoken_fetcher_.reset(new UbertokenFetcher(token_service, | 121 ubertoken_fetcher_.reset(new UbertokenFetcher(token_service, |
| 124 this, | 122 this, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 *base_context->GetNetworkSessionParams(); | 287 *base_context->GetNetworkSessionParams(); |
| 290 network_params.channel_id_service = nullptr; | 288 network_params.channel_id_service = nullptr; |
| 291 http_network_session_.reset(new net::HttpNetworkSession(network_params)); | 289 http_network_session_.reset(new net::HttpNetworkSession(network_params)); |
| 292 app_http_cache_.reset(new net::HttpCache( | 290 app_http_cache_.reset(new net::HttpCache( |
| 293 http_network_session_.get(), std::move(app_backend_), true)); | 291 http_network_session_.get(), std::move(app_backend_), true)); |
| 294 | 292 |
| 295 ubertoken_request_context_->set_http_transaction_factory( | 293 ubertoken_request_context_->set_http_transaction_factory( |
| 296 app_http_cache_.get()); | 294 app_http_cache_.get()); |
| 297 | 295 |
| 298 content::BrowserThread::PostTask( | 296 content::BrowserThread::PostTask( |
| 299 content::BrowserThread::UI, | 297 content::BrowserThread::UI, FROM_HERE, |
| 300 FROM_HERE, | 298 base::BindOnce(&GaiaWebAuthFlow::StartUberTokenFetch, |
| 301 base::Bind(&GaiaWebAuthFlow::StartUberTokenFetch, | 299 gaia_web_auth_flow_)); |
| 302 gaia_web_auth_flow_)); | |
| 303 } | 300 } |
| 304 | 301 |
| 305 void GaiaWebAuthFlow::IOHelper::Cleanup() { | 302 void GaiaWebAuthFlow::IOHelper::Cleanup() { |
| 306 delete this; | 303 delete this; |
| 307 } | 304 } |
| 308 | 305 |
| 309 } // namespace extensions | 306 } // namespace extensions |
| OLD | NEW |