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_
11 #include "storage/browser/quota/special_storage_policy.h"
14 using storage::SpecialStoragePolicy
;
18 class MockSpecialStoragePolicy
: public storage::SpecialStoragePolicy
{
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
;
29 void AddProtected(const GURL
& origin
) {
30 protected_
.insert(origin
);
33 void AddUnlimited(const GURL
& origin
) {
34 unlimited_
.insert(origin
);
37 void RemoveUnlimited(const GURL
& origin
) {
38 unlimited_
.erase(origin
);
41 void AddSessionOnly(const GURL
& origin
) {
42 session_only_
.insert(origin
);
45 void GrantQueryDiskSize(const GURL
& origin
) {
46 can_query_disk_size_
.insert(origin
);
49 void AddIsolated(const GURL
& origin
) {
50 isolated_
.insert(origin
);
53 void RemoveIsolated(const GURL
& origin
) {
54 isolated_
.erase(origin
);
57 void SetAllUnlimited(bool all_unlimited
) {
58 all_unlimited_
= all_unlimited
;
64 session_only_
.clear();
65 can_query_disk_size_
.clear();
66 file_handlers_
.clear();
68 all_unlimited_
= false;
71 void NotifyGranted(const GURL
& origin
, int change_flags
) {
72 SpecialStoragePolicy::NotifyGranted(origin
, change_flags
);
75 void NotifyRevoked(const GURL
& origin
, int change_flags
) {
76 SpecialStoragePolicy::NotifyRevoked(origin
, change_flags
);
79 void NotifyCleared() {
80 SpecialStoragePolicy::NotifyCleared();
84 ~MockSpecialStoragePolicy() override
;
87 std::set
<GURL
> protected_
;
88 std::set
<GURL
> unlimited_
;
89 std::set
<GURL
> session_only_
;
90 std::set
<GURL
> can_query_disk_size_
;
91 std::set
<GURL
> isolated_
;
92 std::set
<std::string
> file_handlers_
;
96 } // namespace content
98 #endif // CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_