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 "chrome/browser/custom_handlers/protocol_handler_registry.h" | 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 ProtocolHandlerRegistry::JobInterceptorFactory::~JobInterceptorFactory() { | 169 ProtocolHandlerRegistry::JobInterceptorFactory::~JobInterceptorFactory() { |
170 } | 170 } |
171 | 171 |
172 void ProtocolHandlerRegistry::JobInterceptorFactory::Chain( | 172 void ProtocolHandlerRegistry::JobInterceptorFactory::Chain( |
173 scoped_ptr<net::URLRequestJobFactory> job_factory) { | 173 scoped_ptr<net::URLRequestJobFactory> job_factory) { |
174 job_factory_ = job_factory.Pass(); | 174 job_factory_ = job_factory.Pass(); |
175 } | 175 } |
176 | 176 |
177 bool ProtocolHandlerRegistry::JobInterceptorFactory::SetProtocolHandler( | |
178 const std::string& scheme, ProtocolHandler* protocol_handler) { | |
179 return job_factory_->SetProtocolHandler(scheme, protocol_handler); | |
180 } | |
181 | |
182 void ProtocolHandlerRegistry::JobInterceptorFactory::AddInterceptor( | |
183 Interceptor* interceptor) { | |
184 return job_factory_->AddInterceptor(interceptor); | |
185 } | |
186 | |
187 net::URLRequestJob* | |
188 ProtocolHandlerRegistry::JobInterceptorFactory::MaybeCreateJobWithInterceptor( | |
189 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | |
190 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); | |
191 } | |
192 | |
193 net::URLRequestJob* | 177 net::URLRequestJob* |
194 ProtocolHandlerRegistry::JobInterceptorFactory:: | 178 ProtocolHandlerRegistry::JobInterceptorFactory:: |
195 MaybeCreateJobWithProtocolHandler( | 179 MaybeCreateJobWithProtocolHandler( |
196 const std::string& scheme, | 180 const std::string& scheme, |
197 net::URLRequest* request, | 181 net::URLRequest* request, |
198 net::NetworkDelegate* network_delegate) const { | 182 net::NetworkDelegate* network_delegate) const { |
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
200 net::URLRequestJob* job = io_thread_delegate_->MaybeCreateJob( | 184 net::URLRequestJob* job = io_thread_delegate_->MaybeCreateJob( |
201 request, network_delegate); | 185 request, network_delegate); |
202 if (job) | 186 if (job) |
203 return job; | 187 return job; |
204 return job_factory_->MaybeCreateJobWithProtocolHandler( | 188 return job_factory_->MaybeCreateJobWithProtocolHandler( |
205 scheme, request, network_delegate); | 189 scheme, request, network_delegate); |
206 } | 190 } |
207 | 191 |
208 net::URLRequestJob* | |
209 ProtocolHandlerRegistry::JobInterceptorFactory::MaybeInterceptRedirect( | |
210 const GURL& location, | |
211 net::URLRequest* request, | |
212 net::NetworkDelegate* network_delegate) const { | |
213 return job_factory_->MaybeInterceptRedirect( | |
214 location, request, network_delegate); | |
215 } | |
216 | |
217 net::URLRequestJob* | |
218 ProtocolHandlerRegistry::JobInterceptorFactory::MaybeInterceptResponse( | |
219 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | |
220 return job_factory_->MaybeInterceptResponse(request, network_delegate); | |
221 } | |
222 | |
223 bool ProtocolHandlerRegistry::JobInterceptorFactory::IsHandledProtocol( | 192 bool ProtocolHandlerRegistry::JobInterceptorFactory::IsHandledProtocol( |
224 const std::string& scheme) const { | 193 const std::string& scheme) const { |
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
226 return io_thread_delegate_->IsHandledProtocol(scheme) || | 195 return io_thread_delegate_->IsHandledProtocol(scheme) || |
227 job_factory_->IsHandledProtocol(scheme); | 196 job_factory_->IsHandledProtocol(scheme); |
228 } | 197 } |
229 | 198 |
230 bool ProtocolHandlerRegistry::JobInterceptorFactory::IsHandledURL( | 199 bool ProtocolHandlerRegistry::JobInterceptorFactory::IsHandledURL( |
231 const GURL& url) const { | 200 const GURL& url) const { |
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 | 869 |
901 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 870 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
902 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { | 871 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { |
903 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 872 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
904 // this is always created on the UI thread (in profile_io's | 873 // this is always created on the UI thread (in profile_io's |
905 // InitializeOnUIThread. Any method calls must be done | 874 // InitializeOnUIThread. Any method calls must be done |
906 // on the IO thread (this is checked). | 875 // on the IO thread (this is checked). |
907 return scoped_ptr<JobInterceptorFactory>(new JobInterceptorFactory( | 876 return scoped_ptr<JobInterceptorFactory>(new JobInterceptorFactory( |
908 io_thread_delegate_)); | 877 io_thread_delegate_)); |
909 } | 878 } |
OLD | NEW |