| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/safe_browsing/base_ui_manager.h" | 5 #include "components/safe_browsing/base_ui_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| 96 namespace safe_browsing { | 96 namespace safe_browsing { |
| 97 | 97 |
| 98 BaseUIManager::BaseUIManager() {} | 98 BaseUIManager::BaseUIManager() {} |
| 99 | 99 |
| 100 void BaseUIManager::StopOnIOThread(bool shutdown) { | 100 void BaseUIManager::StopOnIOThread(bool shutdown) { |
| 101 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 101 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 102 // TODO(ntfschr): implement this once SafeBrowsingService is componentized | |
| 103 return; | 102 return; |
| 104 } | 103 } |
| 105 | 104 |
| 106 BaseUIManager::~BaseUIManager() {} | 105 BaseUIManager::~BaseUIManager() {} |
| 107 | 106 |
| 108 bool BaseUIManager::IsWhitelisted(const UnsafeResource& resource) { | 107 bool BaseUIManager::IsWhitelisted(const UnsafeResource& resource) { |
| 109 NavigationEntry* entry = nullptr; | 108 NavigationEntry* entry = nullptr; |
| 110 if (resource.is_subresource) { | 109 if (resource.is_subresource) { |
| 111 entry = resource.GetNavigationEntryForResource(); | 110 entry = resource.GetNavigationEntryForResource(); |
| 112 } | 111 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 UMA_HISTOGRAM_LONG_TIMES("SB2.Delay", time); | 233 UMA_HISTOGRAM_LONG_TIMES("SB2.Delay", time); |
| 235 return; | 234 return; |
| 236 } | 235 } |
| 237 | 236 |
| 238 // A safebrowsing hit is sent after a blocking page for malware/phishing | 237 // A safebrowsing hit is sent after a blocking page for malware/phishing |
| 239 // or after the warning dialog for download urls, only for | 238 // or after the warning dialog for download urls, only for |
| 240 // UMA || extended_reporting users. | 239 // UMA || extended_reporting users. |
| 241 void BaseUIManager::MaybeReportSafeBrowsingHit( | 240 void BaseUIManager::MaybeReportSafeBrowsingHit( |
| 242 const HitReport& hit_report) { | 241 const HitReport& hit_report) { |
| 243 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 242 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 244 // TODO(ntfschr): implement this once we support reporting in WebView | |
| 245 return; | 243 return; |
| 246 } | 244 } |
| 247 | 245 |
| 248 void BaseUIManager::ReportSafeBrowsingHitOnIOThread( | 246 void BaseUIManager::ReportSafeBrowsingHitOnIOThread( |
| 249 const HitReport& hit_report) { | 247 const HitReport& hit_report) { |
| 250 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 248 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 251 // TODO(ntfschr): implement this once we support reporting in WebView | |
| 252 return; | 249 return; |
| 253 } | 250 } |
| 254 | 251 |
| 255 // If the user had opted-in to send ThreatDetails, this gets called | 252 // If the user had opted-in to send ThreatDetails, this gets called |
| 256 // when the report is ready. | 253 // when the report is ready. |
| 257 void BaseUIManager::SendSerializedThreatDetails( | 254 void BaseUIManager::SendSerializedThreatDetails( |
| 258 const std::string& serialized) { | 255 const std::string& serialized) { |
| 259 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 256 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 260 // TODO(ntfschr): implement this once we support reporting in WebView | |
| 261 return; | 257 return; |
| 262 } | 258 } |
| 263 | 259 |
| 264 // Record this domain in the given WebContents as either whitelisted or | 260 // Record this domain in the given WebContents as either whitelisted or |
| 265 // pending whitelisting (if an interstitial is currently displayed). If an | 261 // pending whitelisting (if an interstitial is currently displayed). If an |
| 266 // existing WhitelistUrlSet does not yet exist, create a new WhitelistUrlSet. | 262 // existing WhitelistUrlSet does not yet exist, create a new WhitelistUrlSet. |
| 267 void BaseUIManager::AddToWhitelistUrlSet(const GURL& whitelist_url, | 263 void BaseUIManager::AddToWhitelistUrlSet(const GURL& whitelist_url, |
| 268 WebContents* web_contents, | 264 WebContents* web_contents, |
| 269 bool pending, | 265 bool pending, |
| 270 SBThreatType threat_type) { | 266 SBThreatType threat_type) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (resource.is_subresource) { | 342 if (resource.is_subresource) { |
| 347 NavigationEntry* entry = resource.GetNavigationEntryForResource(); | 343 NavigationEntry* entry = resource.GetNavigationEntryForResource(); |
| 348 if (!entry) | 344 if (!entry) |
| 349 return GURL(); | 345 return GURL(); |
| 350 return entry->GetURL().GetWithEmptyPath(); | 346 return entry->GetURL().GetWithEmptyPath(); |
| 351 } | 347 } |
| 352 return resource.url.GetWithEmptyPath(); | 348 return resource.url.GetWithEmptyPath(); |
| 353 } | 349 } |
| 354 | 350 |
| 355 } // namespace safe_browsing | 351 } // namespace safe_browsing |
| OLD | NEW |