Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / test / mock_special_storage_policy.h
blob96003e8c12f8517c457927e9a288645d3e918738
1 // Copyright 2014 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 CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
6 #define CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
8 #include <set>
9 #include <string>
11 #include "storage/browser/quota/special_storage_policy.h"
12 #include "url/gurl.h"
14 using storage::SpecialStoragePolicy;
16 namespace content {
18 class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy {
19 public:
20 MockSpecialStoragePolicy();
22 bool IsStorageProtected(const GURL& origin) override;
23 bool IsStorageUnlimited(const GURL& origin) override;
24 bool IsStorageSessionOnly(const GURL& origin) override;
25 bool CanQueryDiskSize(const GURL& origin) override;
26 bool HasIsolatedStorage(const GURL& origin) override;
27 bool HasSessionOnlyOrigins() override;
28 bool IsStorageDurable(const GURL& origin) override;
30 void AddProtected(const GURL& origin) {
31 protected_.insert(origin);
34 void AddUnlimited(const GURL& origin) {
35 unlimited_.insert(origin);
38 void RemoveUnlimited(const GURL& origin) {
39 unlimited_.erase(origin);
42 void AddSessionOnly(const GURL& origin) {
43 session_only_.insert(origin);
46 void GrantQueryDiskSize(const GURL& origin) {
47 can_query_disk_size_.insert(origin);
50 void AddIsolated(const GURL& origin) {
51 isolated_.insert(origin);
54 void RemoveIsolated(const GURL& origin) {
55 isolated_.erase(origin);
58 void SetAllUnlimited(bool all_unlimited) {
59 all_unlimited_ = all_unlimited;
62 void AddDurable(const GURL& origin) {
63 durable_.insert(origin);
66 void Reset() {
67 protected_.clear();
68 unlimited_.clear();
69 session_only_.clear();
70 can_query_disk_size_.clear();
71 file_handlers_.clear();
72 isolated_.clear();
73 all_unlimited_ = false;
76 void NotifyGranted(const GURL& origin, int change_flags) {
77 SpecialStoragePolicy::NotifyGranted(origin, change_flags);
80 void NotifyRevoked(const GURL& origin, int change_flags) {
81 SpecialStoragePolicy::NotifyRevoked(origin, change_flags);
84 void NotifyCleared() {
85 SpecialStoragePolicy::NotifyCleared();
88 protected:
89 ~MockSpecialStoragePolicy() override;
91 private:
92 std::set<GURL> protected_;
93 std::set<GURL> unlimited_;
94 std::set<GURL> session_only_;
95 std::set<GURL> can_query_disk_size_;
96 std::set<GURL> isolated_;
97 std::set<GURL> durable_;
98 std::set<std::string> file_handlers_;
100 bool all_unlimited_;
102 } // namespace content
104 #endif // CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_