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

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

Issue 2964693003: Added experiments section and exported the list of SafeBrowsing features in WebUI (Closed)
Patch Set: Fixed the variable names according to the standard 01 Created 3 years, 5 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 <string> 9 #include <string>
10 #include <unordered_set> 10 #include <unordered_set>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/metrics/field_trial_params.h" 13 #include "base/metrics/field_trial_params.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "components/safe_browsing/common/safebrowsing_messages.h" 17 #include "components/safe_browsing/common/safebrowsing_messages.h"
18 #include "components/safe_browsing/common/safebrowsing_types.h" 18 #include "components/safe_browsing/common/safebrowsing_types.h"
19 #include "components/safe_browsing/features.h"
19 #include "content/public/renderer/render_frame.h" 20 #include "content/public/renderer/render_frame.h"
20 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
21 #include "third_party/WebKit/public/web/WebDocument.h" 22 #include "third_party/WebKit/public/web/WebDocument.h"
22 #include "third_party/WebKit/public/web/WebElement.h" 23 #include "third_party/WebKit/public/web/WebElement.h"
23 #include "third_party/WebKit/public/web/WebElementCollection.h" 24 #include "third_party/WebKit/public/web/WebElementCollection.h"
24 #include "third_party/WebKit/public/web/WebFrame.h" 25 #include "third_party/WebKit/public/web/WebFrame.h"
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" 26 #include "third_party/WebKit/public/web/WebLocalFrame.h"
26 27
27 namespace safe_browsing { 28 namespace safe_browsing {
28 29
29 // A map for keeping track of the identity of DOM Elements, used to generate 30 // A map for keeping track of the identity of DOM Elements, used to generate
30 // unique IDs for each element and lookup elements IDs by parent Element, to 31 // unique IDs for each element and lookup elements IDs by parent Element, to
31 // maintain proper parent/child relationships. 32 // maintain proper parent/child relationships.
32 // They key is a WebNode from the DOM, which is basically a pointer so can be 33 // They key is a WebNode from the DOM, which is basically a pointer so can be
33 // copied into the map when inserting new elements. 34 // copied into the map when inserting new elements.
34 // The values are indices into the resource vector, and are used to retrieve IPC 35 // The values are indices into the resource vector, and are used to retrieve IPC
35 // messages generated by ThreatDOMDetails. 36 // messages generated by ThreatDOMDetails.
36 using ElementToNodeMap = std::map<blink::WebNode, size_t>; 37 using ElementToNodeMap = std::map<blink::WebNode, size_t>;
37 38
38 // This Feature specifies which non-resource HTML Elements to collect based on
39 // their tag and attributes. It's a single param containing a comma-separated
40 // list of pairs. For example: "tag1,id,tag1,height,tag2,foo" - this will
41 // collect elements with tag "tag1" that have attribute "id" or "height" set,
42 // and elements of tag "tag2" if they have attribute "foo" set. All tag names
43 // and attributes should be lower case.
44 const base::Feature kThreatDomDetailsTagAndAttributeFeature{
45 "ThreatDomDetailsTagAttributes", base::FEATURE_DISABLED_BY_DEFAULT};
46
47 // The name of the param containing the tags and attributes list. 39 // The name of the param containing the tags and attributes list.
48 const char kTagAndAttributeParamName[] = "tag_attribute_csv"; 40 const char kTagAndAttributeParamName[] = "tag_attribute_csv";
49 41
50 namespace { 42 namespace {
51 43
52 // Predicate used to search |tag_and_attributes_list_| by tag_name. 44 // Predicate used to search |tag_and_attributes_list_| by tag_name.
53 class TagNameIs { 45 class TagNameIs {
54 public: 46 public:
55 explicit TagNameIs(const std::string& tag) : tag_(tag) {} 47 explicit TagNameIs(const std::string& tag) : tag_(tag) {}
56 bool operator()(const TagAndAttributesItem& tag_and_attribute) { 48 bool operator()(const TagAndAttributesItem& tag_and_attribute) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 300 }
309 } 301 }
310 resources->push_back(details_node); 302 resources->push_back(details_node);
311 } 303 }
312 304
313 void ThreatDOMDetails::OnDestruct() { 305 void ThreatDOMDetails::OnDestruct() {
314 delete this; 306 delete this;
315 } 307 }
316 308
317 } // namespace safe_browsing 309 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing/renderer/threat_dom_details.h ('k') | components/safe_browsing/web_ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698