OLD | NEW |
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 // Implementation of the ThreatDetails class. | 5 // Implementation of the ThreatDetails class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/threat_details.h" | 7 #include "chrome/browser/safe_browsing/threat_details.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 using content::WebContents; | 32 using content::WebContents; |
33 | 33 |
34 // Keep in sync with KMaxNodes in renderer/safe_browsing/threat_dom_details | 34 // Keep in sync with KMaxNodes in renderer/safe_browsing/threat_dom_details |
35 static const uint32_t kMaxDomNodes = 500; | 35 static const uint32_t kMaxDomNodes = 500; |
36 | 36 |
37 namespace safe_browsing { | 37 namespace safe_browsing { |
38 | 38 |
39 // static | 39 // static |
40 ThreatDetailsFactory* ThreatDetails::factory_ = NULL; | 40 ThreatDetailsFactory* ThreatDetails::factory_ = NULL; |
41 | 41 |
42 const base::Feature kFillDOMInThreatDetails{"FillDOMInThreatDetails", | |
43 base::FEATURE_DISABLED_BY_DEFAULT}; | |
44 | |
45 namespace { | 42 namespace { |
46 | 43 |
47 typedef std::unordered_set<std::string> StringSet; | 44 typedef std::unordered_set<std::string> StringSet; |
48 // A set of HTTPS headers that are allowed to be collected. Contains both | 45 // A set of HTTPS headers that are allowed to be collected. Contains both |
49 // request and response headers. All entries in this list should be lower-case | 46 // request and response headers. All entries in this list should be lower-case |
50 // to support case-insensitive comparison. | 47 // to support case-insensitive comparison. |
51 struct WhitelistedHttpsHeadersTraits | 48 struct WhitelistedHttpsHeadersTraits |
52 : base::internal::DestructorAtExitLazyInstanceTraits<StringSet> { | 49 : base::internal::DestructorAtExitLazyInstanceTraits<StringSet> { |
53 static StringSet* New(void* instance) { | 50 static StringSet* New(void* instance) { |
54 StringSet* headers = | 51 StringSet* headers = |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 276 } |
280 | 277 |
281 void ThreatDetails::AddDomElement( | 278 void ThreatDetails::AddDomElement( |
282 const int frame_tree_node_id, | 279 const int frame_tree_node_id, |
283 const std::string& frame_url, | 280 const std::string& frame_url, |
284 const int element_node_id, | 281 const int element_node_id, |
285 const std::string& tagname, | 282 const std::string& tagname, |
286 const int parent_element_node_id, | 283 const int parent_element_node_id, |
287 const std::vector<AttributeNameValue>& attributes, | 284 const std::vector<AttributeNameValue>& attributes, |
288 const ClientSafeBrowsingReportRequest::Resource* resource) { | 285 const ClientSafeBrowsingReportRequest::Resource* resource) { |
289 if (!base::FeatureList::IsEnabled(kFillDOMInThreatDetails)) { | |
290 return; | |
291 } | |
292 | |
293 // Create the element. It should not exist already since this function should | 286 // Create the element. It should not exist already since this function should |
294 // only be called once for each element. | 287 // only be called once for each element. |
295 const std::string element_key = | 288 const std::string element_key = |
296 GetElementKey(frame_tree_node_id, element_node_id); | 289 GetElementKey(frame_tree_node_id, element_node_id); |
297 HTMLElement* cur_element = FindOrCreateElement(element_key); | 290 HTMLElement* cur_element = FindOrCreateElement(element_key); |
298 | 291 |
299 // Set some basic metadata about the element. | 292 // Set some basic metadata about the element. |
300 const std::string tag_name_upper = base::ToUpperASCII(tagname); | 293 const std::string tag_name_upper = base::ToUpperASCII(tagname); |
301 if (!tag_name_upper.empty()) { | 294 if (!tag_name_upper.empty()) { |
302 cur_element->set_tag(tag_name_upper); | 295 cur_element->set_tag(tag_name_upper); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // Send the report, using the SafeBrowsingService. | 582 // Send the report, using the SafeBrowsingService. |
590 std::string serialized; | 583 std::string serialized; |
591 if (!report_->SerializeToString(&serialized)) { | 584 if (!report_->SerializeToString(&serialized)) { |
592 DLOG(ERROR) << "Unable to serialize the threat report."; | 585 DLOG(ERROR) << "Unable to serialize the threat report."; |
593 return; | 586 return; |
594 } | 587 } |
595 ui_manager_->SendSerializedThreatDetails(serialized); | 588 ui_manager_->SendSerializedThreatDetails(serialized); |
596 } | 589 } |
597 | 590 |
598 } // namespace safe_browsing | 591 } // namespace safe_browsing |
OLD | NEW |