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