1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_NET_XWALK_URL_REQUEST_JOB_FACTORY_H_
7 #define XWALK_RUNTIME_BROWSER_ANDROID_NET_XWALK_URL_REQUEST_JOB_FACTORY_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "net/url_request/url_request_job_factory.h"
15 class URLRequestJobFactoryImpl;
20 // Crosswalk uses a custom URLRequestJobFactoryImpl to support
21 // navigation interception and URLRequestJob interception for navigations to
22 // url with unsupported schemes.
23 // This is achieved by returning a URLRequestErrorJob for schemes that would
24 // otherwise be unhandled, which gives the embedder an opportunity to intercept
26 class XWalkURLRequestJobFactory : public net::URLRequestJobFactory {
28 XWalkURLRequestJobFactory();
29 virtual ~XWalkURLRequestJobFactory();
31 bool SetProtocolHandler(const std::string& scheme,
32 ProtocolHandler* protocol_handler);
34 // net::URLRequestJobFactory implementation.
35 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler(
36 const std::string& scheme,
37 net::URLRequest* request,
38 net::NetworkDelegate* network_delegate) const override;
40 net::URLRequestJob* MaybeInterceptRedirect(
41 net::URLRequest* request,
42 net::NetworkDelegate* network_delegate,
43 const GURL& location) const override;
45 net::URLRequestJob* MaybeInterceptResponse(
46 net::URLRequest* request,
47 net::NetworkDelegate* network_delegate) const override;
49 bool IsHandledProtocol(const std::string& scheme) const override;
50 bool IsHandledURL(const GURL& url) const override;
51 bool IsSafeRedirectTarget(const GURL& location) const override;
54 // By default calls are forwarded to this factory, to avoid having to
55 // subclass an existing implementation class.
56 scoped_ptr<net::URLRequestJobFactoryImpl> next_factory_;
58 DISALLOW_COPY_AND_ASSIGN(XWalkURLRequestJobFactory);
63 #endif // XWALK_RUNTIME_BROWSER_ANDROID_NET_XWALK_URL_REQUEST_JOB_FACTORY_H_