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