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. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 7 8 #include <map> 9 #include <set> 10 #include <string> 11 #include <vector> 12 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/prefs/pref_change_registrar.h" 19 #include "base/strings/string16.h" 20 #include "chrome/browser/extensions/blacklist.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/common/extension.h" 29 #include "extensions/common/extension_set.h" 30 #include "extensions/common/manifest.h" 31 #include "sync/api/string_ordinal.h" 32 33 class ExtensionSyncService; 34 class GURL; 35 class Profile; 36 37 namespace base { 38 class CommandLine; 39 class SequencedTaskRunner; 40 class Version; 41 } 42 43 namespace content { 44 class DevToolsAgentHost; 45 } 46 47 namespace extensions { 48 class ComponentLoader; 49 class CrxInstaller; 50 class ExtensionActionStorageManager; 51 class ExtensionErrorController; 52 class ExtensionRegistry; 53 class ExtensionSystem; 54 class ExtensionUpdater; 55 class OneShotEvent; 56 class SharedModuleService; 57 class UpdateObserver; 58 } // namespace extensions 59 60 // This is an interface class to encapsulate the dependencies that 61 // various classes have on ExtensionService. This allows easy mocking. 62 class ExtensionServiceInterface 63 : public base::SupportsWeakPtr<ExtensionServiceInterface> { 64 public: ~ExtensionServiceInterface()65 virtual ~ExtensionServiceInterface() {} 66 67 // DEPRECATED: Use ExtensionRegistry::enabled_extensions() instead. 68 // ExtensionRegistry also has the disabled, terminated and blacklisted sets. 69 virtual const extensions::ExtensionSet* extensions() const = 0; 70 71 // Gets the object managing the set of pending extensions. 72 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; 73 74 // Installs an update with the contents from |extension_path|. Returns true if 75 // the install can be started. Sets |out_crx_installer| to the installer if 76 // one was started. 77 // TODO(aa): This method can be removed. ExtensionUpdater could use 78 // CrxInstaller directly instead. 79 virtual bool UpdateExtension( 80 const std::string& id, 81 const base::FilePath& path, 82 bool file_ownership_passed, 83 extensions::CrxInstaller** out_crx_installer) = 0; 84 85 // Look up an extension by ID. Does not include terminated 86 // extensions. 87 virtual const extensions::Extension* GetExtensionById( 88 const std::string& id, 89 bool include_disabled) const = 0; 90 91 // Looks up an extension by ID, regardless of whether it's enabled, 92 // disabled, blacklisted, or terminated. 93 // DEPRECATED: Replace with: 94 // ExtensionRegistry::GetExtensionById(id, ExtensionRegistry::EVERYTHING). 95 virtual const extensions::Extension* GetInstalledExtension( 96 const std::string& id) const = 0; 97 98 // Returns an update for an extension with the specified id, if installation 99 // of that update was previously delayed because the extension was in use. If 100 // no updates are pending for the extension returns NULL. 101 virtual const extensions::Extension* GetPendingExtensionUpdate( 102 const std::string& extension_id) const = 0; 103 104 // Finishes installation of an update for an extension with the specified id, 105 // when installation of that extension was previously delayed because the 106 // extension was in use. 107 virtual void FinishDelayedInstallation(const std::string& extension_id) = 0; 108 109 // Returns true if the extension with the given |extension_id| is enabled. 110 // This will return a valid answer even if the extension is not loaded yet. 111 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; 112 113 // Go through each extension and unload those that are not allowed to run by 114 // management policy providers (ie. network admin and Google-managed 115 // blacklist). 116 virtual void CheckManagementPolicy() = 0; 117 118 // Safe to call multiple times in a row. 119 // 120 // TODO(akalin): Remove this method (and others) once we refactor 121 // themes sync to not use it directly. 122 virtual void CheckForUpdatesSoon() = 0; 123 124 // Adds |extension| to this ExtensionService and notifies observers that the 125 // extensions have been loaded. 126 virtual void AddExtension(const extensions::Extension* extension) = 0; 127 128 // Check if we have preferences for the component extension and, if not or if 129 // the stored version differs, install the extension (without requirements 130 // checking) before calling AddExtension. 131 virtual void AddComponentExtension( 132 const extensions::Extension* extension) = 0; 133 134 // Unload the specified extension. 135 virtual void UnloadExtension( 136 const std::string& extension_id, 137 extensions::UnloadedExtensionInfo::Reason reason) = 0; 138 139 // Remove the specified component extension. 140 virtual void RemoveComponentExtension(const std::string& extension_id) = 0; 141 142 // Whether the extension service is ready. 143 virtual bool is_ready() = 0; 144 145 // Returns task runner for crx installation file I/O operations. 146 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; 147 }; 148 149 // Manages installed and running Chromium extensions. An instance is shared 150 // between normal and incognito profiles. 151 class ExtensionService 152 : public ExtensionServiceInterface, 153 public extensions::ExternalProviderInterface::VisitorInterface, 154 public content::NotificationObserver, 155 public extensions::Blacklist::Observer { 156 public: 157 // Attempts to uninstall an extension from a given ExtensionService. Returns 158 // true iff the target extension exists. 159 static bool UninstallExtensionHelper(ExtensionService* extensions_service, 160 const std::string& extension_id); 161 162 // Constructor stores pointers to |profile| and |extension_prefs| but 163 // ownership remains at caller. 164 ExtensionService(Profile* profile, 165 const base::CommandLine* command_line, 166 const base::FilePath& install_directory, 167 extensions::ExtensionPrefs* extension_prefs, 168 extensions::Blacklist* blacklist, 169 bool autoupdate_enabled, 170 bool extensions_enabled, 171 extensions::OneShotEvent* ready); 172 173 virtual ~ExtensionService(); 174 175 // ExtensionServiceInterface implementation: 176 virtual const extensions::ExtensionSet* extensions() const OVERRIDE; 177 virtual extensions::PendingExtensionManager* 178 pending_extension_manager() OVERRIDE; 179 virtual const extensions::Extension* GetExtensionById( 180 const std::string& id, bool include_disabled) const OVERRIDE; 181 virtual const extensions::Extension* GetInstalledExtension( 182 const std::string& id) const OVERRIDE; 183 virtual bool UpdateExtension( 184 const std::string& id, 185 const base::FilePath& extension_path, 186 bool file_ownership_passed, 187 extensions::CrxInstaller** out_crx_installer) OVERRIDE; 188 virtual bool IsExtensionEnabled( 189 const std::string& extension_id) const OVERRIDE; 190 virtual void UnloadExtension( 191 const std::string& extension_id, 192 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; 193 virtual void RemoveComponentExtension(const std::string& extension_id) 194 OVERRIDE; 195 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; 196 virtual void AddComponentExtension(const extensions::Extension* extension) 197 OVERRIDE; 198 virtual const extensions::Extension* GetPendingExtensionUpdate( 199 const std::string& extension_id) const OVERRIDE; 200 virtual void FinishDelayedInstallation( 201 const std::string& extension_id) OVERRIDE; 202 virtual void CheckManagementPolicy() OVERRIDE; 203 virtual void CheckForUpdatesSoon() OVERRIDE; 204 virtual bool is_ready() OVERRIDE; 205 virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE; 206 207 // ExternalProvider::Visitor implementation. 208 // Exposed for testing. 209 virtual bool OnExternalExtensionFileFound( 210 const std::string& id, 211 const base::Version* version, 212 const base::FilePath& path, 213 extensions::Manifest::Location location, 214 int creation_flags, 215 bool mark_acknowledged) OVERRIDE; 216 virtual bool OnExternalExtensionUpdateUrlFound( 217 const std::string& id, 218 const std::string& install_parameter, 219 const GURL& update_url, 220 extensions::Manifest::Location location, 221 int creation_flags, 222 bool mark_acknowledged) OVERRIDE; 223 virtual void OnExternalProviderReady( 224 const extensions::ExternalProviderInterface* provider) OVERRIDE; 225 226 // Getter and setter for the flag that specifies whether the extension is 227 // being reloaded. 228 bool IsBeingReloaded(const std::string& extension_id) const; 229 void SetBeingReloaded(const std::string& extension_id, bool value); 230 231 // Initialize and start all installed extensions. 232 void Init(); 233 234 // Called when the associated Profile is going to be destroyed. 235 void Shutdown(); 236 237 // Reloads the specified extension, sending the onLaunched() event to it if it 238 // currently has any window showing. 239 void ReloadExtension(const std::string& extension_id); 240 241 // Uninstalls the specified extension. Callers should only call this method 242 // with extensions that exist. |external_uninstall| is a magical parameter 243 // that is only used to send information to ExtensionPrefs, which external 244 // callers should never set to true. 245 // 246 // TODO(aa): Remove |external_uninstall| -- this information should be passed 247 // to ExtensionPrefs some other way. 248 virtual bool UninstallExtension(const std::string& extension_id, 249 bool external_uninstall, 250 base::string16* error); 251 252 // Enables the extension. If the extension is already enabled, does 253 // nothing. 254 virtual void EnableExtension(const std::string& extension_id); 255 256 // Disables the extension. If the extension is already disabled, or 257 // cannot be disabled, does nothing. 258 virtual void DisableExtension( 259 const std::string& extension_id, 260 extensions::Extension::DisableReason disable_reason); 261 262 // Disable non-default and non-managed extensions with ids not in 263 // |except_ids|. Default extensions are those from the Web Store with 264 // |was_installed_by_default| flag. 265 void DisableUserExtensions(const std::vector<std::string>& except_ids); 266 267 // Updates the |extension|'s granted permissions lists to include all 268 // permissions in the |extension|'s manifest and re-enables the 269 // extension. 270 void GrantPermissionsAndEnableExtension( 271 const extensions::Extension* extension); 272 273 // Updates the |extension|'s granted permissions lists to include all 274 // permissions in the |extensions|'s manifest. 275 void GrantPermissions(const extensions::Extension* extension); 276 277 // Check for updates (or potentially new extensions from external providers) 278 void CheckForExternalUpdates(); 279 280 // Called when the initial extensions load has completed. 281 virtual void OnLoadedInstalledExtensions(); 282 283 // Informs the service that an extension's files are in place for loading. 284 // 285 // |extension| the extension 286 // |page_ordinal| the location of the extension in the app launcher 287 // |install_flags| a bitmask of extensions::InstallFlags 288 void OnExtensionInstalled(const extensions::Extension* extension, 289 const syncer::StringOrdinal& page_ordinal, 290 int install_flags); OnExtensionInstalled(const extensions::Extension * extension,const syncer::StringOrdinal & page_ordinal)291 void OnExtensionInstalled(const extensions::Extension* extension, 292 const syncer::StringOrdinal& page_ordinal) { 293 OnExtensionInstalled(extension, 294 page_ordinal, 295 static_cast<int>(extensions::kInstallFlagNone)); 296 } 297 298 // Checks for delayed installation for all pending installs. 299 void MaybeFinishDelayedInstallations(); 300 301 // Promotes an ephemeral app to a regular installed app. Ephemeral apps 302 // are already installed in extension system (albiet transiently) and only 303 // need to be exposed in the UI. Set |is_from_sync| to true if the 304 // install was initiated via sync. 305 void PromoteEphemeralApp( 306 const extensions::Extension* extension, bool is_from_sync); 307 308 // ExtensionHost of background page calls this method right after its render 309 // view has been created. 310 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host); 311 312 // Changes sequenced task runner for crx installation tasks to |task_runner|. 313 void SetFileTaskRunnerForTesting(base::SequencedTaskRunner* task_runner); 314 315 // Checks if there are any new external extensions to notify the user about. 316 void UpdateExternalExtensionAlert(); 317 318 // Given a (presumably just-installed) extension id, mark that extension as 319 // acknowledged. 320 void AcknowledgeExternalExtension(const std::string& id); 321 322 // Disable extensions that are known to be disabled yet are currently enabled. 323 void ReconcileKnownDisabled(); 324 325 // Postpone installations so that we don't have to worry about race 326 // conditions. 327 void OnGarbageCollectIsolatedStorageStart(); 328 329 // Restart any extension installs which were delayed for isolated storage 330 // garbage collection. 331 void OnGarbageCollectIsolatedStorageFinished(); 332 333 // Record a histogram using the PermissionMessage enum values for each 334 // permission in |e|. 335 // NOTE: If this is ever called with high frequency, the implementation may 336 // need to be made more efficient. 337 static void RecordPermissionMessagesHistogram( 338 const extensions::Extension* extension, const char* histogram); 339 340 // Unloads the given extension and mark the extension as terminated. This 341 // doesn't notify the user that the extension was terminated, if such a 342 // notification is desired the calling code is responsible for doing that. 343 void TerminateExtension(const std::string& extension_id); 344 345 // Adds/Removes update observers. 346 void AddUpdateObserver(extensions::UpdateObserver* observer); 347 void RemoveUpdateObserver(extensions::UpdateObserver* observer); 348 349 ////////////////////////////////////////////////////////////////////////////// 350 // Simple Accessors 351 352 // Returns a WeakPtr to the ExtensionService. AsWeakPtr()353 base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); } 354 355 // Returns profile_ as a BrowserContext. 356 content::BrowserContext* GetBrowserContext() const; 357 extensions_enabled()358 bool extensions_enabled() const { return extensions_enabled_; } set_extensions_enabled(bool enabled)359 void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; } 360 install_directory()361 const base::FilePath& install_directory() const { return install_directory_; } 362 delayed_installs()363 const extensions::ExtensionSet* delayed_installs() const { 364 return &delayed_installs_; 365 } 366 show_extensions_prompts()367 bool show_extensions_prompts() const { return show_extensions_prompts_; } set_show_extensions_prompts(bool show_extensions_prompts)368 void set_show_extensions_prompts(bool show_extensions_prompts) { 369 show_extensions_prompts_ = show_extensions_prompts; 370 } 371 profile()372 Profile* profile() { return profile_; } 373 set_extension_sync_service(ExtensionSyncService * extension_sync_service)374 void set_extension_sync_service( 375 ExtensionSyncService* extension_sync_service) { 376 extension_sync_service_ = extension_sync_service; 377 } 378 379 // Note that this may return NULL if autoupdate is not turned on. updater()380 extensions::ExtensionUpdater* updater() { return updater_.get(); } 381 component_loader()382 extensions::ComponentLoader* component_loader() { 383 return component_loader_.get(); 384 } 385 browser_terminating()386 bool browser_terminating() const { return browser_terminating_; } 387 shared_module_service()388 extensions::SharedModuleService* shared_module_service() { 389 return shared_module_service_.get(); 390 } 391 392 ////////////////////////////////////////////////////////////////////////////// 393 // For Testing 394 395 // Unload all extensions. Does not send notifications. 396 void UnloadAllExtensionsForTest(); 397 398 // Reloads all extensions. Does not notify that extensions are ready. 399 void ReloadExtensionsForTest(); 400 401 // Clear all ExternalProviders. 402 void ClearProvidersForTesting(); 403 404 // Adds an ExternalProviderInterface for the service to use during testing. 405 // Takes ownership of |test_provider|. 406 void AddProviderForTesting( 407 extensions::ExternalProviderInterface* test_provider); 408 409 #if defined(UNIT_TEST) TrackTerminatedExtensionForTest(const extensions::Extension * extension)410 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) { 411 TrackTerminatedExtension(extension); 412 } 413 FinishInstallationForTest(const extensions::Extension * extension)414 void FinishInstallationForTest(const extensions::Extension* extension) { 415 FinishInstallation(extension, false /* not ephemeral */); 416 } 417 #endif 418 set_browser_terminating_for_test(bool value)419 void set_browser_terminating_for_test(bool value) { 420 browser_terminating_ = value; 421 } 422 423 // By default ExtensionService will wait with installing an updated extension 424 // until the extension is idle. Tests might not like this behavior, so you can 425 // disable it with this method. set_install_updates_when_idle_for_test(bool value)426 void set_install_updates_when_idle_for_test(bool value) { 427 install_updates_when_idle_ = value; 428 } 429 430 // Set a callback to be called when all external providers are ready and their 431 // extensions have been installed. set_external_updates_finished_callback_for_test(const base::Closure & callback)432 void set_external_updates_finished_callback_for_test( 433 const base::Closure& callback) { 434 external_updates_finished_callback_ = callback; 435 } 436 437 438 private: 439 // content::NotificationObserver implementation: 440 virtual void Observe(int type, 441 const content::NotificationSource& source, 442 const content::NotificationDetails& details) OVERRIDE; 443 444 // extensions::Blacklist::Observer implementation. 445 virtual void OnBlacklistUpdated() OVERRIDE; 446 447 // Similar to FinishInstallation, but first checks if there still is an update 448 // pending for the extension, and makes sure the extension is still idle. 449 void MaybeFinishDelayedInstallation(const std::string& extension_id); 450 451 // For the extension in |version_path| with |id|, check to see if it's an 452 // externally managed extension. If so, uninstall it. 453 void CheckExternalUninstall(const std::string& id); 454 455 // Populates greylist_. 456 void LoadGreylistFromPrefs(); 457 458 // Signals *ready_ and sends a notification to the listeners. 459 void SetReadyAndNotifyListeners(); 460 461 // Returns true if all the external extension providers are ready. 462 bool AreAllExternalProvidersReady() const; 463 464 // Called once all external providers are ready. Checks for unclaimed 465 // external extensions. 466 void OnAllExternalProvidersReady(); 467 468 // Returns true if this extension is an external one that has yet to be 469 // marked as acknowledged. 470 bool IsUnacknowledgedExternalExtension( 471 const extensions::Extension* extension); 472 473 // Return true if the sync type of |extension| matches |type|. 474 void OnExtensionInstallPrefChanged(); 475 476 // Adds the given extension to the list of terminated extensions if 477 // it is not already there and unloads it. 478 void TrackTerminatedExtension(const extensions::Extension* extension); 479 480 // Removes the extension with the given id from the list of 481 // terminated extensions if it is there. 482 void UntrackTerminatedExtension(const std::string& id); 483 484 // Update preferences for a new or updated extension; notify observers that 485 // the extension is installed, e.g., to update event handlers on background 486 // pages; and perform other extension install tasks before calling 487 // AddExtension. 488 // |install_flags| is a bitmask of extensions::InstallFlags. 489 void AddNewOrUpdatedExtension(const extensions::Extension* extension, 490 extensions::Extension::State initial_state, 491 int install_flags, 492 const syncer::StringOrdinal& page_ordinal, 493 const std::string& install_parameter); 494 495 // Handles sending notification that |extension| was loaded. 496 void NotifyExtensionLoaded(const extensions::Extension* extension); 497 498 // Handles sending notification that |extension| was unloaded. 499 void NotifyExtensionUnloaded( 500 const extensions::Extension* extension, 501 extensions::UnloadedExtensionInfo::Reason reason); 502 503 // Common helper to finish installing the given extension. |was_ephemeral| 504 // should be true if the extension was previously installed and ephemeral. 505 void FinishInstallation(const extensions::Extension* extension, 506 bool was_ephemeral); 507 508 // Disables the extension if the privilege level has increased 509 // (e.g., due to an upgrade). 510 void CheckPermissionsIncrease(const extensions::Extension* extension, 511 bool is_extension_installed); 512 513 // Helper that updates the active extension list used for crash reporting. 514 void UpdateActiveExtensionsInCrashReporter(); 515 516 // Helper to determine whether we should initially enable an installed 517 // (or upgraded) extension. 518 bool ShouldEnableOnInstall(const extensions::Extension* extension); 519 520 // Helper to determine if updating an extensions should proceed immediately, 521 // or if we should delay the update until further notice. 522 bool ShouldDelayExtensionUpdate(const std::string& extension_id, 523 bool install_immediately) const; 524 525 // Manages the blacklisted extensions, intended as callback from 526 // Blacklist::GetBlacklistedIDs. 527 void ManageBlacklist( 528 const extensions::Blacklist::BlacklistStateMap& blacklisted_ids); 529 530 // Add extensions in |blocked| to blacklisted_extensions, remove extensions 531 // that are neither in |blocked|, nor in |unchanged|. 532 void UpdateBlockedExtensions(const extensions::ExtensionIdSet& blocked, 533 const extensions::ExtensionIdSet& unchanged); 534 535 void UpdateGreylistedExtensions( 536 const extensions::ExtensionIdSet& greylist, 537 const extensions::ExtensionIdSet& unchanged, 538 const extensions::Blacklist::BlacklistStateMap& state_map); 539 540 // Used only by test code. 541 void UnloadAllExtensionsInternal(); 542 543 // Disable apps & extensions now to stop them from running after a profile 544 // has been conceptually deleted. Don't wait for full browser shutdown and 545 // the actual profile objects to be destroyed. 546 void OnProfileDestructionStarted(); 547 548 // Called on file task runner thread to uninstall extension. 549 static void UninstallExtensionOnFileThread( 550 const std::string& id, 551 Profile* profile, 552 const base::FilePath& install_dir, 553 const base::FilePath& extension_path); 554 555 // The normal profile associated with this ExtensionService. 556 Profile* profile_; 557 558 // The ExtensionSystem for the profile above. 559 extensions::ExtensionSystem* system_; 560 561 // Preferences for the owning profile. 562 extensions::ExtensionPrefs* extension_prefs_; 563 564 // Blacklist for the owning profile. 565 extensions::Blacklist* blacklist_; 566 567 // The ExtensionSyncService that is used by this ExtensionService. 568 ExtensionSyncService* extension_sync_service_; 569 570 // Sets of enabled/disabled/terminated/blacklisted extensions. Not owned. 571 extensions::ExtensionRegistry* registry_; 572 573 // Set of greylisted extensions. These extensions are disabled if they are 574 // already installed in Chromium at the time when they are added to 575 // the greylist. Unlike blacklisted extensions, greylisted ones are visible 576 // to the user and if user re-enables such an extension, they remain enabled. 577 // 578 // These extensions should appear in registry_. 579 extensions::ExtensionSet greylist_; 580 581 // The list of extension installs delayed for various reasons. The reason 582 // for delayed install is stored in ExtensionPrefs. These are not part of 583 // ExtensionRegistry because they are not yet installed. 584 extensions::ExtensionSet delayed_installs_; 585 586 // Hold the set of pending extensions. 587 extensions::PendingExtensionManager pending_extension_manager_; 588 589 // The full path to the directory where extensions are installed. 590 base::FilePath install_directory_; 591 592 // Whether or not extensions are enabled. 593 bool extensions_enabled_; 594 595 // Whether to notify users when they attempt to install an extension. 596 bool show_extensions_prompts_; 597 598 // Whether to delay installing of extension updates until the extension is 599 // idle. 600 bool install_updates_when_idle_; 601 602 // Signaled when all extensions are loaded. 603 extensions::OneShotEvent* const ready_; 604 605 // Our extension updater, if updates are turned on. 606 scoped_ptr<extensions::ExtensionUpdater> updater_; 607 608 // Map unloaded extensions' ids to their paths. When a temporarily loaded 609 // extension is unloaded, we lose the information about it and don't have 610 // any in the extension preferences file. 611 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; 612 UnloadedExtensionPathMap unloaded_extension_paths_; 613 614 // Map of DevToolsAgentHost instances that are detached, 615 // waiting for an extension to be reloaded. 616 typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> > 617 OrphanedDevTools; 618 OrphanedDevTools orphaned_dev_tools_; 619 620 content::NotificationRegistrar registrar_; 621 PrefChangeRegistrar pref_change_registrar_; 622 623 // Keeps track of loading and unloading component extensions. 624 scoped_ptr<extensions::ComponentLoader> component_loader_; 625 626 // A collection of external extension providers. Each provider reads 627 // a source of external extension information. Examples include the 628 // windows registry and external_extensions.json. 629 extensions::ProviderCollection external_extension_providers_; 630 631 // Set to true by OnExternalExtensionUpdateUrlFound() when an external 632 // extension URL is found, and by CheckForUpdatesSoon() when an update check 633 // has to wait for the external providers. Used in 634 // OnAllExternalProvidersReady() to determine if an update check is needed to 635 // install pending extensions. 636 bool update_once_all_providers_are_ready_; 637 638 // A callback to be called when all external providers are ready and their 639 // extensions have been installed. Normally this is a null callback, but 640 // is used in external provider related tests. 641 base::Closure external_updates_finished_callback_; 642 643 // Set when the browser is terminating. Prevents us from installing or 644 // updating additional extensions and allows in-progress installations to 645 // decide to abort. 646 bool browser_terminating_; 647 648 // Set to true to delay all new extension installations. Acts as a lock to 649 // allow background processing of garbage collection of on-disk state without 650 // needing to worry about race conditions caused by extension installation and 651 // reinstallation. 652 bool installs_delayed_for_gc_; 653 654 // Set to true if this is the first time this ExtensionService has run. 655 // Used for specially handling external extensions that are installed the 656 // first time. 657 bool is_first_run_; 658 659 // TODO(rdevlin.cronin): Okay, clearly something is very wrong with this 660 // picture... 661 // A set of the extension ids currently being reloaded. We use this to 662 // avoid showing a "new install" notice for an extension reinstall. 663 std::set<std::string> extensions_being_reloaded_; 664 // Store the ids of reloading extensions. We use this to re-enable extensions 665 // which were disabled for a reload. 666 std::set<std::string> reloading_extensions_; 667 668 // A set of the extension ids currently being terminated. We use this to 669 // avoid trying to unload the same extension twice. 670 std::set<std::string> extensions_being_terminated_; 671 672 // The controller for the UI that alerts the user about any blacklisted 673 // extensions. 674 scoped_ptr<extensions::ExtensionErrorController> error_controller_; 675 676 // Sequenced task runner for extension related file operations. 677 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 678 679 #if defined(ENABLE_EXTENSIONS) 680 scoped_ptr<extensions::ExtensionActionStorageManager> 681 extension_action_storage_manager_; 682 #endif 683 scoped_ptr<extensions::ManagementPolicy::Provider> 684 shared_module_policy_provider_; 685 686 // The SharedModuleService used to check for import dependencies. 687 scoped_ptr<extensions::SharedModuleService> shared_module_service_; 688 689 ObserverList<extensions::UpdateObserver, true> update_observers_; 690 691 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 692 DestroyingProfileClearsExtensions); 693 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, SetUnsetBlacklistInPrefs); 694 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 695 BlacklistedExtensionWillNotInstall); 696 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 697 UnloadBlacklistedExtensionPolicy); 698 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 699 WillNotLoadBlacklistedExtensionsFromDirectory); 700 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ReloadBlacklistedExtension); 701 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, BlacklistedInPrefsFromStartup); 702 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 703 GreylistedExtensionDisabled); 704 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 705 GreylistDontEnableManuallyDisabled); 706 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 707 GreylistUnknownDontChange); 708 709 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 710 }; 711 712 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 713