Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: components/subresource_filter/content/browser/fake_safe_browsing_database_manager.cc

Issue 2859783002: [subresource_filter] Make website setting existence imply site activation (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/subresource_filter/content/browser/fake_safe_browsing_datab ase_manager.h" 5 #include "components/subresource_filter/content/browser/fake_safe_browsing_datab ase_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/logging.h" 9 #include "base/logging.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 FakeSafeBrowsingDatabaseManager::FakeSafeBrowsingDatabaseManager() 13 FakeSafeBrowsingDatabaseManager::FakeSafeBrowsingDatabaseManager()
14 : simulate_timeout_(false) {} 14 : simulate_timeout_(false) {}
15 15
16 void FakeSafeBrowsingDatabaseManager::AddBlacklistedUrl( 16 void FakeSafeBrowsingDatabaseManager::AddBlacklistedUrl(
17 const GURL& url, 17 const GURL& url,
18 safe_browsing::SBThreatType threat_type) { 18 safe_browsing::SBThreatType threat_type) {
19 url_to_threat_type_[url] = threat_type; 19 url_to_threat_type_[url] = threat_type;
20 } 20 }
21 21
22 void FakeSafeBrowsingDatabaseManager::RemoveBlacklistedUrl(const GURL& url) {
23 url_to_threat_type_.erase(url);
24 }
25
22 void FakeSafeBrowsingDatabaseManager::SimulateTimeout() { 26 void FakeSafeBrowsingDatabaseManager::SimulateTimeout() {
23 simulate_timeout_ = true; 27 simulate_timeout_ = true;
24 } 28 }
25 29
26 FakeSafeBrowsingDatabaseManager::~FakeSafeBrowsingDatabaseManager() {} 30 FakeSafeBrowsingDatabaseManager::~FakeSafeBrowsingDatabaseManager() {}
27 31
28 bool FakeSafeBrowsingDatabaseManager::CheckUrlForSubresourceFilter( 32 bool FakeSafeBrowsingDatabaseManager::CheckUrlForSubresourceFilter(
29 const GURL& url, 33 const GURL& url,
30 Client* client) { 34 Client* client) {
31 if (simulate_timeout_) 35 if (simulate_timeout_)
(...skipping 14 matching lines...) Expand all
46 } 50 }
47 51
48 void FakeSafeBrowsingDatabaseManager::OnCheckUrlForSubresourceFilterComplete( 52 void FakeSafeBrowsingDatabaseManager::OnCheckUrlForSubresourceFilterComplete(
49 Client* client, 53 Client* client,
50 const GURL& url) { 54 const GURL& url) {
51 // Check to see if the request was cancelled to avoid use-after-free. 55 // Check to see if the request was cancelled to avoid use-after-free.
52 if (checks_.find(client) == checks_.end()) 56 if (checks_.find(client) == checks_.end())
53 return; 57 return;
54 client->OnCheckBrowseUrlResult(url, url_to_threat_type_[url], 58 client->OnCheckBrowseUrlResult(url, url_to_threat_type_[url],
55 safe_browsing::ThreatMetadata()); 59 safe_browsing::ThreatMetadata());
60 // Erase the client when a check is complete. Otherwise, it's possible
61 // subsequent clients that share an address with this one will DCHECK in
62 // CheckUrlForSubresourceFilter.
63 checks_.erase(client);
56 } 64 }
57 65
58 bool FakeSafeBrowsingDatabaseManager::CheckResourceUrl(const GURL& url, 66 bool FakeSafeBrowsingDatabaseManager::CheckResourceUrl(const GURL& url,
59 Client* client) { 67 Client* client) {
60 return true; 68 return true;
61 } 69 }
62 70
63 bool FakeSafeBrowsingDatabaseManager::IsSupported() const { 71 bool FakeSafeBrowsingDatabaseManager::IsSupported() const {
64 return true; 72 return true;
65 } 73 }
(...skipping 11 matching lines...) Expand all
77 safe_browsing::ThreatSource FakeSafeBrowsingDatabaseManager::GetThreatSource() 85 safe_browsing::ThreatSource FakeSafeBrowsingDatabaseManager::GetThreatSource()
78 const { 86 const {
79 return safe_browsing::ThreatSource::LOCAL_PVER4; 87 return safe_browsing::ThreatSource::LOCAL_PVER4;
80 } 88 }
81 89
82 bool FakeSafeBrowsingDatabaseManager::CheckExtensionIDs( 90 bool FakeSafeBrowsingDatabaseManager::CheckExtensionIDs(
83 const std::set<std::string>& extension_ids, 91 const std::set<std::string>& extension_ids,
84 Client* client) { 92 Client* client) {
85 return true; 93 return true;
86 } 94 }
OLDNEW
« no previous file with comments | « components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698