| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "net/url_request/url_request_interceptor.h" | 9 #include "net/url_request/url_request_interceptor.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 class NetworkDelegate; | 12 class NetworkDelegate; |
| 13 class URLRequest; | 13 class URLRequest; |
| 14 class URLRequestJob; | 14 class URLRequestJob; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace previews { |
| 18 class PreviewsDecider; |
| 19 } |
| 20 |
| 17 namespace offline_pages { | 21 namespace offline_pages { |
| 18 | 22 |
| 19 // An interceptor to hijack requests and potentially service them based on | 23 // An interceptor to hijack requests and potentially service them based on |
| 20 // their offline information. Created one per profile. | 24 // their offline information. Created one per profile. |
| 21 class OfflinePageRequestInterceptor : public net::URLRequestInterceptor { | 25 class OfflinePageRequestInterceptor : public net::URLRequestInterceptor { |
| 22 public: | 26 public: |
| 23 OfflinePageRequestInterceptor(); | 27 // Embedder must guarantee that |previews_decider| outlives |this|. |
| 28 explicit OfflinePageRequestInterceptor( |
| 29 previews::PreviewsDecider* previews_decider); |
| 24 ~OfflinePageRequestInterceptor() override; | 30 ~OfflinePageRequestInterceptor() override; |
| 25 | 31 |
| 26 private: | 32 private: |
| 27 // Overrides from net::URLRequestInterceptor: | 33 // Overrides from net::URLRequestInterceptor: |
| 28 net::URLRequestJob* MaybeInterceptRequest( | 34 net::URLRequestJob* MaybeInterceptRequest( |
| 29 net::URLRequest* request, | 35 net::URLRequest* request, |
| 30 net::NetworkDelegate* network_delegate) const override; | 36 net::NetworkDelegate* network_delegate) const override; |
| 31 | 37 |
| 38 // Used to determine if an URLRequest is eligible for offline previews. |
| 39 previews::PreviewsDecider* previews_decider_; |
| 40 |
| 32 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestInterceptor); | 41 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestInterceptor); |
| 33 }; | 42 }; |
| 34 | 43 |
| 35 } // namespace offline_pages | 44 } // namespace offline_pages |
| 36 | 45 |
| 37 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_
H_ | 46 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_INTERCEPTOR_
H_ |
| OLD | NEW |