| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 13 #include "chrome/browser/download/download_request_limiter.h" | 13 #include "chrome/browser/download/download_request_limiter.h" |
| 14 #include "chrome/browser/download/download_resource_throttle.h" | 14 #include "chrome/browser/download/download_resource_throttle.h" |
| 15 #include "chrome/browser/download/download_util.h" | 15 #include "chrome/browser/download/download_util.h" |
| 16 #include "chrome/browser/extensions/api/streams_private/streams_resource_throttl
e.h" |
| 16 #include "chrome/browser/extensions/user_script_listener.h" | 17 #include "chrome/browser/extensions/user_script_listener.h" |
| 17 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 18 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 18 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
| 19 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" | 20 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
| 20 #include "chrome/browser/net/load_timing_observer.h" | 21 #include "chrome/browser/net/load_timing_observer.h" |
| 21 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 22 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 22 #include "chrome/browser/prerender/prerender_manager.h" | 23 #include "chrome/browser/prerender/prerender_manager.h" |
| 23 #include "chrome/browser/prerender/prerender_tracker.h" | 24 #include "chrome/browser/prerender/prerender_tracker.h" |
| 24 #include "chrome/browser/prerender/prerender_util.h" | 25 #include "chrome/browser/prerender/prerender_util.h" |
| 25 #include "chrome/browser/profiles/profile_io_data.h" | 26 #include "chrome/browser/profiles/profile_io_data.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 52 #include <google/protobuf/repeated_field.h> | 53 #include <google/protobuf/repeated_field.h> |
| 53 #else | 54 #else |
| 54 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" | 55 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
| 58 #include "components/navigation_interception/intercept_navigation_delegate.h" | 59 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
| 62 #include "chrome/browser/chromeos/extensions/file_browser_resource_throttle.h" | |
| 63 #include "chrome/browser/chromeos/login/merge_session_throttle.h" | 63 #include "chrome/browser/chromeos/login/merge_session_throttle.h" |
| 64 // TODO(oshima): Enable this for other platforms. | 64 // TODO(oshima): Enable this for other platforms. |
| 65 #include "chrome/browser/renderer_host/offline_resource_throttle.h" | 65 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 using content::BrowserThread; | 68 using content::BrowserThread; |
| 69 using content::RenderViewHost; | 69 using content::RenderViewHost; |
| 70 using content::ResourceDispatcherHostLoginDelegate; | 70 using content::ResourceDispatcherHostLoginDelegate; |
| 71 using content::ResourceRequestInfo; | 71 using content::ResourceRequestInfo; |
| 72 | 72 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 int request_id, | 214 int request_id, |
| 215 bool is_content_initiated, | 215 bool is_content_initiated, |
| 216 bool must_download, | 216 bool must_download, |
| 217 ScopedVector<content::ResourceThrottle>* throttles) { | 217 ScopedVector<content::ResourceThrottle>* throttles) { |
| 218 BrowserThread::PostTask( | 218 BrowserThread::PostTask( |
| 219 BrowserThread::UI, FROM_HERE, | 219 BrowserThread::UI, FROM_HERE, |
| 220 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); | 220 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); |
| 221 | 221 |
| 222 // If it's from the web, we don't trust it, so we push the throttle on. | 222 // If it's from the web, we don't trust it, so we push the throttle on. |
| 223 if (is_content_initiated) { | 223 if (is_content_initiated) { |
| 224 #if defined(OS_CHROMEOS) | 224 #if !defined(OS_ANDROID) |
| 225 if (!must_download) { | 225 if (!must_download) { |
| 226 ProfileIOData* io_data = | 226 ProfileIOData* io_data = |
| 227 ProfileIOData::FromResourceContext(resource_context); | 227 ProfileIOData::FromResourceContext(resource_context); |
| 228 throttles->push_back(FileBrowserResourceThrottle::Create( | 228 throttles->push_back(StreamsResourceThrottle::Create( |
| 229 child_id, route_id, request, io_data->is_incognito(), | 229 child_id, route_id, request, io_data->is_incognito(), |
| 230 io_data->GetExtensionInfoMap())); | 230 io_data->GetExtensionInfoMap())); |
| 231 } | 231 } |
| 232 #endif // defined(OS_CHROMEOS) | 232 #endif |
| 233 | 233 |
| 234 throttles->push_back(new DownloadResourceThrottle( | 234 throttles->push_back(new DownloadResourceThrottle( |
| 235 download_request_limiter_, child_id, route_id, request_id, | 235 download_request_limiter_, child_id, route_id, request_id, |
| 236 request->method())); | 236 request->method())); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // If this isn't a new request, we've seen this before and added the standard | 239 // If this isn't a new request, we've seen this before and added the standard |
| 240 // resource throttles already so no need to add it again. | 240 // resource throttles already so no need to add it again. |
| 241 if (!request->is_pending()) { | 241 if (!request->is_pending()) { |
| 242 AppendStandardResourceThrottles(request, | 242 AppendStandardResourceThrottles(request, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 info->GetChildID(), | 452 info->GetChildID(), |
| 453 info->GetRouteID()); | 453 info->GetRouteID()); |
| 454 AppendChromeSyncGaiaHeader(request, resource_context); | 454 AppendChromeSyncGaiaHeader(request, resource_context); |
| 455 #endif | 455 #endif |
| 456 | 456 |
| 457 if (io_data->resource_prefetch_predictor_observer()) { | 457 if (io_data->resource_prefetch_predictor_observer()) { |
| 458 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( | 458 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( |
| 459 redirect_url, request); | 459 redirect_url, request); |
| 460 } | 460 } |
| 461 } | 461 } |
| OLD | NEW |