| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/memory/linked_ptr.h" | 19 #include "base/memory/linked_ptr.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/property_bag.h" | 22 #include "base/property_bag.h" |
| 23 #include "base/time.h" | 23 #include "base/time.h" |
| 24 #include "base/tuple.h" | 24 #include "base/tuple.h" |
| 25 #include "chrome/browser/extensions/app_shortcut_manager.h" |
| 25 #include "chrome/browser/extensions/apps_promo.h" | 26 #include "chrome/browser/extensions/apps_promo.h" |
| 26 #include "chrome/browser/extensions/extension_icon_manager.h" | 27 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 27 #include "chrome/browser/extensions/extension_menu_manager.h" | 28 #include "chrome/browser/extensions/extension_menu_manager.h" |
| 28 #include "chrome/browser/extensions/extension_prefs.h" | 29 #include "chrome/browser/extensions/extension_prefs.h" |
| 29 #include "chrome/browser/extensions/extension_process_manager.h" | 30 #include "chrome/browser/extensions/extension_process_manager.h" |
| 30 #include "chrome/browser/extensions/extension_sync_data.h" | 31 #include "chrome/browser/extensions/extension_sync_data.h" |
| 31 #include "chrome/browser/extensions/extension_toolbar_model.h" | 32 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 32 #include "chrome/browser/extensions/extension_warning_set.h" | 33 #include "chrome/browser/extensions/extension_warning_set.h" |
| 33 #include "chrome/browser/extensions/extensions_quota_service.h" | 34 #include "chrome/browser/extensions/extensions_quota_service.h" |
| 34 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 35 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
| 35 #include "chrome/browser/extensions/pending_extension_manager.h" | 36 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 36 #include "chrome/browser/extensions/process_map.h" | 37 #include "chrome/browser/extensions/process_map.h" |
| 37 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 38 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
| 38 #include "chrome/browser/prefs/pref_change_registrar.h" | 39 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 39 #include "chrome/browser/shell_integration.h" | |
| 40 #include "chrome/browser/sync/api/sync_change.h" | 40 #include "chrome/browser/sync/api/sync_change.h" |
| 41 #include "chrome/browser/sync/api/syncable_service.h" | 41 #include "chrome/browser/sync/api/syncable_service.h" |
| 42 #include "chrome/common/extensions/extension.h" | 42 #include "chrome/common/extensions/extension.h" |
| 43 #include "chrome/common/extensions/extension_constants.h" | 43 #include "chrome/common/extensions/extension_constants.h" |
| 44 #include "chrome/common/extensions/extension_set.h" | 44 #include "chrome/common/extensions/extension_set.h" |
| 45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/notification_observer.h" | 46 #include "content/public/browser/notification_observer.h" |
| 47 #include "content/public/browser/notification_registrar.h" | 47 #include "content/public/browser/notification_registrar.h" |
| 48 | 48 |
| 49 class AppNotificationManager; | 49 class AppNotificationManager; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 extension_misc::UnloadedExtensionReason reason) = 0; | 124 extension_misc::UnloadedExtensionReason reason) = 0; |
| 125 | 125 |
| 126 virtual bool is_ready() = 0; | 126 virtual bool is_ready() = 0; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 // Manages installed and running Chromium extensions. | 129 // Manages installed and running Chromium extensions. |
| 130 class ExtensionService | 130 class ExtensionService |
| 131 : public ExtensionServiceInterface, | 131 : public ExtensionServiceInterface, |
| 132 public ExternalExtensionProviderInterface::VisitorInterface, | 132 public ExternalExtensionProviderInterface::VisitorInterface, |
| 133 public base::SupportsWeakPtr<ExtensionService>, | 133 public base::SupportsWeakPtr<ExtensionService>, |
| 134 public content::NotificationObserver, | 134 public content::NotificationObserver { |
| 135 public ImageLoadingTracker::Observer { | |
| 136 public: | 135 public: |
| 137 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr; | 136 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr; |
| 138 | 137 |
| 139 // The name of the directory inside the profile where extensions are | 138 // The name of the directory inside the profile where extensions are |
| 140 // installed to. | 139 // installed to. |
| 141 static const char* kInstallDirectoryName; | 140 static const char* kInstallDirectoryName; |
| 142 | 141 |
| 143 // If auto-updates are turned on, default to running every 5 hours. | 142 // If auto-updates are turned on, default to running every 5 hours. |
| 144 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 143 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
| 145 | 144 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 569 } |
| 571 #endif | 570 #endif |
| 572 | 571 |
| 573 ExtensionWarningSet* extension_warnings() { | 572 ExtensionWarningSet* extension_warnings() { |
| 574 return &extension_warnings_; | 573 return &extension_warnings_; |
| 575 } | 574 } |
| 576 | 575 |
| 577 // Call only from IO thread. | 576 // Call only from IO thread. |
| 578 extensions::SocketController* socket_controller(); | 577 extensions::SocketController* socket_controller(); |
| 579 | 578 |
| 580 // Implement ImageLoadingTracker::Observer. |tracker_| is used to | 579 AppShortcutManager* app_shortcut_manager() { return &app_shortcut_manager_; } |
| 581 // load the application's icon, which is done when we start creating an | 580 |
| 582 // application's shortcuts. This method receives the icon, and completes | |
| 583 // the process of installing the shortcuts. | |
| 584 virtual void OnImageLoaded(SkBitmap* image, | |
| 585 const ExtensionResource& resource, | |
| 586 int index) OVERRIDE; | |
| 587 private: | 581 private: |
| 588 // Bundle of type (app or extension)-specific sync stuff. | 582 // Bundle of type (app or extension)-specific sync stuff. |
| 589 struct SyncBundle { | 583 struct SyncBundle { |
| 590 SyncBundle(); | 584 SyncBundle(); |
| 591 ~SyncBundle(); | 585 ~SyncBundle(); |
| 592 | 586 |
| 593 bool HasExtensionId(const std::string& id) const; | 587 bool HasExtensionId(const std::string& id) const; |
| 594 bool HasPendingExtensionId(const std::string& id) const; | 588 bool HasPendingExtensionId(const std::string& id) const; |
| 595 | 589 |
| 596 ExtensionFilter filter; | 590 ExtensionFilter filter; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 // type, just the ones that are responsible for rendering a particular MIME | 685 // type, just the ones that are responsible for rendering a particular MIME |
| 692 // type, like application/pdf. Note: We only register NaCl modules in the | 686 // type, like application/pdf. Note: We only register NaCl modules in the |
| 693 // browser process. | 687 // browser process. |
| 694 void RegisterNaClModule(const GURL& url, const std::string& mime_type); | 688 void RegisterNaClModule(const GURL& url, const std::string& mime_type); |
| 695 void UnregisterNaClModule(const GURL& url); | 689 void UnregisterNaClModule(const GURL& url); |
| 696 | 690 |
| 697 // Call UpdatePluginListWithNaClModules() after registering or unregistering | 691 // Call UpdatePluginListWithNaClModules() after registering or unregistering |
| 698 // a NaCl module to see those changes reflected in the PluginList. | 692 // a NaCl module to see those changes reflected in the PluginList. |
| 699 void UpdatePluginListWithNaClModules(); | 693 void UpdatePluginListWithNaClModules(); |
| 700 | 694 |
| 701 // Start the process of installing an application shortcut. | |
| 702 // The process is finished when OnImageLoaded is called. | |
| 703 void StartInstallApplicationShortcut(const Extension* extension); | |
| 704 | |
| 705 NaClModuleInfoList::iterator FindNaClModule(const GURL& url); | 695 NaClModuleInfoList::iterator FindNaClModule(const GURL& url); |
| 706 | 696 |
| 707 // The profile this ExtensionService is part of. | 697 // The profile this ExtensionService is part of. |
| 708 Profile* profile_; | 698 Profile* profile_; |
| 709 | 699 |
| 710 // Preferences for the owning profile (weak reference). | 700 // Preferences for the owning profile (weak reference). |
| 711 ExtensionPrefs* extension_prefs_; | 701 ExtensionPrefs* extension_prefs_; |
| 712 | 702 |
| 713 // Settings for the owning profile. | 703 // Settings for the owning profile. |
| 714 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; | 704 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 824 |
| 835 // Contains an entry for each warning that shall be currently shown. | 825 // Contains an entry for each warning that shall be currently shown. |
| 836 ExtensionWarningSet extension_warnings_; | 826 ExtensionWarningSet extension_warnings_; |
| 837 | 827 |
| 838 // We need to control destruction of this object (it needs to happen on the | 828 // We need to control destruction of this object (it needs to happen on the |
| 839 // IO thread), so we don't get to use any RAII devices with it. | 829 // IO thread), so we don't get to use any RAII devices with it. |
| 840 extensions::SocketController* socket_controller_; | 830 extensions::SocketController* socket_controller_; |
| 841 | 831 |
| 842 extensions::ProcessMap process_map_; | 832 extensions::ProcessMap process_map_; |
| 843 | 833 |
| 844 // Fields used when installing application shortcuts. | 834 AppShortcutManager app_shortcut_manager_; |
| 845 ShellIntegration::ShortcutInfo shortcut_info_; | |
| 846 ImageLoadingTracker tracker_; | |
| 847 | 835 |
| 848 scoped_ptr<ExtensionGlobalError> extension_global_error_; | 836 scoped_ptr<ExtensionGlobalError> extension_global_error_; |
| 849 | 837 |
| 850 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 838 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 851 InstallAppsWithUnlimtedStorage); | 839 InstallAppsWithUnlimtedStorage); |
| 852 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 840 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 853 InstallAppsAndCheckStorageProtection); | 841 InstallAppsAndCheckStorageProtection); |
| 854 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 842 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 855 }; | 843 }; |
| 856 | 844 |
| 857 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 845 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |