OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | 5 #ifndef WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ |
6 #define WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | 6 #define WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 #include "webkit/quota/special_storage_policy.h" | 12 #include "webkit/quota/special_storage_policy.h" |
13 | 13 |
14 namespace quota { | 14 namespace quota { |
15 | 15 |
16 class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { | 16 class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { |
17 public: | 17 public: |
18 MockSpecialStoragePolicy(); | 18 MockSpecialStoragePolicy(); |
19 | 19 |
20 virtual bool IsStorageProtected(const GURL& origin) OVERRIDE; | 20 virtual bool IsStorageProtected(const GURL& origin) OVERRIDE; |
21 virtual bool IsStorageUnlimited(const GURL& origin) OVERRIDE; | 21 virtual bool IsStorageUnlimited(const GURL& origin) OVERRIDE; |
22 virtual bool IsStorageSessionOnly(const GURL& origin) OVERRIDE; | 22 virtual bool IsStorageSessionOnly(const GURL& origin) OVERRIDE; |
23 virtual bool IsInstalledApp(const GURL& origin) OVERRIDE; | 23 virtual bool CanQueryDiskSize(const GURL& origin) OVERRIDE; |
24 virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE; | 24 virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE; |
25 virtual bool HasSessionOnlyOrigins() OVERRIDE; | 25 virtual bool HasSessionOnlyOrigins() OVERRIDE; |
26 | 26 |
27 void AddProtected(const GURL& origin) { | 27 void AddProtected(const GURL& origin) { |
28 protected_.insert(origin); | 28 protected_.insert(origin); |
29 } | 29 } |
30 | 30 |
31 void AddUnlimited(const GURL& origin) { | 31 void AddUnlimited(const GURL& origin) { |
32 unlimited_.insert(origin); | 32 unlimited_.insert(origin); |
33 } | 33 } |
34 | 34 |
35 void AddSessionOnly(const GURL& origin) { | 35 void AddSessionOnly(const GURL& origin) { |
36 session_only_.insert(origin); | 36 session_only_.insert(origin); |
37 } | 37 } |
38 | 38 |
39 void AddInstalledApp(const GURL& origin) { | 39 void GrantQueryDiskSize(const GURL& origin) { |
40 installed_.insert(origin); | 40 can_query_disk_size_.insert(origin); |
41 } | 41 } |
42 | 42 |
43 void AddFileHandler(const std::string& id) { | 43 void AddFileHandler(const std::string& id) { |
44 file_handlers_.insert(id); | 44 file_handlers_.insert(id); |
45 } | 45 } |
46 | 46 |
47 void SetAllUnlimited(bool all_unlimited) { | 47 void SetAllUnlimited(bool all_unlimited) { |
48 all_unlimited_ = all_unlimited; | 48 all_unlimited_ = all_unlimited; |
49 } | 49 } |
50 | 50 |
51 void Reset() { | 51 void Reset() { |
52 protected_.clear(); | 52 protected_.clear(); |
53 unlimited_.clear(); | 53 unlimited_.clear(); |
54 session_only_.clear(); | 54 session_only_.clear(); |
55 installed_.clear(); | 55 can_query_disk_size_.clear(); |
56 file_handlers_.clear(); | 56 file_handlers_.clear(); |
57 all_unlimited_ = false; | 57 all_unlimited_ = false; |
58 } | 58 } |
59 | 59 |
60 void NotifyChanged() { | 60 void NotifyChanged() { |
61 SpecialStoragePolicy::NotifyObservers(); | 61 SpecialStoragePolicy::NotifyObservers(); |
62 } | 62 } |
63 | 63 |
64 protected: | 64 protected: |
65 virtual ~MockSpecialStoragePolicy(); | 65 virtual ~MockSpecialStoragePolicy(); |
66 | 66 |
67 private: | 67 private: |
68 std::set<GURL> protected_; | 68 std::set<GURL> protected_; |
69 std::set<GURL> unlimited_; | 69 std::set<GURL> unlimited_; |
70 std::set<GURL> session_only_; | 70 std::set<GURL> session_only_; |
71 std::set<GURL> installed_; | 71 std::set<GURL> can_query_disk_size_; |
72 std::set<std::string> file_handlers_; | 72 std::set<std::string> file_handlers_; |
73 | 73 |
74 bool all_unlimited_; | 74 bool all_unlimited_; |
75 }; | 75 }; |
76 } // namespace quota | 76 } // namespace quota |
77 | 77 |
78 #endif // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | 78 #endif // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ |
OLD | NEW |