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

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

Issue 131743021: app_shell: Extract extension runtime data from ExtensionService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add ExtensionRegistry observer (runtime_data) 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 | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/extension_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_EXTENSION_REGISTRY_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/observer_list.h"
12 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
13 #include "extensions/common/extension_set.h" 14 #include "extensions/common/extension_set.h"
14 15
15 namespace content { 16 namespace content {
16 class BrowserContext; 17 class BrowserContext;
17 } 18 }
18 19
19 namespace extensions { 20 namespace extensions {
20 class Extension; 21 class Extension;
22 class ExtensionRegistryObserver;
21 23
22 // ExtensionRegistry holds sets of the installed extensions for a given 24 // ExtensionRegistry holds sets of the installed extensions for a given
23 // BrowserContext. An incognito browser context and its master browser context 25 // BrowserContext. An incognito browser context and its master browser context
24 // share a single registry. 26 // share a single registry.
25 class ExtensionRegistry : public BrowserContextKeyedService { 27 class ExtensionRegistry : public BrowserContextKeyedService {
26 public: 28 public:
27 // Flags to pass to GetExtensionById() to select which sets to look in. 29 // Flags to pass to GetExtensionById() to select which sets to look in.
28 enum IncludeFlag { 30 enum IncludeFlag {
29 NONE = 0, 31 NONE = 0,
30 ENABLED = 1 << 0, 32 ENABLED = 1 << 0,
(...skipping 17 matching lines...) Expand all
48 const ExtensionSet& disabled_extensions() const { 50 const ExtensionSet& disabled_extensions() const {
49 return disabled_extensions_; 51 return disabled_extensions_;
50 } 52 }
51 const ExtensionSet& terminated_extensions() const { 53 const ExtensionSet& terminated_extensions() const {
52 return terminated_extensions_; 54 return terminated_extensions_;
53 } 55 }
54 const ExtensionSet& blacklisted_extensions() const { 56 const ExtensionSet& blacklisted_extensions() const {
55 return blacklisted_extensions_; 57 return blacklisted_extensions_;
56 } 58 }
57 59
60 // The usual observer interface.
61 void AddObserver(ExtensionRegistryObserver* observer);
62 void RemoveObserver(ExtensionRegistryObserver* observer);
63
58 // Find an extension by ID using |include_mask| to pick the sets to search: 64 // Find an extension by ID using |include_mask| to pick the sets to search:
59 // * enabled_extensions() --> ExtensionRegistry::ENABLED 65 // * enabled_extensions() --> ExtensionRegistry::ENABLED
60 // * disabled_extensions() --> ExtensionRegistry::DISABLED 66 // * disabled_extensions() --> ExtensionRegistry::DISABLED
61 // * terminated_extensions() --> ExtensionRegistry::TERMINATED 67 // * terminated_extensions() --> ExtensionRegistry::TERMINATED
62 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED 68 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED
63 // Returns NULL if the extension is not found in the selected sets. 69 // Returns NULL if the extension is not found in the selected sets.
64 const Extension* GetExtensionById(const std::string& id, 70 const Extension* GetExtensionById(const std::string& id,
65 int include_mask) const; 71 int include_mask) const;
66 72
73 // Removes an extension from the enabled and disabled sets. Invokes the
74 // observer method OnExtensionUnloaded() after the extension is removed.
75 void UnloadExtension(const scoped_refptr<const Extension>& extension);
not at google - send to devlin 2014/01/21 23:58:59 I kind of preferred the way it was... making this
76
77 // Moves an extension to the enabled set from the disabled set. The extension
78 // must exist in the disabled set.
79 void EnableExtension(const scoped_refptr<const Extension>& extension);
James Cook 2014/01/21 23:20:39 By adding this function and the one below I was ab
80
81 // Adds an extension to the disabled set and removes it from the enabled
82 // and terminated sets. Invokes the observer method OnExtensionDisabled()
83 // after the extension is added.
84 void DisableExtension(const scoped_refptr<const Extension>& extension);
85
67 // Adds the specified extension to the enabled set. The registry becomes an 86 // Adds the specified extension to the enabled set. The registry becomes an
68 // owner. Any previous extension with the same ID is removed. 87 // owner. Any previous extension with the same ID is removed.
69 // Returns true if there is no previous extension. 88 // Returns true if there is no previous extension.
70 // NOTE: You probably want to use ExtensionService instead of calling this 89 // NOTE: You probably want to use ExtensionService instead of calling this
71 // method directly. 90 // method directly.
72 bool AddEnabled(const scoped_refptr<const Extension>& extension); 91 bool AddEnabled(const scoped_refptr<const Extension>& extension);
73 92
74 // Removes the specified extension from the enabled set.
75 // Returns true if the set contained the specified extension.
76 // NOTE: You probably want to use ExtensionService instead of calling this
77 // method directly.
78 bool RemoveEnabled(const std::string& id);
79
80 // As above, but for the disabled set. 93 // As above, but for the disabled set.
81 bool AddDisabled(const scoped_refptr<const Extension>& extension); 94 bool AddDisabled(const scoped_refptr<const Extension>& extension);
82 bool RemoveDisabled(const std::string& id);
83 95
84 // As above, but for the terminated set. 96 // As above, but for the terminated set.
85 bool AddTerminated(const scoped_refptr<const Extension>& extension); 97 bool AddTerminated(const scoped_refptr<const Extension>& extension);
86 bool RemoveTerminated(const std::string& id); 98 bool RemoveTerminated(const std::string& id);
87 99
88 // As above, but for the blacklisted set. 100 // As above, but for the blacklisted set.
89 bool AddBlacklisted(const scoped_refptr<const Extension>& extension); 101 bool AddBlacklisted(const scoped_refptr<const Extension>& extension);
90 bool RemoveBlacklisted(const std::string& id); 102 bool RemoveBlacklisted(const std::string& id);
91 103
92 // Removes all extensions from all sets. 104 // Removes all extensions from all sets.
(...skipping 17 matching lines...) Expand all
110 122
111 // Extensions that are installed and terminated. 123 // Extensions that are installed and terminated.
112 ExtensionSet terminated_extensions_; 124 ExtensionSet terminated_extensions_;
113 125
114 // Extensions that are installed and blacklisted. Generally these shouldn't be 126 // Extensions that are installed and blacklisted. Generally these shouldn't be
115 // considered as installed by the extension platform: we only keep them around 127 // considered as installed by the extension platform: we only keep them around
116 // so that if extensions are blacklisted by mistake they can easily be 128 // so that if extensions are blacklisted by mistake they can easily be
117 // un-blacklisted. 129 // un-blacklisted.
118 ExtensionSet blacklisted_extensions_; 130 ExtensionSet blacklisted_extensions_;
119 131
132 ObserverList<ExtensionRegistryObserver> observers_;
133
120 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); 134 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry);
121 }; 135 };
122 136
123 } // namespace extensions 137 } // namespace extensions
124 138
125 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ 139 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/extension_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698