OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | 5 #ifndef EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
6 #define EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | 6 #define EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 bool HasExtensionForTesting(const Extension* extension) const; | 47 bool HasExtensionForTesting(const Extension* extension) const; |
48 | 48 |
49 // Erase runtime data for all extensions. Used only for testing. Cannot be | 49 // Erase runtime data for all extensions. Used only for testing. Cannot be |
50 // named ClearAllForTesting due to false-positive presubmit errors. | 50 // named ClearAllForTesting due to false-positive presubmit errors. |
51 void ClearAll(); | 51 void ClearAll(); |
52 | 52 |
53 // ExtensionRegistryObserver overrides. Public for testing. | 53 // ExtensionRegistryObserver overrides. Public for testing. |
54 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, | 54 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, |
55 const Extension* extension, | 55 const Extension* extension, |
56 UnloadedExtensionInfo::Reason reason) | 56 UnloadedExtensionInfo::Reason reason) |
57 OVERRIDE; | 57 override; |
58 | 58 |
59 private: | 59 private: |
60 // Bitmasks for runtime states. | 60 // Bitmasks for runtime states. |
61 enum RuntimeFlag { | 61 enum RuntimeFlag { |
62 // Set if the background page is ready. | 62 // Set if the background page is ready. |
63 BACKGROUND_PAGE_READY = 1 << 0, | 63 BACKGROUND_PAGE_READY = 1 << 0, |
64 // Set while the extension is being upgraded. | 64 // Set while the extension is being upgraded. |
65 BEING_UPGRADED = 1 << 1, | 65 BEING_UPGRADED = 1 << 1, |
66 // Set if the extension has used the webRequest API. | 66 // Set if the extension has used the webRequest API. |
67 HAS_USED_WEBREQUEST = 1 << 2, | 67 HAS_USED_WEBREQUEST = 1 << 2, |
68 }; | 68 }; |
69 | 69 |
70 // Returns the setting for the flag or false if the extension isn't found. | 70 // Returns the setting for the flag or false if the extension isn't found. |
71 bool HasFlag(const Extension* extension, RuntimeFlag flag) const; | 71 bool HasFlag(const Extension* extension, RuntimeFlag flag) const; |
72 | 72 |
73 // Sets |flag| for |extension| to |value|. Adds |extension| to the list of | 73 // Sets |flag| for |extension| to |value|. Adds |extension| to the list of |
74 // extensions if it isn't present. | 74 // extensions if it isn't present. |
75 void SetFlag(const Extension* extension, RuntimeFlag flag, bool value); | 75 void SetFlag(const Extension* extension, RuntimeFlag flag, bool value); |
76 | 76 |
77 // Map from extension ID to the RuntimeFlags bits. | 77 // Map from extension ID to the RuntimeFlags bits. |
78 typedef std::map<std::string, int> ExtensionFlagsMap; | 78 typedef std::map<std::string, int> ExtensionFlagsMap; |
79 ExtensionFlagsMap extension_flags_; | 79 ExtensionFlagsMap extension_flags_; |
80 | 80 |
81 ExtensionRegistry* registry_; // Not owned. | 81 ExtensionRegistry* registry_; // Not owned. |
82 }; | 82 }; |
83 | 83 |
84 } // namespace extensions | 84 } // namespace extensions |
85 | 85 |
86 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | 86 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
OLD | NEW |