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/safe_browsing_resource_handler.h" | 5 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/renderer_host/global_request_id.h" | 8 #include "chrome/browser/renderer_host/global_request_id.h" |
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "chrome/browser/renderer_host/resource_message_filter.h" | 10 #include "chrome/browser/renderer_host/resource_message_filter.h" |
11 #include "chrome/common/resource_response.h" | 11 #include "chrome/common/resource_response.h" |
12 #include "net/base/io_buffer.h" | |
13 #include "net/base/load_flags.h" | |
12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
13 #include "net/base/io_buffer.h" | |
14 | 15 |
15 // Maximum time in milliseconds to wait for the safe browsing service to | 16 // Maximum time in milliseconds to wait for the safe browsing service to |
16 // verify a URL. After this amount of time the outstanding check will be | 17 // verify a URL. After this amount of time the outstanding check will be |
17 // aborted, and the URL will be treated as if it were safe. | 18 // aborted, and the URL will be treated as if it were safe. |
18 static const int kCheckUrlTimeoutMs = 5000; | 19 static const int kCheckUrlTimeoutMs = 5000; |
19 | 20 |
20 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more | 21 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more |
21 // unit test coverage. | 22 // unit test coverage. |
22 | 23 |
23 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( | 24 SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 } | 166 } |
166 | 167 |
167 void SafeBrowsingResourceHandler::StartDisplayingBlockingPage( | 168 void SafeBrowsingResourceHandler::StartDisplayingBlockingPage( |
168 const GURL& url, | 169 const GURL& url, |
169 SafeBrowsingService::UrlCheckResult result) { | 170 SafeBrowsingService::UrlCheckResult result) { |
170 CHECK(state_ == STATE_NONE); | 171 CHECK(state_ == STATE_NONE); |
171 CHECK(defer_state_ != DEFERRED_NONE); | 172 CHECK(defer_state_ != DEFERRED_NONE); |
172 CHECK(deferred_request_id_ != -1); | 173 CHECK(deferred_request_id_ != -1); |
173 | 174 |
174 state_ = STATE_DISPLAYING_BLOCKING_PAGE; | 175 state_ = STATE_DISPLAYING_BLOCKING_PAGE; |
175 AddRef(); // Balanced in OnBlockingPageComplete(). | 176 AddRef(); // Balanced in OnBlockingPageComplete(). |
cbentzel
2011/02/22 15:56:04
Should you just move this after the PREFETCH test
gavinp
2011/02/22 22:51:33
Mooted by moving the code over to OnBrowseUrlCheck
| |
176 | 177 |
177 // Grab the original url of this request as well. | 178 // Grab the original url of this request as well. |
178 GURL original_url; | 179 GURL original_url; |
179 net::URLRequest* request = rdh_->GetURLRequest( | 180 net::URLRequest* request = rdh_->GetURLRequest( |
180 GlobalRequestID(render_process_host_id_, deferred_request_id_)); | 181 GlobalRequestID(render_process_host_id_, deferred_request_id_)); |
182 | |
lzheng
2011/02/22 19:07:18
Instead of putting this logic here, can you move i
gavinp
2011/02/22 22:51:33
Good point Lei! Done. However, the original reas
| |
183 if (request->load_flags() & net::LOAD_PREFETCH) { | |
184 // Don't prefetch resources that fail safe browsing, disallow | |
185 // them. | |
186 rdh_->CancelRequest(render_process_host_id_, deferred_request_id_, false); | |
187 next_handler_->OnResponseCompleted( | |
cbentzel
2011/02/22 15:56:04
Why do you need to call next_handler_->OnResponseC
gavinp
2011/02/22 22:51:33
Without the call here, the load of the current pag
| |
188 deferred_request_id_, | |
189 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_ABORTED), | |
190 std::string()); | |
191 state_ = STATE_NONE; | |
192 ClearDeferredRequestInfo(); | |
193 Release(); | |
194 return; | |
195 } | |
196 | |
181 if (request) | 197 if (request) |
182 original_url = request->original_url(); | 198 original_url = request->original_url(); |
183 else | 199 else |
184 original_url = url; | 200 original_url = url; |
185 | 201 |
186 safe_browsing_->DisplayBlockingPage( | 202 safe_browsing_->DisplayBlockingPage( |
187 url, original_url, redirect_urls_, resource_type_, | 203 url, original_url, redirect_urls_, resource_type_, |
188 result, this, render_process_host_id_, render_view_id_); | 204 result, this, render_process_host_id_, render_view_id_); |
189 } | 205 } |
190 | 206 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, | 313 rdh_->FollowDeferredRedirect(render_process_host_id_, request_id, |
298 false, GURL()); | 314 false, GURL()); |
299 } | 315 } |
300 } | 316 } |
301 | 317 |
302 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { | 318 void SafeBrowsingResourceHandler::ClearDeferredRequestInfo() { |
303 deferred_request_id_ = -1; | 319 deferred_request_id_ = -1; |
304 deferred_url_ = GURL(); | 320 deferred_url_ = GURL(); |
305 deferred_redirect_response_ = NULL; | 321 deferred_redirect_response_ = NULL; |
306 } | 322 } |
OLD | NEW |