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

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

Issue 2814733002: Add the SocEng as a type for checking in CheckUrlForSubresourceFilter. (Closed)
Patch Set: . 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
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 safe_browsing::ThreatPatternType pattern_type) {
20 url_to_threat_type_[url] = std::make_pair(threat_type, pattern_type);
20 } 21 }
21 22
22 void FakeSafeBrowsingDatabaseManager::RemoveBlacklistedUrl(const GURL& url) { 23 void FakeSafeBrowsingDatabaseManager::RemoveBlacklistedUrl(const GURL& url) {
23 url_to_threat_type_.erase(url); 24 url_to_threat_type_.erase(url);
24 } 25 }
25 26
26 void FakeSafeBrowsingDatabaseManager::SimulateTimeout() { 27 void FakeSafeBrowsingDatabaseManager::SimulateTimeout() {
27 simulate_timeout_ = true; 28 simulate_timeout_ = true;
28 } 29 }
29 30
(...skipping 18 matching lines...) Expand all
48 base::Unretained(this), base::Unretained(client), url)); 49 base::Unretained(this), base::Unretained(client), url));
49 return false; 50 return false;
50 } 51 }
51 52
52 void FakeSafeBrowsingDatabaseManager::OnCheckUrlForSubresourceFilterComplete( 53 void FakeSafeBrowsingDatabaseManager::OnCheckUrlForSubresourceFilterComplete(
53 Client* client, 54 Client* client,
54 const GURL& url) { 55 const GURL& url) {
55 // Check to see if the request was cancelled to avoid use-after-free. 56 // Check to see if the request was cancelled to avoid use-after-free.
56 if (checks_.find(client) == checks_.end()) 57 if (checks_.find(client) == checks_.end())
57 return; 58 return;
58 client->OnCheckBrowseUrlResult(url, url_to_threat_type_[url], 59 safe_browsing::ThreatMetadata metadata;
59 safe_browsing::ThreatMetadata()); 60 metadata.threat_pattern_type = url_to_threat_type_[url].second;
61
62 client->OnCheckBrowseUrlResult(url, url_to_threat_type_[url].first, metadata);
60 // Erase the client when a check is complete. Otherwise, it's possible 63 // 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 64 // subsequent clients that share an address with this one will DCHECK in
62 // CheckUrlForSubresourceFilter. 65 // CheckUrlForSubresourceFilter.
63 checks_.erase(client); 66 checks_.erase(client);
64 } 67 }
65 68
66 bool FakeSafeBrowsingDatabaseManager::CheckResourceUrl(const GURL& url, 69 bool FakeSafeBrowsingDatabaseManager::CheckResourceUrl(const GURL& url,
67 Client* client) { 70 Client* client) {
68 return true; 71 return true;
69 } 72 }
(...skipping 15 matching lines...) Expand all
85 safe_browsing::ThreatSource FakeSafeBrowsingDatabaseManager::GetThreatSource() 88 safe_browsing::ThreatSource FakeSafeBrowsingDatabaseManager::GetThreatSource()
86 const { 89 const {
87 return safe_browsing::ThreatSource::LOCAL_PVER4; 90 return safe_browsing::ThreatSource::LOCAL_PVER4;
88 } 91 }
89 92
90 bool FakeSafeBrowsingDatabaseManager::CheckExtensionIDs( 93 bool FakeSafeBrowsingDatabaseManager::CheckExtensionIDs(
91 const std::set<std::string>& extension_ids, 94 const std::set<std::string>& extension_ids,
92 Client* client) { 95 Client* client) {
93 return true; 96 return true;
94 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698