1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/url_request/url_request_intercepting_job_factory.h"
7 #include "base/logging.h"
8 #include "net/url_request/url_request_interceptor.h"
12 URLRequestInterceptingJobFactory::URLRequestInterceptingJobFactory(
13 scoped_ptr
<URLRequestJobFactory
> job_factory
,
14 scoped_ptr
<URLRequestInterceptor
> interceptor
)
15 : job_factory_(job_factory
.Pass()),
16 interceptor_(interceptor
.Pass()) {
19 URLRequestInterceptingJobFactory::~URLRequestInterceptingJobFactory() {}
21 URLRequestJob
* URLRequestInterceptingJobFactory::
22 MaybeCreateJobWithProtocolHandler(
23 const std::string
& scheme
,
25 NetworkDelegate
* network_delegate
) const {
26 DCHECK(CalledOnValidThread());
27 URLRequestJob
* job
= interceptor_
->MaybeInterceptRequest(request
,
31 return job_factory_
->MaybeCreateJobWithProtocolHandler(
32 scheme
, request
, network_delegate
);
35 bool URLRequestInterceptingJobFactory::IsHandledProtocol(
36 const std::string
& scheme
) const {
37 return job_factory_
->IsHandledProtocol(scheme
);
40 bool URLRequestInterceptingJobFactory::IsHandledURL(const GURL
& url
) const {
41 return job_factory_
->IsHandledURL(url
);
44 bool URLRequestInterceptingJobFactory::IsSafeRedirectTarget(
45 const GURL
& location
) const {
46 return job_factory_
->IsSafeRedirectTarget(location
);