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 // 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 |
122 // on policies first. | 123 // on policies first. |
123 if (safe_browsing_->enabled()) { | 124 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 125 resource_context.GetUserData(NULL)); |
| 126 if (io_data->safe_browsing_enabled()->GetValue()) { |
124 handler = CreateSafeBrowsingResourceHandler( | 127 handler = CreateSafeBrowsingResourceHandler( |
125 handler, child_id, route_id, is_subresource); | 128 handler, child_id, route_id, is_subresource); |
126 } | 129 } |
127 | 130 |
128 #if defined(OS_CHROMEOS) | 131 #if defined(OS_CHROMEOS) |
129 // 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 |
130 // unsafe site after we remove offline page. | 133 // unsafe site after we remove offline page. |
131 handler = new OfflineResourceHandler( | 134 handler = new OfflineResourceHandler( |
132 handler, child_id, route_id, resource_dispatcher_host_, request); | 135 handler, child_id, route_id, resource_dispatcher_host_, request); |
133 #endif | 136 #endif |
134 return handler; | 137 return handler; |
135 } | 138 } |
136 | 139 |
137 ResourceHandler* ChromeResourceDispatcherHostDelegate::DownloadStarting( | 140 ResourceHandler* ChromeResourceDispatcherHostDelegate::DownloadStarting( |
138 ResourceHandler* handler, | 141 ResourceHandler* handler, |
| 142 const content::ResourceContext& resource_context, |
139 int child_id, | 143 int child_id, |
140 int route_id) { | 144 int route_id) { |
141 if (!safe_browsing_->enabled()) | 145 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 146 resource_context.GetUserData(NULL)); |
| 147 if (!io_data->safe_browsing_enabled()->GetValue()) |
142 return handler; | 148 return handler; |
143 | 149 |
144 return CreateSafeBrowsingResourceHandler(handler, child_id, route_id, false); | 150 return CreateSafeBrowsingResourceHandler(handler, child_id, route_id, false); |
145 } | 151 } |
146 | 152 |
147 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart( | 153 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart( |
148 net::URLRequest* request, | 154 net::URLRequest* request, |
149 const content::ResourceContext& resource_context) { | 155 const content::ResourceContext& resource_context) { |
150 ResourceDispatcherHostRequestInfo* info = | 156 ResourceDispatcherHostRequestInfo* info = |
151 resource_dispatcher_host_->InfoForRequest(request); | 157 resource_dispatcher_host_->InfoForRequest(request); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 info->route_id(), request->url(), | 249 info->route_id(), request->url(), |
244 map->GetContentSettings(request->url(), request->url()))); | 250 map->GetContentSettings(request->url(), request->url()))); |
245 } | 251 } |
246 | 252 |
247 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 253 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
248 net::URLRequest* request, | 254 net::URLRequest* request, |
249 ResourceResponse* response, | 255 ResourceResponse* response, |
250 ResourceMessageFilter* filter) { | 256 ResourceMessageFilter* filter) { |
251 LoadTimingObserver::PopulateTimingInfo(request, response); | 257 LoadTimingObserver::PopulateTimingInfo(request, response); |
252 } | 258 } |
OLD | NEW |