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 IsFileHandler(const std::string& extension_id) OVERRIDE; | 24 virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE; |
24 virtual bool HasSessionOnlyOrigins() OVERRIDE; | 25 virtual bool HasSessionOnlyOrigins() OVERRIDE; |
25 | 26 |
26 void AddProtected(const GURL& origin) { | 27 void AddProtected(const GURL& origin) { |
27 protected_.insert(origin); | 28 protected_.insert(origin); |
28 } | 29 } |
29 | 30 |
30 void AddUnlimited(const GURL& origin) { | 31 void AddUnlimited(const GURL& origin) { |
31 unlimited_.insert(origin); | 32 unlimited_.insert(origin); |
32 } | 33 } |
33 | 34 |
34 void AddSessionOnly(const GURL& origin) { | 35 void AddSessionOnly(const GURL& origin) { |
35 session_only_.insert(origin); | 36 session_only_.insert(origin); |
36 } | 37 } |
37 | 38 |
| 39 void AddInstalledApp(const GURL& origin) { |
| 40 // Installed implies unlimited. |
| 41 unlimited_.insert(origin); |
| 42 installed_.insert(origin); |
| 43 } |
| 44 |
38 void AddFileHandler(const std::string& id) { | 45 void AddFileHandler(const std::string& id) { |
39 file_handlers_.insert(id); | 46 file_handlers_.insert(id); |
40 } | 47 } |
41 | 48 |
42 void SetAllUnlimited(bool all_unlimited) { | 49 void SetAllUnlimited(bool all_unlimited) { |
43 all_unlimited_ = all_unlimited; | 50 all_unlimited_ = all_unlimited; |
44 } | 51 } |
45 | 52 |
46 void Reset() { | 53 void Reset() { |
47 protected_.clear(); | 54 protected_.clear(); |
48 unlimited_.clear(); | 55 unlimited_.clear(); |
49 session_only_.clear(); | 56 session_only_.clear(); |
| 57 installed_.clear(); |
50 file_handlers_.clear(); | 58 file_handlers_.clear(); |
51 all_unlimited_ = false; | 59 all_unlimited_ = false; |
52 } | 60 } |
53 | 61 |
54 void NotifyChanged() { | 62 void NotifyChanged() { |
55 SpecialStoragePolicy::NotifyObservers(); | 63 SpecialStoragePolicy::NotifyObservers(); |
56 } | 64 } |
57 | 65 |
58 protected: | 66 protected: |
59 virtual ~MockSpecialStoragePolicy(); | 67 virtual ~MockSpecialStoragePolicy(); |
60 | 68 |
61 private: | 69 private: |
62 std::set<GURL> protected_; | 70 std::set<GURL> protected_; |
63 std::set<GURL> unlimited_; | 71 std::set<GURL> unlimited_; |
64 std::set<GURL> session_only_; | 72 std::set<GURL> session_only_; |
| 73 std::set<GURL> installed_; |
65 std::set<std::string> file_handlers_; | 74 std::set<std::string> file_handlers_; |
66 | 75 |
67 bool all_unlimited_; | 76 bool all_unlimited_; |
68 }; | 77 }; |
69 } // namespace quota | 78 } // namespace quota |
70 | 79 |
71 #endif // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ | 80 #endif // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_ |
OLD | NEW |