Chromium Code Reviews| Index: chrome/browser/android/intercept_download_resource_throttle.cc |
| diff --git a/chrome/browser/android/intercept_download_resource_throttle.cc b/chrome/browser/android/intercept_download_resource_throttle.cc |
| index 1592233f81895c4a8ad36a5e77f949d2378b0100..09a0585dcfa1d27ef997425efecbe4cf0d199df5 100644 |
| --- a/chrome/browser/android/intercept_download_resource_throttle.cc |
| +++ b/chrome/browser/android/intercept_download_resource_throttle.cc |
| @@ -4,7 +4,11 @@ |
| #include "chrome/browser/android/intercept_download_resource_throttle.h" |
| +#include "base/command_line.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram_macros.h" |
| +#include "base/strings/string_util.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" |
| #include "content/public/browser/android/download_controller_android.h" |
| #include "content/public/browser/resource_controller.h" |
| @@ -14,6 +18,9 @@ |
| namespace { |
| +// Finch flag to be passed in. |
| +const char kDisableDownloadInterception[] = "DisableDownloadInterception"; |
| + |
| // UMA histogram for tracking reasons that chrome fails to intercept the |
| // download. Keep this in sync with MobileDownloadInterceptFailureReasons in |
| // histograms.xml. |
| @@ -41,6 +48,24 @@ void RecordInterceptFailureReasons( |
| namespace chrome { |
| +// static |
| +bool InterceptDownloadResourceThrottle::IsDownloadInterceptionEnabled() { |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableDownloadInterception)) { |
| + return true; |
| + } |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kDisableDownloadInterception)) { |
| + return false; |
| + } |
| + |
| + return !base::StartsWith( |
| + base::FieldTrialList::FindFullName(kDisableDownloadInterception), |
|
asanka
2016/02/23 02:55:30
See base/feature_list.h . Rather than add the enab
qinmin
2016/02/23 22:28:05
Done.
|
| + "Enabled", base::CompareCase::INSENSITIVE_ASCII); |
| +} |
| + |
| InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle( |
| net::URLRequest* request, |
| int render_process_id, |
| @@ -64,6 +89,9 @@ const char* InterceptDownloadResourceThrottle::GetNameForLogging() const { |
| } |
| void InterceptDownloadResourceThrottle::ProcessDownloadRequest() { |
| + if (!IsDownloadInterceptionEnabled()) |
| + return; |
| + |
| if (request_->url_chain().empty()) { |
| RecordInterceptFailureReasons(EMPTY_URL); |
| return; |