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