OLD | NEW |
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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABAS
E_MANAGER_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABAS
E_MANAGER_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABAS
E_MANAGER_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABAS
E_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/safe_browsing_db/test_database_manager.h" | 11 #include "components/safe_browsing_db/test_database_manager.h" |
12 #include "content/public/common/resource_type.h" | 12 #include "content/public/common/resource_type.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 // Database manager that allows any URL to be configured as blacklisted for | 16 // Database manager that allows any URL to be configured as blacklisted for |
17 // testing. | 17 // testing. |
18 class FakeSafeBrowsingDatabaseManager | 18 class FakeSafeBrowsingDatabaseManager |
19 : public safe_browsing::TestSafeBrowsingDatabaseManager { | 19 : public safe_browsing::TestSafeBrowsingDatabaseManager { |
20 public: | 20 public: |
21 FakeSafeBrowsingDatabaseManager(); | 21 FakeSafeBrowsingDatabaseManager(); |
22 | 22 |
23 void AddBlacklistedUrl(const GURL& url, | 23 void AddBlacklistedUrl(const GURL& url, |
24 safe_browsing::SBThreatType threat_type); | 24 safe_browsing::SBThreatType threat_type); |
| 25 void AddBlacklistedUrl(const GURL& url, |
| 26 safe_browsing::SBThreatType threat_type, |
| 27 safe_browsing::ThreatPatternType pattern_type); |
25 | 28 |
26 void SimulateTimeout(); | 29 void SimulateTimeout(); |
27 | 30 |
28 protected: | 31 protected: |
29 ~FakeSafeBrowsingDatabaseManager() override; | 32 ~FakeSafeBrowsingDatabaseManager() override; |
30 | 33 |
31 // safe_browsing::TestSafeBrowsingDatabaseManager: | 34 // safe_browsing::TestSafeBrowsingDatabaseManager: |
32 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override; | 35 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override; |
33 bool CheckResourceUrl(const GURL& url, Client* client) override; | 36 bool CheckResourceUrl(const GURL& url, Client* client) override; |
34 bool IsSupported() const override; | 37 bool IsSupported() const override; |
35 void CancelCheck(Client* client) override; | 38 void CancelCheck(Client* client) override; |
36 bool ChecksAreAlwaysAsync() const override; | 39 bool ChecksAreAlwaysAsync() const override; |
37 bool CanCheckResourceType( | 40 bool CanCheckResourceType( |
38 content::ResourceType /* resource_type */) const override; | 41 content::ResourceType /* resource_type */) const override; |
39 safe_browsing::ThreatSource GetThreatSource() const override; | 42 safe_browsing::ThreatSource GetThreatSource() const override; |
40 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, | 43 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
41 Client* client) override; | 44 Client* client) override; |
42 | 45 |
43 private: | 46 private: |
44 std::map<GURL, safe_browsing::SBThreatType> url_to_threat_type_; | 47 std::map< |
| 48 GURL, |
| 49 std::pair<safe_browsing::SBThreatType, safe_browsing::ThreatPatternType>> |
| 50 url_to_threat_type_; |
45 bool simulate_timeout_; | 51 bool simulate_timeout_; |
46 | 52 |
47 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); | 53 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); |
48 }; | 54 }; |
49 | 55 |
50 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATA
BASE_MANAGER_H_ | 56 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATA
BASE_MANAGER_H_ |
OLD | NEW |