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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 const base::Feature kFillDOMInThreatDetails{"FillDOMInThreatDetails", | 42 const base::Feature kFillDOMInThreatDetails{"FillDOMInThreatDetails", |
43 base::FEATURE_DISABLED_BY_DEFAULT}; | 43 base::FEATURE_DISABLED_BY_DEFAULT}; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 typedef std::unordered_set<std::string> StringSet; | 47 typedef std::unordered_set<std::string> StringSet; |
48 // A set of HTTPS headers that are allowed to be collected. Contains both | 48 // 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 | 49 // request and response headers. All entries in this list should be lower-case |
50 // to support case-insensitive comparison. | 50 // to support case-insensitive comparison. |
51 struct WhitelistedHttpsHeadersTraits : | 51 struct WhitelistedHttpsHeadersTraits |
52 base::DefaultLazyInstanceTraits<StringSet> { | 52 : base::internal::DestructorAtExitLazyInstanceTraits<StringSet> { |
53 static StringSet* New(void* instance) { | 53 static StringSet* New(void* instance) { |
54 StringSet* headers = base::DefaultLazyInstanceTraits<StringSet>::New( | 54 StringSet* headers = |
55 instance); | 55 base::internal::DestructorAtExitLazyInstanceTraits<StringSet>::New( |
| 56 instance); |
56 headers->insert({"google-creative-id", "google-lineitem-id", "referer", | 57 headers->insert({"google-creative-id", "google-lineitem-id", "referer", |
57 "content-type", "content-length", "date", "server", "cache-control", | 58 "content-type", "content-length", "date", "server", "cache-control", |
58 "pragma", "expires"}); | 59 "pragma", "expires"}); |
59 return headers; | 60 return headers; |
60 } | 61 } |
61 }; | 62 }; |
62 base::LazyInstance<StringSet, WhitelistedHttpsHeadersTraits> | 63 base::LazyInstance<StringSet, WhitelistedHttpsHeadersTraits> |
63 g_https_headers_whitelist = LAZY_INSTANCE_INITIALIZER; | 64 g_https_headers_whitelist = LAZY_INSTANCE_INITIALIZER; |
64 | 65 |
65 // Helper function that converts SBThreatType to | 66 // Helper function that converts SBThreatType to |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { | 138 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { |
138 public: | 139 public: |
139 ThreatDetails* CreateThreatDetails( | 140 ThreatDetails* CreateThreatDetails( |
140 BaseUIManager* ui_manager, | 141 BaseUIManager* ui_manager, |
141 WebContents* web_contents, | 142 WebContents* web_contents, |
142 const security_interstitials::UnsafeResource& unsafe_resource) override { | 143 const security_interstitials::UnsafeResource& unsafe_resource) override { |
143 return new ThreatDetails(ui_manager, web_contents, unsafe_resource); | 144 return new ThreatDetails(ui_manager, web_contents, unsafe_resource); |
144 } | 145 } |
145 | 146 |
146 private: | 147 private: |
147 friend struct base::DefaultLazyInstanceTraits<ThreatDetailsFactoryImpl>; | 148 friend struct base::LazyInstanceTraitsBase<ThreatDetailsFactoryImpl>; |
148 | 149 |
149 ThreatDetailsFactoryImpl() {} | 150 ThreatDetailsFactoryImpl() {} |
150 | 151 |
151 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); | 152 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); |
152 }; | 153 }; |
153 | 154 |
154 static base::LazyInstance<ThreatDetailsFactoryImpl> | 155 static base::LazyInstance<ThreatDetailsFactoryImpl>::DestructorAtExit |
155 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER; | 156 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER; |
156 | 157 |
157 // Create a ThreatDetails for the given tab. | 158 // Create a ThreatDetails for the given tab. |
158 /* static */ | 159 /* static */ |
159 ThreatDetails* ThreatDetails::NewThreatDetails( | 160 ThreatDetails* ThreatDetails::NewThreatDetails( |
160 BaseUIManager* ui_manager, | 161 BaseUIManager* ui_manager, |
161 WebContents* web_contents, | 162 WebContents* web_contents, |
162 const UnsafeResource& resource) { | 163 const UnsafeResource& resource) { |
163 // Set up the factory if this has not been done already (tests do that | 164 // Set up the factory if this has not been done already (tests do that |
164 // before this method is called). | 165 // before this method is called). |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 // Send the report, using the SafeBrowsingService. | 589 // Send the report, using the SafeBrowsingService. |
589 std::string serialized; | 590 std::string serialized; |
590 if (!report_->SerializeToString(&serialized)) { | 591 if (!report_->SerializeToString(&serialized)) { |
591 DLOG(ERROR) << "Unable to serialize the threat report."; | 592 DLOG(ERROR) << "Unable to serialize the threat report."; |
592 return; | 593 return; |
593 } | 594 } |
594 ui_manager_->SendSerializedThreatDetails(serialized); | 595 ui_manager_->SendSerializedThreatDetails(serialized); |
595 } | 596 } |
596 | 597 |
597 } // namespace safe_browsing | 598 } // namespace safe_browsing |
OLD | NEW |