Chromium Code Reviews| 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/external_protocol/external_protocol_handler.h" | 10 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 prerender::FINAL_STATUS_INVALID_HTTP_METHOD); | 105 prerender::FINAL_STATUS_INVALID_HTTP_METHOD); |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 ResourceHandler* ChromeResourceDispatcherHostDelegate::RequestBeginning( | 112 ResourceHandler* ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 113 ResourceHandler* handler, | 113 ResourceHandler* handler, |
| 114 net::URLRequest* request, | 114 net::URLRequest* request, |
| 115 const content::ResourceContext& resource_context, | |
| 115 bool is_subresource, | 116 bool is_subresource, |
| 116 int child_id, | 117 int child_id, |
| 117 int route_id) { | 118 int route_id) { |
| 118 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) | 119 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) |
| 119 request->set_load_flags(request->load_flags() | net::LOAD_PRERENDERING); | 120 request->set_load_flags(request->load_flags() | net::LOAD_PRERENDERING); |
| 120 | 121 |
| 121 #if defined(ENABLE_SAFE_BROWSING) | |
|
mattm
2011/07/12 21:41:58
dropped merges
Miranda Callahan
2011/07/13 18:13:51
Done.
| |
| 122 // Insert safe browsing at the front of the chain, so it gets to decide | 122 // Insert safe browsing at the front of the chain, so it gets to decide |
| 123 // on policies first. | 123 // on policies first. |
| 124 if (safe_browsing_->enabled()) { | 124 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 125 resource_context.GetUserData(NULL)); | |
| 126 if (io_data->safe_browsing_enabled()->GetValue()) { | |
| 125 handler = CreateSafeBrowsingResourceHandler( | 127 handler = CreateSafeBrowsingResourceHandler( |
| 126 handler, child_id, route_id, is_subresource); | 128 handler, child_id, route_id, is_subresource); |
| 127 } | 129 } |
| 128 #endif | |
| 129 | 130 |
| 130 #if defined(OS_CHROMEOS) | 131 #if defined(OS_CHROMEOS) |
| 131 // We check offline first, then check safe browsing so that we still can block | 132 // We check offline first, then check safe browsing so that we still can block |
| 132 // unsafe site after we remove offline page. | 133 // unsafe site after we remove offline page. |
| 133 handler = new OfflineResourceHandler( | 134 handler = new OfflineResourceHandler( |
| 134 handler, child_id, route_id, resource_dispatcher_host_, request); | 135 handler, child_id, route_id, resource_dispatcher_host_, request); |
| 135 #endif | 136 #endif |
| 136 return handler; | 137 return handler; |
| 137 } | 138 } |
| 138 | 139 |
| 139 ResourceHandler* ChromeResourceDispatcherHostDelegate::DownloadStarting( | 140 ResourceHandler* ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 140 ResourceHandler* handler, | 141 ResourceHandler* handler, |
| 142 const content::ResourceContext& resource_context, | |
| 141 int child_id, | 143 int child_id, |
| 142 int route_id) { | 144 int route_id) { |
| 143 #if defined(ENABLE_SAFE_BROWSING) | 145 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 144 if (!safe_browsing_->enabled()) | 146 resource_context.GetUserData(NULL)); |
| 147 if (!io_data->safe_browsing_enabled()->GetValue()) | |
| 145 return handler; | 148 return handler; |
| 146 | 149 |
| 147 return CreateSafeBrowsingResourceHandler(handler, child_id, route_id, false); | 150 return CreateSafeBrowsingResourceHandler(handler, child_id, route_id, false); |
| 148 #else | |
| 149 return handler; | |
| 150 #endif | |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart( | 153 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart( |
| 154 net::URLRequest* request, | 154 net::URLRequest* request, |
| 155 const content::ResourceContext& resource_context) { | 155 const content::ResourceContext& resource_context) { |
| 156 ResourceDispatcherHostRequestInfo* info = | 156 ResourceDispatcherHostRequestInfo* info = |
| 157 resource_dispatcher_host_->InfoForRequest(request); | 157 resource_dispatcher_host_->InfoForRequest(request); |
| 158 return prerender_tracker_->PotentiallyDelayRequestOnIOThread( | 158 return prerender_tracker_->PotentiallyDelayRequestOnIOThread( |
| 159 request->url(), resource_context.prerender_manager(), | 159 request->url(), resource_context.prerender_manager(), |
| 160 info->child_id(), info->route_id(), info->request_id()); | 160 info->child_id(), info->route_id(), info->request_id()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 } | 208 } |
| 209 | 209 |
| 210 void ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 210 void ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
| 211 const GURL& url, int child_id, int route_id) { | 211 const GURL& url, int child_id, int route_id) { |
| 212 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
| 213 BrowserThread::UI, FROM_HERE, | 213 BrowserThread::UI, FROM_HERE, |
| 214 NewRunnableFunction( | 214 NewRunnableFunction( |
| 215 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); | 215 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 #if defined(ENABLE_SAFE_BROWSING) | |
| 219 ResourceHandler* | 218 ResourceHandler* |
| 220 ChromeResourceDispatcherHostDelegate::CreateSafeBrowsingResourceHandler( | 219 ChromeResourceDispatcherHostDelegate::CreateSafeBrowsingResourceHandler( |
| 221 ResourceHandler* handler, int child_id, int route_id, | 220 ResourceHandler* handler, int child_id, int route_id, |
| 222 bool subresource) { | 221 bool subresource) { |
| 223 return SafeBrowsingResourceHandler::Create( | 222 return SafeBrowsingResourceHandler::Create( |
| 224 handler, child_id, route_id, subresource, safe_browsing_, | 223 handler, child_id, route_id, subresource, safe_browsing_, |
| 225 resource_dispatcher_host_); | 224 resource_dispatcher_host_); |
| 226 } | 225 } |
| 227 #endif | |
| 228 | 226 |
| 229 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( | 227 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
| 230 const GURL& url, const std::string& mime_type) { | 228 const GURL& url, const std::string& mime_type) { |
| 231 // Special-case user scripts to get downloaded instead of viewed. | 229 // Special-case user scripts to get downloaded instead of viewed. |
| 232 return UserScript::IsURLUserScript(url, mime_type); | 230 return UserScript::IsURLUserScript(url, mime_type); |
| 233 } | 231 } |
| 234 | 232 |
| 235 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 233 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
| 236 net::URLRequest* request, | 234 net::URLRequest* request, |
| 237 ResourceResponse* response, | 235 ResourceResponse* response, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 251 info->route_id(), request->url(), | 249 info->route_id(), request->url(), |
| 252 map->GetContentSettings(request->url(), request->url()))); | 250 map->GetContentSettings(request->url(), request->url()))); |
| 253 } | 251 } |
| 254 | 252 |
| 255 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 253 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
| 256 net::URLRequest* request, | 254 net::URLRequest* request, |
| 257 ResourceResponse* response, | 255 ResourceResponse* response, |
| 258 ResourceMessageFilter* filter) { | 256 ResourceMessageFilter* filter) { |
| 259 LoadTimingObserver::PopulateTimingInfo(request, response); | 257 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 260 } | 258 } |
| OLD | NEW |