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