OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/subresource_filter/content/browser/fake_safe_browsing_datab
ase_manager.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 FakeSafeBrowsingDatabaseManager::FakeSafeBrowsingDatabaseManager() |
| 13 : simulate_timeout_(false) {} |
| 14 |
| 15 void FakeSafeBrowsingDatabaseManager::AddBlacklistedUrl( |
| 16 const GURL& url, |
| 17 safe_browsing::SBThreatType threat_type) { |
| 18 url_to_threat_type_[url] = threat_type; |
| 19 } |
| 20 |
| 21 void FakeSafeBrowsingDatabaseManager::SimulateTimeout() { |
| 22 simulate_timeout_ = true; |
| 23 } |
| 24 |
| 25 FakeSafeBrowsingDatabaseManager::~FakeSafeBrowsingDatabaseManager() {} |
| 26 |
| 27 bool FakeSafeBrowsingDatabaseManager::CheckUrlForSubresourceFilter( |
| 28 const GURL& url, |
| 29 Client* client) { |
| 30 if (simulate_timeout_) |
| 31 return false; |
| 32 if (!url_to_threat_type_.count(url)) |
| 33 return true; |
| 34 |
| 35 content::BrowserThread::PostTask( |
| 36 content::BrowserThread::IO, FROM_HERE, |
| 37 base::Bind(&Client::OnCheckBrowseUrlResult, base::Unretained(client), url, |
| 38 url_to_threat_type_[url], safe_browsing::ThreatMetadata())); |
| 39 return false; |
| 40 } |
| 41 |
| 42 bool FakeSafeBrowsingDatabaseManager::CheckResourceUrl(const GURL& url, |
| 43 Client* client) { |
| 44 return true; |
| 45 } |
| 46 |
| 47 bool FakeSafeBrowsingDatabaseManager::IsSupported() const { |
| 48 return true; |
| 49 } |
| 50 bool FakeSafeBrowsingDatabaseManager::ChecksAreAlwaysAsync() const { |
| 51 return false; |
| 52 } |
| 53 void FakeSafeBrowsingDatabaseManager::CancelCheck(Client* client) {} |
| 54 bool FakeSafeBrowsingDatabaseManager::CanCheckResourceType( |
| 55 content::ResourceType /* resource_type */) const { |
| 56 return true; |
| 57 } |
| 58 |
| 59 safe_browsing::ThreatSource FakeSafeBrowsingDatabaseManager::GetThreatSource() |
| 60 const { |
| 61 return safe_browsing::ThreatSource::LOCAL_PVER4; |
| 62 } |
| 63 |
| 64 bool FakeSafeBrowsingDatabaseManager::CheckExtensionIDs( |
| 65 const std::set<std::string>& extension_ids, |
| 66 Client* client) { |
| 67 return true; |
| 68 } |
OLD | NEW |