| 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 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 5 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/aw_request_interceptor.h" | 8 #include "android_webview/browser/aw_request_interceptor.h" |
| 9 #include "android_webview/browser/net/aw_network_delegate.h" | 9 #include "android_webview/browser/net/aw_network_delegate.h" |
| 10 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 10 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (!job_factory_) { | 94 if (!job_factory_) { |
| 95 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); | 95 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); |
| 96 bool set_protocol = job_factory->SetProtocolHandler( | 96 bool set_protocol = job_factory->SetProtocolHandler( |
| 97 chrome::kFileScheme, new net::FileProtocolHandler()); | 97 chrome::kFileScheme, new net::FileProtocolHandler()); |
| 98 DCHECK(set_protocol); | 98 DCHECK(set_protocol); |
| 99 set_protocol = job_factory->SetProtocolHandler( | 99 set_protocol = job_factory->SetProtocolHandler( |
| 100 chrome::kDataScheme, new net::DataProtocolHandler()); | 100 chrome::kDataScheme, new net::DataProtocolHandler()); |
| 101 DCHECK(set_protocol); | 101 DCHECK(set_protocol); |
| 102 DCHECK(blob_protocol_handler_); | 102 DCHECK(blob_protocol_handler_); |
| 103 set_protocol = job_factory->SetProtocolHandler( | 103 set_protocol = job_factory->SetProtocolHandler( |
| 104 chrome::kBlobScheme, blob_protocol_handler_.release()); | 104 chrome::kBlobScheme, protocol_handlers_[chrome::kBlobScheme].release()); |
| 105 DCHECK(set_protocol); | 105 DCHECK(set_protocol); |
| 106 DCHECK(file_system_protocol_handler_); | 106 DCHECK(file_system_protocol_handler_); |
| 107 set_protocol = job_factory->SetProtocolHandler( | 107 set_protocol = job_factory->SetProtocolHandler( |
| 108 chrome::kFileSystemScheme, file_system_protocol_handler_.release()); | 108 chrome::kFileSystemScheme, |
| 109 protocol_handlers_[chrome::kFileSystemScheme].release()); |
| 109 DCHECK(set_protocol); | 110 DCHECK(set_protocol); |
| 110 DCHECK(chrome_protocol_handler_); | 111 DCHECK(chrome_protocol_handler_); |
| 111 set_protocol = job_factory->SetProtocolHandler( | 112 set_protocol = job_factory->SetProtocolHandler( |
| 112 chrome::kChromeUIScheme, chrome_protocol_handler_.release()); | 113 chrome::kChromeUIScheme, |
| 114 protocol_handlers_[chrome::kChromeUIScheme].release()); |
| 113 DCHECK(set_protocol); | 115 DCHECK(set_protocol); |
| 114 DCHECK(chrome_devtools_protocol_handler_); | 116 DCHECK(chrome_devtools_protocol_handler_); |
| 115 set_protocol = job_factory->SetProtocolHandler( | 117 set_protocol = job_factory->SetProtocolHandler( |
| 116 chrome::kChromeDevToolsScheme, | 118 chrome::kChromeDevToolsScheme, |
| 117 chrome_devtools_protocol_handler_.release()); | 119 protocol_handlers_[chrome::kChromeDevToolsScheme].release()); |
| 118 DCHECK(set_protocol); | 120 DCHECK(set_protocol); |
| 121 protocol_handlers_.clear(); |
| 119 // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed | 122 // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed |
| 120 // at the beginning of the chain. | 123 // at the beginning of the chain. |
| 121 job_factory_ = CreateAndroidJobFactoryAndCookieMonster( | 124 job_factory_ = CreateAndroidJobFactoryAndCookieMonster( |
| 122 url_request_context_.get(), job_factory.Pass()); | 125 url_request_context_.get(), job_factory.Pass()); |
| 123 job_factory_.reset(new net::ProtocolInterceptJobFactory( | 126 job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| 124 job_factory_.Pass(), | 127 job_factory_.Pass(), |
| 125 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 128 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 126 new AwRequestInterceptor()))); | 129 new AwRequestInterceptor()))); |
| 127 job_factory_.reset(new net::ProtocolInterceptJobFactory( | 130 job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| 128 job_factory_.Pass(), | 131 job_factory_.Pass(), |
| 129 developer_protocol_handler_.Pass())); | 132 developer_protocol_handler_.Pass())); |
| 130 url_request_context_->set_job_factory(job_factory_.get()); | 133 url_request_context_->set_job_factory(job_factory_.get()); |
| 131 } | 134 } |
| 132 return url_request_context_.get(); | 135 return url_request_context_.get(); |
| 133 } | 136 } |
| 134 | 137 |
| 135 scoped_refptr<base::SingleThreadTaskRunner> | 138 scoped_refptr<base::SingleThreadTaskRunner> |
| 136 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 139 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 137 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 140 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 138 } | 141 } |
| 139 | 142 |
| 140 void AwURLRequestContextGetter::SetProtocolHandlers( | 143 void AwURLRequestContextGetter::SetProtocolHandlers( |
| 141 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 144 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 142 blob_protocol_handler, | |
| 143 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 144 file_system_protocol_handler, | |
| 145 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 146 developer_protocol_handler, | 145 developer_protocol_handler, |
| 147 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 146 content::ProtocolHandlerMap* protocol_handlers) { |
| 148 chrome_protocol_handler, | |
| 149 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 150 chrome_devtools_protocol_handler) { | |
| 151 blob_protocol_handler_ = blob_protocol_handler.Pass(); | |
| 152 file_system_protocol_handler_ = file_system_protocol_handler.Pass(); | |
| 153 developer_protocol_handler_ = developer_protocol_handler.Pass(); | 147 developer_protocol_handler_ = developer_protocol_handler.Pass(); |
| 154 chrome_protocol_handler_ = chrome_protocol_handler.Pass(); | 148 std::swap(protocol_handlers_, *protocol_handlers); |
| 155 chrome_devtools_protocol_handler_ = chrome_devtools_protocol_handler.Pass(); | |
| 156 } | 149 } |
| 157 | 150 |
| 158 } // namespace android_webview | 151 } // namespace android_webview |
| OLD | NEW |