Remove keyboard_ui.css and manifest_keyboard.json
[chromium-blink-merge.git] / chrome / browser / extensions / extension_service.h
blob01efc6156303f30522673a96d3e670f7da4e6cee
1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h"
19 #include "chrome/browser/extensions/blacklist.h"
20 #include "chrome/browser/extensions/extension_management.h"
21 #include "chrome/browser/extensions/pending_extension_manager.h"
22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h"
24 #include "extensions/browser/crx_file_info.h"
25 #include "extensions/browser/external_provider_interface.h"
26 #include "extensions/browser/install_flag.h"
27 #include "extensions/browser/management_policy.h"
28 #include "extensions/browser/process_manager.h"
29 #include "extensions/browser/uninstall_reason.h"
30 #include "extensions/common/extension.h"
31 #include "extensions/common/extension_set.h"
32 #include "extensions/common/manifest.h"
33 #include "sync/api/string_ordinal.h"
35 #if !defined(ENABLE_EXTENSIONS)
36 #error "Extensions must be enabled"
37 #endif
39 class ExtensionSyncService;
40 class GURL;
41 class HostContentSettingsMap;
42 class Profile;
44 namespace base {
45 class CommandLine;
46 class SequencedTaskRunner;
47 class Version;
50 namespace content {
51 class DevToolsAgentHost;
54 namespace extensions {
55 class AppDataMigrator;
56 class ComponentLoader;
57 class CrxInstaller;
58 class ExtensionActionStorageManager;
59 class ExtensionDownloader;
60 class ExtensionDownloaderDelegate;
61 class ExtensionErrorController;
62 class ExtensionRegistry;
63 class ExtensionSystem;
64 class ExtensionUpdater;
65 class OneShotEvent;
66 class ExternalInstallManager;
67 class SharedModuleService;
68 class UpdateObserver;
69 } // namespace extensions
71 // This is an interface class to encapsulate the dependencies that
72 // various classes have on ExtensionService. This allows easy mocking.
73 class ExtensionServiceInterface
74 : public base::SupportsWeakPtr<ExtensionServiceInterface> {
75 public:
76 virtual ~ExtensionServiceInterface() {}
78 // Gets the object managing the set of pending extensions.
79 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0;
81 // Installs an update with the contents from |extension_path|. Returns true if
82 // the install can be started. Sets |out_crx_installer| to the installer if
83 // one was started.
84 // TODO(aa): This method can be removed. ExtensionUpdater could use
85 // CrxInstaller directly instead.
86 virtual bool UpdateExtension(
87 const extensions::CRXFileInfo& file,
88 bool file_ownership_passed,
89 extensions::CrxInstaller** out_crx_installer) = 0;
91 // DEPRECATED. Use ExtensionRegistry instead.
93 // Looks up an extension by its ID.
95 // If |include_disabled| is false then this will only include enabled
96 // extensions. Use instead:
98 // ExtensionRegistry::enabled_extensions().GetByID(id).
100 // If |include_disabled| is true then this will also include disabled and
101 // blacklisted extensions (not terminated extensions). Use instead:
103 // ExtensionRegistry::GetExtensionById(
104 // id, ExtensionRegistry::ENABLED |
105 // ExtensionRegistry::DISABLED |
106 // ExtensionRegistry::BLACKLISTED)
108 // Or don't, because it's probably not something you ever need to know.
109 virtual const extensions::Extension* GetExtensionById(
110 const std::string& id,
111 bool include_disabled) const = 0;
113 // DEPRECATED: Use ExtensionRegistry instead.
115 // Looks up an extension by ID, regardless of whether it's enabled,
116 // disabled, blacklisted, or terminated. Use instead:
118 // ExtensionRegistry::GetInstalledExtension(id).
119 virtual const extensions::Extension* GetInstalledExtension(
120 const std::string& id) const = 0;
122 // Returns an update for an extension with the specified id, if installation
123 // of that update was previously delayed because the extension was in use. If
124 // no updates are pending for the extension returns NULL.
125 virtual const extensions::Extension* GetPendingExtensionUpdate(
126 const std::string& extension_id) const = 0;
128 // Finishes installation of an update for an extension with the specified id,
129 // when installation of that extension was previously delayed because the
130 // extension was in use.
131 virtual void FinishDelayedInstallation(const std::string& extension_id) = 0;
133 // Returns true if the extension with the given |extension_id| is enabled.
134 // This will return a valid answer even if the extension is not loaded yet.
135 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
137 // Go through each extension and unload those that are not allowed to run by
138 // management policy providers (ie. network admin and Google-managed
139 // blacklist).
140 virtual void CheckManagementPolicy() = 0;
142 // Safe to call multiple times in a row.
144 // TODO(akalin): Remove this method (and others) once we refactor
145 // themes sync to not use it directly.
146 virtual void CheckForUpdatesSoon() = 0;
148 // Adds |extension| to this ExtensionService and notifies observers that the
149 // extensions have been loaded.
150 virtual void AddExtension(const extensions::Extension* extension) = 0;
152 // Check if we have preferences for the component extension and, if not or if
153 // the stored version differs, install the extension (without requirements
154 // checking) before calling AddExtension.
155 virtual void AddComponentExtension(
156 const extensions::Extension* extension) = 0;
158 // Unload the specified extension.
159 virtual void UnloadExtension(
160 const std::string& extension_id,
161 extensions::UnloadedExtensionInfo::Reason reason) = 0;
163 // Remove the specified component extension.
164 virtual void RemoveComponentExtension(const std::string& extension_id) = 0;
166 // Whether the extension service is ready.
167 virtual bool is_ready() = 0;
169 // Returns task runner for crx installation file I/O operations.
170 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0;
173 // Manages installed and running Chromium extensions. An instance is shared
174 // between normal and incognito profiles.
175 class ExtensionService
176 : public ExtensionServiceInterface,
177 public extensions::ExternalProviderInterface::VisitorInterface,
178 public content::NotificationObserver,
179 public extensions::Blacklist::Observer,
180 public extensions::ExtensionManagement::Observer {
181 public:
182 // Attempts to uninstall an extension from a given ExtensionService. Returns
183 // true iff the target extension exists.
184 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
185 const std::string& extension_id,
186 extensions::UninstallReason reason);
188 // Constructor stores pointers to |profile| and |extension_prefs| but
189 // ownership remains at caller.
190 ExtensionService(Profile* profile,
191 const base::CommandLine* command_line,
192 const base::FilePath& install_directory,
193 extensions::ExtensionPrefs* extension_prefs,
194 extensions::Blacklist* blacklist,
195 bool autoupdate_enabled,
196 bool extensions_enabled,
197 extensions::OneShotEvent* ready);
199 ~ExtensionService() override;
201 // ExtensionServiceInterface implementation.
203 // NOTE: Many of these methods are DEPRECATED. See the interface for details.
204 extensions::PendingExtensionManager* pending_extension_manager() override;
205 const extensions::Extension* GetExtensionById(
206 const std::string& id,
207 bool include_disabled) const override;
208 const extensions::Extension* GetInstalledExtension(
209 const std::string& id) const override;
210 bool UpdateExtension(const extensions::CRXFileInfo& file,
211 bool file_ownership_passed,
212 extensions::CrxInstaller** out_crx_installer) override;
213 bool IsExtensionEnabled(const std::string& extension_id) const override;
214 void UnloadExtension(
215 const std::string& extension_id,
216 extensions::UnloadedExtensionInfo::Reason reason) override;
217 void RemoveComponentExtension(const std::string& extension_id) override;
218 void AddExtension(const extensions::Extension* extension) override;
219 void AddComponentExtension(const extensions::Extension* extension) override;
220 const extensions::Extension* GetPendingExtensionUpdate(
221 const std::string& extension_id) const override;
222 void FinishDelayedInstallation(const std::string& extension_id) override;
223 void CheckManagementPolicy() override;
224 void CheckForUpdatesSoon() override;
225 bool is_ready() override;
226 base::SequencedTaskRunner* GetFileTaskRunner() override;
228 // ExternalProvider::Visitor implementation.
229 // Exposed for testing.
230 bool OnExternalExtensionFileFound(const std::string& id,
231 const base::Version* version,
232 const base::FilePath& path,
233 extensions::Manifest::Location location,
234 int creation_flags,
235 bool mark_acknowledged,
236 bool install_immediately) override;
237 bool OnExternalExtensionUpdateUrlFound(
238 const std::string& id,
239 const std::string& install_parameter,
240 const GURL& update_url,
241 extensions::Manifest::Location location,
242 int creation_flags,
243 bool mark_acknowledged) override;
244 void OnExternalProviderReady(
245 const extensions::ExternalProviderInterface* provider) override;
247 // ExtensionManagement::Observer implementation:
248 void OnExtensionManagementSettingsChanged() override;
250 // Initialize and start all installed extensions.
251 void Init();
253 // Called when the associated Profile is going to be destroyed.
254 void Shutdown();
256 // Reloads the specified extension, sending the onLaunched() event to it if it
257 // currently has any window showing.
258 // Allows noisy failures.
259 // NOTE: Reloading an extension can invalidate |extension_id| and Extension
260 // pointers for the given extension. Consider making a copy of |extension_id|
261 // first and retrieving a new Extension pointer afterwards.
262 void ReloadExtension(const std::string& extension_id);
264 // Suppresses noisy failures.
265 void ReloadExtensionWithQuietFailure(const std::string& extension_id);
267 // Uninstalls the specified extension. Callers should only call this method
268 // with extensions that exist. |reason| lets the caller specify why the
269 // extension is uninstalled.
271 // If the return value is true, |deletion_done_callback| is invoked when data
272 // deletion is done or at least is scheduled.
273 virtual bool UninstallExtension(const std::string& extension_id,
274 extensions::UninstallReason reason,
275 const base::Closure& deletion_done_callback,
276 base::string16* error);
278 // Enables the extension. If the extension is already enabled, does
279 // nothing.
280 virtual void EnableExtension(const std::string& extension_id);
282 // Disables the extension. If the extension is already disabled, just adds
283 // the |disable_reasons| (a bitmask of Extension::DisableReason - there can
284 // be multiple DisableReasons e.g. when an extension comes in disabled from
285 // Sync). If the extension cannot be disabled (due to policy), does nothing.
286 virtual void DisableExtension(const std::string& extension_id,
287 int disable_reasons);
289 // Disable non-default and non-managed extensions with ids not in
290 // |except_ids|. Default extensions are those from the Web Store with
291 // |was_installed_by_default| flag.
292 void DisableUserExtensions(const std::vector<std::string>& except_ids);
294 // Puts all extensions in a blocked state: Unloading every extension, and
295 // preventing them from ever loading until UnblockAllExtensions is called.
296 // This state is stored in preferences, so persists until Chrome restarts.
298 // Component, external component and whitelisted policy installed extensions
299 // are exempt from being Blocked (see CanBlockExtension).
300 void BlockAllExtensions();
302 // All blocked extensions are reverted to their previous state, and are
303 // reloaded. Newly added extensions are no longer automatically blocked.
304 void UnblockAllExtensions();
306 // Updates the |extension|'s granted permissions lists to include all
307 // permissions in the |extension|'s manifest and re-enables the
308 // extension.
309 void GrantPermissionsAndEnableExtension(
310 const extensions::Extension* extension);
312 // Updates the |extension|'s granted permissions lists to include all
313 // permissions in the |extensions|'s manifest.
314 void GrantPermissions(const extensions::Extension* extension);
316 // Check for updates (or potentially new extensions from external providers)
317 void CheckForExternalUpdates();
319 // Called when the initial extensions load has completed.
320 virtual void OnLoadedInstalledExtensions();
322 // Informs the service that an extension's files are in place for loading.
324 // |extension| the extension
325 // |page_ordinal| the location of the extension in the app launcher
326 // |install_flags| a bitmask of extensions::InstallFlags
327 void OnExtensionInstalled(const extensions::Extension* extension,
328 const syncer::StringOrdinal& page_ordinal,
329 int install_flags);
330 void OnExtensionInstalled(const extensions::Extension* extension,
331 const syncer::StringOrdinal& page_ordinal) {
332 OnExtensionInstalled(extension,
333 page_ordinal,
334 static_cast<int>(extensions::kInstallFlagNone));
337 // Checks for delayed installation for all pending installs.
338 void MaybeFinishDelayedInstallations();
340 // Promotes an ephemeral app to a regular installed app. Ephemeral apps
341 // are already installed in extension system (albiet transiently) and only
342 // need to be exposed in the UI. Set |is_from_sync| to true if the
343 // install was initiated via sync.
344 void PromoteEphemeralApp(
345 const extensions::Extension* extension, bool is_from_sync);
347 // ExtensionHost of background page calls this method right after its render
348 // view has been created.
349 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host);
351 // Changes sequenced task runner for crx installation tasks to |task_runner|.
352 void SetFileTaskRunnerForTesting(
353 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
355 // Postpone installations so that we don't have to worry about race
356 // conditions.
357 void OnGarbageCollectIsolatedStorageStart();
359 // Restart any extension installs which were delayed for isolated storage
360 // garbage collection.
361 void OnGarbageCollectIsolatedStorageFinished();
363 // Record a histogram using the PermissionMessage enum values for each
364 // permission in |e|.
365 // NOTE: If this is ever called with high frequency, the implementation may
366 // need to be made more efficient.
367 static void RecordPermissionMessagesHistogram(
368 const extensions::Extension* extension, const char* histogram);
370 // Unloads the given extension and mark the extension as terminated. This
371 // doesn't notify the user that the extension was terminated, if such a
372 // notification is desired the calling code is responsible for doing that.
373 void TerminateExtension(const std::string& extension_id);
375 // Register self and content settings API with the specified map.
376 void RegisterContentSettings(
377 HostContentSettingsMap* host_content_settings_map);
379 // Adds/Removes update observers.
380 void AddUpdateObserver(extensions::UpdateObserver* observer);
381 void RemoveUpdateObserver(extensions::UpdateObserver* observer);
383 //////////////////////////////////////////////////////////////////////////////
384 // Simple Accessors
386 // Returns a WeakPtr to the ExtensionService.
387 base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); }
389 // Returns profile_ as a BrowserContext.
390 content::BrowserContext* GetBrowserContext() const;
392 bool extensions_enabled() const { return extensions_enabled_; }
393 void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; }
395 const base::FilePath& install_directory() const { return install_directory_; }
397 const extensions::ExtensionSet* delayed_installs() const {
398 return &delayed_installs_;
401 bool show_extensions_prompts() const { return show_extensions_prompts_; }
402 void set_show_extensions_prompts(bool show_extensions_prompts) {
403 show_extensions_prompts_ = show_extensions_prompts;
406 Profile* profile() { return profile_; }
408 void set_extension_sync_service(
409 ExtensionSyncService* extension_sync_service) {
410 extension_sync_service_ = extension_sync_service;
413 // Note that this may return NULL if autoupdate is not turned on.
414 extensions::ExtensionUpdater* updater() { return updater_.get(); }
416 extensions::ComponentLoader* component_loader() {
417 return component_loader_.get();
420 bool browser_terminating() const { return browser_terminating_; }
422 extensions::SharedModuleService* shared_module_service() {
423 return shared_module_service_.get();
426 extensions::ExternalInstallManager* external_install_manager() {
427 return external_install_manager_.get();
430 //////////////////////////////////////////////////////////////////////////////
431 // For Testing
433 // Unload all extensions. Does not send notifications.
434 void UnloadAllExtensionsForTest();
436 // Reloads all extensions. Does not notify that extensions are ready.
437 void ReloadExtensionsForTest();
439 // Clear all ExternalProviders.
440 void ClearProvidersForTesting();
442 // Adds an ExternalProviderInterface for the service to use during testing.
443 // Takes ownership of |test_provider|.
444 void AddProviderForTesting(
445 extensions::ExternalProviderInterface* test_provider);
447 // Simulate an extension being blacklisted for tests.
448 void BlacklistExtensionForTest(const std::string& extension_id);
450 #if defined(UNIT_TEST)
451 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
452 TrackTerminatedExtension(extension->id());
455 void FinishInstallationForTest(const extensions::Extension* extension) {
456 FinishInstallation(extension, false /* not ephemeral */);
458 #endif
460 void set_browser_terminating_for_test(bool value) {
461 browser_terminating_ = value;
464 // By default ExtensionService will wait with installing an updated extension
465 // until the extension is idle. Tests might not like this behavior, so you can
466 // disable it with this method.
467 void set_install_updates_when_idle_for_test(bool value) {
468 install_updates_when_idle_ = value;
471 // Set a callback to be called when all external providers are ready and their
472 // extensions have been installed.
473 void set_external_updates_finished_callback_for_test(
474 const base::Closure& callback) {
475 external_updates_finished_callback_ = callback;
479 private:
480 // Creates an ExtensionDownloader for use by the updater.
481 scoped_ptr<extensions::ExtensionDownloader> CreateExtensionDownloader(
482 extensions::ExtensionDownloaderDelegate* delegate);
484 // Reloads the specified extension, sending the onLaunched() event to it if it
485 // currently has any window showing. |be_noisy| determines whether noisy
486 // failures are allowed for unpacked extension installs.
487 void ReloadExtensionImpl(const std::string& extension_id, bool be_noisy);
489 // content::NotificationObserver implementation:
490 void Observe(int type,
491 const content::NotificationSource& source,
492 const content::NotificationDetails& details) override;
494 // extensions::Blacklist::Observer implementation.
495 void OnBlacklistUpdated() override;
497 // Similar to FinishInstallation, but first checks if there still is an update
498 // pending for the extension, and makes sure the extension is still idle.
499 void MaybeFinishDelayedInstallation(const std::string& extension_id);
501 // For the extension in |version_path| with |id|, check to see if it's an
502 // externally managed extension. If so, uninstall it.
503 void CheckExternalUninstall(const std::string& id);
505 // Attempt to enable all disabled extensions which the only disabled reason is
506 // reloading.
507 void EnabledReloadableExtensions();
509 // Finish install (if possible) of extensions that were still delayed while
510 // the browser was shut down.
511 void MaybeFinishShutdownDelayed();
513 // Populates greylist_.
514 void LoadGreylistFromPrefs();
516 // Signals *ready_ and sends a notification to the listeners.
517 void SetReadyAndNotifyListeners();
519 // Returns true if all the external extension providers are ready.
520 bool AreAllExternalProvidersReady() const;
522 // Called once all external providers are ready. Checks for unclaimed
523 // external extensions.
524 void OnAllExternalProvidersReady();
526 // Adds the given extension id to the list of terminated extensions if
527 // it is not already there and unloads it.
528 void TrackTerminatedExtension(const std::string& extension_id);
530 // Removes the extension with the given id from the list of
531 // terminated extensions if it is there.
532 void UntrackTerminatedExtension(const std::string& id);
534 // Update preferences for a new or updated extension; notify observers that
535 // the extension is installed, e.g., to update event handlers on background
536 // pages; and perform other extension install tasks before calling
537 // AddExtension.
538 // |install_flags| is a bitmask of extensions::InstallFlags.
539 void AddNewOrUpdatedExtension(const extensions::Extension* extension,
540 extensions::Extension::State initial_state,
541 int install_flags,
542 const syncer::StringOrdinal& page_ordinal,
543 const std::string& install_parameter);
545 // Handles sending notification that |extension| was loaded.
546 void NotifyExtensionLoaded(const extensions::Extension* extension);
548 // Handles sending notification that |extension| was unloaded.
549 void NotifyExtensionUnloaded(
550 const extensions::Extension* extension,
551 extensions::UnloadedExtensionInfo::Reason reason);
553 // Common helper to finish installing the given extension. |was_ephemeral|
554 // should be true if the extension was previously installed and ephemeral.
555 void FinishInstallation(const extensions::Extension* extension,
556 bool was_ephemeral);
558 // Disables the extension if the privilege level has increased
559 // (e.g., due to an upgrade).
560 void CheckPermissionsIncrease(const extensions::Extension* extension,
561 bool is_extension_installed);
563 // Helper that updates the active extension list used for crash reporting.
564 void UpdateActiveExtensionsInCrashReporter();
566 // Helper to get the disable reasons for an installed (or upgraded) extension.
567 // A return value of Extension::DISABLE_NONE indicates that we should enable
568 // this extension initially.
569 int GetDisableReasonsOnInstalled(const extensions::Extension* extension);
571 // Helper method to determine if an extension can be blocked.
572 bool CanBlockExtension(const extensions::Extension* extension) const;
574 // Helper to determine if updating an extensions should proceed immediately,
575 // or if we should delay the update until further notice.
576 bool ShouldDelayExtensionUpdate(const std::string& extension_id,
577 bool install_immediately) const;
579 // Manages the blacklisted extensions, intended as callback from
580 // Blacklist::GetBlacklistedIDs.
581 void ManageBlacklist(
582 const extensions::Blacklist::BlacklistStateMap& blacklisted_ids);
584 // Add extensions in |blacklisted| to blacklisted_extensions, remove
585 // extensions that are neither in |blacklisted|, nor in |unchanged|.
586 void UpdateBlacklistedExtensions(
587 const extensions::ExtensionIdSet& to_blacklist,
588 const extensions::ExtensionIdSet& unchanged);
590 void UpdateGreylistedExtensions(
591 const extensions::ExtensionIdSet& greylist,
592 const extensions::ExtensionIdSet& unchanged,
593 const extensions::Blacklist::BlacklistStateMap& state_map);
595 // Used only by test code.
596 void UnloadAllExtensionsInternal();
598 // Disable apps & extensions now to stop them from running after a profile
599 // has been conceptually deleted. Don't wait for full browser shutdown and
600 // the actual profile objects to be destroyed.
601 void OnProfileDestructionStarted();
603 // Called on file task runner thread to uninstall extension.
604 static void UninstallExtensionOnFileThread(
605 const std::string& id,
606 Profile* profile,
607 const base::FilePath& install_dir,
608 const base::FilePath& extension_path);
610 // The normal profile associated with this ExtensionService.
611 Profile* profile_;
613 // The ExtensionSystem for the profile above.
614 extensions::ExtensionSystem* system_;
616 // Preferences for the owning profile.
617 extensions::ExtensionPrefs* extension_prefs_;
619 // Blacklist for the owning profile.
620 extensions::Blacklist* blacklist_;
622 // The ExtensionSyncService that is used by this ExtensionService.
623 ExtensionSyncService* extension_sync_service_;
625 // Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
626 extensions::ExtensionRegistry* registry_;
628 // Set of greylisted extensions. These extensions are disabled if they are
629 // already installed in Chromium at the time when they are added to
630 // the greylist. Unlike blacklisted extensions, greylisted ones are visible
631 // to the user and if user re-enables such an extension, they remain enabled.
633 // These extensions should appear in registry_.
634 extensions::ExtensionSet greylist_;
636 // The list of extension installs delayed for various reasons. The reason
637 // for delayed install is stored in ExtensionPrefs. These are not part of
638 // ExtensionRegistry because they are not yet installed.
639 extensions::ExtensionSet delayed_installs_;
641 // Hold the set of pending extensions.
642 extensions::PendingExtensionManager pending_extension_manager_;
644 // The full path to the directory where extensions are installed.
645 base::FilePath install_directory_;
647 // Whether or not extensions are enabled.
648 bool extensions_enabled_;
650 // Whether to notify users when they attempt to install an extension.
651 bool show_extensions_prompts_;
653 // Whether to delay installing of extension updates until the extension is
654 // idle.
655 bool install_updates_when_idle_;
657 // Signaled when all extensions are loaded.
658 extensions::OneShotEvent* const ready_;
660 // Our extension updater, if updates are turned on.
661 scoped_ptr<extensions::ExtensionUpdater> updater_;
663 // Map unloaded extensions' ids to their paths. When a temporarily loaded
664 // extension is unloaded, we lose the information about it and don't have
665 // any in the extension preferences file.
666 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap;
667 UnloadedExtensionPathMap unloaded_extension_paths_;
669 // Map of DevToolsAgentHost instances that are detached,
670 // waiting for an extension to be reloaded.
671 typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> >
672 OrphanedDevTools;
673 OrphanedDevTools orphaned_dev_tools_;
675 content::NotificationRegistrar registrar_;
677 // Keeps track of loading and unloading component extensions.
678 scoped_ptr<extensions::ComponentLoader> component_loader_;
680 // A collection of external extension providers. Each provider reads
681 // a source of external extension information. Examples include the
682 // windows registry and external_extensions.json.
683 extensions::ProviderCollection external_extension_providers_;
685 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
686 // extension URL is found, and by CheckForUpdatesSoon() when an update check
687 // has to wait for the external providers. Used in
688 // OnAllExternalProvidersReady() to determine if an update check is needed to
689 // install pending extensions.
690 bool update_once_all_providers_are_ready_;
692 // A callback to be called when all external providers are ready and their
693 // extensions have been installed. Normally this is a null callback, but
694 // is used in external provider related tests.
695 base::Closure external_updates_finished_callback_;
697 // Set when the browser is terminating. Prevents us from installing or
698 // updating additional extensions and allows in-progress installations to
699 // decide to abort.
700 bool browser_terminating_;
702 // Set to true to delay all new extension installations. Acts as a lock to
703 // allow background processing of garbage collection of on-disk state without
704 // needing to worry about race conditions caused by extension installation and
705 // reinstallation.
706 bool installs_delayed_for_gc_;
708 // Set to true if this is the first time this ExtensionService has run.
709 // Used for specially handling external extensions that are installed the
710 // first time.
711 bool is_first_run_;
713 // Set to true if extensions are all to be blocked.
714 bool block_extensions_;
716 // Store the ids of reloading extensions. We use this to re-enable extensions
717 // which were disabled for a reload.
718 std::set<std::string> reloading_extensions_;
720 // A set of the extension ids currently being terminated. We use this to
721 // avoid trying to unload the same extension twice.
722 std::set<std::string> extensions_being_terminated_;
724 // The controller for the UI that alerts the user about any blacklisted
725 // extensions.
726 scoped_ptr<extensions::ExtensionErrorController> error_controller_;
728 // The manager for extensions that were externally installed that is
729 // responsible for prompting the user about suspicious extensions.
730 scoped_ptr<extensions::ExternalInstallManager> external_install_manager_;
732 // Sequenced task runner for extension related file operations.
733 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
735 scoped_ptr<extensions::ExtensionActionStorageManager>
736 extension_action_storage_manager_;
737 scoped_ptr<extensions::ManagementPolicy::Provider>
738 shared_module_policy_provider_;
740 // The SharedModuleService used to check for import dependencies.
741 scoped_ptr<extensions::SharedModuleService> shared_module_service_;
743 base::ObserverList<extensions::UpdateObserver, true> update_observers_;
745 // Migrates app data when upgrading a legacy packaged app to a platform app
746 scoped_ptr<extensions::AppDataMigrator> app_data_migrator_;
748 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
749 DestroyingProfileClearsExtensions);
750 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, SetUnsetBlacklistInPrefs);
751 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
752 BlacklistedExtensionWillNotInstall);
753 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
754 UnloadBlacklistedExtensionPolicy);
755 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
756 WillNotLoadBlacklistedExtensionsFromDirectory);
757 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ReloadBlacklistedExtension);
758 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, BlacklistedInPrefsFromStartup);
759 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
760 GreylistedExtensionDisabled);
761 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
762 GreylistDontEnableManuallyDisabled);
763 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
764 GreylistUnknownDontChange);
765 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
766 ManagementPolicyProhibitsEnableOnInstalled);
767 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
768 BlockAndUnblockBlacklistedExtension);
770 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
773 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_