Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / fake_safe_browsing_database_manager.h
blobb8d2a97588669ba6fe066816236bf896a941d787
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_
8 #include <set>
9 #include <string>
11 #include "chrome/browser/safe_browsing/local_database_manager.h"
13 namespace extensions {
15 // A fake safe browsing database manager for use with extensions tests.
17 // By default it is disabled (returning true and ignoring |unsafe_ids_|);
18 // call set_enabled to enable it.
19 class FakeSafeBrowsingDatabaseManager
20 : public LocalSafeBrowsingDatabaseManager {
21 public:
22 explicit FakeSafeBrowsingDatabaseManager(bool enabled);
24 // Returns true if synchronously safe, false if not in which case the unsafe
25 // IDs taken from |unsafe_ids_| are passed to to |client| on the current
26 // message loop.
27 bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
28 Client* client) override;
30 // Return |this| to chain together SetUnsafe(...).NotifyUpdate() conveniently.
31 FakeSafeBrowsingDatabaseManager& Enable();
32 FakeSafeBrowsingDatabaseManager& Disable();
33 FakeSafeBrowsingDatabaseManager& ClearUnsafe();
34 FakeSafeBrowsingDatabaseManager& SetUnsafe(const std::string& a);
35 FakeSafeBrowsingDatabaseManager& SetUnsafe(const std::string& a,
36 const std::string& b);
37 FakeSafeBrowsingDatabaseManager& SetUnsafe(const std::string& a,
38 const std::string& b,
39 const std::string& c);
40 FakeSafeBrowsingDatabaseManager& SetUnsafe(const std::string& a,
41 const std::string& b,
42 const std::string& c,
43 const std::string& d);
44 FakeSafeBrowsingDatabaseManager& AddUnsafe(const std::string& a);
45 FakeSafeBrowsingDatabaseManager& RemoveUnsafe(const std::string& a);
47 // Send the update notification.
48 void NotifyUpdate();
50 private:
51 ~FakeSafeBrowsingDatabaseManager() override;
53 // Runs result->SafeBrowsingResult().
54 void OnSafeBrowsingResult(scoped_ptr<SafeBrowsingCheck> result);
56 // Whether to respond to CheckExtensionIDs immediately with true (indicating
57 // that there is definitely no extension ID match).
58 bool enabled_;
60 // The extension IDs considered unsafe.
61 std::set<std::string> unsafe_ids_;
64 } // namespace extensions
66 #endif // CHROME_BROWSER_EXTENSIONS_FAKE_SAFE_BROWSING_DATABASE_MANAGER_H_