| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/download/download_request_limiter.h" | 10 #include "chrome/browser/download/download_request_limiter.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // If prefetch is disabled, kill the request. | 116 // If prefetch is disabled, kill the request. |
| 117 if (!ResourceDispatcherHost::is_prefetch_enabled()) | 117 if (!ResourceDispatcherHost::is_prefetch_enabled()) |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Handle a PRERENDER motivated request. Very similar to rel=prefetch, these | 121 // Handle a PRERENDER motivated request. Very similar to rel=prefetch, these |
| 122 // rel=prerender requests instead launch an early render of the entire page. | 122 // rel=prerender requests instead launch an early render of the entire page. |
| 123 if (request_data.resource_type == ResourceType::PRERENDER) { | 123 if (request_data.resource_type == ResourceType::PRERENDER) { |
| 124 if (prerender::PrerenderManager::IsPrerenderingPossible()) { | 124 if (prerender::PrerenderManager::IsPrerenderingPossible()) { |
| 125 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 125 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 126 NewRunnableFunction(AddPrerenderOnUI, | 126 base::Bind(&AddPrerenderOnUI, |
| 127 child_id, | 127 child_id, |
| 128 route_id, | 128 route_id, |
| 129 request_data.url, | 129 request_data.url, |
| 130 referrer)); | 130 referrer)); |
| 131 } | 131 } |
| 132 // Prerendering or not, this request should be aborted. | 132 // Prerendering or not, this request should be aborted. |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Abort any prerenders that spawn requests that use invalid HTTP methods. | 136 // Abort any prerenders that spawn requests that use invalid HTTP methods. |
| 137 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id) && | 137 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id) && |
| 138 !prerender::PrerenderManager::IsValidHttpMethod(request_data.method)) { | 138 !prerender::PrerenderManager::IsValidHttpMethod(request_data.method)) { |
| 139 prerender_tracker_->TryCancelOnIOThread( | 139 prerender_tracker_->TryCancelOnIOThread( |
| 140 child_id, route_id, | 140 child_id, route_id, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 const content::ResourceContext& resource_context, | 185 const content::ResourceContext& resource_context, |
| 186 net::URLRequest* request, | 186 net::URLRequest* request, |
| 187 int child_id, | 187 int child_id, |
| 188 int route_id, | 188 int route_id, |
| 189 int request_id, | 189 int request_id, |
| 190 bool is_new_request, | 190 bool is_new_request, |
| 191 bool in_complete) { | 191 bool in_complete) { |
| 192 | 192 |
| 193 BrowserThread::PostTask( | 193 BrowserThread::PostTask( |
| 194 BrowserThread::UI, FROM_HERE, | 194 BrowserThread::UI, FROM_HERE, |
| 195 NewRunnableFunction(&NotifyDownloadInitiatedOnUI, child_id, route_id)); | 195 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); |
| 196 | 196 |
| 197 // If this isn't a new request, we've seen this before and added the safe | 197 // If this isn't a new request, we've seen this before and added the safe |
| 198 // browsing resource handler already so no need to add it again. This code | 198 // browsing resource handler already so no need to add it again. This code |
| 199 // path is only hit for requests initiated through the browser, and not the | 199 // path is only hit for requests initiated through the browser, and not the |
| 200 // web, so no need to add the throttling handler. | 200 // web, so no need to add the throttling handler. |
| 201 if (is_new_request) { | 201 if (is_new_request) { |
| 202 #if defined(ENABLE_SAFE_BROWSING) | 202 #if defined(ENABLE_SAFE_BROWSING) |
| 203 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( | 203 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 204 resource_context.GetUserData(NULL)); | 204 resource_context.GetUserData(NULL)); |
| 205 if (!io_data->safe_browsing_enabled()->GetValue()) | 205 if (!io_data->safe_browsing_enabled()->GetValue()) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 InstantLoader::kInstantHeader, &instant_header_value) && | 277 InstantLoader::kInstantHeader, &instant_header_value) && |
| 278 instant_header_value == InstantLoader::kInstantHeaderValue) | 278 instant_header_value == InstantLoader::kInstantHeaderValue) |
| 279 return new InstantResourceDispatcherHostLoginDelegate; | 279 return new InstantResourceDispatcherHostLoginDelegate; |
| 280 return CreateLoginPrompt(auth_info, request); | 280 return CreateLoginPrompt(auth_info, request); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 283 void ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
| 284 const GURL& url, int child_id, int route_id) { | 284 const GURL& url, int child_id, int route_id) { |
| 285 BrowserThread::PostTask( | 285 BrowserThread::PostTask( |
| 286 BrowserThread::UI, FROM_HERE, | 286 BrowserThread::UI, FROM_HERE, |
| 287 NewRunnableFunction( | 287 base::Bind(&ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); |
| 288 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); | |
| 289 } | 288 } |
| 290 | 289 |
| 291 #if defined(ENABLE_SAFE_BROWSING) | 290 #if defined(ENABLE_SAFE_BROWSING) |
| 292 ResourceHandler* | 291 ResourceHandler* |
| 293 ChromeResourceDispatcherHostDelegate::CreateSafeBrowsingResourceHandler( | 292 ChromeResourceDispatcherHostDelegate::CreateSafeBrowsingResourceHandler( |
| 294 ResourceHandler* handler, int child_id, int route_id, | 293 ResourceHandler* handler, int child_id, int route_id, |
| 295 bool subresource) { | 294 bool subresource) { |
| 296 return SafeBrowsingResourceHandler::Create( | 295 return SafeBrowsingResourceHandler::Create( |
| 297 handler, child_id, route_id, subresource, safe_browsing_, | 296 handler, child_id, route_id, subresource, safe_browsing_, |
| 298 resource_dispatcher_host_); | 297 resource_dispatcher_host_); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->child_id(), | 329 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->child_id(), |
| 331 info->route_id()); | 330 info->route_id()); |
| 332 } | 331 } |
| 333 | 332 |
| 334 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 333 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
| 335 net::URLRequest* request, | 334 net::URLRequest* request, |
| 336 ResourceResponse* response, | 335 ResourceResponse* response, |
| 337 ResourceMessageFilter* filter) { | 336 ResourceMessageFilter* filter) { |
| 338 LoadTimingObserver::PopulateTimingInfo(request, response); | 337 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 339 } | 338 } |
| OLD | NEW |