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