OLD | NEW |
---|---|
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/renderer_host/chrome_resource_dispatcher_host_delegate. h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 #include "chrome/browser/supervised_user/supervised_user_resource_throttle.h" | 85 #include "chrome/browser/supervised_user/supervised_user_resource_throttle.h" |
86 #endif | 86 #endif |
87 | 87 |
88 #if defined(USE_SYSTEM_PROTOBUF) | 88 #if defined(USE_SYSTEM_PROTOBUF) |
89 #include <google/protobuf/repeated_field.h> | 89 #include <google/protobuf/repeated_field.h> |
90 #else | 90 #else |
91 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" | 91 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
92 #endif | 92 #endif |
93 | 93 |
94 #if BUILDFLAG(ANDROID_JAVA_UI) | 94 #if BUILDFLAG(ANDROID_JAVA_UI) |
95 #include "base/command_line.h" | |
96 #include "base/metrics/field_trial.h" | |
95 #include "chrome/browser/android/intercept_download_resource_throttle.h" | 97 #include "chrome/browser/android/intercept_download_resource_throttle.h" |
96 #endif | 98 #endif |
97 | 99 |
98 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
99 #include "chrome/browser/renderer_host/data_reduction_proxy_resource_throttle_an droid.h" | 101 #include "chrome/browser/renderer_host/data_reduction_proxy_resource_throttle_an droid.h" |
100 #include "components/navigation_interception/intercept_navigation_delegate.h" | 102 #include "components/navigation_interception/intercept_navigation_delegate.h" |
101 #endif | 103 #endif |
102 | 104 |
103 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 105 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
104 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_d ebug_resource_throttle.h" | 106 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_d ebug_resource_throttle.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 | 263 |
262 if (crx_id) { | 264 if (crx_id) { |
263 // We got a component we need to install, so throttle the resource | 265 // We got a component we need to install, so throttle the resource |
264 // until the component is installed. | 266 // until the component is installed. |
265 throttles->push_back( | 267 throttles->push_back( |
266 component_updater::GetOnDemandResourceThrottle(cus, crx_id)); | 268 component_updater::GetOnDemandResourceThrottle(cus, crx_id)); |
267 } | 269 } |
268 } | 270 } |
269 #endif // !defined(DISABLE_NACL) | 271 #endif // !defined(DISABLE_NACL) |
270 | 272 |
273 #if BUILDFLAG(ANDROID_JAVA_UI) | |
274 const char kDownloadInterception[] = "EnableDownloadInterception"; | |
275 | |
276 bool IsDownloadInterceptionEnabled() { | |
277 return base::StartsWith( | |
278 base::FieldTrialList::FindFullName(kDownloadInterception), "Enabled", | |
279 base::CompareCase::INSENSITIVE_ASCII); | |
asanka
2016/02/11 22:49:20
Let's move these out to a separate file.
qinmin
2016/02/12 00:31:56
Done. Moved to InterceptDownloadResourceThrottle c
| |
280 } | |
281 #endif // BUILDFLAG(ANDROID_JAVA_UI) | |
271 } // namespace | 282 } // namespace |
272 | 283 |
273 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 284 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
274 : download_request_limiter_(g_browser_process->download_request_limiter()), | 285 : download_request_limiter_(g_browser_process->download_request_limiter()), |
275 safe_browsing_(g_browser_process->safe_browsing_service()) | 286 safe_browsing_(g_browser_process->safe_browsing_service()) |
276 #if defined(ENABLE_EXTENSIONS) | 287 #if defined(ENABLE_EXTENSIONS) |
277 , user_script_listener_(new extensions::UserScriptListener()) | 288 , user_script_listener_(new extensions::UserScriptListener()) |
278 #endif | 289 #endif |
279 { | 290 { |
280 BrowserThread::PostTask( | 291 BrowserThread::PostTask( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); | 422 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); |
412 | 423 |
413 // If it's from the web, we don't trust it, so we push the throttle on. | 424 // If it's from the web, we don't trust it, so we push the throttle on. |
414 if (is_content_initiated) { | 425 if (is_content_initiated) { |
415 const content::ResourceRequestInfo* info = | 426 const content::ResourceRequestInfo* info = |
416 content::ResourceRequestInfo::ForRequest(request); | 427 content::ResourceRequestInfo::ForRequest(request); |
417 throttles->push_back(new DownloadResourceThrottle( | 428 throttles->push_back(new DownloadResourceThrottle( |
418 download_request_limiter_, info->GetWebContentsGetterForRequest(), | 429 download_request_limiter_, info->GetWebContentsGetterForRequest(), |
419 request->url(), request->method())); | 430 request->url(), request->method())); |
420 #if BUILDFLAG(ANDROID_JAVA_UI) | 431 #if BUILDFLAG(ANDROID_JAVA_UI) |
421 throttles->push_back( | 432 if (IsDownloadInterceptionEnabled() || |
422 new chrome::InterceptDownloadResourceThrottle( | 433 base::CommandLine::ForCurrentProcess()->HasSwitch( |
423 request, child_id, route_id, request_id)); | 434 switches::kEnableDownloadInterception)) { |
asanka
2016/02/11 22:49:20
Why is disabling the default?
Also, if the featur
qinmin
2016/02/12 00:31:56
Done. Now the remote server will disable download
| |
435 throttles->push_back(new chrome::InterceptDownloadResourceThrottle( | |
436 request, child_id, route_id, request_id)); | |
437 } | |
424 #endif | 438 #endif |
425 } | 439 } |
426 | 440 |
427 // If this isn't a new request, we've seen this before and added the standard | 441 // If this isn't a new request, we've seen this before and added the standard |
428 // resource throttles already so no need to add it again. | 442 // resource throttles already so no need to add it again. |
429 if (!request->is_pending()) { | 443 if (!request->is_pending()) { |
430 AppendStandardResourceThrottles(request, | 444 AppendStandardResourceThrottles(request, |
431 resource_context, | 445 resource_context, |
432 content::RESOURCE_TYPE_MAIN_FRAME, | 446 content::RESOURCE_TYPE_MAIN_FRAME, |
433 throttles); | 447 throttles); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 743 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); |
730 return false; | 744 return false; |
731 } | 745 } |
732 | 746 |
733 // static | 747 // static |
734 void ChromeResourceDispatcherHostDelegate:: | 748 void ChromeResourceDispatcherHostDelegate:: |
735 SetExternalProtocolHandlerDelegateForTesting( | 749 SetExternalProtocolHandlerDelegateForTesting( |
736 ExternalProtocolHandler::Delegate* delegate) { | 750 ExternalProtocolHandler::Delegate* delegate) { |
737 g_external_protocol_handler_delegate = delegate; | 751 g_external_protocol_handler_delegate = delegate; |
738 } | 752 } |
OLD | NEW |