OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ |
6 #define CHROME_BROWSER_ANDROID_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ | 6 #define CHROME_BROWSER_ANDROID_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "chrome/browser/android/download/download_controller_base.h" | 9 #include "chrome/browser/android/download/download_controller_base.h" |
| 10 #include "content/public/browser/resource_request_info.h" |
10 #include "content/public/browser/resource_throttle.h" | 11 #include "content/public/browser/resource_throttle.h" |
11 #include "net/cookies/cookie_store.h" | 12 #include "net/cookies/cookie_store.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 class URLRequest; | 15 class URLRequest; |
15 } | 16 } |
16 | 17 |
17 namespace chrome { | 18 namespace chrome { |
18 | 19 |
19 // InterceptDownloadResourceThrottle checks if a download request should be | 20 // InterceptDownloadResourceThrottle checks if a download request should be |
20 // handled by Chrome or passsed to the Android Download Manager. | 21 // handled by Chrome or passsed to the Android Download Manager. |
21 class InterceptDownloadResourceThrottle : public content::ResourceThrottle { | 22 class InterceptDownloadResourceThrottle : public content::ResourceThrottle { |
22 public: | 23 public: |
23 static bool IsDownloadInterceptionEnabled(); | 24 static bool IsDownloadInterceptionEnabled(); |
24 | 25 |
25 InterceptDownloadResourceThrottle(net::URLRequest* request, | 26 InterceptDownloadResourceThrottle( |
26 int render_process_id, | 27 net::URLRequest* request, |
27 int render_view_id, | 28 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
28 bool must_download); | 29 bool must_download); |
29 | 30 |
30 // content::ResourceThrottle implementation: | 31 // content::ResourceThrottle implementation: |
31 void WillProcessResponse(bool* defer) override; | 32 void WillProcessResponse(bool* defer) override; |
32 const char* GetNameForLogging() const override; | 33 const char* GetNameForLogging() const override; |
33 | 34 |
34 private: | 35 private: |
35 ~InterceptDownloadResourceThrottle() override; | 36 ~InterceptDownloadResourceThrottle() override; |
36 | 37 |
37 void ProcessDownloadRequest(bool* defer); | 38 void ProcessDownloadRequest(bool* defer); |
38 void CheckCookiePolicy(const net::CookieList& cookie_list); | 39 void CheckCookiePolicy(const net::CookieList& cookie_list); |
39 void StartDownload(const DownloadInfo& info); | 40 void StartDownload(const DownloadInfo& info); |
40 | 41 |
41 // Set to true when if we want chrome to handle the download. | 42 // Set to true when if we want chrome to handle the download. |
42 const net::URLRequest* request_; | 43 const net::URLRequest* request_; |
43 int render_process_id_; | 44 content::ResourceRequestInfo::WebContentsGetter wc_getter_; |
44 int render_view_id_; | |
45 bool must_download_; | 45 bool must_download_; |
46 | 46 |
47 base::WeakPtrFactory<InterceptDownloadResourceThrottle> weak_factory_; | 47 base::WeakPtrFactory<InterceptDownloadResourceThrottle> weak_factory_; |
48 DISALLOW_COPY_AND_ASSIGN(InterceptDownloadResourceThrottle); | 48 DISALLOW_COPY_AND_ASSIGN(InterceptDownloadResourceThrottle); |
49 }; | 49 }; |
50 | 50 |
51 } // namespace chrome | 51 } // namespace chrome |
52 | 52 |
53 #endif // CHROME_BROWSER_ANDROID_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ | 53 #endif // CHROME_BROWSER_ANDROID_INTERCEPT_DOWNLOAD_RESOURCE_THROTTLE_H_ |
OLD | NEW |