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

Side by Side Diff: components/safe_browsing/renderer/threat_dom_details.cc

Issue 2837603002: Content API changes to improve DOM stitching in ThreatDetails code. (Closed)
Patch Set: Set output pointers correctly Created 3 years, 7 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 #include "components/safe_browsing/renderer/threat_dom_details.h" 5 #include "components/safe_browsing/renderer/threat_dom_details.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unordered_set> 9 #include <unordered_set>
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 const GURL& child_url = GURL(full_url); 139 const GURL& child_url = GURL(full_url);
140 if (!child_url.is_empty() && child_url.is_valid()) { 140 if (!child_url.is_empty() && child_url.is_valid()) {
141 summary_node->children.push_back(child_url); 141 summary_node->children.push_back(child_url);
142 } 142 }
143 143
144 SafeBrowsingHostMsg_ThreatDOMDetails_Node child_node; 144 SafeBrowsingHostMsg_ThreatDOMDetails_Node child_node;
145 child_node.url = child_url; 145 child_node.url = child_url;
146 child_node.tag_name = element.TagName().Utf8(); 146 child_node.tag_name = element.TagName().Utf8();
147 child_node.parent = summary_node->url; 147 child_node.parent = summary_node->url;
148 148
149 // The body of an iframe will be in a different renderer. Look up the
Charlie Reis 2017/05/05 21:03:08 s/will/may/
lpz 2017/05/10 14:21:09 Done.
150 // routing_id of that renderer and store it with the iframe node. If this
Charlie Reis 2017/05/05 21:03:07 nit: routing ID of the local or remote frame and
lpz 2017/05/10 14:21:09 Done.
151 // element is not a frame then the result of the lookup will be null.
152 blink::WebFrame* subwebframe =
153 blink::WebFrame::FromFrameOwnerElement(element);
154 if (subwebframe) {
155 child_node.other_frame_routing_id =
156 content::RenderFrame::GetRoutingIdForWebFrame(subwebframe);
157 }
158
149 // Populate the element's attributes, but only collect the ones that are 159 // Populate the element's attributes, but only collect the ones that are
150 // configured in the finch study. 160 // configured in the finch study.
151 const auto& tag_attribute_iter = std::find_if( 161 const auto& tag_attribute_iter = std::find_if(
152 tag_and_attributes_list.begin(), tag_and_attributes_list.end(), 162 tag_and_attributes_list.begin(), tag_and_attributes_list.end(),
153 TagNameIs(base::ToLowerASCII(child_node.tag_name))); 163 TagNameIs(base::ToLowerASCII(child_node.tag_name)));
154 if (tag_attribute_iter != tag_and_attributes_list.end()) { 164 if (tag_attribute_iter != tag_and_attributes_list.end()) {
155 const std::vector<std::string> attributes_to_collect = 165 const std::vector<std::string> attributes_to_collect =
156 tag_attribute_iter->attributes; 166 tag_attribute_iter->attributes;
157 for (const std::string& attribute : attributes_to_collect) { 167 for (const std::string& attribute : attributes_to_collect) {
158 blink::WebString attr_webstring = blink::WebString::FromASCII(attribute); 168 blink::WebString attr_webstring = blink::WebString::FromASCII(attribute);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 308 }
299 } 309 }
300 resources->push_back(details_node); 310 resources->push_back(details_node);
301 } 311 }
302 312
303 void ThreatDOMDetails::OnDestruct() { 313 void ThreatDOMDetails::OnDestruct() {
304 delete this; 314 delete this;
305 } 315 }
306 316
307 } // namespace safe_browsing 317 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698