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
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_JOB_FACTORY_H_
6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_JOB_FACTORY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "net/url_request/url_request_job_factory.h"
12 class URLRequestJobFactoryImpl
;
15 namespace android_webview
{
17 // android_webview uses a custom URLRequestJobFactoryImpl to support
18 // navigation interception and URLRequestJob interception for navigations to
19 // url with unsupported schemes.
20 // This is achieved by returning a URLRequestErrorJob for schemes that would
21 // otherwise be unhandled, which gives the embedder an opportunity to intercept
23 class AwURLRequestJobFactory
: public net::URLRequestJobFactory
{
25 AwURLRequestJobFactory();
26 ~AwURLRequestJobFactory() override
;
28 bool SetProtocolHandler(const std::string
& scheme
,
29 ProtocolHandler
* protocol_handler
);
31 // net::URLRequestJobFactory implementation.
32 net::URLRequestJob
* MaybeCreateJobWithProtocolHandler(
33 const std::string
& scheme
,
34 net::URLRequest
* request
,
35 net::NetworkDelegate
* network_delegate
) const override
;
37 net::URLRequestJob
* MaybeInterceptRedirect(
38 net::URLRequest
* request
,
39 net::NetworkDelegate
* network_delegate
,
40 const GURL
& location
) const override
;
42 net::URLRequestJob
* MaybeInterceptResponse(
43 net::URLRequest
* request
,
44 net::NetworkDelegate
* network_delegate
) const override
;
46 bool IsHandledProtocol(const std::string
& scheme
) const override
;
47 bool IsHandledURL(const GURL
& url
) const override
;
48 bool IsSafeRedirectTarget(const GURL
& location
) const override
;
51 // By default calls are forwarded to this factory, to avoid having to
52 // subclass an existing implementation class.
53 scoped_ptr
<net::URLRequestJobFactoryImpl
> next_factory_
;
55 DISALLOW_COPY_AND_ASSIGN(AwURLRequestJobFactory
);
58 } // namespace android_webview
60 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_JOB_FACTORY_H_