Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / extension_service.h
blob5dbaeaa60ecf0b2544a9b30f4d869a9b8f02f465
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 // Note that this may return NULL if autoupdate is not turned on.
409 extensions::ExtensionUpdater* updater() { return updater_.get(); }
411 extensions::ComponentLoader* component_loader() {
412 return component_loader_.get();
415 bool browser_terminating() const { return browser_terminating_; }
417 extensions::SharedModuleService* shared_module_service() {
418 return shared_module_service_.get();
421 extensions::ExternalInstallManager* external_install_manager() {
422 return external_install_manager_.get();
425 //////////////////////////////////////////////////////////////////////////////
426 // For Testing
428 // Unload all extensions. Does not send notifications.
429 void UnloadAllExtensionsForTest();
431 // Reloads all extensions. Does not notify that extensions are ready.
432 void ReloadExtensionsForTest();
434 // Clear all ExternalProviders.
435 void ClearProvidersForTesting();
437 // Adds an ExternalProviderInterface for the service to use during testing.
438 // Takes ownership of |test_provider|.
439 void AddProviderForTesting(
440 extensions::ExternalProviderInterface* test_provider);
442 // Simulate an extension being blacklisted for tests.
443 void BlacklistExtensionForTest(const std::string& extension_id);
445 #if defined(UNIT_TEST)
446 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
447 TrackTerminatedExtension(extension->id());
450 void FinishInstallationForTest(const extensions::Extension* extension) {
451 FinishInstallation(extension, false /* not ephemeral */);
453 #endif
455 void set_browser_terminating_for_test(bool value) {
456 browser_terminating_ = value;
459 // By default ExtensionService will wait with installing an updated extension
460 // until the extension is idle. Tests might not like this behavior, so you can
461 // disable it with this method.
462 void set_install_updates_when_idle_for_test(bool value) {
463 install_updates_when_idle_ = value;
466 // Set a callback to be called when all external providers are ready and their
467 // extensions have been installed.
468 void set_external_updates_finished_callback_for_test(
469 const base::Closure& callback) {
470 external_updates_finished_callback_ = callback;
474 private:
475 // Creates an ExtensionDownloader for use by the updater.
476 scoped_ptr<extensions::ExtensionDownloader> CreateExtensionDownloader(
477 extensions::ExtensionDownloaderDelegate* delegate);
479 // Reloads the specified extension, sending the onLaunched() event to it if it
480 // currently has any window showing. |be_noisy| determines whether noisy
481 // failures are allowed for unpacked extension installs.
482 void ReloadExtensionImpl(const std::string& extension_id, bool be_noisy);
484 // content::NotificationObserver implementation:
485 void Observe(int type,
486 const content::NotificationSource& source,
487 const content::NotificationDetails& details) override;
489 // extensions::Blacklist::Observer implementation.
490 void OnBlacklistUpdated() override;
492 // Similar to FinishInstallation, but first checks if there still is an update
493 // pending for the extension, and makes sure the extension is still idle.
494 void MaybeFinishDelayedInstallation(const std::string& extension_id);
496 // For the extension in |version_path| with |id|, check to see if it's an
497 // externally managed extension. If so, uninstall it.
498 void CheckExternalUninstall(const std::string& id);
500 // Attempt to enable all disabled extensions which the only disabled reason is
501 // reloading.
502 void EnabledReloadableExtensions();
504 // Finish install (if possible) of extensions that were still delayed while
505 // the browser was shut down.
506 void MaybeFinishShutdownDelayed();
508 // Populates greylist_.
509 void LoadGreylistFromPrefs();
511 // Signals *ready_ and sends a notification to the listeners.
512 void SetReadyAndNotifyListeners();
514 // Returns true if all the external extension providers are ready.
515 bool AreAllExternalProvidersReady() const;
517 // Called once all external providers are ready. Checks for unclaimed
518 // external extensions.
519 void OnAllExternalProvidersReady();
521 // Adds the given extension id to the list of terminated extensions if
522 // it is not already there and unloads it.
523 void TrackTerminatedExtension(const std::string& extension_id);
525 // Removes the extension with the given id from the list of
526 // terminated extensions if it is there.
527 void UntrackTerminatedExtension(const std::string& id);
529 // Update preferences for a new or updated extension; notify observers that
530 // the extension is installed, e.g., to update event handlers on background
531 // pages; and perform other extension install tasks before calling
532 // AddExtension.
533 // |install_flags| is a bitmask of extensions::InstallFlags.
534 void AddNewOrUpdatedExtension(const extensions::Extension* extension,
535 extensions::Extension::State initial_state,
536 int install_flags,
537 const syncer::StringOrdinal& page_ordinal,
538 const std::string& install_parameter);
540 // Handles sending notification that |extension| was loaded.
541 void NotifyExtensionLoaded(const extensions::Extension* extension);
543 // Completes extension loading after URLRequestContexts have been updated
544 // on the IO thread.
545 void OnExtensionRegisteredWithRequestContexts(
546 scoped_refptr<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 // Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
623 extensions::ExtensionRegistry* registry_;
625 // Set of greylisted extensions. These extensions are disabled if they are
626 // already installed in Chromium at the time when they are added to
627 // the greylist. Unlike blacklisted extensions, greylisted ones are visible
628 // to the user and if user re-enables such an extension, they remain enabled.
630 // These extensions should appear in registry_.
631 extensions::ExtensionSet greylist_;
633 // The list of extension installs delayed for various reasons. The reason
634 // for delayed install is stored in ExtensionPrefs. These are not part of
635 // ExtensionRegistry because they are not yet installed.
636 extensions::ExtensionSet delayed_installs_;
638 // Hold the set of pending extensions.
639 extensions::PendingExtensionManager pending_extension_manager_;
641 // The full path to the directory where extensions are installed.
642 base::FilePath install_directory_;
644 // Whether or not extensions are enabled.
645 bool extensions_enabled_;
647 // Whether to notify users when they attempt to install an extension.
648 bool show_extensions_prompts_;
650 // Whether to delay installing of extension updates until the extension is
651 // idle.
652 bool install_updates_when_idle_;
654 // Signaled when all extensions are loaded.
655 extensions::OneShotEvent* const ready_;
657 // Our extension updater, if updates are turned on.
658 scoped_ptr<extensions::ExtensionUpdater> updater_;
660 // Map unloaded extensions' ids to their paths. When a temporarily loaded
661 // extension is unloaded, we lose the information about it and don't have
662 // any in the extension preferences file.
663 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap;
664 UnloadedExtensionPathMap unloaded_extension_paths_;
666 // Map of DevToolsAgentHost instances that are detached,
667 // waiting for an extension to be reloaded.
668 typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> >
669 OrphanedDevTools;
670 OrphanedDevTools orphaned_dev_tools_;
672 content::NotificationRegistrar registrar_;
674 // Keeps track of loading and unloading component extensions.
675 scoped_ptr<extensions::ComponentLoader> component_loader_;
677 // A collection of external extension providers. Each provider reads
678 // a source of external extension information. Examples include the
679 // windows registry and external_extensions.json.
680 extensions::ProviderCollection external_extension_providers_;
682 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
683 // extension URL is found, and by CheckForUpdatesSoon() when an update check
684 // has to wait for the external providers. Used in
685 // OnAllExternalProvidersReady() to determine if an update check is needed to
686 // install pending extensions.
687 bool update_once_all_providers_are_ready_;
689 // A callback to be called when all external providers are ready and their
690 // extensions have been installed. Normally this is a null callback, but
691 // is used in external provider related tests.
692 base::Closure external_updates_finished_callback_;
694 // Set when the browser is terminating. Prevents us from installing or
695 // updating additional extensions and allows in-progress installations to
696 // decide to abort.
697 bool browser_terminating_;
699 // Set to true to delay all new extension installations. Acts as a lock to
700 // allow background processing of garbage collection of on-disk state without
701 // needing to worry about race conditions caused by extension installation and
702 // reinstallation.
703 bool installs_delayed_for_gc_;
705 // Set to true if this is the first time this ExtensionService has run.
706 // Used for specially handling external extensions that are installed the
707 // first time.
708 bool is_first_run_;
710 // Set to true if extensions are all to be blocked.
711 bool block_extensions_;
713 // Store the ids of reloading extensions. We use this to re-enable extensions
714 // which were disabled for a reload.
715 std::set<std::string> reloading_extensions_;
717 // A set of the extension ids currently being terminated. We use this to
718 // avoid trying to unload the same extension twice.
719 std::set<std::string> extensions_being_terminated_;
721 // The controller for the UI that alerts the user about any blacklisted
722 // extensions.
723 scoped_ptr<extensions::ExtensionErrorController> error_controller_;
725 // The manager for extensions that were externally installed that is
726 // responsible for prompting the user about suspicious extensions.
727 scoped_ptr<extensions::ExternalInstallManager> external_install_manager_;
729 // Sequenced task runner for extension related file operations.
730 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
732 scoped_ptr<extensions::ExtensionActionStorageManager>
733 extension_action_storage_manager_;
734 scoped_ptr<extensions::ManagementPolicy::Provider>
735 shared_module_policy_provider_;
737 // The SharedModuleService used to check for import dependencies.
738 scoped_ptr<extensions::SharedModuleService> shared_module_service_;
740 base::ObserverList<extensions::UpdateObserver, true> update_observers_;
742 // Migrates app data when upgrading a legacy packaged app to a platform app
743 scoped_ptr<extensions::AppDataMigrator> app_data_migrator_;
745 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
746 DestroyingProfileClearsExtensions);
747 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, SetUnsetBlacklistInPrefs);
748 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
749 BlacklistedExtensionWillNotInstall);
750 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
751 UnloadBlacklistedExtensionPolicy);
752 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
753 WillNotLoadBlacklistedExtensionsFromDirectory);
754 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ReloadBlacklistedExtension);
755 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, BlacklistedInPrefsFromStartup);
756 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
757 GreylistedExtensionDisabled);
758 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
759 GreylistDontEnableManuallyDisabled);
760 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
761 GreylistUnknownDontChange);
762 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
763 ManagementPolicyProhibitsEnableOnInstalled);
764 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
765 BlockAndUnblockBlacklistedExtension);
767 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
770 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_