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