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

Side by Side Diff: chrome/renderer/safe_browsing/threat_dom_details.h

Issue 2756933003: Componentize safe_browsing: move renderer/ reporting part for WebView. (Closed)
Patch Set: fix 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
« no previous file with comments | « chrome/renderer/safe_browsing/DEPS ('k') | chrome/renderer/safe_browsing/threat_dom_details.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // ThreatDOMDetails iterates over a document's frames and gathers
6 // interesting URLs such as those of scripts and frames. When done, it sends
7 // them to the ThreatDetails that requested them.
8
9 #ifndef CHROME_RENDERER_SAFE_BROWSING_THREAT_DOM_DETAILS_H_
10 #define CHROME_RENDERER_SAFE_BROWSING_THREAT_DOM_DETAILS_H_
11
12 #include <vector>
13
14 #include "base/compiler_specific.h"
15 #include "base/feature_list.h"
16 #include "content/public/renderer/render_frame_observer.h"
17
18 struct SafeBrowsingHostMsg_ThreatDOMDetails_Node;
19
20 namespace safe_browsing {
21
22 extern const base::Feature kThreatDomDetailsTagAndAttributeFeature;
23 extern const char kTagAndAttributeParamName[];
24
25 // Represents the tag name of an HTML Element and its associated attributes.
26 // Used to determine which elements to collect. Populated from the param value
27 // of |kThreatDomDetailsTagAndAttributeFeature|.
28 class TagAndAttributesItem {
29 public:
30 TagAndAttributesItem();
31 TagAndAttributesItem(const TagAndAttributesItem& item);
32 ~TagAndAttributesItem();
33
34 std::string tag_name;
35 std::vector<std::string> attributes;
36 };
37
38 // There is one ThreatDOMDetails per RenderFrame.
39 class ThreatDOMDetails : public content::RenderFrameObserver {
40 public:
41 // An upper limit on the number of nodes we collect. Not const for the test.
42 static uint32_t kMaxNodes;
43
44 // An upper limit on the number of attributes to collect per node. Not const
45 // for the test.
46 static uint32_t kMaxAttributes;
47
48 // An upper limit on the length of an attribute string.
49 static uint32_t kMaxAttributeStringLength;
50
51 static ThreatDOMDetails* Create(content::RenderFrame* render_frame);
52 ~ThreatDOMDetails() override;
53
54 // Begins extracting resource urls for the page currently loaded in
55 // this object's RenderFrame.
56 // Exposed for testing.
57 void ExtractResources(
58 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>* resources);
59
60 private:
61 // Creates a ThreatDOMDetails for the specified RenderFrame.
62 // The ThreatDOMDetails should be destroyed prior to destroying
63 // the RenderFrame.
64 explicit ThreatDOMDetails(content::RenderFrame* render_frame);
65
66 // RenderFrameObserver implementation.
67 bool OnMessageReceived(const IPC::Message& message) override;
68 void OnDestruct() override;
69
70 void OnGetThreatDOMDetails();
71
72 // A list of tag names and associates attributes, used to determine which
73 // elements need to be collected.
74 std::vector<TagAndAttributesItem> tag_and_attributes_list_;
75
76 DISALLOW_COPY_AND_ASSIGN(ThreatDOMDetails);
77 };
78
79 } // namespace safe_browsing
80
81 #endif // CHROME_RENDERER_SAFE_BROWSING_THREAT_DOM_DETAILS_H_
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/DEPS ('k') | chrome/renderer/safe_browsing/threat_dom_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698