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