OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | |
6 #define EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 namespace extensions { | |
12 | |
13 class Extension; | |
14 | |
15 // Contains per-extension data that can change during the life of the process, | |
16 // but does not persist across restarts. Shared between incognito and regular | |
17 // browser contexts. Lives on the UI thread. | |
18 class RuntimeData { | |
19 public: | |
20 RuntimeData(); | |
21 ~RuntimeData(); | |
22 | |
23 // Erase runtime data for |extension|. | |
24 void Erase(const Extension* extension); | |
25 | |
26 // Erase runtime data for all extensions. | |
27 void ClearAll(); | |
28 | |
29 // Whether the persistent background page, if any, is ready. We don't load | |
30 // other components until then. If there is no background page, or if it is | |
31 // non-persistent (lazy), we consider it to be ready. | |
32 bool IsBackgroundPageReady(const Extension* extension) const; | |
33 void SetBackgroundPageReady(const Extension* extension, bool value); | |
34 | |
35 // Getter and setter for the flag that specifies whether the extension is | |
36 // being upgraded. | |
37 bool IsBeingUpgraded(const Extension* extension) const; | |
38 void SetBeingUpgraded(const Extension* extension, bool value); | |
39 | |
40 // Getter and setter for the flag that specifies if the extension has used | |
41 // the webrequest API. | |
42 // TODO(mpcomplete): remove. http://crbug.com/100411 | |
43 bool HasUsedWebRequest(const Extension* extension) const; | |
44 void SetHasUsedWebRequest(const Extension* extension, bool value); | |
45 | |
46 private: | |
47 // Bitmasks for runtime states. | |
48 enum RuntimeFlag { | |
49 // Set if the background page is ready. | |
50 BACKGROUND_PAGE_READY = 1 << 0, | |
51 // Set while the extension is being upgraded. | |
52 BEING_UPGRADED = 1 << 1, | |
53 // Set if the extension has used the webRequest API. | |
54 HAS_USED_WEBREQUEST = 1 << 2, | |
55 }; | |
56 | |
57 // Returns the setting for the flag or false if the extenion isn't found. | |
58 bool GetFlag(const Extension* extension, RuntimeFlag flag) const; | |
not at google - send to devlin
2014/01/21 18:47:47
nit: HasFlag?
| |
59 | |
60 void SetFlag(const Extension* extension, RuntimeFlag flag, bool value); | |
61 | |
62 // Map from extension ID to the RuntimeFlags bits. | |
63 typedef std::map<std::string, int> ExtensionFlagsMap; | |
64 ExtensionFlagsMap extension_flags_; | |
65 }; | |
66 | |
67 } // namespace extensions | |
68 | |
69 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_ | |
OLD | NEW |