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 #include "chrome/browser/safe_browsing/ui_manager.h" | 5 #include "chrome/browser/safe_browsing/ui_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/debug/leak_tracker.h" | 10 #include "base/debug/leak_tracker.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/safe_browsing/ping_manager.h" | 19 #include "chrome/browser/safe_browsing/ping_manager.h" |
20 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
22 #include "chrome/browser/safe_browsing/threat_details.h" | 22 #include "chrome/browser/safe_browsing/threat_details.h" |
23 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
26 #include "components/safe_browsing_db/metadata.pb.h" | 26 #include "components/safe_browsing_db/metadata.pb.h" |
| 27 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
31 #include "ipc/ipc_message.h" | 32 #include "ipc/ipc_message.h" |
32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
33 #include "net/ssl/ssl_info.h" | 34 #include "net/ssl/ssl_info.h" |
34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
35 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
36 | 37 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (!resource.is_subresource && | 234 if (!resource.is_subresource && |
234 !resource.original_url.is_empty() && | 235 !resource.original_url.is_empty() && |
235 resource.original_url != resource.url) { | 236 resource.original_url != resource.url) { |
236 hit_report.referrer_url = hit_report.page_url; | 237 hit_report.referrer_url = hit_report.page_url; |
237 hit_report.page_url = resource.original_url; | 238 hit_report.page_url = resource.original_url; |
238 } | 239 } |
239 | 240 |
240 Profile* profile = | 241 Profile* profile = |
241 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 242 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
242 hit_report.is_extended_reporting = | 243 hit_report.is_extended_reporting = |
243 profile && | 244 profile && IsExtendedReportingEnabled(*profile->GetPrefs()); |
244 profile->GetPrefs()->GetBoolean( | |
245 prefs::kSafeBrowsingExtendedReportingEnabled); | |
246 hit_report.is_metrics_reporting_active = | 245 hit_report.is_metrics_reporting_active = |
247 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 246 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
248 | 247 |
249 MaybeReportSafeBrowsingHit(hit_report); | 248 MaybeReportSafeBrowsingHit(hit_report); |
250 } | 249 } |
251 | 250 |
252 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { | 251 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { |
253 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingHit(resource)); | 252 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingHit(resource)); |
254 } | 253 } |
255 AddToWhitelistUrlSet(resource, true /* A decision is now pending */); | 254 AddToWhitelistUrlSet(resource, true /* A decision is now pending */); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 426 |
428 bool whitelisted = site_list->Contains(lookup_url); | 427 bool whitelisted = site_list->Contains(lookup_url); |
429 if (whitelist_only) { | 428 if (whitelist_only) { |
430 return whitelisted; | 429 return whitelisted; |
431 } else { | 430 } else { |
432 return whitelisted || site_list->ContainsPending(lookup_url); | 431 return whitelisted || site_list->ContainsPending(lookup_url); |
433 } | 432 } |
434 } | 433 } |
435 | 434 |
436 } // namespace safe_browsing | 435 } // namespace safe_browsing |
OLD | NEW |