| 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 void RemoveBlacklistedUrl(const GURL& url); |
| 26 | 27 |
| 27 void SimulateTimeout(); | 28 void SimulateTimeout(); |
| 28 | 29 |
| 29 protected: | 30 protected: |
| 30 ~FakeSafeBrowsingDatabaseManager() override; | 31 ~FakeSafeBrowsingDatabaseManager() override; |
| 31 | 32 |
| 32 // safe_browsing::TestSafeBrowsingDatabaseManager: | 33 // safe_browsing::TestSafeBrowsingDatabaseManager: |
| 33 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override; | 34 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override; |
| 34 bool CheckResourceUrl(const GURL& url, Client* client) override; | 35 bool CheckResourceUrl(const GURL& url, Client* client) override; |
| 35 bool IsSupported() const override; | 36 bool IsSupported() const override; |
| 36 void CancelCheck(Client* client) override; | 37 void CancelCheck(Client* client) override; |
| 37 bool ChecksAreAlwaysAsync() const override; | 38 bool ChecksAreAlwaysAsync() const override; |
| 38 bool CanCheckResourceType( | 39 bool CanCheckResourceType( |
| 39 content::ResourceType /* resource_type */) const override; | 40 content::ResourceType /* resource_type */) const override; |
| 40 safe_browsing::ThreatSource GetThreatSource() const override; | 41 safe_browsing::ThreatSource GetThreatSource() const override; |
| 41 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, | 42 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
| 42 Client* client) override; | 43 Client* client) override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 void OnCheckUrlForSubresourceFilterComplete(Client* client, const GURL& url); | 46 void OnCheckUrlForSubresourceFilterComplete(Client* client, const GURL& url); |
| 46 | 47 |
| 47 std::map<GURL, safe_browsing::SBThreatType> url_to_threat_type_; | 48 std::map<GURL, safe_browsing::SBThreatType> url_to_threat_type_; |
| 48 std::set<Client*> checks_; | 49 std::set<Client*> checks_; |
| 49 bool simulate_timeout_; | 50 bool simulate_timeout_; |
| 50 | 51 |
| 51 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); | 52 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATA
BASE_MANAGER_H_ | 55 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATA
BASE_MANAGER_H_ |
| OLD | NEW |