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 // Implementation of the ThreatDetails class. | 5 // Implementation of the ThreatDetails class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/threat_details.h" | 7 #include "chrome/browser/safe_browsing/threat_details.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // Set the previous redirect url as the parent of the next one | 220 // Set the previous redirect url as the parent of the next one |
221 for (size_t i = 0; i < resource_.redirect_urls.size(); ++i) { | 221 for (size_t i = 0; i < resource_.redirect_urls.size(); ++i) { |
222 AddUrl(resource_.redirect_urls[i], parent_url, std::string(), NULL); | 222 AddUrl(resource_.redirect_urls[i], parent_url, std::string(), NULL); |
223 parent_url = resource_.redirect_urls[i]; | 223 parent_url = resource_.redirect_urls[i]; |
224 } | 224 } |
225 | 225 |
226 // Add the referrer url. | 226 // Add the referrer url. |
227 if (nav_entry && !referrer_url.is_empty()) | 227 if (nav_entry && !referrer_url.is_empty()) |
228 AddUrl(referrer_url, GURL(), std::string(), NULL); | 228 AddUrl(referrer_url, GURL(), std::string(), NULL); |
229 | 229 |
230 // Get URLs of frames, scripts etc from the DOM. | 230 if (!resource_.IsMainPageLoadBlocked()) { |
231 // OnReceivedThreatDOMDetails will be called when the renderer replies. | 231 // Get URLs of frames, scripts etc from the DOM. |
232 content::RenderViewHost* view = web_contents()->GetRenderViewHost(); | 232 // OnReceivedThreatDOMDetails will be called when the renderer replies. |
233 view->Send(new SafeBrowsingMsg_GetThreatDOMDetails(view->GetRoutingID())); | 233 // TODO(mattm): In theory, if the user proceeds through the warning DOM |
| 234 // detail collection could be started once the page loads. |
| 235 content::RenderViewHost* view = web_contents()->GetRenderViewHost(); |
| 236 view->Send(new SafeBrowsingMsg_GetThreatDOMDetails(view->GetRoutingID())); |
| 237 } |
234 } | 238 } |
235 | 239 |
236 // When the renderer is done, this is called. | 240 // When the renderer is done, this is called. |
237 void ThreatDetails::OnReceivedThreatDOMDetails( | 241 void ThreatDetails::OnReceivedThreatDOMDetails( |
238 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params) { | 242 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params) { |
239 // Schedule this in IO thread, so it doesn't conflict with future users | 243 // Schedule this in IO thread, so it doesn't conflict with future users |
240 // of our data structures (eg GetSerializedReport). | 244 // of our data structures (eg GetSerializedReport). |
241 BrowserThread::PostTask( | 245 BrowserThread::PostTask( |
242 BrowserThread::IO, FROM_HERE, | 246 BrowserThread::IO, FROM_HERE, |
243 base::Bind(&ThreatDetails::AddDOMDetails, this, params)); | 247 base::Bind(&ThreatDetails::AddDOMDetails, this, params)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Send the report, using the SafeBrowsingService. | 339 // Send the report, using the SafeBrowsingService. |
336 std::string serialized; | 340 std::string serialized; |
337 if (!report_->SerializeToString(&serialized)) { | 341 if (!report_->SerializeToString(&serialized)) { |
338 DLOG(ERROR) << "Unable to serialize the threat report."; | 342 DLOG(ERROR) << "Unable to serialize the threat report."; |
339 return; | 343 return; |
340 } | 344 } |
341 ui_manager_->SendSerializedThreatDetails(serialized); | 345 ui_manager_->SendSerializedThreatDetails(serialized); |
342 } | 346 } |
343 | 347 |
344 } // namespace safe_browsing | 348 } // namespace safe_browsing |
OLD | NEW |