Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / extensions / browser / extension_system.h
blobb431dde319789a23d9b42d2fe2fb1dd1b4ce0130
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.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "extensions/common/extension.h"
15 #if !defined(ENABLE_EXTENSIONS)
16 #error "Extensions must be enabled"
17 #endif
19 class ExtensionService;
21 #if defined(OS_CHROMEOS)
22 namespace chromeos {
23 class DeviceLocalAccountManagementPolicyProvider;
25 #endif // defined(OS_CHROMEOS)
27 namespace content {
28 class BrowserContext;
31 namespace extensions {
33 class AppSorting;
34 class ContentVerifier;
35 class Extension;
36 class ExtensionSet;
37 class InfoMap;
38 class ManagementPolicy;
39 class OneShotEvent;
40 class QuotaService;
41 class RuntimeData;
42 class SharedUserScriptMaster;
43 class StateStore;
45 // ExtensionSystem manages the lifetime of many of the services used by the
46 // extensions and apps system, and it handles startup and shutdown as needed.
47 // Eventually, we'd like to make more of these services into KeyedServices in
48 // their own right.
49 class ExtensionSystem : public KeyedService {
50 public:
51 ExtensionSystem();
52 ~ExtensionSystem() override;
54 // Returns the instance for the given browser context, or NULL if none.
55 static ExtensionSystem* Get(content::BrowserContext* context);
57 // Initializes extensions machinery.
58 // Component extensions are always enabled, external and user extensions are
59 // controlled by |extensions_enabled|.
60 virtual void InitForRegularProfile(bool extensions_enabled) = 0;
62 // The ExtensionService is created at startup.
63 virtual ExtensionService* extension_service() = 0;
65 // Per-extension data that can change during the life of the process but
66 // does not persist across restarts. Lives on UI thread. Created at startup.
67 virtual RuntimeData* runtime_data() = 0;
69 // The class controlling whether users are permitted to perform certain
70 // actions on extensions (install, uninstall, disable, etc.).
71 // The ManagementPolicy is created at startup.
72 virtual ManagementPolicy* management_policy() = 0;
74 // The SharedUserScriptMaster is created at startup.
75 virtual SharedUserScriptMaster* shared_user_script_master() = 0;
77 // The StateStore is created at startup.
78 virtual StateStore* state_store() = 0;
80 // The rules store is created at startup.
81 virtual StateStore* rules_store() = 0;
83 // Returns the IO-thread-accessible extension data.
84 virtual InfoMap* info_map() = 0;
86 // Returns the QuotaService that limits calls to certain extension functions.
87 // Lives on the UI thread. Created at startup.
88 virtual QuotaService* quota_service() = 0;
90 // Returns the AppSorting which provides an ordering for all installed apps.
91 virtual AppSorting* app_sorting() = 0;
93 // Called by the ExtensionService that lives in this system. Gives the
94 // info map a chance to react to the load event before the EXTENSION_LOADED
95 // notification has fired. The purpose for handling this event first is to
96 // avoid race conditions by making sure URLRequestContexts learn about new
97 // extensions before anything else needs them to know. This operation happens
98 // asynchronously. |callback| is run on the calling thread once completed.
99 virtual void RegisterExtensionWithRequestContexts(
100 const Extension* extension,
101 const base::Closure& callback) {}
103 // Called by the ExtensionService that lives in this system. Lets the
104 // info map clean up its RequestContexts once all the listeners to the
105 // EXTENSION_UNLOADED notification have finished running.
106 virtual void UnregisterExtensionWithRequestContexts(
107 const std::string& extension_id,
108 const UnloadedExtensionInfo::Reason reason) {}
110 // Signaled when the extension system has completed its startup tasks.
111 virtual const OneShotEvent& ready() const = 0;
113 // Returns the content verifier, if any.
114 virtual ContentVerifier* content_verifier() = 0;
116 // Get a set of extensions that depend on the given extension.
117 // TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
118 // so it can be retrieved from ExtensionSystem directly.
119 virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
120 const Extension* extension) = 0;
123 } // namespace extensions
125 #endif // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_