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