Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1419)

Side by Side Diff: chrome/browser/android/intercept_download_resource_throttle.cc

Issue 1692693003: add a flag to enable/disable download interception on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused variable Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/intercept_download_resource_throttle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/android/intercept_download_resource_throttle.h" 5 #include "chrome/browser/android/intercept_download_resource_throttle.h"
6 6
7 #include "base/feature_list.h"
7 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "chrome/browser/android/chrome_feature_list.h"
8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
9 #include "content/public/browser/android/download_controller_android.h" 11 #include "content/public/browser/android/download_controller_android.h"
10 #include "content/public/browser/resource_controller.h" 12 #include "content/public/browser/resource_controller.h"
11 #include "net/http/http_request_headers.h" 13 #include "net/http/http_request_headers.h"
12 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
13 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
14 16
15 namespace { 17 namespace {
16 18
17 // UMA histogram for tracking reasons that chrome fails to intercept the 19 // UMA histogram for tracking reasons that chrome fails to intercept the
(...skipping 16 matching lines...) Expand all
34 MobileDownloadInterceptFailureReason reason) { 36 MobileDownloadInterceptFailureReason reason) {
35 UMA_HISTOGRAM_ENUMERATION("MobileDownload.InterceptFailureReason", 37 UMA_HISTOGRAM_ENUMERATION("MobileDownload.InterceptFailureReason",
36 reason, 38 reason,
37 FAILURE_REASON_SIZE); 39 FAILURE_REASON_SIZE);
38 } 40 }
39 41
40 } // namespace 42 } // namespace
41 43
42 namespace chrome { 44 namespace chrome {
43 45
46 // static
47 bool InterceptDownloadResourceThrottle::IsDownloadInterceptionEnabled() {
48 return base::FeatureList::IsEnabled(chrome::android::kSystemDownloadManager);
49 }
50
44 InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle( 51 InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle(
45 net::URLRequest* request, 52 net::URLRequest* request,
46 int render_process_id, 53 int render_process_id,
47 int render_view_id, 54 int render_view_id,
48 int request_id) 55 int request_id)
49 : request_(request), 56 : request_(request),
50 render_process_id_(render_process_id), 57 render_process_id_(render_process_id),
51 render_view_id_(render_view_id), 58 render_view_id_(render_view_id),
52 request_id_(request_id) { 59 request_id_(request_id) {
53 } 60 }
54 61
55 InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() { 62 InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() {
56 } 63 }
57 64
58 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) { 65 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) {
59 ProcessDownloadRequest(); 66 ProcessDownloadRequest();
60 } 67 }
61 68
62 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const { 69 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const {
63 return "InterceptDownloadResourceThrottle"; 70 return "InterceptDownloadResourceThrottle";
64 } 71 }
65 72
66 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() { 73 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
74 if (!IsDownloadInterceptionEnabled())
75 return;
76
67 if (request_->url_chain().empty()) { 77 if (request_->url_chain().empty()) {
68 RecordInterceptFailureReasons(EMPTY_URL); 78 RecordInterceptFailureReasons(EMPTY_URL);
69 return; 79 return;
70 } 80 }
71 81
72 GURL url = request_->url_chain().back(); 82 GURL url = request_->url_chain().back();
73 if (!url.SchemeIsHTTPOrHTTPS()) { 83 if (!url.SchemeIsHTTPOrHTTPS()) {
74 RecordInterceptFailureReasons(NON_HTTP_OR_HTTPS); 84 RecordInterceptFailureReasons(NON_HTTP_OR_HTTPS);
75 return; 85 return;
76 } 86 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return; 118 return;
109 } 119 }
110 120
111 content::DownloadControllerAndroid::Get()->CreateGETDownload( 121 content::DownloadControllerAndroid::Get()->CreateGETDownload(
112 render_process_id_, render_view_id_, request_id_); 122 render_process_id_, render_view_id_, request_id_);
113 controller()->Cancel(); 123 controller()->Cancel();
114 RecordInterceptFailureReasons(NO_FAILURE); 124 RecordInterceptFailureReasons(NO_FAILURE);
115 } 125 }
116 126
117 } // namespace chrome 127 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/intercept_download_resource_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698