| 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 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "chrome/common/extensions/extension_set.h" | 12 #include "extensions/common/extension_set.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 #include "webkit/browser/quota/special_storage_policy.h" | 14 #include "webkit/browser/quota/special_storage_policy.h" |
| 15 | 15 |
| 16 class CookieSettings; | 16 class CookieSettings; |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 class Extension; | 19 class Extension; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // Special rights are granted to 'extensions' and 'applications'. The | 22 // Special rights are granted to 'extensions' and 'applications'. The |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 // Methods used by the ExtensionService to populate this class. | 39 // Methods used by the ExtensionService to populate this class. |
| 40 void GrantRightsForExtension(const extensions::Extension* extension); | 40 void GrantRightsForExtension(const extensions::Extension* extension); |
| 41 void RevokeRightsForExtension(const extensions::Extension* extension); | 41 void RevokeRightsForExtension(const extensions::Extension* extension); |
| 42 void RevokeRightsForAllExtensions(); | 42 void RevokeRightsForAllExtensions(); |
| 43 | 43 |
| 44 // Decides whether the storage for |extension|'s web extent needs protection. | 44 // Decides whether the storage for |extension|'s web extent needs protection. |
| 45 bool NeedsProtection(const extensions::Extension* extension); | 45 bool NeedsProtection(const extensions::Extension* extension); |
| 46 | 46 |
| 47 // Returns the set of extensions protecting this origin. The caller does not | 47 // Returns the set of extensions protecting this origin. The caller does not |
| 48 // take ownership of the return value. | 48 // take ownership of the return value. |
| 49 const ExtensionSet* ExtensionsProtectingOrigin(const GURL& origin); | 49 const extensions::ExtensionSet* ExtensionsProtectingOrigin( |
| 50 const GURL& origin); |
| 50 | 51 |
| 51 protected: | 52 protected: |
| 52 virtual ~ExtensionSpecialStoragePolicy(); | 53 virtual ~ExtensionSpecialStoragePolicy(); |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 class SpecialCollection { | 56 class SpecialCollection { |
| 56 public: | 57 public: |
| 57 SpecialCollection(); | 58 SpecialCollection(); |
| 58 ~SpecialCollection(); | 59 ~SpecialCollection(); |
| 59 | 60 |
| 60 bool Contains(const GURL& origin); | 61 bool Contains(const GURL& origin); |
| 61 const ExtensionSet* ExtensionsContaining(const GURL& origin); | 62 const extensions::ExtensionSet* ExtensionsContaining(const GURL& origin); |
| 62 bool ContainsExtension(const std::string& extension_id); | 63 bool ContainsExtension(const std::string& extension_id); |
| 63 bool Add(const extensions::Extension* extension); | 64 bool Add(const extensions::Extension* extension); |
| 64 bool Remove(const extensions::Extension* extension); | 65 bool Remove(const extensions::Extension* extension); |
| 65 void Clear(); | 66 void Clear(); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 typedef std::map<GURL, ExtensionSet*> CachedResults; | 69 typedef std::map<GURL, extensions::ExtensionSet*> CachedResults; |
| 69 | 70 |
| 70 void ClearCache(); | 71 void ClearCache(); |
| 71 | 72 |
| 72 ExtensionSet extensions_; | 73 extensions::ExtensionSet extensions_; |
| 73 CachedResults cached_results_; | 74 CachedResults cached_results_; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 void NotifyGranted(const GURL& origin, int change_flags); | 77 void NotifyGranted(const GURL& origin, int change_flags); |
| 77 void NotifyRevoked(const GURL& origin, int change_flags); | 78 void NotifyRevoked(const GURL& origin, int change_flags); |
| 78 void NotifyCleared(); | 79 void NotifyCleared(); |
| 79 | 80 |
| 80 base::Lock lock_; // Synchronize all access to the collections. | 81 base::Lock lock_; // Synchronize all access to the collections. |
| 81 SpecialCollection protected_apps_; | 82 SpecialCollection protected_apps_; |
| 82 SpecialCollection installed_apps_; | 83 SpecialCollection installed_apps_; |
| 83 SpecialCollection unlimited_extensions_; | 84 SpecialCollection unlimited_extensions_; |
| 84 SpecialCollection file_handler_extensions_; | 85 SpecialCollection file_handler_extensions_; |
| 85 SpecialCollection isolated_extensions_; | 86 SpecialCollection isolated_extensions_; |
| 86 scoped_refptr<CookieSettings> cookie_settings_; | 87 scoped_refptr<CookieSettings> cookie_settings_; |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ |
| OLD | NEW |