Index: extensions/browser/runtime_data.h |
diff --git a/extensions/browser/runtime_data.h b/extensions/browser/runtime_data.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ac75e21df576c677d3ba02dcf236e0f95e3750af |
--- /dev/null |
+++ b/extensions/browser/runtime_data.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
+#define EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |
+ |
+#include <map> |
+#include <string> |
+ |
+namespace extensions { |
+ |
+class Extension; |
+ |
+// 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. |
+class RuntimeData { |
+ public: |
+ RuntimeData(); |
+ ~RuntimeData(); |
+ |
+ // Erase runtime data for |extension|. |
+ void Erase(const Extension* extension); |
+ |
+ // Erase runtime data for all extensions. |
+ void ClearAll(); |
+ |
+ // Whether the persistent background page, if any, is ready. We don't load |
+ // 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); |
+ |
+ // 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); |
+ |
+ // Getter and setter for the flag that specifies if the extension has used |
+ // the webrequest API. |
+ // TODO(mpcomplete): remove. http://crbug.com/100411 |
+ bool HasUsedWebRequest(const Extension* extension) const; |
+ void SetHasUsedWebRequest(const Extension* extension, bool value); |
+ |
+ private: |
+ // Bitmasks for runtime states. |
+ enum RuntimeFlag { |
+ // Set if the background page is ready. |
+ BACKGROUND_PAGE_READY = 1 << 0, |
+ // Set while the extension is being upgraded. |
+ BEING_UPGRADED = 1 << 1, |
+ // Set if the extension has used the webRequest API. |
+ HAS_USED_WEBREQUEST = 1 << 2, |
+ }; |
+ |
+ // Returns the setting for the flag or false if the extenion isn't found. |
+ bool GetFlag(const Extension* extension, RuntimeFlag flag) const; |
not at google - send to devlin
2014/01/21 18:47:47
nit: HasFlag?
|
+ |
+ void SetFlag(const Extension* extension, RuntimeFlag flag, bool value); |
+ |
+ // Map from extension ID to the RuntimeFlags bits. |
+ typedef std::map<std::string, int> ExtensionFlagsMap; |
+ ExtensionFlagsMap extension_flags_; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ |