[Smart Lock] Record a detailed UMA metric for each unlock attempt by Smart Lock users.
[chromium-blink-merge.git] / extensions / browser / extension_system.h
blob400f45e866734c14dba9cbc4d9a25e95ed6b8306
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/memory/ref_counted.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "extensions/common/extension.h"
14 #if !defined(ENABLE_EXTENSIONS)
15 #error "Extensions must be enabled"
16 #endif
18 class ExtensionService;
20 #if defined(OS_CHROMEOS)
21 namespace chromeos {
22 class DeviceLocalAccountManagementPolicyProvider;
24 #endif // defined(OS_CHROMEOS)
26 namespace content {
27 class BrowserContext;
30 namespace extensions {
32 class ContentVerifier;
33 class DeclarativeUserScriptManager;
34 class ErrorConsole;
35 class EventRouter;
36 class Extension;
37 class ExtensionSet;
38 class InfoMap;
39 class InstallVerifier;
40 class LazyBackgroundTaskQueue;
41 class ManagementPolicy;
42 class OneShotEvent;
43 class QuotaService;
44 class RuntimeData;
45 class SharedUserScriptMaster;
46 class StateStore;
48 // ExtensionSystem manages the lifetime of many of the services used by the
49 // extensions and apps system, and it handles startup and shutdown as needed.
50 // Eventually, we'd like to make more of these services into KeyedServices in
51 // their own right.
52 class ExtensionSystem : public KeyedService {
53 public:
54 ExtensionSystem();
55 ~ExtensionSystem() override;
57 // Returns the instance for the given browser context, or NULL if none.
58 static ExtensionSystem* Get(content::BrowserContext* context);
60 // Initializes extensions machinery.
61 // Component extensions are always enabled, external and user extensions are
62 // controlled by |extensions_enabled|.
63 virtual void InitForRegularProfile(bool extensions_enabled) = 0;
65 // The ExtensionService is created at startup.
66 virtual ExtensionService* extension_service() = 0;
68 // Per-extension data that can change during the life of the process but
69 // does not persist across restarts. Lives on UI thread. Created at startup.
70 virtual RuntimeData* runtime_data() = 0;
72 // The class controlling whether users are permitted to perform certain
73 // actions on extensions (install, uninstall, disable, etc.).
74 // The ManagementPolicy is created at startup.
75 virtual ManagementPolicy* management_policy() = 0;
77 // The SharedUserScriptMaster is created at startup.
78 virtual SharedUserScriptMaster* shared_user_script_master() = 0;
80 // The DeclarativeUserScriptManager is created at startup.
81 virtual DeclarativeUserScriptManager* declarative_user_script_manager() = 0;
83 // The StateStore is created at startup.
84 virtual StateStore* state_store() = 0;
86 // The rules store is created at startup.
87 virtual StateStore* rules_store() = 0;
89 // Returns the IO-thread-accessible extension data.
90 virtual InfoMap* info_map() = 0;
92 // The LazyBackgroundTaskQueue is created at startup.
93 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0;
95 // The EventRouter is created at startup.
96 virtual EventRouter* event_router() = 0;
98 // The ErrorConsole is created at startup.
99 virtual ErrorConsole* error_console() = 0;
101 // The InstallVerifier is created at startup.
102 virtual InstallVerifier* install_verifier() = 0;
104 // Returns the QuotaService that limits calls to certain extension functions.
105 // Lives on the UI thread. Created at startup.
106 virtual QuotaService* quota_service() = 0;
108 // Called by the ExtensionService that lives in this system. Gives the
109 // info map a chance to react to the load event before the EXTENSION_LOADED
110 // notification has fired. The purpose for handling this event first is to
111 // avoid race conditions by making sure URLRequestContexts learn about new
112 // extensions before anything else needs them to know.
113 virtual void RegisterExtensionWithRequestContexts(
114 const Extension* extension) {}
116 // Called by the ExtensionService that lives in this system. Lets the
117 // info map clean up its RequestContexts once all the listeners to the
118 // EXTENSION_UNLOADED notification have finished running.
119 virtual void UnregisterExtensionWithRequestContexts(
120 const std::string& extension_id,
121 const UnloadedExtensionInfo::Reason reason) {}
123 // Signaled when the extension system has completed its startup tasks.
124 virtual const OneShotEvent& ready() const = 0;
126 // Returns the content verifier, if any.
127 virtual ContentVerifier* content_verifier() = 0;
129 // Get a set of extensions that depend on the given extension.
130 // TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
131 // so it can be retrieved from ExtensionSystem directly.
132 virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
133 const Extension* extension) = 0;
136 } // namespace extensions
138 #endif // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_