| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 const FilePath& install_directory, | 190 const FilePath& install_directory, |
| 191 ExtensionPrefs* extension_prefs, | 191 ExtensionPrefs* extension_prefs, |
| 192 bool autoupdate_enabled, | 192 bool autoupdate_enabled, |
| 193 bool extensions_enabled); | 193 bool extensions_enabled); |
| 194 | 194 |
| 195 virtual ~ExtensionService(); | 195 virtual ~ExtensionService(); |
| 196 | 196 |
| 197 // Gets the list of currently installed extensions. | 197 // Gets the list of currently installed extensions. |
| 198 virtual const ExtensionSet* extensions() const OVERRIDE; | 198 virtual const ExtensionSet* extensions() const OVERRIDE; |
| 199 const ExtensionSet* disabled_extensions() const; | 199 const ExtensionSet* disabled_extensions() const; |
| 200 const ExtensionSet* terminated_extensions() const; | |
| 201 | 200 |
| 202 // Retuns a set of all installed, disabled, and terminated extensions and | 201 // Retuns a set of all installed and disabled extensions, and transfers |
| 203 // transfers ownership to caller. | 202 // ownership to caller. |
| 204 const ExtensionSet* GenerateInstalledExtensionsSet() const; | 203 const ExtensionSet* GenerateInstalledExtensionsSet() const; |
| 205 | 204 |
| 206 // Gets the object managing the set of pending extensions. | 205 // Gets the object managing the set of pending extensions. |
| 207 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE; | 206 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE; |
| 208 | 207 |
| 209 const FilePath& install_directory() const { return install_directory_; } | 208 const FilePath& install_directory() const { return install_directory_; } |
| 210 | 209 |
| 211 AppsPromo* apps_promo() { return &apps_promo_; } | 210 AppsPromo* apps_promo() { return &apps_promo_; } |
| 212 | 211 |
| 213 extensions::ProcessMap* process_map() { return &process_map_; } | 212 extensions::ProcessMap* process_map() { return &process_map_; } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // TODO(yoz): remove InitEventRoutersAterImport. | 289 // TODO(yoz): remove InitEventRoutersAterImport. |
| 291 void InitEventRoutersAfterImport(); | 290 void InitEventRoutersAfterImport(); |
| 292 void RegisterForImportFinished(); | 291 void RegisterForImportFinished(); |
| 293 | 292 |
| 294 // Complete some initialization after being notified that import has finished. | 293 // Complete some initialization after being notified that import has finished. |
| 295 void InitAfterImport(); | 294 void InitAfterImport(); |
| 296 | 295 |
| 297 // Start up the extension event routers. | 296 // Start up the extension event routers. |
| 298 void InitEventRouters(); | 297 void InitEventRouters(); |
| 299 | 298 |
| 300 // Look up an extension by ID. Does not include terminated | 299 // Look up an extension by ID. |
| 301 // extensions. | |
| 302 virtual const Extension* GetExtensionById( | 300 virtual const Extension* GetExtensionById( |
| 303 const std::string& id, bool include_disabled) const OVERRIDE; | 301 const std::string& id, bool include_disabled) const OVERRIDE; |
| 304 | 302 |
| 305 // Looks up a terminated (crashed) extension by ID. | 303 // Looks up an extension by ID, regardless of whether it's enabled or |
| 306 const Extension* GetTerminatedExtension(const std::string& id) const; | 304 // disabled. |
| 307 | |
| 308 // Looks up an extension by ID, regardless of whether it's enabled, | |
| 309 // disabled, or terminated. | |
| 310 virtual const Extension* GetInstalledExtension( | 305 virtual const Extension* GetInstalledExtension( |
| 311 const std::string& id) const OVERRIDE; | 306 const std::string& id) const OVERRIDE; |
| 312 | 307 |
| 313 // Updates a currently-installed extension with the contents from | 308 // Updates a currently-installed extension with the contents from |
| 314 // |extension_path|. | 309 // |extension_path|. |
| 315 // TODO(aa): This method can be removed. ExtensionUpdater could use | 310 // TODO(aa): This method can be removed. ExtensionUpdater could use |
| 316 // CrxInstaller directly instead. | 311 // CrxInstaller directly instead. |
| 317 virtual bool UpdateExtension( | 312 virtual bool UpdateExtension( |
| 318 const std::string& id, | 313 const std::string& id, |
| 319 const FilePath& extension_path, | 314 const FilePath& extension_path, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // Gets the set of loaded app ids. Component apps are not included. | 552 // Gets the set of loaded app ids. Component apps are not included. |
| 558 ExtensionIdSet GetAppIds() const; | 553 ExtensionIdSet GetAppIds() const; |
| 559 | 554 |
| 560 // Record a histogram using the PermissionMessage enum values for each | 555 // Record a histogram using the PermissionMessage enum values for each |
| 561 // permission in |e|. | 556 // permission in |e|. |
| 562 // NOTE: If this is ever called with high frequency, the implementation may | 557 // NOTE: If this is ever called with high frequency, the implementation may |
| 563 // need to be made more efficient. | 558 // need to be made more efficient. |
| 564 static void RecordPermissionMessagesHistogram( | 559 static void RecordPermissionMessagesHistogram( |
| 565 const Extension* e, const char* histogram); | 560 const Extension* e, const char* histogram); |
| 566 | 561 |
| 567 #if defined(UNIT_TEST) | |
| 568 void TrackTerminatedExtensionForTest(const Extension* extension) { | |
| 569 TrackTerminatedExtension(extension); | |
| 570 } | |
| 571 #endif | |
| 572 | |
| 573 ExtensionWarningSet* extension_warnings() { | 562 ExtensionWarningSet* extension_warnings() { |
| 574 return &extension_warnings_; | 563 return &extension_warnings_; |
| 575 } | 564 } |
| 576 | 565 |
| 577 // Call only from IO thread. | 566 // Call only from IO thread. |
| 578 extensions::SocketController* socket_controller(); | 567 extensions::SocketController* socket_controller(); |
| 579 | 568 |
| 580 // Implement ImageLoadingTracker::Observer. |tracker_| is used to | 569 // Implement ImageLoadingTracker::Observer. |tracker_| is used to |
| 581 // load the application's icon, which is done when we start creating an | 570 // load the application's icon, which is done when we start creating an |
| 582 // application's shortcuts. This method receives the icon, and completes | 571 // application's shortcuts. This method receives the icon, and completes |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 646 |
| 658 // Applies the change specified in an ExtensionSyncData to the current system. | 647 // Applies the change specified in an ExtensionSyncData to the current system. |
| 659 void ProcessExtensionSyncData( | 648 void ProcessExtensionSyncData( |
| 660 const ExtensionSyncData& extension_sync_data, | 649 const ExtensionSyncData& extension_sync_data, |
| 661 SyncBundle& bundle); | 650 SyncBundle& bundle); |
| 662 | 651 |
| 663 // Look up an extension by ID, optionally including either or both of enabled | 652 // Look up an extension by ID, optionally including either or both of enabled |
| 664 // and disabled extensions. | 653 // and disabled extensions. |
| 665 const Extension* GetExtensionByIdInternal(const std::string& id, | 654 const Extension* GetExtensionByIdInternal(const std::string& id, |
| 666 bool include_enabled, | 655 bool include_enabled, |
| 667 bool include_disabled, | 656 bool include_disabled) const; |
| 668 bool include_terminated) const; | |
| 669 | |
| 670 // Adds the given extension to the list of terminated extensions if | |
| 671 // it is not already there and unloads it. | |
| 672 void TrackTerminatedExtension(const Extension* extension); | |
| 673 | |
| 674 // Removes the extension with the given id from the list of | |
| 675 // terminated extensions if it is there. | |
| 676 void UntrackTerminatedExtension(const std::string& id); | |
| 677 | 657 |
| 678 // Handles sending notification that |extension| was loaded. | 658 // Handles sending notification that |extension| was loaded. |
| 679 void NotifyExtensionLoaded(const Extension* extension); | 659 void NotifyExtensionLoaded(const Extension* extension); |
| 680 | 660 |
| 681 // Handles sending notification that |extension| was unloaded. | 661 // Handles sending notification that |extension| was unloaded. |
| 682 void NotifyExtensionUnloaded(const Extension* extension, | 662 void NotifyExtensionUnloaded(const Extension* extension, |
| 683 extension_misc::UnloadedExtensionReason reason); | 663 extension_misc::UnloadedExtensionReason reason); |
| 684 | 664 |
| 685 // Helper that updates the active extension list used for crash reporting. | 665 // Helper that updates the active extension list used for crash reporting. |
| 686 void UpdateActiveExtensionsInCrashReporter(); | 666 void UpdateActiveExtensionsInCrashReporter(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 713 // Settings for the owning profile. | 693 // Settings for the owning profile. |
| 714 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; | 694 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
| 715 | 695 |
| 716 // The current list of installed extensions. | 696 // The current list of installed extensions. |
| 717 // TODO(aa): This should use chrome/common/extensions/extension_set.h. | 697 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
| 718 ExtensionSet extensions_; | 698 ExtensionSet extensions_; |
| 719 | 699 |
| 720 // The list of installed extensions that have been disabled. | 700 // The list of installed extensions that have been disabled. |
| 721 ExtensionSet disabled_extensions_; | 701 ExtensionSet disabled_extensions_; |
| 722 | 702 |
| 723 // The list of installed extensions that have been terminated. | |
| 724 ExtensionSet terminated_extensions_; | |
| 725 | |
| 726 // Hold the set of pending extensions. | 703 // Hold the set of pending extensions. |
| 727 PendingExtensionManager pending_extension_manager_; | 704 PendingExtensionManager pending_extension_manager_; |
| 728 | 705 |
| 729 // The map of extension IDs to their runtime data. | 706 // The map of extension IDs to their runtime data. |
| 730 ExtensionRuntimeDataMap extension_runtime_data_; | 707 ExtensionRuntimeDataMap extension_runtime_data_; |
| 731 | 708 |
| 732 // Holds a map between renderer process IDs that are associated with an | 709 // Holds a map between renderer process IDs that are associated with an |
| 733 // installed app and their app. | 710 // installed app and their app. |
| 734 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; | 711 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; |
| 735 InstalledAppMap installed_app_hosts_; | 712 InstalledAppMap installed_app_hosts_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 scoped_ptr<ExtensionGlobalError> extension_global_error_; | 825 scoped_ptr<ExtensionGlobalError> extension_global_error_; |
| 849 | 826 |
| 850 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 827 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 851 InstallAppsWithUnlimtedStorage); | 828 InstallAppsWithUnlimtedStorage); |
| 852 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 829 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 853 InstallAppsAndCheckStorageProtection); | 830 InstallAppsAndCheckStorageProtection); |
| 854 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 831 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 855 }; | 832 }; |
| 856 | 833 |
| 857 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 834 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |