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

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: Use explicitly-sized int types in IPC definition 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 may be in a different renderer. Look up the routing
150 // ID of the local or remote frame and store it with the iframe node. If this
151 // element is not a frame then the result of the lookup will be null.
152 blink::WebFrame* subframe = blink::WebFrame::FromFrameOwnerElement(element);
153 if (subframe) {
154 child_node.child_frame_routing_id =
155 content::RenderFrame::GetRoutingIdForWebFrame(subframe);
156 }
157
149 // Populate the element's attributes, but only collect the ones that are 158 // Populate the element's attributes, but only collect the ones that are
150 // configured in the finch study. 159 // configured in the finch study.
151 const auto& tag_attribute_iter = std::find_if( 160 const auto& tag_attribute_iter = std::find_if(
152 tag_and_attributes_list.begin(), tag_and_attributes_list.end(), 161 tag_and_attributes_list.begin(), tag_and_attributes_list.end(),
153 TagNameIs(base::ToLowerASCII(child_node.tag_name))); 162 TagNameIs(base::ToLowerASCII(child_node.tag_name)));
154 if (tag_attribute_iter != tag_and_attributes_list.end()) { 163 if (tag_attribute_iter != tag_and_attributes_list.end()) {
155 const std::vector<std::string> attributes_to_collect = 164 const std::vector<std::string> attributes_to_collect =
156 tag_attribute_iter->attributes; 165 tag_attribute_iter->attributes;
157 for (const std::string& attribute : attributes_to_collect) { 166 for (const std::string& attribute : attributes_to_collect) {
158 blink::WebString attr_webstring = blink::WebString::FromASCII(attribute); 167 blink::WebString attr_webstring = blink::WebString::FromASCII(attribute);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 307 }
299 } 308 }
300 resources->push_back(details_node); 309 resources->push_back(details_node);
301 } 310 }
302 311
303 void ThreatDOMDetails::OnDestruct() { 312 void ThreatDOMDetails::OnDestruct() {
304 delete this; 313 delete this;
305 } 314 }
306 315
307 } // namespace safe_browsing 316 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing/common/safebrowsing_messages.h ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698