| 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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/prefs/pref_change_registrar.h" | 19 #include "base/prefs/pref_change_registrar.h" |
| 20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "chrome/browser/extensions/blacklist.h" | 21 #include "chrome/browser/extensions/blacklist.h" |
| 22 #include "chrome/browser/extensions/extension_function_histogram_value.h" | 22 #include "chrome/browser/extensions/extension_function_histogram_value.h" |
| 23 #include "chrome/browser/extensions/extension_prefs.h" | 23 #include "chrome/browser/extensions/extension_prefs.h" |
| 24 #include "chrome/browser/extensions/extension_sync_service.h" | 24 #include "chrome/browser/extensions/extension_sync_service.h" |
| 25 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 26 #include "chrome/common/extensions/extension_set.h" | |
| 27 #include "content/public/browser/devtools_agent_host.h" | 26 #include "content/public/browser/devtools_agent_host.h" |
| 28 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| 29 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
| 30 #include "extensions/browser/external_provider_interface.h" | 29 #include "extensions/browser/external_provider_interface.h" |
| 31 #include "extensions/browser/management_policy.h" | 30 #include "extensions/browser/management_policy.h" |
| 32 #include "extensions/browser/pending_extension_manager.h" | 31 #include "extensions/browser/pending_extension_manager.h" |
| 33 #include "extensions/browser/process_manager.h" | 32 #include "extensions/browser/process_manager.h" |
| 34 #include "extensions/browser/process_map.h" | 33 #include "extensions/browser/process_map.h" |
| 35 #include "extensions/browser/quota_service.h" | 34 #include "extensions/browser/quota_service.h" |
| 36 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
| 36 #include "extensions/common/extension_set.h" |
| 37 #include "extensions/common/manifest.h" | 37 #include "extensions/common/manifest.h" |
| 38 #include "extensions/common/manifest_handlers/shared_module_info.h" | 38 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 39 #include "extensions/common/one_shot_event.h" | 39 #include "extensions/common/one_shot_event.h" |
| 40 | 40 |
| 41 class CommandLine; | 41 class CommandLine; |
| 42 class ExtensionErrorUI; | 42 class ExtensionErrorUI; |
| 43 class ExtensionToolbarModel; | 43 class ExtensionToolbarModel; |
| 44 class GURL; | 44 class GURL; |
| 45 class Profile; | 45 class Profile; |
| 46 | 46 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 namespace syncer { | 65 namespace syncer { |
| 66 class SyncErrorFactory; | 66 class SyncErrorFactory; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // This is an interface class to encapsulate the dependencies that | 69 // This is an interface class to encapsulate the dependencies that |
| 70 // various classes have on ExtensionService. This allows easy mocking. | 70 // various classes have on ExtensionService. This allows easy mocking. |
| 71 class ExtensionServiceInterface | 71 class ExtensionServiceInterface |
| 72 : public base::SupportsWeakPtr<ExtensionServiceInterface> { | 72 : public base::SupportsWeakPtr<ExtensionServiceInterface> { |
| 73 public: | 73 public: |
| 74 virtual ~ExtensionServiceInterface() {} | 74 virtual ~ExtensionServiceInterface() {} |
| 75 virtual const ExtensionSet* extensions() const = 0; | 75 virtual const extensions::ExtensionSet* extensions() const = 0; |
| 76 virtual const ExtensionSet* disabled_extensions() const = 0; | 76 virtual const extensions::ExtensionSet* disabled_extensions() const = 0; |
| 77 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; | 77 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; |
| 78 | 78 |
| 79 // Install an update. Return true if the install can be started. | 79 // Install an update. Return true if the install can be started. |
| 80 // Set out_crx_installer to the installer if one was started. | 80 // Set out_crx_installer to the installer if one was started. |
| 81 virtual bool UpdateExtension( | 81 virtual bool UpdateExtension( |
| 82 const std::string& id, | 82 const std::string& id, |
| 83 const base::FilePath& path, | 83 const base::FilePath& path, |
| 84 const GURL& download_url, | 84 const GURL& download_url, |
| 85 extensions::CrxInstaller** out_crx_installer) = 0; | 85 extensions::CrxInstaller** out_crx_installer) = 0; |
| 86 virtual const extensions::Extension* GetExtensionById( | 86 virtual const extensions::Extension* GetExtensionById( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 const base::FilePath& install_directory, | 145 const base::FilePath& install_directory, |
| 146 extensions::ExtensionPrefs* extension_prefs, | 146 extensions::ExtensionPrefs* extension_prefs, |
| 147 extensions::Blacklist* blacklist, | 147 extensions::Blacklist* blacklist, |
| 148 bool autoupdate_enabled, | 148 bool autoupdate_enabled, |
| 149 bool extensions_enabled, | 149 bool extensions_enabled, |
| 150 extensions::OneShotEvent* ready); | 150 extensions::OneShotEvent* ready); |
| 151 | 151 |
| 152 virtual ~ExtensionService(); | 152 virtual ~ExtensionService(); |
| 153 | 153 |
| 154 // Gets the list of currently installed extensions. | 154 // Gets the list of currently installed extensions. |
| 155 virtual const ExtensionSet* extensions() const OVERRIDE; | 155 virtual const extensions::ExtensionSet* extensions() const OVERRIDE; |
| 156 virtual const ExtensionSet* disabled_extensions() const OVERRIDE; | 156 virtual const extensions::ExtensionSet* disabled_extensions() const OVERRIDE; |
| 157 const ExtensionSet* terminated_extensions() const; | 157 const extensions::ExtensionSet* terminated_extensions() const; |
| 158 const ExtensionSet* blacklisted_extensions() const; | 158 const extensions::ExtensionSet* blacklisted_extensions() const; |
| 159 const ExtensionSet* delayed_installs() const; | 159 const extensions::ExtensionSet* delayed_installs() const; |
| 160 | 160 |
| 161 // Returns a set of all installed, disabled, blacklisted, and terminated | 161 // Returns a set of all installed, disabled, blacklisted, and terminated |
| 162 // extensions. | 162 // extensions. |
| 163 scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const; | 163 scoped_ptr<extensions::ExtensionSet> GenerateInstalledExtensionsSet() const; |
| 164 | 164 |
| 165 // Gets the object managing the set of pending extensions. | 165 // Gets the object managing the set of pending extensions. |
| 166 virtual extensions::PendingExtensionManager* | 166 virtual extensions::PendingExtensionManager* |
| 167 pending_extension_manager() OVERRIDE; | 167 pending_extension_manager() OVERRIDE; |
| 168 | 168 |
| 169 const base::FilePath& install_directory() const { return install_directory_; } | 169 const base::FilePath& install_directory() const { return install_directory_; } |
| 170 | 170 |
| 171 extensions::ProcessMap* process_map() { return &process_map_; } | 171 extensions::ProcessMap* process_map() { return &process_map_; } |
| 172 | 172 |
| 173 // Updates the app launcher value for the moved extension so that it is now | 173 // Updates the app launcher value for the moved extension so that it is now |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 const extensions::Extension* extension, | 356 const extensions::Extension* extension, |
| 357 std::list<extensions::SharedModuleInfo::ImportInfo>* missing_modules, | 357 std::list<extensions::SharedModuleInfo::ImportInfo>* missing_modules, |
| 358 std::list<extensions::SharedModuleInfo::ImportInfo>* outdated_modules); | 358 std::list<extensions::SharedModuleInfo::ImportInfo>* outdated_modules); |
| 359 | 359 |
| 360 // Checks an extension's shared module imports to see if they are satisfied. | 360 // Checks an extension's shared module imports to see if they are satisfied. |
| 361 // If they are not, this function adds the dependencies to the pending install | 361 // If they are not, this function adds the dependencies to the pending install |
| 362 // list if |extension| came from the webstore. | 362 // list if |extension| came from the webstore. |
| 363 ImportStatus SatisfyImports(const extensions::Extension* extension); | 363 ImportStatus SatisfyImports(const extensions::Extension* extension); |
| 364 | 364 |
| 365 // Returns a set of extensions that import a given extension. | 365 // Returns a set of extensions that import a given extension. |
| 366 scoped_ptr<const ExtensionSet> GetDependentExtensions( | 366 scoped_ptr<const extensions::ExtensionSet> GetDependentExtensions( |
| 367 const extensions::Extension* extension); | 367 const extensions::Extension* extension); |
| 368 | 368 |
| 369 // Uninstalls shared modules that were only referenced by |extension|. | 369 // Uninstalls shared modules that were only referenced by |extension|. |
| 370 void PruneSharedModulesOnUninstall(const extensions::Extension* extension); | 370 void PruneSharedModulesOnUninstall(const extensions::Extension* extension); |
| 371 | 371 |
| 372 // Informs the service that an extension's files are in place for loading. | 372 // Informs the service that an extension's files are in place for loading. |
| 373 // | 373 // |
| 374 // |page_ordinal| is the location of the extension in the app launcher. | 374 // |page_ordinal| is the location of the extension in the app launcher. |
| 375 // |has_requirement_errors| is true if requirements of the extension weren't | 375 // |has_requirement_errors| is true if requirements of the extension weren't |
| 376 // met (for example graphics capabilities). | 376 // met (for example graphics capabilities). |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 // Blacklist for the owning profile. | 714 // Blacklist for the owning profile. |
| 715 extensions::Blacklist* blacklist_; | 715 extensions::Blacklist* blacklist_; |
| 716 | 716 |
| 717 // Settings for the owning profile. | 717 // Settings for the owning profile. |
| 718 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; | 718 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
| 719 | 719 |
| 720 // The ExtensionSyncService that is used by this ExtensionService. | 720 // The ExtensionSyncService that is used by this ExtensionService. |
| 721 ExtensionSyncService* extension_sync_service_; | 721 ExtensionSyncService* extension_sync_service_; |
| 722 | 722 |
| 723 // The current list of installed extensions. | 723 // The current list of installed extensions. |
| 724 ExtensionSet extensions_; | 724 extensions::ExtensionSet extensions_; |
| 725 | 725 |
| 726 // The list of installed extensions that have been disabled. | 726 // The list of installed extensions that have been disabled. |
| 727 ExtensionSet disabled_extensions_; | 727 extensions::ExtensionSet disabled_extensions_; |
| 728 | 728 |
| 729 // The list of installed extensions that have been terminated. | 729 // The list of installed extensions that have been terminated. |
| 730 ExtensionSet terminated_extensions_; | 730 extensions::ExtensionSet terminated_extensions_; |
| 731 | 731 |
| 732 // The list of installed extensions that have been blacklisted. Generally | 732 // The list of installed extensions that have been blacklisted. Generally |
| 733 // these shouldn't be considered as installed by the extension platform: we | 733 // these shouldn't be considered as installed by the extension platform: we |
| 734 // only keep them around so that if extensions are blacklisted by mistake | 734 // only keep them around so that if extensions are blacklisted by mistake |
| 735 // they can easily be un-blacklisted. | 735 // they can easily be un-blacklisted. |
| 736 ExtensionSet blacklisted_extensions_; | 736 extensions::ExtensionSet blacklisted_extensions_; |
| 737 | 737 |
| 738 // The list of extension installs delayed for various reasons. The reason | 738 // The list of extension installs delayed for various reasons. The reason |
| 739 // for delayed install is stored in ExtensionPrefs. | 739 // for delayed install is stored in ExtensionPrefs. |
| 740 ExtensionSet delayed_installs_; | 740 extensions::ExtensionSet delayed_installs_; |
| 741 | 741 |
| 742 // Hold the set of pending extensions. | 742 // Hold the set of pending extensions. |
| 743 extensions::PendingExtensionManager pending_extension_manager_; | 743 extensions::PendingExtensionManager pending_extension_manager_; |
| 744 | 744 |
| 745 // The map of extension IDs to their runtime data. | 745 // The map of extension IDs to their runtime data. |
| 746 ExtensionRuntimeDataMap extension_runtime_data_; | 746 ExtensionRuntimeDataMap extension_runtime_data_; |
| 747 | 747 |
| 748 // The full path to the directory where extensions are installed. | 748 // The full path to the directory where extensions are installed. |
| 749 base::FilePath install_directory_; | 749 base::FilePath install_directory_; |
| 750 | 750 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 #endif | 844 #endif |
| 845 | 845 |
| 846 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 846 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 847 InstallAppsWithUnlimtedStorage); | 847 InstallAppsWithUnlimtedStorage); |
| 848 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 848 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 849 InstallAppsAndCheckStorageProtection); | 849 InstallAppsAndCheckStorageProtection); |
| 850 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 850 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 851 }; | 851 }; |
| 852 | 852 |
| 853 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 853 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |