Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Side by Side Diff: chrome/browser/safe_browsing/threat_details.cc

Issue 2713233002: Update ThreatDOMDetails to be able to collect non-resource HTML Elements based on their attributes. (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (frame_url.is_empty()) { 489 if (frame_url.is_empty()) {
490 ambiguous_dom_ = true; 490 ambiguous_dom_ = true;
491 } 491 }
492 492
493 // Add the urls from the DOM to |resources_|. The renderer could be sending 493 // Add the urls from the DOM to |resources_|. The renderer could be sending
494 // bogus messages, so limit the number of nodes we accept. 494 // bogus messages, so limit the number of nodes we accept.
495 // Also update |elements_| with the DOM structure. 495 // Also update |elements_| with the DOM structure.
496 for (size_t i = 0; i < params.size() && i < kMaxDomNodes; ++i) { 496 for (size_t i = 0; i < params.size() && i < kMaxDomNodes; ++i) {
497 SafeBrowsingHostMsg_ThreatDOMDetails_Node node = params[i]; 497 SafeBrowsingHostMsg_ThreatDOMDetails_Node node = params[i];
498 DVLOG(1) << node.url << ", " << node.tag_name << ", " << node.parent; 498 DVLOG(1) << node.url << ", " << node.tag_name << ", " << node.parent;
499 ClientSafeBrowsingReportRequest::Resource* resource = 499 ClientSafeBrowsingReportRequest::Resource* resource = nullptr;
500 AddUrl(node.url, node.parent, node.tag_name, &(node.children)); 500 if (!node.url.is_empty()) {
501 resource = AddUrl(node.url, node.parent, node.tag_name, &(node.children));
502 }
501 if (!node.tag_name.empty()) { 503 if (!node.tag_name.empty()) {
Nathan Parker 2017/02/27 23:00:36 When would there a URL but no tag name? Maybe I'm
lpz 2017/02/28 22:53:28 The last Node in each IPC is a "summary" node whos
502 AddDomElement(frame_tree_node_id, frame_url.spec(), node.node_id, 504 AddDomElement(frame_tree_node_id, frame_url.spec(), node.node_id,
503 node.tag_name, node.parent_node_id, resource); 505 node.tag_name, node.parent_node_id, resource);
504 } 506 }
505 } 507 }
506 } 508 }
507 509
508 // Called from the SB Service on the IO thread, after the user has 510 // Called from the SB Service on the IO thread, after the user has
509 // closed the tab, or clicked proceed or goback. Since the user needs 511 // closed the tab, or clicked proceed or goback. Since the user needs
510 // to take an action, we expect this to be called after 512 // to take an action, we expect this to be called after
511 // OnReceivedThreatDOMDetails in most cases. If not, we don't include 513 // OnReceivedThreatDOMDetails in most cases. If not, we don't include
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // Send the report, using the SafeBrowsingService. 583 // Send the report, using the SafeBrowsingService.
582 std::string serialized; 584 std::string serialized;
583 if (!report_->SerializeToString(&serialized)) { 585 if (!report_->SerializeToString(&serialized)) {
584 DLOG(ERROR) << "Unable to serialize the threat report."; 586 DLOG(ERROR) << "Unable to serialize the threat report.";
585 return; 587 return;
586 } 588 }
587 ui_manager_->SendSerializedThreatDetails(serialized); 589 ui_manager_->SendSerializedThreatDetails(serialized);
588 } 590 }
589 591
590 } // namespace safe_browsing 592 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698