| 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" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 resource_type, | 196 resource_type, |
| 197 throttles); | 197 throttles); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 200 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 201 net::URLRequest* request, | 201 net::URLRequest* request, |
| 202 content::ResourceContext* resource_context, | 202 content::ResourceContext* resource_context, |
| 203 int child_id, | 203 int child_id, |
| 204 int route_id, | 204 int route_id, |
| 205 int request_id, | 205 int request_id, |
| 206 bool is_new_request, | 206 bool is_content_initiated, |
| 207 ScopedVector<content::ResourceThrottle>* throttles) { | 207 ScopedVector<content::ResourceThrottle>* throttles) { |
| 208 BrowserThread::PostTask( | 208 BrowserThread::PostTask( |
| 209 BrowserThread::UI, FROM_HERE, | 209 BrowserThread::UI, FROM_HERE, |
| 210 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); | 210 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); |
| 211 | 211 |
| 212 // If this isn't a new request, we've seen this before and added the safe | 212 // If it's from the web, we don't trust it, so we push the throttle on. |
| 213 // browsing resource throttle already so no need to add it again. This code | 213 if (is_content_initiated) { |
| 214 // path is only hit for requests initiated through the browser, and not the | 214 throttles->push_back(new DownloadResourceThrottle( |
| 215 // web, so no need to add the download throttle. | 215 download_request_limiter_, child_id, route_id, request_id, |
| 216 if (is_new_request) { | 216 request->method())); |
| 217 } |
| 218 |
| 219 // If this isn't a new request, we've seen this before and added the standard |
| 220 // resource throttles already so no need to add it again. |
| 221 if (!request->is_pending()) { |
| 217 AppendStandardResourceThrottles(request, | 222 AppendStandardResourceThrottles(request, |
| 218 resource_context, | 223 resource_context, |
| 219 child_id, | 224 child_id, |
| 220 route_id, | 225 route_id, |
| 221 ResourceType::MAIN_FRAME, | 226 ResourceType::MAIN_FRAME, |
| 222 throttles); | 227 throttles); |
| 223 } else { | |
| 224 throttles->push_back(new DownloadResourceThrottle( | |
| 225 download_request_limiter_, child_id, route_id, request_id, | |
| 226 request->method())); | |
| 227 } | 228 } |
| 228 } | 229 } |
| 229 | 230 |
| 230 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest( | 231 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest( |
| 231 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) { | 232 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) { |
| 232 if (request->load_flags() & net::LOAD_PREFETCH) | 233 if (request->load_flags() & net::LOAD_PREFETCH) |
| 233 return false; | 234 return false; |
| 234 | 235 |
| 235 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); | 236 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); |
| 236 if (user_data && user_data->is_prerender()) { | 237 if (user_data && user_data->is_prerender()) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 if (base::Base64Encode(serialized, &hashed)) { | 456 if (base::Base64Encode(serialized, &hashed)) { |
| 456 // If successful, swap the header value with the new one. | 457 // If successful, swap the header value with the new one. |
| 457 // Note that the list of IDs and the header could be temporarily out of sync | 458 // Note that the list of IDs and the header could be temporarily out of sync |
| 458 // if IDs are added as we are recreating the header, but we're OK with those | 459 // if IDs are added as we are recreating the header, but we're OK with those |
| 459 // descrepancies. | 460 // descrepancies. |
| 460 variation_ids_header_ = hashed; | 461 variation_ids_header_ = hashed; |
| 461 } else { | 462 } else { |
| 462 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; | 463 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; |
| 463 } | 464 } |
| 464 } | 465 } |
| OLD | NEW |