| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/quota/special_storage_policy.h" | 14 #include "webkit/quota/special_storage_policy.h" |
| 15 | 15 |
| 16 class Extension; | 16 class Extension; |
| 17 | 17 |
| 18 // Special rights are granted to 'extensions' and 'applications'. The | 18 // Special rights are granted to 'extensions' and 'applications'. The |
| 19 // storage subsystems and the browsing data remover query this interface | 19 // storage subsystems and the browsing data remover query this interface |
| 20 // to determine which origins have these rights. | 20 // to determine which origins have these rights. |
| 21 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy { | 21 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy { |
| 22 public: | 22 public: |
| 23 ExtensionSpecialStoragePolicy(); |
| 24 |
| 23 // SpecialStoragePolicy methods used by storage subsystems and the browsing | 25 // SpecialStoragePolicy methods used by storage subsystems and the browsing |
| 24 // data remover. These methods are safe to call on any thread. | 26 // data remover. These methods are safe to call on any thread. |
| 25 virtual bool IsStorageProtected(const GURL& origin); | 27 virtual bool IsStorageProtected(const GURL& origin); |
| 26 virtual bool IsStorageUnlimited(const GURL& origin); | 28 virtual bool IsStorageUnlimited(const GURL& origin); |
| 27 | 29 |
| 28 // Methods used by the ExtensionService to populate this class. | 30 // Methods used by the ExtensionService to populate this class. |
| 29 void GrantRightsForExtension(const Extension* extension); | 31 void GrantRightsForExtension(const Extension* extension); |
| 30 void RevokeRightsForExtension(const Extension* extension); | 32 void RevokeRightsForExtension(const Extension* extension); |
| 31 void RevokeRightsForAllExtensions(); | 33 void RevokeRightsForAllExtensions(); |
| 32 | 34 |
| 33 private: | 35 private: |
| 36 friend class base::RefCountedThreadSafe<SpecialStoragePolicy>; |
| 37 virtual ~ExtensionSpecialStoragePolicy(); |
| 38 |
| 34 class SpecialCollection { | 39 class SpecialCollection { |
| 35 public: | 40 public: |
| 41 SpecialCollection(); |
| 42 ~SpecialCollection(); |
| 43 |
| 36 bool Contains(const GURL& origin); | 44 bool Contains(const GURL& origin); |
| 37 void Add(const Extension* extension); | 45 void Add(const Extension* extension); |
| 38 void Remove(const Extension* extension); | 46 void Remove(const Extension* extension); |
| 39 void Clear(); | 47 void Clear(); |
| 40 | 48 |
| 41 private: | 49 private: |
| 42 typedef std::map<GURL, bool> CachedResults; | 50 typedef std::map<GURL, bool> CachedResults; |
| 43 typedef std::set<const Extension*> Extensions; | 51 typedef std::set<const Extension*> Extensions; |
| 44 Extensions extensions_; | 52 Extensions extensions_; |
| 45 CachedResults cached_resuts_; | 53 CachedResults cached_resuts_; |
| 46 }; | 54 }; |
| 47 | 55 |
| 48 base::Lock lock_; // Synchronize all access to the collections. | 56 base::Lock lock_; // Synchronize all access to the collections. |
| 49 SpecialCollection protected_apps_; | 57 SpecialCollection protected_apps_; |
| 50 SpecialCollection unlimited_extensions_; | 58 SpecialCollection unlimited_extensions_; |
| 51 }; | 59 }; |
| 52 | 60 |
| 53 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ | 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ |
| OLD | NEW |