diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2014-11-20 17:35:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-21 01:36:05 +0000 |
commit | 2c16c6099f1f799509a19bacf6b04add78410e55 (patch) | |
tree | ff821051f07fd104d237869c374ed0c42c655cc2 /extensions/browser/runtime_data.h | |
parent | 4167dc6b93bbcbee8b2503f8c57d7f16e4149c0c (diff) | |
download | chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.zip chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.tar.gz chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.tar.bz2 |
[Extensions] Fix IsBeingUpgraded runtime data bug and make RuntimeData take ids
Fix a bug where IsBeingUpgraded would be reset during the reload process (even
though it's also *set* during the reload process...), and make RuntimeData take
extension ids instead of extensions.
BUG=435336
TBR=sky@chromium.org (micro change in ui/toolbar/)
Review URL: https://codereview.chromium.org/743373002
Cr-Commit-Position: refs/heads/master@{#305134}
Diffstat (limited to 'extensions/browser/runtime_data.h')
-rw-r--r-- | extensions/browser/runtime_data.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/extensions/browser/runtime_data.h b/extensions/browser/runtime_data.h index 9d74041..c937a99 100644 --- a/extensions/browser/runtime_data.h +++ b/extensions/browser/runtime_data.h @@ -13,13 +13,15 @@ namespace extensions { -class Extension; class ExtensionRegistry; // Contains per-extension data that can change during the life of the process, // but does not persist across restarts. Shared between incognito and regular // browser contexts. Lives on the UI thread. Must be destroyed before // ExtensionRegistry. +// If we start putting to much into this, we should expose the generic +// "[G|S]etRuntimeProperty(const std::string& extension_id, RuntimeFlag flag)" +// instead of all these. class RuntimeData : public ExtensionRegistryObserver { public: // Observes |registry| to clean itself up when extensions change state. @@ -31,20 +33,21 @@ class RuntimeData : public ExtensionRegistryObserver { // other components until then. If there is no background page, or if it is // non-persistent (lazy), we consider it to be ready. bool IsBackgroundPageReady(const Extension* extension) const; - void SetBackgroundPageReady(const Extension* extension, bool value); + void SetBackgroundPageReady(const std::string& extension_id, bool value); // Getter and setter for the flag that specifies whether the extension is // being upgraded. - bool IsBeingUpgraded(const Extension* extension) const; - void SetBeingUpgraded(const Extension* extension, bool value); + // For these purposes, a reload counts as an upgrade. + bool IsBeingUpgraded(const std::string& extension_id) const; + void SetBeingUpgraded(const std::string& extension_id, bool value); // Getter and setter for the flag that specifies if the extension has used // the webrequest API. - bool HasUsedWebRequest(const Extension* extension) const; - void SetHasUsedWebRequest(const Extension* extension, bool value); + bool HasUsedWebRequest(const std::string& extension_id) const; + void SetHasUsedWebRequest(const std::string& extension_id, bool value); // Returns true if the extension is being tracked. Used only for testing. - bool HasExtensionForTesting(const Extension* extension) const; + bool HasExtensionForTesting(const std::string& extension_id) const; // Erase runtime data for all extensions. Used only for testing. Cannot be // named ClearAllForTesting due to false-positive presubmit errors. @@ -66,12 +69,16 @@ class RuntimeData : public ExtensionRegistryObserver { HAS_USED_WEBREQUEST = 1 << 2, }; + // The mask of any data that should persist across the extension being + // unloaded. + static const int kPersistAcrossUnloadMask = BEING_UPGRADED; + // Returns the setting for the flag or false if the extension isn't found. - bool HasFlag(const Extension* extension, RuntimeFlag flag) const; + bool HasFlag(const std::string& extension_id, RuntimeFlag flag) const; // Sets |flag| for |extension| to |value|. Adds |extension| to the list of // extensions if it isn't present. - void SetFlag(const Extension* extension, RuntimeFlag flag, bool value); + void SetFlag(const std::string& extension_id, RuntimeFlag flag, bool value); // Map from extension ID to the RuntimeFlags bits. typedef std::map<std::string, int> ExtensionFlagsMap; |