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

Side by Side Diff: chrome/renderer/safe_browsing/malware_dom_details.cc

Issue 146053007: Update safe_browsing code to use WebElementCollection instead of WebNodeCollection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/renderer/safe_browsing/malware_dom_details.h" 5 #include "chrome/renderer/safe_browsing/malware_dom_details.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "chrome/common/chrome_constants.h" 8 #include "chrome/common/chrome_constants.h"
9 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 9 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
11 #include "third_party/WebKit/public/platform/WebString.h" 11 #include "third_party/WebKit/public/platform/WebString.h"
12 #include "third_party/WebKit/public/web/WebDocument.h" 12 #include "third_party/WebKit/public/web/WebDocument.h"
13 #include "third_party/WebKit/public/web/WebElement.h" 13 #include "third_party/WebKit/public/web/WebElement.h"
14 #include "third_party/WebKit/public/web/WebElementCollection.h"
14 #include "third_party/WebKit/public/web/WebFrame.h" 15 #include "third_party/WebKit/public/web/WebFrame.h"
15 #include "third_party/WebKit/public/web/WebNodeCollection.h"
16 #include "third_party/WebKit/public/web/WebView.h" 16 #include "third_party/WebKit/public/web/WebView.h"
17 17
18 namespace safe_browsing { 18 namespace safe_browsing {
19 19
20 // An upper limit on the number of nodes we collect. 20 // An upper limit on the number of nodes we collect.
21 uint32 MalwareDOMDetails::kMaxNodes = 500; 21 uint32 MalwareDOMDetails::kMaxNodes = 500;
22 22
23 // static 23 // static
24 MalwareDOMDetails* MalwareDOMDetails::Create(content::RenderView* render_view) { 24 MalwareDOMDetails* MalwareDOMDetails::Create(content::RenderView* render_view) {
25 // Private constructor and public static Create() method to facilitate 25 // Private constructor and public static Create() method to facilitate
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 DCHECK(frame); 64 DCHECK(frame);
65 SafeBrowsingHostMsg_MalwareDOMDetails_Node details_node; 65 SafeBrowsingHostMsg_MalwareDOMDetails_Node details_node;
66 blink::WebDocument document = frame->document(); 66 blink::WebDocument document = frame->document();
67 details_node.url = GURL(document.url()); 67 details_node.url = GURL(document.url());
68 if (document.isNull()) { 68 if (document.isNull()) {
69 // Nothing in this frame, move on to the next one. 69 // Nothing in this frame, move on to the next one.
70 resources->push_back(details_node); 70 resources->push_back(details_node);
71 continue; 71 continue;
72 } 72 }
73 73
74 blink::WebNodeCollection elements = document.all(); 74 blink::WebElementCollection elements = document.all();
75 blink::WebNode cur_node = elements.firstItem(); 75 blink::WebElement element = elements.firstItem();
76 for (; !cur_node.isNull(); cur_node = elements.nextItem()) { 76 for (; !element.isNull(); element = elements.nextItem()) {
77 if (!cur_node.isElementNode()) {
78 continue;
79 }
80 blink::WebElement element = cur_node.to<blink::WebElement>();
81 if (element.hasTagName("iframe") || element.hasTagName("frame") || 77 if (element.hasTagName("iframe") || element.hasTagName("frame") ||
82 element.hasTagName("embed") || element.hasTagName("script")) { 78 element.hasTagName("embed") || element.hasTagName("script")) {
83 HandleElement(element, &details_node, resources); 79 HandleElement(element, &details_node, resources);
84 if (resources->size() >= kMaxNodes) { 80 if (resources->size() >= kMaxNodes) {
85 // We have reached kMaxNodes, exit early. 81 // We have reached kMaxNodes, exit early.
86 resources->push_back(details_node); 82 resources->push_back(details_node);
87 return; 83 return;
88 } 84 }
89 } 85 }
90 } 86 }
(...skipping 21 matching lines...) Expand all
112 108
113 // Create the child node. 109 // Create the child node.
114 SafeBrowsingHostMsg_MalwareDOMDetails_Node child_node; 110 SafeBrowsingHostMsg_MalwareDOMDetails_Node child_node;
115 child_node.url = child_url; 111 child_node.url = child_url;
116 child_node.tag_name = element.tagName().utf8(); 112 child_node.tag_name = element.tagName().utf8();
117 child_node.parent = parent_node->url; 113 child_node.parent = parent_node->url;
118 resources->push_back(child_node); 114 resources->push_back(child_node);
119 } 115 }
120 116
121 } // namespace safe_browsing 117 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698