OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 6 #define COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_H_ |
7 | 7 |
8 // A class that encapsulates the detailed threat reports sent when | 8 // A class that encapsulates the detailed threat reports sent when |
9 // users opt-in to do so from the safe browsing warning page. | 9 // users opt-in to do so from the safe browsing warning page. |
10 | 10 |
11 // An instance of this class is generated when a safe browsing warning page | 11 // An instance of this class is generated when a safe browsing warning page |
12 // is shown (SafeBrowsingBlockingPage). | 12 // is shown (SafeBrowsingBlockingPage). |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <unordered_set> | 16 #include <unordered_set> |
(...skipping 29 matching lines...) Expand all Loading... |
46 class ThreatDetailsRedirectsCollector; | 46 class ThreatDetailsRedirectsCollector; |
47 class ThreatDetailsFactory; | 47 class ThreatDetailsFactory; |
48 | 48 |
49 using ResourceMap = | 49 using ResourceMap = |
50 base::hash_map<std::string, | 50 base::hash_map<std::string, |
51 std::unique_ptr<ClientSafeBrowsingReportRequest::Resource>>; | 51 std::unique_ptr<ClientSafeBrowsingReportRequest::Resource>>; |
52 | 52 |
53 // Maps a key of an HTML element to its corresponding HTMLElement proto message. | 53 // Maps a key of an HTML element to its corresponding HTMLElement proto message. |
54 // HTML Element keys have the form "<frame_id>-<node_id>", where |frame_id| is | 54 // HTML Element keys have the form "<frame_id>-<node_id>", where |frame_id| is |
55 // the FrameTree NodeID of the render frame containing the element, and | 55 // the FrameTree NodeID of the render frame containing the element, and |
56 // |node_id| is a seqeuntial ID for the element generated by the renderer. | 56 // |node_id| is a sequential ID for the element generated by the renderer. |
57 using ElementMap = base::hash_map<std::string, std::unique_ptr<HTMLElement>>; | 57 using ElementMap = base::hash_map<std::string, std::unique_ptr<HTMLElement>>; |
58 | 58 |
59 // Maps a URL to some HTML Elements. Used to maintain parent/child relationship | 59 // Maps a URL to some HTML Elements. Used to maintain parent/child relationship |
60 // for HTML Elements across IFrame boundaries. | 60 // for HTML Elements across IFrame boundaries. |
61 // The key is the string URL set as the src attribute of an iframe. The value is | 61 // The key is the string URL set as the src attribute of an iframe. The value is |
62 // the HTMLElement proto that represents the iframe element with that URL. | 62 // the HTMLElement proto that represents the iframe element with that URL. |
63 // The HTMLElement protos are not owned by this map. | 63 // The HTMLElement protos are not owned by this map. |
64 using UrlToDomElementMap = base::hash_map<std::string, HTMLElement*>; | 64 using UrlToDomElementMap = base::hash_map<std::string, HTMLElement*>; |
65 | 65 |
66 // Maps a URL to some Element IDs. Used to maintain parent/child relationship | 66 // Maps a URL to some Element IDs. Used to maintain parent/child relationship |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); | 166 const std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node>& params); |
167 | 167 |
168 void AddRedirectUrlList(const std::vector<GURL>& urls); | 168 void AddRedirectUrlList(const std::vector<GURL>& urls); |
169 | 169 |
170 // Adds an HTML Element to the DOM structure. | 170 // Adds an HTML Element to the DOM structure. |
171 // |frame_tree_node_id| is the unique ID of the render frame the element came | 171 // |frame_tree_node_id| is the unique ID of the render frame the element came |
172 // from. |frame_url| is the URL that the render frame was handling. | 172 // from. |frame_url| is the URL that the render frame was handling. |
173 // |element_node_id| is a unique ID of the element within the render frame. | 173 // |element_node_id| is a unique ID of the element within the render frame. |
174 // |tag_name| is the tag of the element. |parent_element_node_id| is the | 174 // |tag_name| is the tag of the element. |parent_element_node_id| is the |
175 // unique ID of the parent element with the render frame. |attributes| | 175 // unique ID of the parent element with the render frame. |attributes| |
176 // containes the names and values of the element's attributes.|resource| is | 176 // contains the names and values of the element's attributes.|resource| is |
177 // set if this element is a resource. | 177 // set if this element is a resource. |
178 void AddDomElement(const int frame_tree_node_id, | 178 void AddDomElement(const int frame_tree_node_id, |
179 const std::string& frame_url, | 179 const std::string& frame_url, |
180 const int element_node_id, | 180 const int element_node_id, |
181 const std::string& tag_name, | 181 const std::string& tag_name, |
182 const int parent_element_node_id, | 182 const int parent_element_node_id, |
183 const std::vector<AttributeNameValue>& attributes, | 183 const std::vector<AttributeNameValue>& attributes, |
184 const ClientSafeBrowsingReportRequest::Resource* resource); | 184 const ClientSafeBrowsingReportRequest::Resource* resource); |
185 | 185 |
186 scoped_refptr<BaseUIManager> ui_manager_; | 186 scoped_refptr<BaseUIManager> ui_manager_; |
(...skipping 28 matching lines...) Expand all Loading... |
215 bool did_proceed_; | 215 bool did_proceed_; |
216 | 216 |
217 // How many times this user has visited this page before. | 217 // How many times this user has visited this page before. |
218 int num_visits_; | 218 int num_visits_; |
219 | 219 |
220 // Keeps track of whether we have an ambiguous DOM in this report. This can | 220 // Keeps track of whether we have an ambiguous DOM in this report. This can |
221 // happen when the HTML Elements returned by a render frame can't be | 221 // happen when the HTML Elements returned by a render frame can't be |
222 // associated with a parent Element in the parent frame. | 222 // associated with a parent Element in the parent frame. |
223 bool ambiguous_dom_; | 223 bool ambiguous_dom_; |
224 | 224 |
225 // The factory used to instanciate SafeBrowsingBlockingPage objects. | 225 // The factory used to instantiate SafeBrowsingBlockingPage objects. |
226 // Usefull for tests, so they can provide their own implementation of | 226 // Useful for tests, so they can provide their own implementation of |
227 // SafeBrowsingBlockingPage. | 227 // SafeBrowsingBlockingPage. |
228 static ThreatDetailsFactory* factory_; | 228 static ThreatDetailsFactory* factory_; |
229 | 229 |
230 // Used to collect details from the HTTP Cache. | 230 // Used to collect details from the HTTP Cache. |
231 scoped_refptr<ThreatDetailsCacheCollector> cache_collector_; | 231 scoped_refptr<ThreatDetailsCacheCollector> cache_collector_; |
232 | 232 |
233 // Used to collect redirect urls from the history service | 233 // Used to collect redirect urls from the history service |
234 scoped_refptr<ThreatDetailsRedirectsCollector> redirects_collector_; | 234 scoped_refptr<ThreatDetailsRedirectsCollector> redirects_collector_; |
235 | 235 |
236 FRIEND_TEST_ALL_PREFIXES(ThreatDetailsTest, HistoryServiceUrls); | 236 FRIEND_TEST_ALL_PREFIXES(ThreatDetailsTest, HistoryServiceUrls); |
(...skipping 15 matching lines...) Expand all Loading... |
252 virtual ThreatDetails* CreateThreatDetails( | 252 virtual ThreatDetails* CreateThreatDetails( |
253 BaseUIManager* ui_manager, | 253 BaseUIManager* ui_manager, |
254 content::WebContents* web_contents, | 254 content::WebContents* web_contents, |
255 const security_interstitials::UnsafeResource& unsafe_resource, | 255 const security_interstitials::UnsafeResource& unsafe_resource, |
256 net::URLRequestContextGetter* request_context_getter, | 256 net::URLRequestContextGetter* request_context_getter, |
257 history::HistoryService* history_service) = 0; | 257 history::HistoryService* history_service) = 0; |
258 }; | 258 }; |
259 | 259 |
260 } // namespace safe_browsing | 260 } // namespace safe_browsing |
261 | 261 |
262 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ | 262 #endif // COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_H_ |
OLD | NEW |