[email protected] | c333e79 | 2012-01-06 16:57:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 7 | |
[email protected] | 669b237 | 2013-10-17 15:04:58 | [diff] [blame] | 8 | #include <list> |
[email protected] | da50530a | 2009-06-15 17:43:01 | [diff] [blame] | 9 | #include <map> |
[email protected] | 31bb5ee6 | 2012-09-12 22:58:40 | [diff] [blame] | 10 | #include <set> |
[email protected] | b0beaa66 | 2009-02-26 00:04:15 | [diff] [blame] | 11 | #include <string> |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
[email protected] | e078590 | 2011-05-19 23:34:17 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 15 | #include "base/files/file_path.h" |
[email protected] | a918f87 | 2010-06-01 14:30:51 | [diff] [blame] | 16 | #include "base/gtest_prod_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 17 | #include "base/memory/ref_counted.h" |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 18 | #include "base/memory/weak_ptr.h" |
[email protected] | 1ab137b | 2013-03-21 03:33:18 | [diff] [blame] | 19 | #include "base/prefs/pref_change_registrar.h" |
[email protected] | 00e7bef | 2013-06-10 20:35:17 | [diff] [blame] | 20 | #include "base/strings/string16.h" |
[email protected] | fdd679b | 2012-11-15 20:49:39 | [diff] [blame] | 21 | #include "chrome/browser/extensions/blacklist.h" |
[email protected] | 07ad962 | 2013-01-18 23:00:33 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_function_histogram_value.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 23 | #include "chrome/browser/extensions/extension_prefs.h" |
[email protected] | f8aefb13 | 2013-10-30 09:29:52 | [diff] [blame] | 24 | #include "chrome/browser/extensions/extension_sync_service.h" |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 25 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 04ea1bb | 2013-07-10 09:26:09 | [diff] [blame] | 26 | #include "content/public/browser/devtools_agent_host.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 27 | #include "content/public/browser/notification_observer.h" |
| 28 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 29 | #include "extensions/browser/external_provider_interface.h" |
| 30 | #include "extensions/browser/management_policy.h" |
[email protected] | b52f8ca | 2013-11-28 08:25:22 | [diff] [blame] | 31 | #include "extensions/browser/pending_extension_manager.h" |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 32 | #include "extensions/browser/process_manager.h" |
[email protected] | 50de9aa2 | 2013-11-14 06:30:34 | [diff] [blame] | 33 | #include "extensions/browser/process_map.h" |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 34 | #include "extensions/browser/quota_service.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 35 | #include "extensions/common/extension.h" |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 36 | #include "extensions/common/extension_set.h" |
[email protected] | d42c1115 | 2013-08-22 19:36:32 | [diff] [blame] | 37 | #include "extensions/common/manifest.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 38 | #include "extensions/common/manifest_handlers/shared_module_info.h" |
[email protected] | 4a10006a | 2013-05-17 23:18:35 | [diff] [blame] | 39 | #include "extensions/common/one_shot_event.h" |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 40 | |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 41 | class CommandLine; |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 42 | class ExtensionErrorUI; |
[email protected] | e0360f2c | 2009-12-07 22:34:31 | [diff] [blame] | 43 | class ExtensionToolbarModel; |
[email protected] | 69f1be8 | 2009-04-16 22:27:21 | [diff] [blame] | 44 | class GURL; |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 45 | class Profile; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 46 | |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 47 | namespace base { |
| 48 | class SequencedTaskRunner; |
[email protected] | 1f04ef4 | 2013-04-22 07:35:50 | [diff] [blame] | 49 | class Version; |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 50 | } |
| 51 | |
[email protected] | 9c70e0d9 | 2012-07-16 08:39:44 | [diff] [blame] | 52 | namespace extensions { |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 53 | class BrowserEventRouter; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 54 | class ComponentLoader; |
[email protected] | e2d720aa | 2012-05-17 00:11:35 | [diff] [blame] | 55 | class ContentSettingsStore; |
[email protected] | bf3d9df | 2012-07-24 23:20:27 | [diff] [blame] | 56 | class CrxInstaller; |
[email protected] | c77f235 | 2012-08-08 22:07:58 | [diff] [blame] | 57 | class ExtensionActionStorageManager; |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 58 | class ExtensionSystem; |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 59 | class ExtensionUpdater; |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 60 | class PendingExtensionManager; |
[email protected] | cccdf0aa | 2011-11-11 03:43:38 | [diff] [blame] | 61 | class SettingsFrontend; |
[email protected] | a9aa62b31 | 2013-11-29 05:35:06 | [diff] [blame] | 62 | class UpdateObserver; |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 63 | } // namespace extensions |
[email protected] | 163ed19 | 2012-07-24 19:31:07 | [diff] [blame] | 64 | |
| 65 | namespace syncer { |
[email protected] | 163ed19 | 2012-07-24 19:31:07 | [diff] [blame] | 66 | class SyncErrorFactory; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 67 | } |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 68 | |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 69 | // This is an interface class to encapsulate the dependencies that |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 70 | // various classes have on ExtensionService. This allows easy mocking. |
[email protected] | f8aefb13 | 2013-10-30 09:29:52 | [diff] [blame] | 71 | class ExtensionServiceInterface |
| 72 | : public base::SupportsWeakPtr<ExtensionServiceInterface> { |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 73 | public: |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 74 | virtual ~ExtensionServiceInterface() {} |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 75 | virtual const extensions::ExtensionSet* extensions() const = 0; |
| 76 | virtual const extensions::ExtensionSet* disabled_extensions() const = 0; |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 77 | virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 78 | |
| 79 | // Install an update. Return true if the install can be started. |
| 80 | // Set out_crx_installer to the installer if one was started. |
| 81 | virtual bool UpdateExtension( |
| 82 | const std::string& id, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 83 | const base::FilePath& path, |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 84 | const GURL& download_url, |
[email protected] | bf3d9df | 2012-07-24 23:20:27 | [diff] [blame] | 85 | extensions::CrxInstaller** out_crx_installer) = 0; |
[email protected] | f574c40 | 2012-12-04 23:20:31 | [diff] [blame] | 86 | virtual const extensions::Extension* GetExtensionById( |
| 87 | const std::string& id, |
| 88 | bool include_disabled) const = 0; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 89 | virtual const extensions::Extension* GetInstalledExtension( |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 90 | const std::string& id) const = 0; |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 91 | |
[email protected] | 76b6544 | 2012-11-17 14:11:48 | [diff] [blame] | 92 | virtual const extensions::Extension* GetPendingExtensionUpdate( |
| 93 | const std::string& extension_id) const = 0; |
[email protected] | 6f610183 | 2012-11-27 22:10:48 | [diff] [blame] | 94 | virtual void FinishDelayedInstallation(const std::string& extension_id) = 0; |
[email protected] | 76b6544 | 2012-11-17 14:11:48 | [diff] [blame] | 95 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 96 | virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; |
| 97 | virtual bool IsExternalExtensionUninstalled( |
| 98 | const std::string& extension_id) const = 0; |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 99 | |
[email protected] | 4ee07c6 | 2012-08-21 12:40:42 | [diff] [blame] | 100 | virtual void CheckManagementPolicy() = 0; |
[email protected] | 5ef47ec | 2010-01-28 05:58:05 | [diff] [blame] | 101 | |
[email protected] | 3120660 | 2011-04-13 23:07:32 | [diff] [blame] | 102 | // Safe to call multiple times in a row. |
| 103 | // |
[email protected] | 90310d9 | 2011-04-17 07:35:04 | [diff] [blame] | 104 | // TODO(akalin): Remove this method (and others) once we refactor |
| 105 | // themes sync to not use it directly. |
[email protected] | 3120660 | 2011-04-13 23:07:32 | [diff] [blame] | 106 | virtual void CheckForUpdatesSoon() = 0; |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 107 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 108 | virtual void AddExtension(const extensions::Extension* extension) = 0; |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 109 | virtual void AddComponentExtension( |
| 110 | const extensions::Extension* extension) = 0; |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 111 | |
| 112 | virtual void UnloadExtension( |
| 113 | const std::string& extension_id, |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 114 | extensions::UnloadedExtensionInfo::Reason reason) = 0; |
[email protected] | 8b1ec20 | 2013-09-05 02:09:50 | [diff] [blame] | 115 | virtual void RemoveComponentExtension(const std::string& extension_id) = 0; |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 116 | |
| 117 | virtual bool is_ready() = 0; |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 118 | |
| 119 | // Returns task runner for crx installation file I/O operations. |
| 120 | virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 121 | }; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 122 | |
[email protected] | 4f313d5 | 2009-05-21 00:42:29 | [diff] [blame] | 123 | // Manages installed and running Chromium extensions. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 124 | class ExtensionService |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 125 | : public ExtensionServiceInterface, |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 126 | public extensions::ExternalProviderInterface::VisitorInterface, |
[email protected] | fdd679b | 2012-11-15 20:49:39 | [diff] [blame] | 127 | public content::NotificationObserver, |
| 128 | public extensions::Blacklist::Observer { |
[email protected] | 4f313d5 | 2009-05-21 00:42:29 | [diff] [blame] | 129 | public: |
[email protected] | 68e5cc7 | 2013-12-17 02:41:53 | [diff] [blame] | 130 | // Returns the Extension for a given url or NULL if the url doesn't belong to |
| 131 | // an installed extension. This may be a hosted app extent or a |
| 132 | // chrome-extension:// url. |
[email protected] | 400c439 | 2013-12-13 14:41:58 | [diff] [blame] | 133 | const extensions::Extension* GetInstalledExtensionByUrl( |
| 134 | const GURL& url) const; |
| 135 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 136 | // Returns the Extension of hosted or packaged apps, NULL otherwise. |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 137 | const extensions::Extension* GetInstalledApp(const GURL& url) const; |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 138 | |
[email protected] | ffb204f2 | 2010-12-05 23:20:27 | [diff] [blame] | 139 | // Returns whether the URL is from either a hosted or packaged app. |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 140 | bool IsInstalledApp(const GURL& url) const; |
[email protected] | ffb204f2 | 2010-12-05 23:20:27 | [diff] [blame] | 141 | |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 142 | // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 143 | // true iff the target extension exists. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 144 | static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 145 | const std::string& extension_id); |
| 146 | |
[email protected] | 73c4793 | 2010-12-06 18:13:43 | [diff] [blame] | 147 | // Constructor stores pointers to |profile| and |extension_prefs| but |
| 148 | // ownership remains at caller. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 149 | ExtensionService(Profile* profile, |
[email protected] | a29a517a | 2011-01-21 21:11:12 | [diff] [blame] | 150 | const CommandLine* command_line, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 151 | const base::FilePath& install_directory, |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 152 | extensions::ExtensionPrefs* extension_prefs, |
[email protected] | fdd679b | 2012-11-15 20:49:39 | [diff] [blame] | 153 | extensions::Blacklist* blacklist, |
[email protected] | 0436b10 | 2011-04-15 18:30:03 | [diff] [blame] | 154 | bool autoupdate_enabled, |
[email protected] | 4a10006a | 2013-05-17 23:18:35 | [diff] [blame] | 155 | bool extensions_enabled, |
| 156 | extensions::OneShotEvent* ready); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 157 | |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 158 | virtual ~ExtensionService(); |
| 159 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 160 | // Gets the list of currently installed extensions. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 161 | virtual const extensions::ExtensionSet* extensions() const OVERRIDE; |
| 162 | virtual const extensions::ExtensionSet* disabled_extensions() const OVERRIDE; |
| 163 | const extensions::ExtensionSet* terminated_extensions() const; |
| 164 | const extensions::ExtensionSet* blacklisted_extensions() const; |
| 165 | const extensions::ExtensionSet* delayed_installs() const; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 166 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 167 | // Returns a set of all installed, disabled, blacklisted, and terminated |
| 168 | // extensions. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 169 | scoped_ptr<extensions::ExtensionSet> GenerateInstalledExtensionsSet() const; |
[email protected] | 7f4308d | 2012-01-18 07:43:01 | [diff] [blame] | 170 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 171 | // Gets the object managing the set of pending extensions. |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 172 | virtual extensions::PendingExtensionManager* |
| 173 | pending_extension_manager() OVERRIDE; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 174 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 175 | const base::FilePath& install_directory() const { return install_directory_; } |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 176 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 177 | extensions::ProcessMap* process_map() { return &process_map_; } |
| 178 | |
[email protected] | 168389f | 2011-12-20 17:12:48 | [diff] [blame] | 179 | // Updates the app launcher value for the moved extension so that it is now |
| 180 | // located after the given predecessor and before the successor. This will |
| 181 | // trigger a sync if needed. Empty strings are used to indicate no successor |
| 182 | // or predecessor. |
| 183 | void OnExtensionMoved(const std::string& moved_extension_id, |
| 184 | const std::string& predecessor_extension_id, |
| 185 | const std::string& successor_extension_id); |
| 186 | |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 187 | // Whether the persistent background page, if any, is ready. We don't load |
| 188 | // other components until then. If there is no background page, or if it is |
| 189 | // non-persistent (lazy), we consider it to be ready. |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 190 | bool IsBackgroundPageReady(const extensions::Extension* extension) const; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 191 | void SetBackgroundPageReady(const extensions::Extension* extension); |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 192 | |
| 193 | // Getter and setter for the flag that specifies whether the extension is |
| 194 | // being upgraded. |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 195 | bool IsBeingUpgraded(const extensions::Extension* extension) const; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 196 | void SetBeingUpgraded(const extensions::Extension* extension, bool value); |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 197 | |
[email protected] | e178ad9 | 2013-06-28 02:29:25 | [diff] [blame] | 198 | // Getter and setter for the flag that specifies whether the extension is |
| 199 | // being reloaded. |
[email protected] | 5b3ee85 | 2013-09-26 06:33:10 | [diff] [blame] | 200 | bool IsBeingReloaded(const std::string& extension_id) const; |
[email protected] | e178ad9 | 2013-06-28 02:29:25 | [diff] [blame] | 201 | void SetBeingReloaded(const std::string& extension_id, bool value); |
| 202 | |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 203 | // Getter and setter for the flag that specifies if the extension has used |
| 204 | // the webrequest API. |
| 205 | // TODO(mpcomplete): remove. http://crbug.com/100411 |
[email protected] | dc9a74f7 | 2012-08-17 18:07:21 | [diff] [blame] | 206 | bool HasUsedWebRequest(const extensions::Extension* extension) const; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 207 | void SetHasUsedWebRequest(const extensions::Extension* extension, bool value); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 208 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 209 | // Initialize and start all installed extensions. |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 210 | void Init(); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 211 | |
[email protected] | 68e5cc7 | 2013-12-17 02:41:53 | [diff] [blame] | 212 | // Attempts to verify all extensions using the InstallVerifier. |
| 213 | void VerifyAllExtensions(); |
| 214 | |
| 215 | // Once the verifier work is finished, we may want to re-check management |
| 216 | // policy if |success| indicates the verifier got a new signature back. |
| 217 | void FinishVerifyAllExtensions(bool success); |
| 218 | |
[email protected] | 47b89656 | 2012-08-22 23:55:15 | [diff] [blame] | 219 | // Called when the associated Profile is going to be destroyed. |
| 220 | void Shutdown(); |
| 221 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 222 | // Look up an extension by ID. Does not include terminated |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 223 | // extensions. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 224 | virtual const extensions::Extension* GetExtensionById( |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 225 | const std::string& id, bool include_disabled) const OVERRIDE; |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 226 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 227 | enum IncludeFlag { |
| 228 | INCLUDE_NONE = 0, |
| 229 | INCLUDE_ENABLED = 1 << 0, |
| 230 | INCLUDE_DISABLED = 1 << 1, |
| 231 | INCLUDE_TERMINATED = 1 << 2, |
| 232 | INCLUDE_BLACKLISTED = 1 << 3, |
| 233 | INCLUDE_EVERYTHING = (1 << 4) - 1, |
| 234 | }; |
| 235 | |
| 236 | // Look up an extension by ID, selecting which sets to look in: |
| 237 | // * extensions() --> INCLUDE_ENABLED |
| 238 | // * disabled_extensions() --> INCLUDE_DISABLED |
| 239 | // * terminated_extensions() --> INCLUDE_TERMINATED |
| 240 | // * blacklisted_extensions() --> INCLUDE_BLACKLISTED |
| 241 | const extensions::Extension* GetExtensionById(const std::string& id, |
| 242 | int include_mask) const; |
| 243 | |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 244 | // Returns the site of the given |extension_id|. Suitable for use with |
| 245 | // BrowserContext::GetStoragePartitionForSite(). |
| 246 | GURL GetSiteForExtensionId(const std::string& extension_id); |
| 247 | |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 248 | // Looks up a terminated (crashed) extension by ID. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 249 | const extensions::Extension* |
| 250 | GetTerminatedExtension(const std::string& id) const; |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 251 | |
| 252 | // Looks up an extension by ID, regardless of whether it's enabled, |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 253 | // disabled, blacklisted, or terminated. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 254 | virtual const extensions::Extension* GetInstalledExtension( |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 255 | const std::string& id) const OVERRIDE; |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 256 | |
[email protected] | e957fe5 | 2009-06-23 16:51:05 | [diff] [blame] | 257 | // Updates a currently-installed extension with the contents from |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 258 | // |extension_path|. |
[email protected] | 2a464a9 | 2009-08-01 17:58:35 | [diff] [blame] | 259 | // TODO(aa): This method can be removed. ExtensionUpdater could use |
| 260 | // CrxInstaller directly instead. |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 261 | virtual bool UpdateExtension( |
| 262 | const std::string& id, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 263 | const base::FilePath& extension_path, |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 264 | const GURL& download_url, |
[email protected] | bf3d9df | 2012-07-24 23:20:27 | [diff] [blame] | 265 | extensions::CrxInstaller** out_crx_installer) OVERRIDE; |
[email protected] | e957fe5 | 2009-06-23 16:51:05 | [diff] [blame] | 266 | |
[email protected] | 2380c6b | 2013-01-09 02:33:13 | [diff] [blame] | 267 | // Reloads the specified extension, sending the onLaunched() event to it if it |
| 268 | // currently has any window showing. |
[email protected] | e178ad9 | 2013-06-28 02:29:25 | [diff] [blame] | 269 | void ReloadExtension(const std::string extension_id); |
[email protected] | 9cddd470 | 2009-07-27 22:09:40 | [diff] [blame] | 270 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 271 | // Uninstalls the specified extension. Callers should only call this method |
[email protected] | 17c4f3c | 2009-07-04 16:36:25 | [diff] [blame] | 272 | // with extensions that exist. |external_uninstall| is a magical parameter |
| 273 | // that is only used to send information to ExtensionPrefs, which external |
| 274 | // callers should never set to true. |
[email protected] | a12c706e | 2011-12-01 00:58:08 | [diff] [blame] | 275 | // |
| 276 | // We pass the |extension_id| by value to avoid having it deleted from under |
| 277 | // us incase someone calls it with Extension::id() or another string that we |
| 278 | // are going to delete in this function. |
| 279 | // |
[email protected] | 17c4f3c | 2009-07-04 16:36:25 | [diff] [blame] | 280 | // TODO(aa): Remove |external_uninstall| -- this information should be passed |
| 281 | // to ExtensionPrefs some other way. |
[email protected] | a12c706e | 2011-12-01 00:58:08 | [diff] [blame] | 282 | virtual bool UninstallExtension(std::string extension_id, |
[email protected] | d6ebc979 | 2011-04-07 18:18:33 | [diff] [blame] | 283 | bool external_uninstall, |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 284 | base::string16* error); |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 285 | |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 286 | virtual bool IsExtensionEnabled( |
| 287 | const std::string& extension_id) const OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 288 | virtual bool IsExternalExtensionUninstalled( |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 289 | const std::string& extension_id) const OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 290 | |
[email protected] | 06f9256 | 2011-04-29 19:27:31 | [diff] [blame] | 291 | // Enables the extension. If the extension is already enabled, does |
| 292 | // nothing. |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 293 | virtual void EnableExtension(const std::string& extension_id); |
[email protected] | 06f9256 | 2011-04-29 19:27:31 | [diff] [blame] | 294 | |
| 295 | // Disables the extension. If the extension is already disabled, or |
| 296 | // cannot be disabled, does nothing. |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 297 | virtual void DisableExtension(const std::string& extension_id, |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 298 | extensions::Extension::DisableReason disable_reason); |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 299 | |
[email protected] | 3082fe3 | 2013-08-06 11:12:38 | [diff] [blame] | 300 | // Disable non-default and non-managed extensions with ids not in |
| 301 | // |except_ids|. Default extensions are those from the Web Store with |
| 302 | // |was_installed_by_default| flag. |
[email protected] | 1abf05e | 2013-07-09 17:04:36 | [diff] [blame] | 303 | void DisableUserExtensions(const std::vector<std::string>& except_ids); |
[email protected] | e516e4c | 2013-06-12 17:41:14 | [diff] [blame] | 304 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 305 | // Updates the |extension|'s granted permissions lists to include all |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 306 | // permissions in the |extension|'s manifest and re-enables the |
| 307 | // extension. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 308 | void GrantPermissionsAndEnableExtension( |
[email protected] | 009633c | 2013-03-07 22:08:28 | [diff] [blame] | 309 | const extensions::Extension* extension); |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 310 | |
[email protected] | be08386 | 2012-09-01 03:53:45 | [diff] [blame] | 311 | // Updates the |extension|'s granted permissions lists to include all |
| 312 | // permissions in the |extensions|'s manifest. |
| 313 | void GrantPermissions( |
[email protected] | 009633c | 2013-03-07 22:08:28 | [diff] [blame] | 314 | const extensions::Extension* extension); |
[email protected] | be08386 | 2012-09-01 03:53:45 | [diff] [blame] | 315 | |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 316 | // Check for updates (or potentially new extensions from external providers) |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 317 | void CheckForExternalUpdates(); |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 318 | |
| 319 | // Unload the specified extension. |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 320 | virtual void UnloadExtension( |
| 321 | const std::string& extension_id, |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 322 | extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 323 | |
[email protected] | 8b1ec20 | 2013-09-05 02:09:50 | [diff] [blame] | 324 | // Remove the specified component extension. |
| 325 | virtual void RemoveComponentExtension(const std::string& extension_id) |
| 326 | OVERRIDE; |
| 327 | |
[email protected] | 57f71b9 | 2009-09-11 19:31:38 | [diff] [blame] | 328 | // Unload all extensions. This is currently only called on shutdown, and |
| 329 | // does not send notifications. |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 330 | void UnloadAllExtensions(); |
| 331 | |
| 332 | // Called only by testing. |
| 333 | void ReloadExtensions(); |
| 334 | |
| 335 | // Scan the extension directory and clean up the cruft. |
| 336 | void GarbageCollectExtensions(); |
| 337 | |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 338 | // Returns true if |url| should get extension api bindings and be permitted |
| 339 | // to make api calls. Note that this is independent of what extension |
| 340 | // permissions the given extension has been granted. |
| 341 | bool ExtensionBindingsAllowed(const GURL& url); |
| 342 | |
[email protected] | 4d007b31 | 2012-10-17 03:00:48 | [diff] [blame] | 343 | // Returns true if a normal browser window should avoid showing |url| in a |
| 344 | // tab. In this case, |url| is also rewritten to an error URL. |
| 345 | bool ShouldBlockUrlInBrowserTab(GURL* url); |
| 346 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 347 | // Called when the initial extensions load has completed. |
| 348 | virtual void OnLoadedInstalledExtensions(); |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 349 | |
[email protected] | bc151cf9 | 2013-02-12 04:57:26 | [diff] [blame] | 350 | // Adds |extension| to this ExtensionService and notifies observers that the |
| 351 | // extensions have been loaded. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 352 | virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 353 | |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 354 | // Check if we have preferences for the component extension and, if not or if |
| 355 | // the stored version differs, install the extension (without requirements |
| 356 | // checking) before calling AddExtension. |
| 357 | virtual void AddComponentExtension(const extensions::Extension* extension) |
| 358 | OVERRIDE; |
| 359 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 360 | enum ImportStatus { |
| 361 | IMPORT_STATUS_OK, |
| 362 | IMPORT_STATUS_UNSATISFIED, |
| 363 | IMPORT_STATUS_UNRECOVERABLE |
| 364 | }; |
| 365 | |
[email protected] | 669b237 | 2013-10-17 15:04:58 | [diff] [blame] | 366 | // Checks an extension's imports. No installed and outdated imports will be |
| 367 | // stored in |missing_modules| and |outdated_modules|. |
| 368 | ImportStatus CheckImports( |
| 369 | const extensions::Extension* extension, |
| 370 | std::list<extensions::SharedModuleInfo::ImportInfo>* missing_modules, |
| 371 | std::list<extensions::SharedModuleInfo::ImportInfo>* outdated_modules); |
| 372 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 373 | // Checks an extension's shared module imports to see if they are satisfied. |
| 374 | // If they are not, this function adds the dependencies to the pending install |
| 375 | // list if |extension| came from the webstore. |
| 376 | ImportStatus SatisfyImports(const extensions::Extension* extension); |
| 377 | |
| 378 | // Returns a set of extensions that import a given extension. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 379 | scoped_ptr<const extensions::ExtensionSet> GetDependentExtensions( |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 380 | const extensions::Extension* extension); |
| 381 | |
| 382 | // Uninstalls shared modules that were only referenced by |extension|. |
| 383 | void PruneSharedModulesOnUninstall(const extensions::Extension* extension); |
| 384 | |
[email protected] | bc151cf9 | 2013-02-12 04:57:26 | [diff] [blame] | 385 | // Informs the service that an extension's files are in place for loading. |
| 386 | // |
[email protected] | 9f3c853 | 2013-07-31 19:52:07 | [diff] [blame] | 387 | // |page_ordinal| is the location of the extension in the app launcher. |
| 388 | // |has_requirement_errors| is true if requirements of the extension weren't |
| 389 | // met (for example graphics capabilities). |
| 390 | // |blacklist_state| will be BLACKLISTED if the extension is blacklisted. |
| 391 | // |wait_for_idle| may be false to install the extension immediately. |
[email protected] | 8266d66 | 2011-07-12 21:53:26 | [diff] [blame] | 392 | void OnExtensionInstalled( |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 393 | const extensions::Extension* extension, |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 394 | const syncer::StringOrdinal& page_ordinal, |
[email protected] | 0db124b0 | 2012-11-07 04:55:05 | [diff] [blame] | 395 | bool has_requirement_errors, |
[email protected] | 9f3c853 | 2013-07-31 19:52:07 | [diff] [blame] | 396 | extensions::Blacklist::BlacklistState blacklist_state, |
[email protected] | 0db124b0 | 2012-11-07 04:55:05 | [diff] [blame] | 397 | bool wait_for_idle); |
| 398 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 399 | // Checks for delayed installation for all pending installs. |
| 400 | void MaybeFinishDelayedInstallations(); |
| 401 | |
[email protected] | 6f610183 | 2012-11-27 22:10:48 | [diff] [blame] | 402 | // Similar to FinishInstallation, but first checks if there still is an update |
| 403 | // pending for the extension, and makes sure the extension is still idle. |
| 404 | void MaybeFinishDelayedInstallation(const std::string& extension_id); |
| 405 | |
[email protected] | 0db124b0 | 2012-11-07 04:55:05 | [diff] [blame] | 406 | // Finishes installation of an update for an extension with the specified id, |
| 407 | // when installation of that extension was previously delayed because the |
| 408 | // extension was in use. |
[email protected] | 6f610183 | 2012-11-27 22:10:48 | [diff] [blame] | 409 | virtual void FinishDelayedInstallation( |
| 410 | const std::string& extension_id) OVERRIDE; |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 411 | |
[email protected] | 76b6544 | 2012-11-17 14:11:48 | [diff] [blame] | 412 | // Returns an update for an extension with the specified id, if installation |
| 413 | // of that update was previously delayed because the extension was in use. If |
| 414 | // no updates are pending for the extension returns NULL. |
| 415 | virtual const extensions::Extension* GetPendingExtensionUpdate( |
| 416 | const std::string& extension_id) const OVERRIDE; |
| 417 | |
[email protected] | 4ee07c6 | 2012-08-21 12:40:42 | [diff] [blame] | 418 | // Go through each extension and unload those that are not allowed to run by |
| 419 | // management policy providers (ie. network admin and Google-managed |
| 420 | // blacklist). |
| 421 | virtual void CheckManagementPolicy() OVERRIDE; |
[email protected] | aa96d3a | 2010-08-21 08:45:25 | [diff] [blame] | 422 | |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 423 | virtual void CheckForUpdatesSoon() OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 424 | |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 425 | void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; } |
[email protected] | abe7a894 | 2009-06-23 05:14:29 | [diff] [blame] | 426 | bool extensions_enabled() { return extensions_enabled_; } |
| 427 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 428 | void set_show_extensions_prompts(bool enabled) { |
| 429 | show_extensions_prompts_ = enabled; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 430 | } |
| 431 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 432 | bool show_extensions_prompts() { |
| 433 | return show_extensions_prompts_; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 434 | } |
| 435 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 436 | Profile* profile(); |
[email protected] | 24e7a9d | 2009-11-04 11:11:34 | [diff] [blame] | 437 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 438 | // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, |
| 439 | // ExtensionPrefs* mutable_extension_prefs(). |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 440 | extensions::ExtensionPrefs* extension_prefs(); |
[email protected] | a7ff4b7 | 2013-10-17 20:56:02 | [diff] [blame] | 441 | const extensions::ExtensionPrefs* extension_prefs() const; |
[email protected] | e81dba3 | 2009-06-19 20:19:13 | [diff] [blame] | 442 | |
[email protected] | 0d9a220 | 2011-11-09 13:48:41 | [diff] [blame] | 443 | extensions::SettingsFrontend* settings_frontend(); |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 444 | |
[email protected] | f8aefb13 | 2013-10-30 09:29:52 | [diff] [blame] | 445 | void set_extension_sync_service( |
| 446 | ExtensionSyncService* extension_sync_service) { |
| 447 | extension_sync_service_ = extension_sync_service; |
| 448 | } |
| 449 | |
[email protected] | e2d720aa | 2012-05-17 00:11:35 | [diff] [blame] | 450 | extensions::ContentSettingsStore* GetContentSettingsStore(); |
[email protected] | b790b07 | 2011-05-20 09:46:44 | [diff] [blame] | 451 | |
[email protected] | 3ecda25 | 2010-11-18 19:50:55 | [diff] [blame] | 452 | // Whether the extension service is ready. |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 453 | virtual bool is_ready() OVERRIDE; |
[email protected] | 3ecda25 | 2010-11-18 19:50:55 | [diff] [blame] | 454 | |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 455 | virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE; |
| 456 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 457 | extensions::ComponentLoader* component_loader() { |
| 458 | return component_loader_.get(); |
| 459 | } |
| 460 | |
[email protected] | 1fab845 | 2009-09-03 02:23:39 | [diff] [blame] | 461 | // Note that this may return NULL if autoupdate is not turned on. |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 462 | extensions::ExtensionUpdater* updater(); |
[email protected] | 1fab845 | 2009-09-03 02:23:39 | [diff] [blame] | 463 | |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 464 | extensions::QuotaService* quota_service() { return "a_service_; } |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 465 | |
[email protected] | b5a507b2 | 2013-11-08 20:41:57 | [diff] [blame] | 466 | // Sets the name, id and icon resource path of the given extension into the |
| 467 | // returned dictionary. Returns an empty dictionary if the given extension id |
| 468 | // is not found. |
| 469 | scoped_ptr<DictionaryValue> GetExtensionInfo( |
| 470 | const std::string& extension_id) const; |
| 471 | |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 472 | // Notify the frontend that there was an error loading an extension. |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 473 | // This method is public because UnpackedInstaller and InstalledLoader |
| 474 | // can post to here. |
| 475 | // TODO(aa): Remove this. It doesn't do enough to be worth the dependency |
| 476 | // of these classes on ExtensionService. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 477 | void ReportExtensionLoadError(const base::FilePath& extension_path, |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 478 | const std::string& error, |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 479 | bool be_noisy); |
| 480 | |
[email protected] | 406027c0 | 2010-09-27 08:03:18 | [diff] [blame] | 481 | // ExtensionHost of background page calls this method right after its render |
| 482 | // view has been created. |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 483 | void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host); |
[email protected] | 406027c0 | 2010-09-27 08:03:18 | [diff] [blame] | 484 | |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 485 | // For the extension in |version_path| with |id|, check to see if it's an |
| 486 | // externally managed extension. If so, uninstall it. |
| 487 | void CheckExternalUninstall(const std::string& id); |
| 488 | |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 489 | // Changes sequenced task runner for crx installation tasks to |task_runner|. |
| 490 | void SetFileTaskRunnerForTesting(base::SequencedTaskRunner* task_runner); |
| 491 | |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 492 | // Clear all ExternalProviders. |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 493 | void ClearProvidersForTesting(); |
| 494 | |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 495 | // Adds an ExternalProviderInterface for the service to use during testing. |
| 496 | // Takes ownership of |test_provider|. |
| 497 | void AddProviderForTesting( |
| 498 | extensions::ExternalProviderInterface* test_provider); |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 499 | |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 500 | // ExternalProvider::Visitor implementation. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 501 | virtual bool OnExternalExtensionFileFound( |
| 502 | const std::string& id, |
[email protected] | 1f04ef4 | 2013-04-22 07:35:50 | [diff] [blame] | 503 | const base::Version* version, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 504 | const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 505 | extensions::Manifest::Location location, |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 506 | int creation_flags, |
| 507 | bool mark_acknowledged) OVERRIDE; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 508 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 509 | virtual bool OnExternalExtensionUpdateUrlFound( |
| 510 | const std::string& id, |
| 511 | const GURL& update_url, |
[email protected] | 464213a | 2013-10-15 01:06:48 | [diff] [blame] | 512 | extensions::Manifest::Location location, |
| 513 | int creation_flags, |
| 514 | bool mark_acknowledged) OVERRIDE; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 515 | |
[email protected] | 50067e5 | 2011-10-20 23:17:07 | [diff] [blame] | 516 | virtual void OnExternalProviderReady( |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 517 | const extensions::ExternalProviderInterface* provider) OVERRIDE; |
[email protected] | 50067e5 | 2011-10-20 23:17:07 | [diff] [blame] | 518 | |
[email protected] | 94fde23 | 2012-04-27 10:22:30 | [diff] [blame] | 519 | // Returns true when all the external extension providers are ready. |
| 520 | bool AreAllExternalProvidersReady() const; |
| 521 | |
[email protected] | 50067e5 | 2011-10-20 23:17:07 | [diff] [blame] | 522 | void OnAllExternalProvidersReady(); |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 523 | |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 524 | // Once all external providers are done, generates any needed alerts about |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 525 | // extensions. |
| 526 | void IdentifyAlertableExtensions(); |
| 527 | |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 528 | // Given an ExtensionErrorUI alert, populates it with any extensions that |
[email protected] | 07c9f2f4 | 2012-02-29 18:45:22 | [diff] [blame] | 529 | // need alerting. Returns true if the alert should be displayed at all. |
| 530 | // |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 531 | // This method takes the extension_error_ui argument rather than using |
[email protected] | 07c9f2f4 | 2012-02-29 18:45:22 | [diff] [blame] | 532 | // the member variable to make it easier to test the method in isolation. |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 533 | bool PopulateExtensionErrorUI(ExtensionErrorUI* extension_error_ui); |
[email protected] | 07c9f2f4 | 2012-02-29 18:45:22 | [diff] [blame] | 534 | |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 535 | // Checks if there are any new external extensions to notify the user about. |
| 536 | void UpdateExternalExtensionAlert(); |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 537 | |
[email protected] | 47fc70c | 2011-12-06 07:29:51 | [diff] [blame] | 538 | // Given a (presumably just-installed) extension id, mark that extension as |
| 539 | // acknowledged. |
| 540 | void AcknowledgeExternalExtension(const std::string& id); |
| 541 | |
[email protected] | d96eb51 | 2012-11-01 23:44:08 | [diff] [blame] | 542 | // Returns true if this extension is an external one that has yet to be |
| 543 | // marked as acknowledged. |
| 544 | bool IsUnacknowledgedExternalExtension( |
| 545 | const extensions::Extension* extension); |
| 546 | |
[email protected] | 59ee99d | 2013-10-11 15:46:16 | [diff] [blame] | 547 | // Disable extensions that are known to be disabled yet are currently enabled. |
| 548 | void ReconcileKnownDisabled(); |
| 549 | |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 550 | // Opens the Extensions page because the user wants to get more details |
| 551 | // about the alerts. |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 552 | void HandleExtensionAlertDetails(); |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 553 | |
[email protected] | 73a85e01 | 2013-04-04 10:45:30 | [diff] [blame] | 554 | // Called when the extension alert is closed. Updates prefs and deletes |
| 555 | // the active |extension_error_ui_|. |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 556 | void HandleExtensionAlertClosed(); |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 557 | |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 558 | // Marks alertable extensions as acknowledged, after the user presses the |
| 559 | // accept button. |
| 560 | void HandleExtensionAlertAccept(); |
| 561 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 562 | // content::NotificationObserver |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 563 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 564 | const content::NotificationSource& source, |
| 565 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 566 | |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 567 | // Whether there are any apps installed. Component apps are not included. |
| 568 | bool HasApps() const; |
| 569 | |
| 570 | // Gets the set of loaded app ids. Component apps are not included. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 571 | extensions::ExtensionIdSet GetAppIds() const; |
[email protected] | 377011d | 2010-07-20 04:18:50 | [diff] [blame] | 572 | |
[email protected] | fe2dd774 | 2011-04-19 22:52:49 | [diff] [blame] | 573 | // Record a histogram using the PermissionMessage enum values for each |
| 574 | // permission in |e|. |
| 575 | // NOTE: If this is ever called with high frequency, the implementation may |
| 576 | // need to be made more efficient. |
| 577 | static void RecordPermissionMessagesHistogram( |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 578 | const extensions::Extension* e, const char* histogram); |
[email protected] | fe2dd774 | 2011-04-19 22:52:49 | [diff] [blame] | 579 | |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 580 | #if defined(UNIT_TEST) |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 581 | void TrackTerminatedExtensionForTest(const extensions::Extension* extension) { |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 582 | TrackTerminatedExtension(extension); |
| 583 | } |
[email protected] | a51c9e9 | 2012-12-09 09:19:20 | [diff] [blame] | 584 | |
| 585 | void FinishInstallationForTest(const extensions::Extension* extension) { |
| 586 | FinishInstallation(extension); |
| 587 | } |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 588 | #endif |
| 589 | |
[email protected] | 77e4dc088 | 2012-06-20 18:53:50 | [diff] [blame] | 590 | base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); } |
| 591 | |
[email protected] | 3c4abc8 | 2012-10-22 22:25:54 | [diff] [blame] | 592 | bool browser_terminating() const { return browser_terminating_; } |
| 593 | |
| 594 | // For testing. |
| 595 | void set_browser_terminating_for_test(bool value) { |
| 596 | browser_terminating_ = value; |
| 597 | } |
| 598 | |
[email protected] | fc332ae | 2012-11-14 20:17:33 | [diff] [blame] | 599 | // By default ExtensionService will wait with installing an updated extension |
| 600 | // until the extension is idle. Tests might not like this behavior, so you can |
| 601 | // disable it with this method. |
| 602 | void set_install_updates_when_idle_for_test(bool value) { |
| 603 | install_updates_when_idle_ = value; |
| 604 | } |
| 605 | |
[email protected] | 75bdcb87 | 2013-03-13 00:41:45 | [diff] [blame] | 606 | // Adds/Removes update observers. |
| 607 | void AddUpdateObserver(extensions::UpdateObserver* observer); |
| 608 | void RemoveUpdateObserver(extensions::UpdateObserver* observer); |
| 609 | |
[email protected] | c04fd3dd | 2013-09-05 08:20:10 | [diff] [blame] | 610 | #if defined(OS_CHROMEOS) |
| 611 | void disable_garbage_collection() { |
| 612 | disable_garbage_collection_ = true; |
| 613 | } |
| 614 | void enable_garbage_collection() { |
| 615 | disable_garbage_collection_ = false; |
| 616 | } |
| 617 | #endif |
| 618 | |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 619 | private: |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 620 | // Contains Extension data that can change during the life of the process, |
| 621 | // but does not persist across restarts. |
| 622 | struct ExtensionRuntimeData { |
| 623 | // True if the background page is ready. |
| 624 | bool background_page_ready; |
| 625 | |
| 626 | // True while the extension is being upgraded. |
| 627 | bool being_upgraded; |
| 628 | |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 629 | // True if the extension has used the webRequest API. |
| 630 | bool has_used_webrequest; |
| 631 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 632 | ExtensionRuntimeData(); |
| 633 | ~ExtensionRuntimeData(); |
| 634 | }; |
| 635 | typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap; |
| 636 | |
[email protected] | 4a10006a | 2013-05-17 23:18:35 | [diff] [blame] | 637 | // Signals *ready_ and sends a notification to the listeners. |
[email protected] | 820d9bd | 2013-04-03 03:46:03 | [diff] [blame] | 638 | void SetReadyAndNotifyListeners(); |
| 639 | |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 640 | // Return true if the sync type of |extension| matches |type|. |
[email protected] | 90bb38d | 2012-11-14 18:36:03 | [diff] [blame] | 641 | void OnExtensionInstallPrefChanged(); |
| 642 | |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 643 | // Adds the given extension to the list of terminated extensions if |
| 644 | // it is not already there and unloads it. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 645 | void TrackTerminatedExtension(const extensions::Extension* extension); |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 646 | |
| 647 | // Removes the extension with the given id from the list of |
| 648 | // terminated extensions if it is there. |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 649 | void UntrackTerminatedExtension(const std::string& id); |
| 650 | |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 651 | // Update preferences for a new or updated extension; notify observers that |
| 652 | // the extension is installed, e.g., to update event handlers on background |
| 653 | // pages; and perform other extension install tasks before calling |
| 654 | // AddExtension. |
[email protected] | 9f3c853 | 2013-07-31 19:52:07 | [diff] [blame] | 655 | void AddNewOrUpdatedExtension( |
| 656 | const extensions::Extension* extension, |
| 657 | extensions::Extension::State initial_state, |
| 658 | extensions::Blacklist::BlacklistState blacklist_state, |
| 659 | const syncer::StringOrdinal& page_ordinal); |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 660 | |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 661 | // Handles sending notification that |extension| was loaded. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 662 | void NotifyExtensionLoaded(const extensions::Extension* extension); |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 663 | |
| 664 | // Handles sending notification that |extension| was unloaded. |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 665 | void NotifyExtensionUnloaded( |
| 666 | const extensions::Extension* extension, |
| 667 | extensions::UnloadedExtensionInfo::Reason reason); |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 668 | |
[email protected] | 6f610183 | 2012-11-27 22:10:48 | [diff] [blame] | 669 | // Common helper to finish installing the given extension. |
| 670 | void FinishInstallation(const extensions::Extension* extension); |
| 671 | |
[email protected] | b914e295 | 2013-04-26 07:10:03 | [diff] [blame] | 672 | // Updates the |extension|'s active permission set to include only permissions |
| 673 | // currently requested by the extension and all the permissions required by |
| 674 | // the extension. |
| 675 | void UpdateActivePermissions(const extensions::Extension* extension); |
| 676 | |
| 677 | // Disables the extension if the privilege level has increased |
| 678 | // (e.g., due to an upgrade). |
| 679 | void CheckPermissionsIncrease(const extensions::Extension* extension, |
[email protected] | 116d40e | 2013-08-08 17:23:17 | [diff] [blame] | 680 | bool is_extension_installed); |
[email protected] | b914e295 | 2013-04-26 07:10:03 | [diff] [blame] | 681 | |
[email protected] | aab98a5 | 2009-12-02 03:22:35 | [diff] [blame] | 682 | // Helper that updates the active extension list used for crash reporting. |
| 683 | void UpdateActiveExtensionsInCrashReporter(); |
| 684 | |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 685 | // Helper to determine whether we should initially enable an installed |
| 686 | // (or upgraded) extension. |
| 687 | bool ShouldEnableOnInstall(const extensions::Extension* extension); |
| 688 | |
[email protected] | 0db124b0 | 2012-11-07 04:55:05 | [diff] [blame] | 689 | // Helper to determine if an extension is idle, and it should be safe |
| 690 | // to update the extension. |
| 691 | bool IsExtensionIdle(const std::string& extension_id) const; |
| 692 | |
[email protected] | e7aa7b7e | 2012-11-27 04:51:22 | [diff] [blame] | 693 | // Helper to determine if updating an extensions should proceed immediately, |
| 694 | // or if we should delay the update until further notice. |
| 695 | bool ShouldDelayExtensionUpdate(const std::string& extension_id, |
| 696 | bool wait_for_idle) const; |
| 697 | |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 698 | // Helper to search storage directories for extensions with isolated storage |
| 699 | // that have been orphaned by an uninstall. |
| 700 | void GarbageCollectIsolatedStorage(); |
| 701 | void OnGarbageCollectIsolatedStorageFinished(); |
| 702 | void OnNeedsToGarbageCollectIsolatedStorage(); |
| 703 | |
[email protected] | fdd679b | 2012-11-15 20:49:39 | [diff] [blame] | 704 | // extensions::Blacklist::Observer implementation. |
| 705 | virtual void OnBlacklistUpdated() OVERRIDE; |
| 706 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 707 | // Manages the blacklisted extensions, intended as callback from |
| 708 | // Blacklist::GetBlacklistedIDs. |
[email protected] | 3f2a2fa | 2013-09-24 02:55:25 | [diff] [blame] | 709 | void ManageBlacklist(const std::set<std::string>& blacklisted_ids); |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 710 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 711 | // Controls if installs are delayed. See comment for |
| 712 | // |installs_delayed_for_gc_|. |
| 713 | void set_installs_delayed_for_gc(bool value) { |
| 714 | installs_delayed_for_gc_ = value; |
| 715 | } |
| 716 | bool installs_delayed_for_gc() const { return installs_delayed_for_gc_; } |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 717 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 718 | // The normal profile associated with this ExtensionService. |
[email protected] | 6ef635e4 | 2009-07-26 06:16:12 | [diff] [blame] | 719 | Profile* profile_; |
| 720 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 721 | // The ExtensionSystem for the profile above. |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 722 | extensions::ExtensionSystem* system_; |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 723 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 724 | // Preferences for the owning profile. |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 725 | extensions::ExtensionPrefs* extension_prefs_; |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 726 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 727 | // Blacklist for the owning profile. |
| 728 | extensions::Blacklist* blacklist_; |
| 729 | |
[email protected] | adfc546 | 2011-09-21 19:07:13 | [diff] [blame] | 730 | // Settings for the owning profile. |
[email protected] | cccdf0aa | 2011-11-11 03:43:38 | [diff] [blame] | 731 | scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 732 | |
[email protected] | f8aefb13 | 2013-10-30 09:29:52 | [diff] [blame] | 733 | // The ExtensionSyncService that is used by this ExtensionService. |
| 734 | ExtensionSyncService* extension_sync_service_; |
| 735 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 736 | // The current list of installed extensions. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 737 | extensions::ExtensionSet extensions_; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 738 | |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 739 | // The list of installed extensions that have been disabled. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 740 | extensions::ExtensionSet disabled_extensions_; |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 741 | |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 742 | // The list of installed extensions that have been terminated. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 743 | extensions::ExtensionSet terminated_extensions_; |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 744 | |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 745 | // The list of installed extensions that have been blacklisted. Generally |
| 746 | // these shouldn't be considered as installed by the extension platform: we |
| 747 | // only keep them around so that if extensions are blacklisted by mistake |
| 748 | // they can easily be un-blacklisted. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 749 | extensions::ExtensionSet blacklisted_extensions_; |
[email protected] | 695b571 | 2012-12-06 23:55:28 | [diff] [blame] | 750 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 751 | // The list of extension installs delayed for various reasons. The reason |
| 752 | // for delayed install is stored in ExtensionPrefs. |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame^] | 753 | extensions::ExtensionSet delayed_installs_; |
[email protected] | 0db124b0 | 2012-11-07 04:55:05 | [diff] [blame] | 754 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 755 | // Hold the set of pending extensions. |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 756 | extensions::PendingExtensionManager pending_extension_manager_; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 757 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 758 | // The map of extension IDs to their runtime data. |
| 759 | ExtensionRuntimeDataMap extension_runtime_data_; |
| 760 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 761 | // The full path to the directory where extensions are installed. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 762 | base::FilePath install_directory_; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 763 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 764 | // Whether or not extensions are enabled. |
| 765 | bool extensions_enabled_; |
| 766 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 767 | // Whether to notify users when they attempt to install an extension. |
| 768 | bool show_extensions_prompts_; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 769 | |
[email protected] | fc332ae | 2012-11-14 20:17:33 | [diff] [blame] | 770 | // Whether to delay installing of extension updates until the extension is |
| 771 | // idle. |
| 772 | bool install_updates_when_idle_; |
| 773 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 774 | // Used by dispatchers to limit API quota for individual extensions. |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 775 | extensions::QuotaService quota_service_; |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 776 | |
[email protected] | 4a10006a | 2013-05-17 23:18:35 | [diff] [blame] | 777 | // Signaled when all extensions are loaded. |
| 778 | extensions::OneShotEvent* const ready_; |
[email protected] | e81dba3 | 2009-06-19 20:19:13 | [diff] [blame] | 779 | |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 780 | // Our extension updater, if updates are turned on. |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 781 | scoped_ptr<extensions::ExtensionUpdater> updater_; |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 782 | |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 783 | // Map unloaded extensions' ids to their paths. When a temporarily loaded |
[email protected] | 5fb88938 | 2011-06-03 00:29:20 | [diff] [blame] | 784 | // extension is unloaded, we lose the information about it and don't have |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 785 | // any in the extension preferences file. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 786 | typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 787 | UnloadedExtensionPathMap unloaded_extension_paths_; |
| 788 | |
[email protected] | b914e295 | 2013-04-26 07:10:03 | [diff] [blame] | 789 | // Store the ids of reloading extensions. |
| 790 | std::set<std::string> reloading_extensions_; |
[email protected] | f17dbd4 | 2010-08-16 23:21:10 | [diff] [blame] | 791 | |
[email protected] | 04ea1bb | 2013-07-10 09:26:09 | [diff] [blame] | 792 | // Map of DevToolsAgentHost instances that are detached, |
| 793 | // waiting for an extension to be reloaded. |
| 794 | typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> > |
| 795 | OrphanedDevTools; |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 796 | OrphanedDevTools orphaned_dev_tools_; |
| 797 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 798 | content::NotificationRegistrar registrar_; |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 799 | PrefChangeRegistrar pref_change_registrar_; |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 800 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 801 | // Keeps track of loading and unloading component extensions. |
| 802 | scoped_ptr<extensions::ComponentLoader> component_loader_; |
| 803 | |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 804 | // A collection of external extension providers. Each provider reads |
| 805 | // a source of external extension information. Examples include the |
| 806 | // windows registry and external_extensions.json. |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 807 | extensions::ProviderCollection external_extension_providers_; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 808 | |
| 809 | // Set to true by OnExternalExtensionUpdateUrlFound() when an external |
[email protected] | 94fde23 | 2012-04-27 10:22:30 | [diff] [blame] | 810 | // extension URL is found, and by CheckForUpdatesSoon() when an update check |
| 811 | // has to wait for the external providers. Used in |
| 812 | // OnAllExternalProvidersReady() to determine if an update check is needed to |
| 813 | // install pending extensions. |
| 814 | bool update_once_all_providers_are_ready_; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 815 | |
[email protected] | 3c4abc8 | 2012-10-22 22:25:54 | [diff] [blame] | 816 | // Set when the browser is terminating. Prevents us from installing or |
| 817 | // updating additional extensions and allows in-progress installations to |
| 818 | // decide to abort. |
| 819 | bool browser_terminating_; |
| 820 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 821 | // Set to true to delay all new extension installations. Acts as a lock to |
| 822 | // allow background processing of garbage collection of on-disk state without |
| 823 | // needing to worry about race conditions caused by extension installation and |
| 824 | // reinstallation. |
| 825 | bool installs_delayed_for_gc_; |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 826 | |
[email protected] | 460c671 | 2013-04-24 07:20:01 | [diff] [blame] | 827 | // Set to true if this is the first time this ExtensionService has run. |
| 828 | // Used for specially handling external extensions that are installed the |
| 829 | // first time. |
| 830 | bool is_first_run_; |
| 831 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 832 | extensions::ProcessMap process_map_; |
| 833 | |
[email protected] | e178ad9 | 2013-06-28 02:29:25 | [diff] [blame] | 834 | // A set of the extension ids currently being reloaded. We use this to |
| 835 | // avoid showing a "new install" notice for an extension reinstall. |
| 836 | std::set<std::string> extensions_being_reloaded_; |
| 837 | |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 838 | scoped_ptr<ExtensionErrorUI> extension_error_ui_; |
[email protected] | 7f8f24f | 2012-11-15 19:40:14 | [diff] [blame] | 839 | // Sequenced task runner for extension related file operations. |
| 840 | scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 841 | |
[email protected] | 9ce11d2 | 2012-08-08 23:20:13 | [diff] [blame] | 842 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | c77f235 | 2012-08-08 22:07:58 | [diff] [blame] | 843 | scoped_ptr<extensions::ExtensionActionStorageManager> |
| 844 | extension_action_storage_manager_; |
[email protected] | 9ce11d2 | 2012-08-08 23:20:13 | [diff] [blame] | 845 | #endif |
[email protected] | 4c9201c4 | 2013-08-16 04:56:21 | [diff] [blame] | 846 | scoped_ptr<extensions::ManagementPolicy::Provider> |
| 847 | shared_module_policy_provider_; |
[email protected] | c77f235 | 2012-08-08 22:07:58 | [diff] [blame] | 848 | |
[email protected] | 75bdcb87 | 2013-03-13 00:41:45 | [diff] [blame] | 849 | ObserverList<extensions::UpdateObserver, true> update_observers_; |
| 850 | |
[email protected] | c04fd3dd | 2013-09-05 08:20:10 | [diff] [blame] | 851 | #if defined(OS_CHROMEOS) |
| 852 | // TODO(rkc): HACK alert - this is only in place to allow the |
| 853 | // kiosk_mode_screensaver to prevent its extension from getting garbage |
| 854 | // collected. Remove this once KioskModeScreensaver is removed. |
| 855 | // See crbug.com/280363 |
| 856 | bool disable_garbage_collection_; |
| 857 | #endif |
| 858 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 859 | FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
[email protected] | c2c263c | 2010-08-13 21:59:48 | [diff] [blame] | 860 | InstallAppsWithUnlimtedStorage); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 861 | FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
[email protected] | 654512b | 2010-09-01 02:09:42 | [diff] [blame] | 862 | InstallAppsAndCheckStorageProtection); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 863 | DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 864 | }; |
| 865 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 866 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |