Chromium Code Reviews| 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/file_path.h" | |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/quota/special_storage_policy.h" | 15 #include "webkit/quota/special_storage_policy.h" |
| 15 | 16 |
| 16 class Extension; | 17 class Extension; |
| 17 | 18 |
| 18 // Special rights are granted to 'extensions' and 'applications'. The | 19 // Special rights are granted to 'extensions' and 'applications'. The |
| 19 // storage subsystems and the browsing data remover query this interface | 20 // storage subsystems and the browsing data remover query this interface |
| 20 // to determine which origins have these rights. | 21 // to determine which origins have these rights. |
| 21 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy { | 22 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy { |
| 22 public: | 23 public: |
| 23 ExtensionSpecialStoragePolicy(); | 24 ExtensionSpecialStoragePolicy(); |
| 24 | 25 |
| 25 // SpecialStoragePolicy methods used by storage subsystems and the browsing | 26 // SpecialStoragePolicy methods used by storage subsystems and the browsing |
| 26 // data remover. These methods are safe to call on any thread. | 27 // data remover. These methods are safe to call on any thread. |
| 27 virtual bool IsStorageProtected(const GURL& origin); | 28 virtual bool IsStorageProtected(const GURL& origin); |
| 28 virtual bool IsStorageUnlimited(const GURL& origin); | 29 virtual bool IsStorageUnlimited(const GURL& origin); |
| 29 virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin); | 30 virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin, |
| 31 const FilePath& virtual_path); | |
| 32 virtual void GrantLocalFileSystemAccess(const GURL& origin, | |
| 33 const FilePath& virtual_path); | |
| 30 | 34 |
| 31 // Methods used by the ExtensionService to populate this class. | 35 // Methods used by the ExtensionService to populate this class. |
| 32 void GrantRightsForExtension(const Extension* extension); | 36 void GrantRightsForExtension(const Extension* extension); |
| 33 void RevokeRightsForExtension(const Extension* extension); | 37 void RevokeRightsForExtension(const Extension* extension); |
| 34 void RevokeRightsForAllExtensions(); | 38 void RevokeRightsForAllExtensions(); |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 class SpecialCollection { | 41 class SpecialCollection { |
| 38 public: | 42 public: |
| 39 SpecialCollection(); | 43 SpecialCollection(); |
| 40 ~SpecialCollection(); | 44 virtual ~SpecialCollection(); |
| 41 | 45 |
| 42 bool Contains(const GURL& origin); | 46 bool Contains(const GURL& origin); |
| 43 void Add(const Extension* extension); | 47 void Add(const Extension* extension); |
| 44 void Remove(const Extension* extension); | 48 virtual void Remove(const Extension* extension); |
| 45 void Clear(); | 49 virtual void Clear(); |
| 46 | 50 |
| 47 private: | 51 protected: |
| 48 typedef std::map<GURL, bool> CachedResults; | 52 typedef std::map<GURL, bool> CachedResults; |
| 49 typedef std::set<const Extension*> Extensions; | 53 typedef std::set<const Extension*> Extensions; |
| 50 Extensions extensions_; | 54 Extensions extensions_; |
| 51 CachedResults cached_resuts_; | 55 CachedResults cached_resuts_; |
|
ericu
2011/04/08 02:12:14
typo: results
zel
2011/04/08 04:16:36
Done.
| |
| 52 }; | 56 }; |
| 53 | 57 |
| 58 class SpecialPathCollection : public SpecialCollection { | |
| 59 public: | |
| 60 SpecialPathCollection(); | |
| 61 virtual ~SpecialPathCollection(); | |
| 62 | |
| 63 // SpecialCollection overrides. | |
| 64 virtual void Remove(const Extension* extension); | |
| 65 virtual void Clear(); | |
| 66 | |
| 67 void AddPath(const GURL& origin, const FilePath& path); | |
| 68 bool ContainsPath(const GURL& origin, const FilePath& path); | |
| 69 | |
| 70 private: | |
| 71 typedef std::set<FilePath> PathSet; | |
| 72 typedef std::map<const Extension*, PathSet> PathAccessMap; | |
| 73 const Extension* GetExtension(const GURL& origin); | |
| 74 PathAccessMap path_map_; | |
| 75 }; | |
| 76 | |
| 54 virtual ~ExtensionSpecialStoragePolicy(); | 77 virtual ~ExtensionSpecialStoragePolicy(); |
| 55 | 78 |
| 56 base::Lock lock_; // Synchronize all access to the collections. | 79 base::Lock lock_; // Synchronize all access to the collections. |
| 57 SpecialCollection protected_apps_; | 80 SpecialCollection protected_apps_; |
| 58 SpecialCollection unlimited_extensions_; | 81 SpecialCollection unlimited_extensions_; |
| 59 SpecialCollection local_filesystem_extensions_; | 82 SpecialPathCollection local_filesystem_extensions_; |
| 60 }; | 83 }; |
| 61 | 84 |
| 62 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ | 85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ |
| OLD | NEW |