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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 *orig_resource.mutable_response()->mutable_remote_ip()); | 121 *orig_resource.mutable_response()->mutable_remote_ip()); |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 | 125 |
126 // The default ThreatDetailsFactory. Global, made a singleton so we | 126 // The default ThreatDetailsFactory. Global, made a singleton so we |
127 // don't leak it. | 127 // don't leak it. |
128 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { | 128 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { |
129 public: | 129 public: |
130 ThreatDetails* CreateThreatDetails( | 130 ThreatDetails* CreateThreatDetails( |
131 SafeBrowsingUIManager* ui_manager, | 131 BaseUIManager* ui_manager, |
132 WebContents* web_contents, | 132 WebContents* web_contents, |
133 const security_interstitials::UnsafeResource& unsafe_resource) override { | 133 const security_interstitials::UnsafeResource& unsafe_resource) override { |
134 return new ThreatDetails(ui_manager, web_contents, unsafe_resource); | 134 return new ThreatDetails(ui_manager, web_contents, unsafe_resource); |
135 } | 135 } |
136 | 136 |
137 private: | 137 private: |
138 friend struct base::DefaultLazyInstanceTraits<ThreatDetailsFactoryImpl>; | 138 friend struct base::DefaultLazyInstanceTraits<ThreatDetailsFactoryImpl>; |
139 | 139 |
140 ThreatDetailsFactoryImpl() {} | 140 ThreatDetailsFactoryImpl() {} |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); | 142 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); |
143 }; | 143 }; |
144 | 144 |
145 static base::LazyInstance<ThreatDetailsFactoryImpl> | 145 static base::LazyInstance<ThreatDetailsFactoryImpl> |
146 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER; | 146 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER; |
147 | 147 |
148 // Create a ThreatDetails for the given tab. | 148 // Create a ThreatDetails for the given tab. |
149 /* static */ | 149 /* static */ |
150 ThreatDetails* ThreatDetails::NewThreatDetails( | 150 ThreatDetails* ThreatDetails::NewThreatDetails( |
151 SafeBrowsingUIManager* ui_manager, | 151 BaseUIManager* ui_manager, |
152 WebContents* web_contents, | 152 WebContents* web_contents, |
153 const UnsafeResource& resource) { | 153 const UnsafeResource& resource) { |
154 // Set up the factory if this has not been done already (tests do that | 154 // Set up the factory if this has not been done already (tests do that |
155 // before this method is called). | 155 // before this method is called). |
156 if (!factory_) | 156 if (!factory_) |
157 factory_ = g_threat_details_factory_impl.Pointer(); | 157 factory_ = g_threat_details_factory_impl.Pointer(); |
158 return factory_->CreateThreatDetails(ui_manager, web_contents, resource); | 158 return factory_->CreateThreatDetails(ui_manager, web_contents, resource); |
159 } | 159 } |
160 | 160 |
161 // Create a ThreatDetails for the given tab. Runs in the UI thread. | 161 // Create a ThreatDetails for the given tab. Runs in the UI thread. |
162 ThreatDetails::ThreatDetails(SafeBrowsingUIManager* ui_manager, | 162 ThreatDetails::ThreatDetails(BaseUIManager* ui_manager, |
163 content::WebContents* web_contents, | 163 content::WebContents* web_contents, |
164 const UnsafeResource& resource) | 164 const UnsafeResource& resource) |
165 : content::WebContentsObserver(web_contents), | 165 : content::WebContentsObserver(web_contents), |
166 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 166 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
167 request_context_getter_(profile_->GetRequestContext()), | 167 request_context_getter_(profile_->GetRequestContext()), |
168 ui_manager_(ui_manager), | 168 ui_manager_(ui_manager), |
169 resource_(resource), | 169 resource_(resource), |
170 cache_result_(false), | 170 cache_result_(false), |
171 cache_collector_(new ThreatDetailsCacheCollector), | 171 cache_collector_(new ThreatDetailsCacheCollector), |
172 redirects_collector_(new ThreatDetailsRedirectsCollector(profile_)) { | 172 redirects_collector_(new ThreatDetailsRedirectsCollector(profile_)) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // Send the report, using the SafeBrowsingService. | 412 // Send the report, using the SafeBrowsingService. |
413 std::string serialized; | 413 std::string serialized; |
414 if (!report_->SerializeToString(&serialized)) { | 414 if (!report_->SerializeToString(&serialized)) { |
415 DLOG(ERROR) << "Unable to serialize the threat report."; | 415 DLOG(ERROR) << "Unable to serialize the threat report."; |
416 return; | 416 return; |
417 } | 417 } |
418 ui_manager_->SendSerializedThreatDetails(serialized); | 418 ui_manager_->SendSerializedThreatDetails(serialized); |
419 } | 419 } |
420 | 420 |
421 } // namespace safe_browsing | 421 } // namespace safe_browsing |
OLD | NEW |