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