OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/android/intercept_download_resource_throttle.h" | |
6 | |
7 #include "content/public/browser/android/download_controller_android.h" | |
8 #include "content/public/browser/resource_controller.h" | |
9 #include "net/http/http_request_headers.h" | |
10 #include "net/url_request/url_request.h" | |
11 | |
12 namespace chrome { | |
13 | |
14 InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle( | |
15 net::URLRequest* request, | |
16 int render_process_id, | |
17 int render_view_id, | |
18 int request_id) | |
19 : request_(request), | |
20 render_process_id_(render_process_id), | |
21 render_view_id_(render_view_id), | |
22 request_id_(request_id) { | |
23 } | |
24 | |
25 InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() { | |
26 } | |
27 | |
28 void InterceptDownloadResourceThrottle::WillStartRequest(bool* defer) { | |
29 ProcessDownloadRequest(); | |
30 } | |
31 | |
32 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) { | |
33 ProcessDownloadRequest(); | |
34 } | |
35 | |
36 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() { | |
37 if (request_->method() != net::HttpRequestHeaders::kGetMethod) | |
asanka
2013/04/05 16:57:35
What if the scheme isn't http or https?
| |
38 return; | |
39 | |
40 content::DownloadControllerAndroid::Get()->CreateGETDownload( | |
41 render_process_id_, render_view_id_, request_id_); | |
42 controller()->Cancel(); | |
43 } | |
44 | |
45 } // namespace | |
OLD | NEW |