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_
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/external_provider_interface.h"
25 #include "extensions/browser/install_flag.h"
26 #include "extensions/browser/management_policy.h"
27 #include "extensions/browser/process_manager.h"
28 #include "extensions/browser/uninstall_reason.h"
29 #include "extensions/common/extension.h"
30 #include "extensions/common/extension_set.h"
31 #include "extensions/common/manifest.h"
32 #include "sync/api/string_ordinal.h"
34 #if !defined(ENABLE_EXTENSIONS)
35 #error "Extensions must be enabled"
38 class ExtensionSyncService
;
40 class HostContentSettingsMap
;
45 class SequencedTaskRunner
;
50 class DevToolsAgentHost
;
53 namespace extensions
{
54 class ComponentLoader
;
56 class ExtensionActionStorageManager
;
57 class ExtensionDownloader
;
58 class ExtensionDownloaderDelegate
;
59 class ExtensionErrorController
;
60 class ExtensionRegistry
;
61 class ExtensionSystem
;
62 class ExtensionUpdater
;
64 class ExternalInstallManager
;
65 class SharedModuleService
;
67 } // namespace extensions
69 // This is an interface class to encapsulate the dependencies that
70 // various classes have on ExtensionService. This allows easy mocking.
71 class ExtensionServiceInterface
72 : public base::SupportsWeakPtr
<ExtensionServiceInterface
> {
74 virtual ~ExtensionServiceInterface() {}
76 // DEPRECATED: Use ExtensionRegistry::enabled_extensions() instead.
78 // ExtensionRegistry also has the disabled, terminated and blacklisted sets.
79 virtual const extensions::ExtensionSet
* extensions() const = 0;
81 // Gets the object managing the set of pending extensions.
82 virtual extensions::PendingExtensionManager
* pending_extension_manager() = 0;
84 // Installs an update with the contents from |extension_path|. Returns true if
85 // the install can be started. Sets |out_crx_installer| to the installer if
87 // TODO(aa): This method can be removed. ExtensionUpdater could use
88 // CrxInstaller directly instead.
89 virtual bool UpdateExtension(
90 const std::string
& id
,
91 const base::FilePath
& path
,
92 bool file_ownership_passed
,
93 extensions::CrxInstaller
** out_crx_installer
) = 0;
95 // DEPRECATED. Use ExtensionRegistry instead.
97 // Looks up an extension by its ID.
99 // If |include_disabled| is false then this will only include enabled
100 // extensions. Use instead:
102 // ExtensionRegistry::enabled_extensions().GetByID(id).
104 // If |include_disabled| is true then this will also include disabled and
105 // blacklisted extensions (not terminated extensions). Use instead:
107 // ExtensionRegistry::GetExtensionById(
108 // id, ExtensionRegistry::ENABLED |
109 // ExtensionRegistry::DISABLED |
110 // ExtensionRegistry::BLACKLISTED)
112 // Or don't, because it's probably not something you ever need to know.
113 virtual const extensions::Extension
* GetExtensionById(
114 const std::string
& id
,
115 bool include_disabled
) const = 0;
117 // DEPRECATED: Use ExtensionRegistry instead.
119 // Looks up an extension by ID, regardless of whether it's enabled,
120 // disabled, blacklisted, or terminated. Use instead:
122 // ExtensionRegistry::GetExtensionById(id, ExtensionRegistry::EVERYTHING).
123 virtual const extensions::Extension
* GetInstalledExtension(
124 const std::string
& id
) const = 0;
126 // Returns an update for an extension with the specified id, if installation
127 // of that update was previously delayed because the extension was in use. If
128 // no updates are pending for the extension returns NULL.
129 virtual const extensions::Extension
* GetPendingExtensionUpdate(
130 const std::string
& extension_id
) const = 0;
132 // Finishes installation of an update for an extension with the specified id,
133 // when installation of that extension was previously delayed because the
134 // extension was in use.
135 virtual void FinishDelayedInstallation(const std::string
& extension_id
) = 0;
137 // Returns true if the extension with the given |extension_id| is enabled.
138 // This will return a valid answer even if the extension is not loaded yet.
139 virtual bool IsExtensionEnabled(const std::string
& extension_id
) const = 0;
141 // Go through each extension and unload those that are not allowed to run by
142 // management policy providers (ie. network admin and Google-managed
144 virtual void CheckManagementPolicy() = 0;
146 // Safe to call multiple times in a row.
148 // TODO(akalin): Remove this method (and others) once we refactor
149 // themes sync to not use it directly.
150 virtual void CheckForUpdatesSoon() = 0;
152 // Adds |extension| to this ExtensionService and notifies observers that the
153 // extensions have been loaded.
154 virtual void AddExtension(const extensions::Extension
* extension
) = 0;
156 // Check if we have preferences for the component extension and, if not or if
157 // the stored version differs, install the extension (without requirements
158 // checking) before calling AddExtension.
159 virtual void AddComponentExtension(
160 const extensions::Extension
* extension
) = 0;
162 // Unload the specified extension.
163 virtual void UnloadExtension(
164 const std::string
& extension_id
,
165 extensions::UnloadedExtensionInfo::Reason reason
) = 0;
167 // Remove the specified component extension.
168 virtual void RemoveComponentExtension(const std::string
& extension_id
) = 0;
170 // Whether the extension service is ready.
171 virtual bool is_ready() = 0;
173 // Returns task runner for crx installation file I/O operations.
174 virtual base::SequencedTaskRunner
* GetFileTaskRunner() = 0;
177 // Manages installed and running Chromium extensions. An instance is shared
178 // between normal and incognito profiles.
179 class ExtensionService
180 : public ExtensionServiceInterface
,
181 public extensions::ExternalProviderInterface::VisitorInterface
,
182 public content::NotificationObserver
,
183 public extensions::Blacklist::Observer
,
184 public extensions::ExtensionManagement::Observer
{
186 // Attempts to uninstall an extension from a given ExtensionService. Returns
187 // true iff the target extension exists.
188 static bool UninstallExtensionHelper(ExtensionService
* extensions_service
,
189 const std::string
& extension_id
,
190 extensions::UninstallReason reason
);
192 // Constructor stores pointers to |profile| and |extension_prefs| but
193 // ownership remains at caller.
194 ExtensionService(Profile
* profile
,
195 const base::CommandLine
* command_line
,
196 const base::FilePath
& install_directory
,
197 extensions::ExtensionPrefs
* extension_prefs
,
198 extensions::Blacklist
* blacklist
,
199 bool autoupdate_enabled
,
200 bool extensions_enabled
,
201 extensions::OneShotEvent
* ready
);
203 ~ExtensionService() override
;
205 // ExtensionServiceInterface implementation.
207 // NOTE: Many of these methods are DEPRECATED. See the interface for details.
208 const extensions::ExtensionSet
* extensions() const override
;
209 extensions::PendingExtensionManager
* pending_extension_manager() override
;
210 const extensions::Extension
* GetExtensionById(
211 const std::string
& id
,
212 bool include_disabled
) const override
;
213 const extensions::Extension
* GetInstalledExtension(
214 const std::string
& id
) const override
;
215 bool UpdateExtension(const std::string
& id
,
216 const base::FilePath
& extension_path
,
217 bool file_ownership_passed
,
218 extensions::CrxInstaller
** out_crx_installer
) override
;
219 bool IsExtensionEnabled(const std::string
& extension_id
) const override
;
220 void UnloadExtension(
221 const std::string
& extension_id
,
222 extensions::UnloadedExtensionInfo::Reason reason
) override
;
223 void RemoveComponentExtension(const std::string
& extension_id
) override
;
224 void AddExtension(const extensions::Extension
* extension
) override
;
225 void AddComponentExtension(const extensions::Extension
* extension
) override
;
226 const extensions::Extension
* GetPendingExtensionUpdate(
227 const std::string
& extension_id
) const override
;
228 void FinishDelayedInstallation(const std::string
& extension_id
) override
;
229 void CheckManagementPolicy() override
;
230 void CheckForUpdatesSoon() override
;
231 bool is_ready() override
;
232 base::SequencedTaskRunner
* GetFileTaskRunner() override
;
234 // ExternalProvider::Visitor implementation.
235 // Exposed for testing.
236 bool OnExternalExtensionFileFound(const std::string
& id
,
237 const base::Version
* version
,
238 const base::FilePath
& path
,
239 extensions::Manifest::Location location
,
241 bool mark_acknowledged
) override
;
242 bool OnExternalExtensionUpdateUrlFound(
243 const std::string
& id
,
244 const std::string
& install_parameter
,
245 const GURL
& update_url
,
246 extensions::Manifest::Location location
,
248 bool mark_acknowledged
) override
;
249 void OnExternalProviderReady(
250 const extensions::ExternalProviderInterface
* provider
) override
;
252 // ExtensionManagement::Observer implementation:
253 void OnExtensionManagementSettingsChanged() override
;
255 // Initialize and start all installed extensions.
258 // Called when the associated Profile is going to be destroyed.
261 // Reloads the specified extension, sending the onLaunched() event to it if it
262 // currently has any window showing.
263 // Allows noisy failures.
264 // NOTE: Reloading an extension can invalidate |extension_id| and Extension
265 // pointers for the given extension. Consider making a copy of |extension_id|
266 // first and retrieving a new Extension pointer afterwards.
267 void ReloadExtension(const std::string
& extension_id
);
269 // Suppresses noisy failures.
270 void ReloadExtensionWithQuietFailure(const std::string
& extension_id
);
272 // Uninstalls the specified extension. Callers should only call this method
273 // with extensions that exist. |reason| lets the caller specify why the
274 // extension is uninstalled.
276 // If the return value is true, |deletion_done_callback| is invoked when data
277 // deletion is done or at least is scheduled.
278 virtual bool UninstallExtension(const std::string
& extension_id
,
279 extensions::UninstallReason reason
,
280 const base::Closure
& deletion_done_callback
,
281 base::string16
* error
);
283 // Enables the extension. If the extension is already enabled, does
285 virtual void EnableExtension(const std::string
& extension_id
);
287 // Disables the extension. If the extension is already disabled, or
288 // cannot be disabled, does nothing.
289 virtual void DisableExtension(
290 const std::string
& extension_id
,
291 extensions::Extension::DisableReason disable_reason
);
293 // Disable non-default and non-managed extensions with ids not in
294 // |except_ids|. Default extensions are those from the Web Store with
295 // |was_installed_by_default| flag.
296 void DisableUserExtensions(const std::vector
<std::string
>& except_ids
);
298 // Updates the |extension|'s granted permissions lists to include all
299 // permissions in the |extension|'s manifest and re-enables the
301 void GrantPermissionsAndEnableExtension(
302 const extensions::Extension
* extension
);
304 // Updates the |extension|'s granted permissions lists to include all
305 // permissions in the |extensions|'s manifest.
306 void GrantPermissions(const extensions::Extension
* extension
);
308 // Check for updates (or potentially new extensions from external providers)
309 void CheckForExternalUpdates();
311 // Called when the initial extensions load has completed.
312 virtual void OnLoadedInstalledExtensions();
314 // Informs the service that an extension's files are in place for loading.
316 // |extension| the extension
317 // |page_ordinal| the location of the extension in the app launcher
318 // |install_flags| a bitmask of extensions::InstallFlags
319 void OnExtensionInstalled(const extensions::Extension
* extension
,
320 const syncer::StringOrdinal
& page_ordinal
,
322 void OnExtensionInstalled(const extensions::Extension
* extension
,
323 const syncer::StringOrdinal
& page_ordinal
) {
324 OnExtensionInstalled(extension
,
326 static_cast<int>(extensions::kInstallFlagNone
));
329 // Checks for delayed installation for all pending installs.
330 void MaybeFinishDelayedInstallations();
332 // Promotes an ephemeral app to a regular installed app. Ephemeral apps
333 // are already installed in extension system (albiet transiently) and only
334 // need to be exposed in the UI. Set |is_from_sync| to true if the
335 // install was initiated via sync.
336 void PromoteEphemeralApp(
337 const extensions::Extension
* extension
, bool is_from_sync
);
339 // ExtensionHost of background page calls this method right after its render
340 // view has been created.
341 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost
* host
);
343 // Changes sequenced task runner for crx installation tasks to |task_runner|.
344 void SetFileTaskRunnerForTesting(
345 const scoped_refptr
<base::SequencedTaskRunner
>& task_runner
);
347 // Postpone installations so that we don't have to worry about race
349 void OnGarbageCollectIsolatedStorageStart();
351 // Restart any extension installs which were delayed for isolated storage
352 // garbage collection.
353 void OnGarbageCollectIsolatedStorageFinished();
355 // Record a histogram using the PermissionMessage enum values for each
356 // permission in |e|.
357 // NOTE: If this is ever called with high frequency, the implementation may
358 // need to be made more efficient.
359 static void RecordPermissionMessagesHistogram(
360 const extensions::Extension
* extension
, const char* histogram
);
362 // Unloads the given extension and mark the extension as terminated. This
363 // doesn't notify the user that the extension was terminated, if such a
364 // notification is desired the calling code is responsible for doing that.
365 void TerminateExtension(const std::string
& extension_id
);
367 // Register self and content settings API with the specified map.
368 void RegisterContentSettings(
369 HostContentSettingsMap
* host_content_settings_map
);
371 // Adds/Removes update observers.
372 void AddUpdateObserver(extensions::UpdateObserver
* observer
);
373 void RemoveUpdateObserver(extensions::UpdateObserver
* observer
);
375 //////////////////////////////////////////////////////////////////////////////
378 // Returns a WeakPtr to the ExtensionService.
379 base::WeakPtr
<ExtensionService
> AsWeakPtr() { return base::AsWeakPtr(this); }
381 // Returns profile_ as a BrowserContext.
382 content::BrowserContext
* GetBrowserContext() const;
384 bool extensions_enabled() const { return extensions_enabled_
; }
385 void set_extensions_enabled(bool enabled
) { extensions_enabled_
= enabled
; }
387 const base::FilePath
& install_directory() const { return install_directory_
; }
389 const extensions::ExtensionSet
* delayed_installs() const {
390 return &delayed_installs_
;
393 bool show_extensions_prompts() const { return show_extensions_prompts_
; }
394 void set_show_extensions_prompts(bool show_extensions_prompts
) {
395 show_extensions_prompts_
= show_extensions_prompts
;
398 Profile
* profile() { return profile_
; }
400 void set_extension_sync_service(
401 ExtensionSyncService
* extension_sync_service
) {
402 extension_sync_service_
= extension_sync_service
;
405 // Note that this may return NULL if autoupdate is not turned on.
406 extensions::ExtensionUpdater
* updater() { return updater_
.get(); }
408 extensions::ComponentLoader
* component_loader() {
409 return component_loader_
.get();
412 bool browser_terminating() const { return browser_terminating_
; }
414 extensions::SharedModuleService
* shared_module_service() {
415 return shared_module_service_
.get();
418 extensions::ExternalInstallManager
* external_install_manager() {
419 return external_install_manager_
.get();
422 //////////////////////////////////////////////////////////////////////////////
425 // Unload all extensions. Does not send notifications.
426 void UnloadAllExtensionsForTest();
428 // Reloads all extensions. Does not notify that extensions are ready.
429 void ReloadExtensionsForTest();
431 // Clear all ExternalProviders.
432 void ClearProvidersForTesting();
434 // Adds an ExternalProviderInterface for the service to use during testing.
435 // Takes ownership of |test_provider|.
436 void AddProviderForTesting(
437 extensions::ExternalProviderInterface
* test_provider
);
439 // Simulate an extension being blacklisted for tests.
440 void BlacklistExtensionForTest(const std::string
& extension_id
);
442 #if defined(UNIT_TEST)
443 void TrackTerminatedExtensionForTest(const extensions::Extension
* extension
) {
444 TrackTerminatedExtension(extension
);
447 void FinishInstallationForTest(const extensions::Extension
* extension
) {
448 FinishInstallation(extension
, false /* not ephemeral */);
452 void set_browser_terminating_for_test(bool value
) {
453 browser_terminating_
= value
;
456 // By default ExtensionService will wait with installing an updated extension
457 // until the extension is idle. Tests might not like this behavior, so you can
458 // disable it with this method.
459 void set_install_updates_when_idle_for_test(bool value
) {
460 install_updates_when_idle_
= value
;
463 // Set a callback to be called when all external providers are ready and their
464 // extensions have been installed.
465 void set_external_updates_finished_callback_for_test(
466 const base::Closure
& callback
) {
467 external_updates_finished_callback_
= callback
;
472 // Creates an ExtensionDownloader for use by the updater.
473 scoped_ptr
<extensions::ExtensionDownloader
> CreateExtensionDownloader(
474 extensions::ExtensionDownloaderDelegate
* delegate
);
476 // Reloads the specified extension, sending the onLaunched() event to it if it
477 // currently has any window showing. |be_noisy| determines whether noisy
478 // failures are allowed for unpacked extension installs.
479 void ReloadExtensionImpl(const std::string
& extension_id
, bool be_noisy
);
481 // content::NotificationObserver implementation:
482 void Observe(int type
,
483 const content::NotificationSource
& source
,
484 const content::NotificationDetails
& details
) override
;
486 // extensions::Blacklist::Observer implementation.
487 void OnBlacklistUpdated() override
;
489 // Similar to FinishInstallation, but first checks if there still is an update
490 // pending for the extension, and makes sure the extension is still idle.
491 void MaybeFinishDelayedInstallation(const std::string
& extension_id
);
493 // For the extension in |version_path| with |id|, check to see if it's an
494 // externally managed extension. If so, uninstall it.
495 void CheckExternalUninstall(const std::string
& id
);
497 // Populates greylist_.
498 void LoadGreylistFromPrefs();
500 // Signals *ready_ and sends a notification to the listeners.
501 void SetReadyAndNotifyListeners();
503 // Returns true if all the external extension providers are ready.
504 bool AreAllExternalProvidersReady() const;
506 // Called once all external providers are ready. Checks for unclaimed
507 // external extensions.
508 void OnAllExternalProvidersReady();
510 // Adds the given extension to the list of terminated extensions if
511 // it is not already there and unloads it.
512 void TrackTerminatedExtension(const extensions::Extension
* extension
);
514 // Removes the extension with the given id from the list of
515 // terminated extensions if it is there.
516 void UntrackTerminatedExtension(const std::string
& id
);
518 // Update preferences for a new or updated extension; notify observers that
519 // the extension is installed, e.g., to update event handlers on background
520 // pages; and perform other extension install tasks before calling
522 // |install_flags| is a bitmask of extensions::InstallFlags.
523 void AddNewOrUpdatedExtension(const extensions::Extension
* extension
,
524 extensions::Extension::State initial_state
,
526 const syncer::StringOrdinal
& page_ordinal
,
527 const std::string
& install_parameter
);
529 // Handles sending notification that |extension| was loaded.
530 void NotifyExtensionLoaded(const extensions::Extension
* extension
);
532 // Handles sending notification that |extension| was unloaded.
533 void NotifyExtensionUnloaded(
534 const extensions::Extension
* extension
,
535 extensions::UnloadedExtensionInfo::Reason reason
);
537 // Common helper to finish installing the given extension. |was_ephemeral|
538 // should be true if the extension was previously installed and ephemeral.
539 void FinishInstallation(const extensions::Extension
* extension
,
542 // Disables the extension if the privilege level has increased
543 // (e.g., due to an upgrade).
544 void CheckPermissionsIncrease(const extensions::Extension
* extension
,
545 bool is_extension_installed
);
547 // Helper that updates the active extension list used for crash reporting.
548 void UpdateActiveExtensionsInCrashReporter();
550 // Helper to determine whether we should initially enable an installed
551 // (or upgraded) extension.
552 bool ShouldEnableOnInstall(const extensions::Extension
* extension
);
554 // Helper to determine if updating an extensions should proceed immediately,
555 // or if we should delay the update until further notice.
556 bool ShouldDelayExtensionUpdate(const std::string
& extension_id
,
557 bool install_immediately
) const;
559 // Manages the blacklisted extensions, intended as callback from
560 // Blacklist::GetBlacklistedIDs.
561 void ManageBlacklist(
562 const extensions::Blacklist::BlacklistStateMap
& blacklisted_ids
);
564 // Add extensions in |blocked| to blacklisted_extensions, remove extensions
565 // that are neither in |blocked|, nor in |unchanged|.
566 void UpdateBlockedExtensions(const extensions::ExtensionIdSet
& blocked
,
567 const extensions::ExtensionIdSet
& unchanged
);
569 void UpdateGreylistedExtensions(
570 const extensions::ExtensionIdSet
& greylist
,
571 const extensions::ExtensionIdSet
& unchanged
,
572 const extensions::Blacklist::BlacklistStateMap
& state_map
);
574 // Used only by test code.
575 void UnloadAllExtensionsInternal();
577 // Disable apps & extensions now to stop them from running after a profile
578 // has been conceptually deleted. Don't wait for full browser shutdown and
579 // the actual profile objects to be destroyed.
580 void OnProfileDestructionStarted();
582 // Called on file task runner thread to uninstall extension.
583 static void UninstallExtensionOnFileThread(
584 const std::string
& id
,
586 const base::FilePath
& install_dir
,
587 const base::FilePath
& extension_path
);
589 // The normal profile associated with this ExtensionService.
592 // The ExtensionSystem for the profile above.
593 extensions::ExtensionSystem
* system_
;
595 // Preferences for the owning profile.
596 extensions::ExtensionPrefs
* extension_prefs_
;
598 // Blacklist for the owning profile.
599 extensions::Blacklist
* blacklist_
;
601 // The ExtensionSyncService that is used by this ExtensionService.
602 ExtensionSyncService
* extension_sync_service_
;
604 // Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
605 extensions::ExtensionRegistry
* registry_
;
607 // Set of greylisted extensions. These extensions are disabled if they are
608 // already installed in Chromium at the time when they are added to
609 // the greylist. Unlike blacklisted extensions, greylisted ones are visible
610 // to the user and if user re-enables such an extension, they remain enabled.
612 // These extensions should appear in registry_.
613 extensions::ExtensionSet greylist_
;
615 // The list of extension installs delayed for various reasons. The reason
616 // for delayed install is stored in ExtensionPrefs. These are not part of
617 // ExtensionRegistry because they are not yet installed.
618 extensions::ExtensionSet delayed_installs_
;
620 // Hold the set of pending extensions.
621 extensions::PendingExtensionManager pending_extension_manager_
;
623 // The full path to the directory where extensions are installed.
624 base::FilePath install_directory_
;
626 // Whether or not extensions are enabled.
627 bool extensions_enabled_
;
629 // Whether to notify users when they attempt to install an extension.
630 bool show_extensions_prompts_
;
632 // Whether to delay installing of extension updates until the extension is
634 bool install_updates_when_idle_
;
636 // Signaled when all extensions are loaded.
637 extensions::OneShotEvent
* const ready_
;
639 // Our extension updater, if updates are turned on.
640 scoped_ptr
<extensions::ExtensionUpdater
> updater_
;
642 // Map unloaded extensions' ids to their paths. When a temporarily loaded
643 // extension is unloaded, we lose the information about it and don't have
644 // any in the extension preferences file.
645 typedef std::map
<std::string
, base::FilePath
> UnloadedExtensionPathMap
;
646 UnloadedExtensionPathMap unloaded_extension_paths_
;
648 // Map of DevToolsAgentHost instances that are detached,
649 // waiting for an extension to be reloaded.
650 typedef std::map
<std::string
, scoped_refptr
<content::DevToolsAgentHost
> >
652 OrphanedDevTools orphaned_dev_tools_
;
654 content::NotificationRegistrar registrar_
;
656 // Keeps track of loading and unloading component extensions.
657 scoped_ptr
<extensions::ComponentLoader
> component_loader_
;
659 // A collection of external extension providers. Each provider reads
660 // a source of external extension information. Examples include the
661 // windows registry and external_extensions.json.
662 extensions::ProviderCollection external_extension_providers_
;
664 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
665 // extension URL is found, and by CheckForUpdatesSoon() when an update check
666 // has to wait for the external providers. Used in
667 // OnAllExternalProvidersReady() to determine if an update check is needed to
668 // install pending extensions.
669 bool update_once_all_providers_are_ready_
;
671 // A callback to be called when all external providers are ready and their
672 // extensions have been installed. Normally this is a null callback, but
673 // is used in external provider related tests.
674 base::Closure external_updates_finished_callback_
;
676 // Set when the browser is terminating. Prevents us from installing or
677 // updating additional extensions and allows in-progress installations to
679 bool browser_terminating_
;
681 // Set to true to delay all new extension installations. Acts as a lock to
682 // allow background processing of garbage collection of on-disk state without
683 // needing to worry about race conditions caused by extension installation and
685 bool installs_delayed_for_gc_
;
687 // Set to true if this is the first time this ExtensionService has run.
688 // Used for specially handling external extensions that are installed the
692 // Store the ids of reloading extensions. We use this to re-enable extensions
693 // which were disabled for a reload.
694 std::set
<std::string
> reloading_extensions_
;
696 // A set of the extension ids currently being terminated. We use this to
697 // avoid trying to unload the same extension twice.
698 std::set
<std::string
> extensions_being_terminated_
;
700 // The controller for the UI that alerts the user about any blacklisted
702 scoped_ptr
<extensions::ExtensionErrorController
> error_controller_
;
704 // The manager for extensions that were externally installed that is
705 // responsible for prompting the user about suspicious extensions.
706 scoped_ptr
<extensions::ExternalInstallManager
> external_install_manager_
;
708 // Sequenced task runner for extension related file operations.
709 scoped_refptr
<base::SequencedTaskRunner
> file_task_runner_
;
711 scoped_ptr
<extensions::ExtensionActionStorageManager
>
712 extension_action_storage_manager_
;
713 scoped_ptr
<extensions::ManagementPolicy::Provider
>
714 shared_module_policy_provider_
;
716 // The SharedModuleService used to check for import dependencies.
717 scoped_ptr
<extensions::SharedModuleService
> shared_module_service_
;
719 ObserverList
<extensions::UpdateObserver
, true> update_observers_
;
721 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
722 DestroyingProfileClearsExtensions
);
723 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
, SetUnsetBlacklistInPrefs
);
724 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
725 BlacklistedExtensionWillNotInstall
);
726 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
727 UnloadBlacklistedExtensionPolicy
);
728 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
729 WillNotLoadBlacklistedExtensionsFromDirectory
);
730 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
, ReloadBlacklistedExtension
);
731 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
, BlacklistedInPrefsFromStartup
);
732 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
733 GreylistedExtensionDisabled
);
734 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
735 GreylistDontEnableManuallyDisabled
);
736 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest
,
737 GreylistUnknownDontChange
);
739 DISALLOW_COPY_AND_ASSIGN(ExtensionService
);
742 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_