Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: extensions/browser/runtime_data.h

Issue 131743021: app_shell: Extract extension runtime data from ExtensionService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, RuntimeDataTest tweak, win warning Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/extension_registry_observer.h ('k') | extensions/browser/runtime_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "base/compiler_specific.h"
12 #include "extensions/browser/extension_registry_observer.h"
13
14 namespace extensions {
15
16 class Extension;
17 class ExtensionRegistry;
18
19 // Contains per-extension data that can change during the life of the process,
20 // but does not persist across restarts. Shared between incognito and regular
21 // browser contexts. Lives on the UI thread. Must be destroyed before
22 // ExtensionRegistry.
23 class RuntimeData : public ExtensionRegistryObserver {
24 public:
25 // Observes |registry| to clean itself up when extensions change state.
26 // |registry| must not be NULL.
27 explicit RuntimeData(ExtensionRegistry* registry);
28 virtual ~RuntimeData();
29
30 // Whether the persistent background page, if any, is ready. We don't load
31 // other components until then. If there is no background page, or if it is
32 // non-persistent (lazy), we consider it to be ready.
33 bool IsBackgroundPageReady(const Extension* extension) const;
34 void SetBackgroundPageReady(const Extension* extension, bool value);
35
36 // Getter and setter for the flag that specifies whether the extension is
37 // being upgraded.
38 bool IsBeingUpgraded(const Extension* extension) const;
39 void SetBeingUpgraded(const Extension* extension, bool value);
40
41 // Getter and setter for the flag that specifies if the extension has used
42 // the webrequest API.
43 // TODO(mpcomplete): remove. http://crbug.com/100411
44 bool HasUsedWebRequest(const Extension* extension) const;
45 void SetHasUsedWebRequest(const Extension* extension, bool value);
46
47 // Returns true if the extension is being tracked. Used only for testing.
48 bool HasExtensionForTesting(const Extension* extension) const;
49
50 // Erase runtime data for all extensions. Used only for testing. Cannot be
51 // named ClearAllForTesting due to false-positive presubmit errors.
52 void ClearAll();
53
54 // ExtensionRegistryObserver overrides. Public for testing.
55 virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE;
56
57 private:
58 // Bitmasks for runtime states.
59 enum RuntimeFlag {
60 // Set if the background page is ready.
61 BACKGROUND_PAGE_READY = 1 << 0,
62 // Set while the extension is being upgraded.
63 BEING_UPGRADED = 1 << 1,
64 // Set if the extension has used the webRequest API.
65 HAS_USED_WEBREQUEST = 1 << 2,
66 };
67
68 // Returns the setting for the flag or false if the extension isn't found.
69 bool HasFlag(const Extension* extension, RuntimeFlag flag) const;
70
71 // Sets |flag| for |extension| to |value|. Adds |extension| to the list of
72 // extensions if it isn't present.
73 void SetFlag(const Extension* extension, RuntimeFlag flag, bool value);
74
75 // Map from extension ID to the RuntimeFlags bits.
76 typedef std::map<std::string, int> ExtensionFlagsMap;
77 ExtensionFlagsMap extension_flags_;
78
79 ExtensionRegistry* registry_; // Not owned.
80 };
81
82 } // namespace extensions
83
84 #endif // EXTENSIONS_BROWSER_RUNTIME_DATA_H_
OLDNEW
« no previous file with comments | « extensions/browser/extension_registry_observer.h ('k') | extensions/browser/runtime_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698