Chromium Code Reviews| Index: components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h |
| diff --git a/components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h b/components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..40129229b79965a31e1307ad0f8aba0d7c95969e |
| --- /dev/null |
| +++ b/components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| +#define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <set> |
|
engedy
2017/04/20 12:34:33
nit: No need to include this in the header, it is
Charlie Harrison
2017/04/20 15:55:20
Done.
|
| + |
| +#include "base/macros.h" |
| +#include "components/safe_browsing_db/hit_report.h" |
|
engedy
2017/04/20 12:34:33
nit: Unused?
Charlie Harrison
2017/04/20 15:55:20
Used for safe_browsing::ThreatSource, but it isn't
|
| +#include "components/safe_browsing_db/test_database_manager.h" |
| +#include "content/public/common/resource_type.h" |
|
engedy
2017/04/20 12:34:33
nit: Unused?
Charlie Harrison
2017/04/20 15:55:20
Ditto, done.
|
| +#include "url/gurl.h" |
|
engedy
2017/04/20 12:34:33
nit: Fwd-declaration below seems sufficient.
Charlie Harrison
2017/04/20 15:55:20
Done.
|
| + |
| +class GURL; |
| + |
| +// Database manager that allows any URL to be configured as blacklisted for |
| +// testing. |
| +class FakeSafeBrowsingDatabaseManager |
| + : public safe_browsing::TestSafeBrowsingDatabaseManager { |
| + public: |
| + FakeSafeBrowsingDatabaseManager(); |
| + |
| + void AddBlacklistedUrl(const GURL& url, |
| + safe_browsing::SBThreatType threat_type); |
| + |
| + void SimulateTimeout(); |
| + |
| + protected: |
| + ~FakeSafeBrowsingDatabaseManager() override; |
| + |
| + // safe_browsing::TestSafeBrowsingDatabaseManager: |
| + bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override; |
| + bool CheckResourceUrl(const GURL& url, Client* client) override; |
| + bool IsSupported() const override; |
| + void CancelCheck(Client* client) override; |
| + bool ChecksAreAlwaysAsync() const override; |
| + bool CanCheckResourceType( |
| + content::ResourceType /* resource_type */) const override; |
| + safe_browsing::ThreatSource GetThreatSource() const override; |
| + bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
| + Client* client) override; |
| + |
| + private: |
| + std::map<GURL, safe_browsing::SBThreatType> url_to_threat_type_; |
| + bool simulate_timeout_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); |
| +}; |
| + |
| +#endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_ |