OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #ifndef WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | |
6 #define WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "googleurl/src/gurl.h" | |
12 #include "webkit/quota/special_storage_policy.h" | |
13 | |
14 namespace quota { | |
15 | |
16 class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { | |
17 public: | |
18 MockSpecialStoragePolicy(); | |
19 | |
20 virtual bool IsStorageProtected(const GURL& origin) OVERRIDE; | |
21 virtual bool IsStorageUnlimited(const GURL& origin) OVERRIDE; | |
22 virtual bool IsStorageSessionOnly(const GURL& origin) OVERRIDE; | |
23 virtual bool CanQueryDiskSize(const GURL& origin) OVERRIDE; | |
24 virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE; | |
25 virtual bool HasSessionOnlyOrigins() OVERRIDE; | |
26 | |
27 void AddProtected(const GURL& origin) { | |
28 protected_.insert(origin); | |
29 } | |
30 | |
31 void AddUnlimited(const GURL& origin) { | |
32 unlimited_.insert(origin); | |
33 } | |
34 | |
35 void RemoveUnlimited(const GURL& origin) { | |
36 unlimited_.erase(origin); | |
37 } | |
38 | |
39 void AddSessionOnly(const GURL& origin) { | |
40 session_only_.insert(origin); | |
41 } | |
42 | |
43 void GrantQueryDiskSize(const GURL& origin) { | |
44 can_query_disk_size_.insert(origin); | |
45 } | |
46 | |
47 void AddFileHandler(const std::string& id) { | |
48 file_handlers_.insert(id); | |
49 } | |
50 | |
51 void SetAllUnlimited(bool all_unlimited) { | |
52 all_unlimited_ = all_unlimited; | |
53 } | |
54 | |
55 void Reset() { | |
56 protected_.clear(); | |
57 unlimited_.clear(); | |
58 session_only_.clear(); | |
59 can_query_disk_size_.clear(); | |
60 file_handlers_.clear(); | |
61 all_unlimited_ = false; | |
62 } | |
63 | |
64 void NotifyGranted(const GURL& origin, int change_flags) { | |
65 SpecialStoragePolicy::NotifyGranted(origin, change_flags); | |
66 } | |
67 | |
68 void NotifyRevoked(const GURL& origin, int change_flags) { | |
69 SpecialStoragePolicy::NotifyRevoked(origin, change_flags); | |
70 } | |
71 | |
72 void NotifyCleared() { | |
73 SpecialStoragePolicy::NotifyCleared(); | |
74 } | |
75 | |
76 protected: | |
77 virtual ~MockSpecialStoragePolicy(); | |
78 | |
79 private: | |
80 std::set<GURL> protected_; | |
81 std::set<GURL> unlimited_; | |
82 std::set<GURL> session_only_; | |
83 std::set<GURL> can_query_disk_size_; | |
84 std::set<std::string> file_handlers_; | |
85 | |
86 bool all_unlimited_; | |
87 }; | |
88 } // namespace quota | |
89 | |
90 #endif // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | |
OLD | NEW |