| 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 23 matching lines...) Expand all Loading... |
| 34 // non-persistent (lazy), we consider it to be ready. | 34 // non-persistent (lazy), we consider it to be ready. |
| 35 bool IsBackgroundPageReady(const Extension* extension) const; | 35 bool IsBackgroundPageReady(const Extension* extension) const; |
| 36 void SetBackgroundPageReady(const std::string& extension_id, bool value); | 36 void SetBackgroundPageReady(const std::string& extension_id, bool value); |
| 37 | 37 |
| 38 // Getter and setter for the flag that specifies whether the extension is | 38 // Getter and setter for the flag that specifies whether the extension is |
| 39 // being upgraded. | 39 // being upgraded. |
| 40 // For these purposes, a reload counts as an upgrade. | 40 // For these purposes, a reload counts as an upgrade. |
| 41 bool IsBeingUpgraded(const std::string& extension_id) const; | 41 bool IsBeingUpgraded(const std::string& extension_id) const; |
| 42 void SetBeingUpgraded(const std::string& extension_id, bool value); | 42 void SetBeingUpgraded(const std::string& extension_id, bool value); |
| 43 | 43 |
| 44 // Getter and setter for the flag that specifies if the extension has used | |
| 45 // the webrequest API. | |
| 46 bool HasUsedWebRequest(const std::string& extension_id) const; | |
| 47 void SetHasUsedWebRequest(const std::string& extension_id, bool value); | |
| 48 | |
| 49 // Returns true if the extension is being tracked. Used only for testing. | 44 // Returns true if the extension is being tracked. Used only for testing. |
| 50 bool HasExtensionForTesting(const std::string& extension_id) const; | 45 bool HasExtensionForTesting(const std::string& extension_id) const; |
| 51 | 46 |
| 52 // Erase runtime data for all extensions. Used only for testing. Cannot be | 47 // Erase runtime data for all extensions. Used only for testing. Cannot be |
| 53 // named ClearAllForTesting due to false-positive presubmit errors. | 48 // named ClearAllForTesting due to false-positive presubmit errors. |
| 54 void ClearAll(); | 49 void ClearAll(); |
| 55 | 50 |
| 56 // ExtensionRegistryObserver overrides. Public for testing. | 51 // ExtensionRegistryObserver overrides. Public for testing. |
| 57 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 52 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 58 const Extension* extension, | 53 const Extension* extension, |
| 59 UnloadedExtensionInfo::Reason reason) override; | 54 UnloadedExtensionInfo::Reason reason) override; |
| 60 | 55 |
| 61 private: | 56 private: |
| 62 // Bitmasks for runtime states. | 57 // Bitmasks for runtime states. |
| 63 enum RuntimeFlag { | 58 enum RuntimeFlag { |
| 64 // Set if the background page is ready. | 59 // Set if the background page is ready. |
| 65 BACKGROUND_PAGE_READY = 1 << 0, | 60 BACKGROUND_PAGE_READY = 1 << 0, |
| 66 // Set while the extension is being upgraded. | 61 // Set while the extension is being upgraded. |
| 67 BEING_UPGRADED = 1 << 1, | 62 BEING_UPGRADED = 1 << 1, |
| 68 // Set if the extension has used the webRequest API. | |
| 69 HAS_USED_WEBREQUEST = 1 << 2, | |
| 70 }; | 63 }; |
| 71 | 64 |
| 72 // The mask of any data that should persist across the extension being | 65 // The mask of any data that should persist across the extension being |
| 73 // unloaded. | 66 // unloaded. |
| 74 static const int kPersistAcrossUnloadMask = BEING_UPGRADED; | 67 static const int kPersistAcrossUnloadMask = BEING_UPGRADED; |
| 75 | 68 |
| 76 // 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. |
| 77 bool HasFlag(const std::string& extension_id, RuntimeFlag flag) const; | 70 bool HasFlag(const std::string& extension_id, RuntimeFlag flag) const; |
| 78 | 71 |
| 79 // 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 |
| 80 // extensions if it isn't present. | 73 // extensions if it isn't present. |
| 81 void SetFlag(const std::string& extension_id, RuntimeFlag flag, bool value); | 74 void SetFlag(const std::string& extension_id, RuntimeFlag flag, bool value); |
| 82 | 75 |
| 83 // Map from extension ID to the RuntimeFlags bits. | 76 // Map from extension ID to the RuntimeFlags bits. |
| 84 typedef std::map<std::string, int> ExtensionFlagsMap; | 77 typedef std::map<std::string, int> ExtensionFlagsMap; |
| 85 ExtensionFlagsMap extension_flags_; | 78 ExtensionFlagsMap extension_flags_; |
| 86 | 79 |
| 87 ExtensionRegistry* registry_; // Not owned. | 80 ExtensionRegistry* registry_; // Not owned. |
| 88 }; | 81 }; |
| 89 | 82 |
| 90 } // namespace extensions | 83 } // namespace extensions |
| 91 | 84 |
| 92 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | 85 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
| OLD | NEW |