| 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> |
| 11 | 11 |
| 12 #include "base/base64.h" | 12 #include "base/base64.h" |
| 13 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string_util.h" |
| 15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/component_updater/component_updater_resource_throttle.h
" | 20 #include "chrome/browser/component_updater/component_updater_resource_throttle.h
" |
| 19 #include "chrome/browser/download/download_request_limiter.h" | 21 #include "chrome/browser/download/download_request_limiter.h" |
| 20 #include "chrome/browser/download/download_resource_throttle.h" | 22 #include "chrome/browser/download/download_resource_throttle.h" |
| 21 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" | 23 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" |
| 22 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 24 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 23 #include "chrome/browser/plugins/plugin_prefs.h" | 25 #include "chrome/browser/plugins/plugin_prefs.h" |
| 24 #include "chrome/browser/prefetch/prefetch.h" | |
| 25 #include "chrome/browser/prerender/prerender_manager.h" | 26 #include "chrome/browser/prerender/prerender_manager.h" |
| 26 #include "chrome/browser/prerender/prerender_manager_factory.h" | 27 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 27 #include "chrome/browser/prerender/prerender_resource_throttle.h" | 28 #include "chrome/browser/prerender/prerender_resource_throttle.h" |
| 28 #include "chrome/browser/prerender/prerender_util.h" | 29 #include "chrome/browser/prerender/prerender_util.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_io_data.h" | 31 #include "chrome/browser/profiles/profile_io_data.h" |
| 31 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 32 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
| 32 #include "chrome/browser/renderer_host/thread_hop_resource_throttle.h" | 33 #include "chrome/browser/renderer_host/thread_hop_resource_throttle.h" |
| 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 34 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 34 #include "chrome/browser/signin/chrome_signin_helper.h" | 35 #include "chrome/browser/signin/chrome_signin_helper.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 291 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 291 | 292 |
| 292 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the | 293 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the |
| 293 // request. Otherwise, do a normal request to warm the cache. | 294 // request. Otherwise, do a normal request to warm the cache. |
| 294 if (resource_type == content::RESOURCE_TYPE_PREFETCH) { | 295 if (resource_type == content::RESOURCE_TYPE_PREFETCH) { |
| 295 // All PREFETCH requests should be GETs, but be defensive about it. | 296 // All PREFETCH requests should be GETs, but be defensive about it. |
| 296 if (method != "GET") | 297 if (method != "GET") |
| 297 return false; | 298 return false; |
| 298 | 299 |
| 299 // If prefetch is disabled, kill the request. | 300 // If prefetch is disabled, kill the request. |
| 300 if (!prefetch::IsPrefetchEnabled(resource_context)) | 301 std::string prefetch_experiment = |
| 302 base::FieldTrialList::FindFullName("Prefetch"); |
| 303 if (base::StartsWith(prefetch_experiment, "ExperimentDisable", |
| 304 base::CompareCase::INSENSITIVE_ASCII)) { |
| 301 return false; | 305 return false; |
| 306 } |
| 302 } | 307 } |
| 303 | 308 |
| 304 return true; | 309 return true; |
| 305 } | 310 } |
| 306 | 311 |
| 307 void ChromeResourceDispatcherHostDelegate::RequestBeginning( | 312 void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 308 net::URLRequest* request, | 313 net::URLRequest* request, |
| 309 content::ResourceContext* resource_context, | 314 content::ResourceContext* resource_context, |
| 310 content::AppCacheService* appcache_service, | 315 content::AppCacheService* appcache_service, |
| 311 ResourceType resource_type, | 316 ResourceType resource_type, |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 714 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); |
| 710 return false; | 715 return false; |
| 711 } | 716 } |
| 712 | 717 |
| 713 // static | 718 // static |
| 714 void ChromeResourceDispatcherHostDelegate:: | 719 void ChromeResourceDispatcherHostDelegate:: |
| 715 SetExternalProtocolHandlerDelegateForTesting( | 720 SetExternalProtocolHandlerDelegateForTesting( |
| 716 ExternalProtocolHandler::Delegate* delegate) { | 721 ExternalProtocolHandler::Delegate* delegate) { |
| 717 g_external_protocol_handler_delegate = delegate; | 722 g_external_protocol_handler_delegate = delegate; |
| 718 } | 723 } |
| OLD | NEW |