blob: 486f996f4ff76eb16bab082da9676a4b6654c410 [file] [log] [blame]
[email protected]c333e792012-01-06 16:57:391// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]6014d672008-12-05 00:38:252// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]eaa7dd182010-12-14 11:09:005#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
[email protected]6014d672008-12-05 00:38:257
[email protected]669b2372013-10-17 15:04:588#include <list>
[email protected]da50530a2009-06-15 17:43:019#include <map>
[email protected]31bb5ee62012-09-12 22:58:4010#include <set>
[email protected]b0beaa662009-02-26 00:04:1511#include <string>
[email protected]6014d672008-12-05 00:38:2512#include <vector>
13
[email protected]e0785902011-05-19 23:34:1714#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5215#include "base/files/file_path.h"
[email protected]a918f872010-06-01 14:30:5116#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1517#include "base/memory/ref_counted.h"
[email protected]14908b72011-04-20 06:54:3618#include "base/memory/weak_ptr.h"
[email protected]1ab137b2013-03-21 03:33:1819#include "base/prefs/pref_change_registrar.h"
[email protected]00e7bef2013-06-10 20:35:1720#include "base/strings/string16.h"
[email protected]fdd679b2012-11-15 20:49:3921#include "chrome/browser/extensions/blacklist.h"
[email protected]07ad9622013-01-18 23:00:3322#include "chrome/browser/extensions/extension_function_histogram_value.h"
[email protected]c38831a12011-10-28 12:44:4923#include "chrome/browser/extensions/extension_prefs.h"
[email protected]f8aefb132013-10-30 09:29:5224#include "chrome/browser/extensions/extension_sync_service.h"
[email protected]814a7bf0f2011-08-13 05:30:5925#include "chrome/common/extensions/extension_constants.h"
[email protected]04ea1bb2013-07-10 09:26:0926#include "content/public/browser/devtools_agent_host.h"
[email protected]6c2381d2011-10-19 02:52:5327#include "content/public/browser/notification_observer.h"
28#include "content/public/browser/notification_registrar.h"
[email protected]301116c62013-11-26 10:37:4529#include "extensions/browser/external_provider_interface.h"
30#include "extensions/browser/management_policy.h"
[email protected]b52f8ca2013-11-28 08:25:2231#include "extensions/browser/pending_extension_manager.h"
[email protected]98b6d942013-11-10 00:34:0732#include "extensions/browser/process_manager.h"
[email protected]50de9aa22013-11-14 06:30:3433#include "extensions/browser/process_map.h"
[email protected]38427a12013-11-09 17:34:2034#include "extensions/browser/quota_service.h"
[email protected]e4452d32013-11-15 23:07:4135#include "extensions/common/extension.h"
[email protected]289c44b2013-12-17 03:26:5736#include "extensions/common/extension_set.h"
[email protected]d42c11152013-08-22 19:36:3237#include "extensions/common/manifest.h"
[email protected]301116c62013-11-26 10:37:4538#include "extensions/common/manifest_handlers/shared_module_info.h"
[email protected]4a10006a2013-05-17 23:18:3539#include "extensions/common/one_shot_event.h"
[email protected]6014d672008-12-05 00:38:2540
[email protected]dc9a74f72012-08-17 18:07:2141class CommandLine;
[email protected]89226982012-07-16 20:09:1842class ExtensionErrorUI;
[email protected]e0360f2c2009-12-07 22:34:3143class ExtensionToolbarModel;
[email protected]69f1be82009-04-16 22:27:2144class GURL;
[email protected]81e63782009-02-27 19:35:0945class Profile;
[email protected]aa142702010-03-26 01:26:3346
[email protected]7f8f24f2012-11-15 19:40:1447namespace base {
48class SequencedTaskRunner;
[email protected]1f04ef42013-04-22 07:35:5049class Version;
[email protected]7f8f24f2012-11-15 19:40:1450}
51
[email protected]9c70e0d92012-07-16 08:39:4452namespace extensions {
[email protected]5a38dfd2012-07-23 23:22:1053class BrowserEventRouter;
[email protected]d8c8f25f2011-11-02 18:18:0154class ComponentLoader;
[email protected]e2d720aa2012-05-17 00:11:3555class ContentSettingsStore;
[email protected]bf3d9df2012-07-24 23:20:2756class CrxInstaller;
[email protected]c77f2352012-08-08 22:07:5857class ExtensionActionStorageManager;
[email protected]bd306722012-07-11 20:43:5958class ExtensionSystem;
[email protected]42a08162012-03-16 18:09:1159class ExtensionUpdater;
[email protected]3f213ad2012-07-26 23:39:4160class PendingExtensionManager;
[email protected]cccdf0aa2011-11-11 03:43:3861class SettingsFrontend;
[email protected]a9aa62b312013-11-29 05:35:0662class UpdateObserver;
[email protected]9f4e4f082013-06-21 07:11:1963} // namespace extensions
[email protected]163ed192012-07-24 19:31:0764
65namespace syncer {
[email protected]163ed192012-07-24 19:31:0766class SyncErrorFactory;
[email protected]d8c8f25f2011-11-02 18:18:0167}
[email protected]771a6182011-10-05 16:32:5268
[email protected]d1ca0ed12009-07-01 18:24:3269// This is an interface class to encapsulate the dependencies that
[email protected]2859946f2011-04-04 18:18:0670// various classes have on ExtensionService. This allows easy mocking.
[email protected]f8aefb132013-10-30 09:29:5271class ExtensionServiceInterface
72 : public base::SupportsWeakPtr<ExtensionServiceInterface> {
[email protected]d1ca0ed12009-07-01 18:24:3273 public:
[email protected]2859946f2011-04-04 18:18:0674 virtual ~ExtensionServiceInterface() {}
[email protected]289c44b2013-12-17 03:26:5775 virtual const extensions::ExtensionSet* extensions() const = 0;
76 virtual const extensions::ExtensionSet* disabled_extensions() const = 0;
[email protected]3f213ad2012-07-26 23:39:4177 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0;
[email protected]420a0ec2011-06-01 01:07:0378
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]650b2d52013-02-10 03:41:4583 const base::FilePath& path,
[email protected]420a0ec2011-06-01 01:07:0384 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:2785 extensions::CrxInstaller** out_crx_installer) = 0;
[email protected]f574c402012-12-04 23:20:3186 virtual const extensions::Extension* GetExtensionById(
87 const std::string& id,
88 bool include_disabled) const = 0;
[email protected]1c321ee2012-05-21 03:02:3489 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:4790 const std::string& id) const = 0;
[email protected]2859946f2011-04-04 18:18:0691
[email protected]76b65442012-11-17 14:11:4892 virtual const extensions::Extension* GetPendingExtensionUpdate(
93 const std::string& extension_id) const = 0;
[email protected]6f6101832012-11-27 22:10:4894 virtual void FinishDelayedInstallation(const std::string& extension_id) = 0;
[email protected]76b65442012-11-17 14:11:4895
[email protected]c3cfb012011-04-06 22:07:3596 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
97 virtual bool IsExternalExtensionUninstalled(
98 const std::string& extension_id) const = 0;
[email protected]2859946f2011-04-04 18:18:0699
[email protected]4ee07c62012-08-21 12:40:42100 virtual void CheckManagementPolicy() = 0;
[email protected]5ef47ec2010-01-28 05:58:05101
[email protected]31206602011-04-13 23:07:32102 // Safe to call multiple times in a row.
103 //
[email protected]90310d92011-04-17 07:35:04104 // TODO(akalin): Remove this method (and others) once we refactor
105 // themes sync to not use it directly.
[email protected]31206602011-04-13 23:07:32106 virtual void CheckForUpdatesSoon() = 0;
[email protected]25ae0152011-11-18 14:40:02107
[email protected]1c321ee2012-05-21 03:02:34108 virtual void AddExtension(const extensions::Extension* extension) = 0;
[email protected]8c484b742012-11-29 06:05:36109 virtual void AddComponentExtension(
110 const extensions::Extension* extension) = 0;
[email protected]25ae0152011-11-18 14:40:02111
112 virtual void UnloadExtension(
113 const std::string& extension_id,
[email protected]b0af4792013-10-23 09:12:13114 extensions::UnloadedExtensionInfo::Reason reason) = 0;
[email protected]8b1ec202013-09-05 02:09:50115 virtual void RemoveComponentExtension(const std::string& extension_id) = 0;
[email protected]25ae0152011-11-18 14:40:02116
117 virtual bool is_ready() = 0;
[email protected]7f8f24f2012-11-15 19:40:14118
119 // Returns task runner for crx installation file I/O operations.
120 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0;
[email protected]d1ca0ed12009-07-01 18:24:32121};
[email protected]fbcc40302009-06-12 20:45:45122
[email protected]4f313d52009-05-21 00:42:29123// Manages installed and running Chromium extensions.
[email protected]eaa7dd182010-12-14 11:09:00124class ExtensionService
[email protected]14908b72011-04-20 06:54:36125 : public ExtensionServiceInterface,
[email protected]5df038b2012-07-16 19:03:27126 public extensions::ExternalProviderInterface::VisitorInterface,
[email protected]fdd679b2012-11-15 20:49:39127 public content::NotificationObserver,
128 public extensions::Blacklist::Observer {
[email protected]4f313d52009-05-21 00:42:29129 public:
[email protected]68e5cc72013-12-17 02:41:53130 // 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]400c4392013-12-13 14:41:58133 const extensions::Extension* GetInstalledExtensionByUrl(
134 const GURL& url) const;
135
[email protected]d9696672011-03-15 22:45:09136 // Returns the Extension of hosted or packaged apps, NULL otherwise.
[email protected]dc9a74f72012-08-17 18:07:21137 const extensions::Extension* GetInstalledApp(const GURL& url) const;
[email protected]d9696672011-03-15 22:45:09138
[email protected]ffb204f22010-12-05 23:20:27139 // Returns whether the URL is from either a hosted or packaged app.
[email protected]dc9a74f72012-08-17 18:07:21140 bool IsInstalledApp(const GURL& url) const;
[email protected]ffb204f22010-12-05 23:20:27141
[email protected]6aeac8342010-10-01 20:21:18142 // Attempts to uninstall an extension from a given ExtensionService. Returns
143 // true iff the target extension exists.
[email protected]eaa7dd182010-12-14 11:09:00144 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
[email protected]6aeac8342010-10-01 20:21:18145 const std::string& extension_id);
146
[email protected]73c47932010-12-06 18:13:43147 // Constructor stores pointers to |profile| and |extension_prefs| but
148 // ownership remains at caller.
[email protected]eaa7dd182010-12-14 11:09:00149 ExtensionService(Profile* profile,
[email protected]a29a517a2011-01-21 21:11:12150 const CommandLine* command_line,
[email protected]650b2d52013-02-10 03:41:45151 const base::FilePath& install_directory,
[email protected]45759612012-07-10 17:21:23152 extensions::ExtensionPrefs* extension_prefs,
[email protected]fdd679b2012-11-15 20:49:39153 extensions::Blacklist* blacklist,
[email protected]0436b102011-04-15 18:30:03154 bool autoupdate_enabled,
[email protected]4a10006a2013-05-17 23:18:35155 bool extensions_enabled,
156 extensions::OneShotEvent* ready);
[email protected]6014d672008-12-05 00:38:25157
[email protected]14908b72011-04-20 06:54:36158 virtual ~ExtensionService();
159
[email protected]6014d672008-12-05 00:38:25160 // Gets the list of currently installed extensions.
[email protected]289c44b2013-12-17 03:26:57161 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]6014d672008-12-05 00:38:25166
[email protected]695b5712012-12-06 23:55:28167 // Returns a set of all installed, disabled, blacklisted, and terminated
168 // extensions.
[email protected]289c44b2013-12-17 03:26:57169 scoped_ptr<extensions::ExtensionSet> GenerateInstalledExtensionsSet() const;
[email protected]7f4308d2012-01-18 07:43:01170
[email protected]b2907fd2011-03-25 16:43:37171 // Gets the object managing the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41172 virtual extensions::PendingExtensionManager*
173 pending_extension_manager() OVERRIDE;
[email protected]aa142702010-03-26 01:26:33174
[email protected]650b2d52013-02-10 03:41:45175 const base::FilePath& install_directory() const { return install_directory_; }
[email protected]ec5b50d2010-10-09 16:35:18176
[email protected]6f371442011-11-09 06:45:46177 extensions::ProcessMap* process_map() { return &process_map_; }
178
[email protected]168389f2011-12-20 17:12:48179 // 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]720ad1312012-02-27 23:07:36187 // 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]dc9a74f72012-08-17 18:07:21190 bool IsBackgroundPageReady(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34191 void SetBackgroundPageReady(const extensions::Extension* extension);
[email protected]d7e9a862010-11-03 21:57:49192
193 // Getter and setter for the flag that specifies whether the extension is
194 // being upgraded.
[email protected]dc9a74f72012-08-17 18:07:21195 bool IsBeingUpgraded(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34196 void SetBeingUpgraded(const extensions::Extension* extension, bool value);
[email protected]d7e9a862010-11-03 21:57:49197
[email protected]e178ad92013-06-28 02:29:25198 // Getter and setter for the flag that specifies whether the extension is
199 // being reloaded.
[email protected]5b3ee852013-09-26 06:33:10200 bool IsBeingReloaded(const std::string& extension_id) const;
[email protected]e178ad92013-06-28 02:29:25201 void SetBeingReloaded(const std::string& extension_id, bool value);
202
[email protected]39a5b532011-10-22 01:47:07203 // 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]dc9a74f72012-08-17 18:07:21206 bool HasUsedWebRequest(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34207 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value);
[email protected]39a5b532011-10-22 01:47:07208
[email protected]6014d672008-12-05 00:38:25209 // Initialize and start all installed extensions.
[email protected]9f1087e2009-06-15 17:29:32210 void Init();
[email protected]6014d672008-12-05 00:38:25211
[email protected]68e5cc72013-12-17 02:41:53212 // 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]47b896562012-08-22 23:55:15219 // Called when the associated Profile is going to be destroyed.
220 void Shutdown();
221
[email protected]695b5712012-12-06 23:55:28222 // Look up an extension by ID. Does not include terminated
[email protected]8001df22011-04-28 19:59:47223 // extensions.
[email protected]1c321ee2012-05-21 03:02:34224 virtual const extensions::Extension* GetExtensionById(
[email protected]b05fb9ff2011-04-23 00:07:56225 const std::string& id, bool include_disabled) const OVERRIDE;
[email protected]0c6da502009-08-14 22:32:39226
[email protected]695b5712012-12-06 23:55:28227 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]399583b2012-12-11 09:33:42244 // 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]8001df22011-04-28 19:59:47248 // Looks up a terminated (crashed) extension by ID.
[email protected]1c321ee2012-05-21 03:02:34249 const extensions::Extension*
250 GetTerminatedExtension(const std::string& id) const;
[email protected]8001df22011-04-28 19:59:47251
252 // Looks up an extension by ID, regardless of whether it's enabled,
[email protected]695b5712012-12-06 23:55:28253 // disabled, blacklisted, or terminated.
[email protected]1c321ee2012-05-21 03:02:34254 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:47255 const std::string& id) const OVERRIDE;
[email protected]0dfe05c2011-02-23 23:03:36256
[email protected]e957fe52009-06-23 16:51:05257 // Updates a currently-installed extension with the contents from
[email protected]7577a5c52009-07-30 06:21:58258 // |extension_path|.
[email protected]2a464a92009-08-01 17:58:35259 // TODO(aa): This method can be removed. ExtensionUpdater could use
260 // CrxInstaller directly instead.
[email protected]420a0ec2011-06-01 01:07:03261 virtual bool UpdateExtension(
262 const std::string& id,
[email protected]650b2d52013-02-10 03:41:45263 const base::FilePath& extension_path,
[email protected]420a0ec2011-06-01 01:07:03264 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:27265 extensions::CrxInstaller** out_crx_installer) OVERRIDE;
[email protected]e957fe52009-06-23 16:51:05266
[email protected]2380c6b2013-01-09 02:33:13267 // Reloads the specified extension, sending the onLaunched() event to it if it
268 // currently has any window showing.
[email protected]e178ad92013-06-28 02:29:25269 void ReloadExtension(const std::string extension_id);
[email protected]9cddd4702009-07-27 22:09:40270
[email protected]631cf822009-05-15 07:01:25271 // Uninstalls the specified extension. Callers should only call this method
[email protected]17c4f3c2009-07-04 16:36:25272 // 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]a12c706e2011-12-01 00:58:08275 //
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]17c4f3c2009-07-04 16:36:25280 // TODO(aa): Remove |external_uninstall| -- this information should be passed
281 // to ExtensionPrefs some other way.
[email protected]a12c706e2011-12-01 00:58:08282 virtual bool UninstallExtension(std::string extension_id,
[email protected]d6ebc9792011-04-07 18:18:33283 bool external_uninstall,
[email protected]439f1e32013-12-09 20:09:09284 base::string16* error);
[email protected]631cf822009-05-15 07:01:25285
[email protected]b05fb9ff2011-04-23 00:07:56286 virtual bool IsExtensionEnabled(
287 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35288 virtual bool IsExternalExtensionUninstalled(
[email protected]b05fb9ff2011-04-23 00:07:56289 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35290
[email protected]06f92562011-04-29 19:27:31291 // Enables the extension. If the extension is already enabled, does
292 // nothing.
[email protected]2859946f2011-04-04 18:18:06293 virtual void EnableExtension(const std::string& extension_id);
[email protected]06f92562011-04-29 19:27:31294
295 // Disables the extension. If the extension is already disabled, or
296 // cannot be disabled, does nothing.
[email protected]44d62b62012-04-11 00:06:03297 virtual void DisableExtension(const std::string& extension_id,
[email protected]1c321ee2012-05-21 03:02:34298 extensions::Extension::DisableReason disable_reason);
[email protected]0c6da502009-08-14 22:32:39299
[email protected]3082fe32013-08-06 11:12:38300 // 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]1abf05e2013-07-09 17:04:36303 void DisableUserExtensions(const std::vector<std::string>& except_ids);
[email protected]e516e4c2013-06-12 17:41:14304
[email protected]8d888c12010-11-30 00:00:25305 // Updates the |extension|'s granted permissions lists to include all
[email protected]8d888c12010-11-30 00:00:25306 // permissions in the |extension|'s manifest and re-enables the
307 // extension.
[email protected]1c321ee2012-05-21 03:02:34308 void GrantPermissionsAndEnableExtension(
[email protected]009633c2013-03-07 22:08:28309 const extensions::Extension* extension);
[email protected]8d888c12010-11-30 00:00:25310
[email protected]be083862012-09-01 03:53:45311 // Updates the |extension|'s granted permissions lists to include all
312 // permissions in the |extensions|'s manifest.
313 void GrantPermissions(
[email protected]009633c2013-03-07 22:08:28314 const extensions::Extension* extension);
[email protected]be083862012-09-01 03:53:45315
[email protected]9f1087e2009-06-15 17:29:32316 // Check for updates (or potentially new extensions from external providers)
[email protected]93fd78f42009-07-10 16:43:17317 void CheckForExternalUpdates();
[email protected]9f1087e2009-06-15 17:29:32318
319 // Unload the specified extension.
[email protected]25ae0152011-11-18 14:40:02320 virtual void UnloadExtension(
321 const std::string& extension_id,
[email protected]b0af4792013-10-23 09:12:13322 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE;
[email protected]9f1087e2009-06-15 17:29:32323
[email protected]8b1ec202013-09-05 02:09:50324 // Remove the specified component extension.
325 virtual void RemoveComponentExtension(const std::string& extension_id)
326 OVERRIDE;
327
[email protected]57f71b92009-09-11 19:31:38328 // Unload all extensions. This is currently only called on shutdown, and
329 // does not send notifications.
[email protected]9f1087e2009-06-15 17:29:32330 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]583d45c12010-08-31 02:48:12338 // 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]4d007b312012-10-17 03:00:48343 // 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]c6d474f82009-12-16 21:11:06347 // Called when the initial extensions load has completed.
348 virtual void OnLoadedInstalledExtensions();
[email protected]7577a5c52009-07-30 06:21:58349
[email protected]bc151cf92013-02-12 04:57:26350 // Adds |extension| to this ExtensionService and notifies observers that the
351 // extensions have been loaded.
[email protected]1c321ee2012-05-21 03:02:34352 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE;
[email protected]7577a5c52009-07-30 06:21:58353
[email protected]8c484b742012-11-29 06:05:36354 // 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]9f4e4f082013-06-21 07:11:19360 enum ImportStatus {
361 IMPORT_STATUS_OK,
362 IMPORT_STATUS_UNSATISFIED,
363 IMPORT_STATUS_UNRECOVERABLE
364 };
365
[email protected]669b2372013-10-17 15:04:58366 // 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]9f4e4f082013-06-21 07:11:19373 // 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]289c44b2013-12-17 03:26:57379 scoped_ptr<const extensions::ExtensionSet> GetDependentExtensions(
[email protected]9f4e4f082013-06-21 07:11:19380 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]bc151cf92013-02-12 04:57:26385 // Informs the service that an extension's files are in place for loading.
386 //
[email protected]9f3c8532013-07-31 19:52:07387 // |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]8266d662011-07-12 21:53:26392 void OnExtensionInstalled(
[email protected]1c321ee2012-05-21 03:02:34393 const extensions::Extension* extension,
[email protected]98270432012-09-11 20:51:24394 const syncer::StringOrdinal& page_ordinal,
[email protected]0db124b02012-11-07 04:55:05395 bool has_requirement_errors,
[email protected]9f3c8532013-07-31 19:52:07396 extensions::Blacklist::BlacklistState blacklist_state,
[email protected]0db124b02012-11-07 04:55:05397 bool wait_for_idle);
398
[email protected]9f4e4f082013-06-21 07:11:19399 // Checks for delayed installation for all pending installs.
400 void MaybeFinishDelayedInstallations();
401
[email protected]6f6101832012-11-27 22:10:48402 // 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]0db124b02012-11-07 04:55:05406 // 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]6f6101832012-11-27 22:10:48409 virtual void FinishDelayedInstallation(
410 const std::string& extension_id) OVERRIDE;
[email protected]7577a5c52009-07-30 06:21:58411
[email protected]76b65442012-11-17 14:11:48412 // 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]4ee07c62012-08-21 12:40:42418 // 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]aa96d3a2010-08-21 08:45:25422
[email protected]b05fb9ff2011-04-23 00:07:56423 virtual void CheckForUpdatesSoon() OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35424
[email protected]7577a5c52009-07-30 06:21:58425 void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; }
[email protected]abe7a8942009-06-23 05:14:29426 bool extensions_enabled() { return extensions_enabled_; }
427
[email protected]0e34d7892009-06-05 19:17:40428 void set_show_extensions_prompts(bool enabled) {
429 show_extensions_prompts_ = enabled;
[email protected]e2eb43112009-05-29 21:19:54430 }
431
[email protected]0e34d7892009-06-05 19:17:40432 bool show_extensions_prompts() {
433 return show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54434 }
435
[email protected]c3cfb012011-04-06 22:07:35436 Profile* profile();
[email protected]24e7a9d2009-11-04 11:11:34437
[email protected]c3cfb012011-04-06 22:07:35438 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const,
439 // ExtensionPrefs* mutable_extension_prefs().
[email protected]45759612012-07-10 17:21:23440 extensions::ExtensionPrefs* extension_prefs();
[email protected]a7ff4b72013-10-17 20:56:02441 const extensions::ExtensionPrefs* extension_prefs() const;
[email protected]e81dba32009-06-19 20:19:13442
[email protected]0d9a2202011-11-09 13:48:41443 extensions::SettingsFrontend* settings_frontend();
[email protected]b7f853e282011-08-10 09:24:20444
[email protected]f8aefb132013-10-30 09:29:52445 void set_extension_sync_service(
446 ExtensionSyncService* extension_sync_service) {
447 extension_sync_service_ = extension_sync_service;
448 }
449
[email protected]e2d720aa2012-05-17 00:11:35450 extensions::ContentSettingsStore* GetContentSettingsStore();
[email protected]b790b072011-05-20 09:46:44451
[email protected]3ecda252010-11-18 19:50:55452 // Whether the extension service is ready.
[email protected]25ae0152011-11-18 14:40:02453 virtual bool is_ready() OVERRIDE;
[email protected]3ecda252010-11-18 19:50:55454
[email protected]7f8f24f2012-11-15 19:40:14455 virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE;
456
[email protected]d8c8f25f2011-11-02 18:18:01457 extensions::ComponentLoader* component_loader() {
458 return component_loader_.get();
459 }
460
[email protected]1fab8452009-09-03 02:23:39461 // Note that this may return NULL if autoupdate is not turned on.
[email protected]42a08162012-03-16 18:09:11462 extensions::ExtensionUpdater* updater();
[email protected]1fab8452009-09-03 02:23:39463
[email protected]38427a12013-11-09 17:34:20464 extensions::QuotaService* quota_service() { return &quota_service_; }
[email protected]d13950e2009-12-04 01:43:02465
[email protected]b5a507b22013-11-08 20:41:57466 // 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]d11c8e92009-10-20 23:26:40472 // Notify the frontend that there was an error loading an extension.
[email protected]d8c8f25f2011-11-02 18:18:01473 // 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]650b2d52013-02-10 03:41:45477 void ReportExtensionLoadError(const base::FilePath& extension_path,
[email protected]d11c8e92009-10-20 23:26:40478 const std::string& error,
[email protected]d11c8e92009-10-20 23:26:40479 bool be_noisy);
480
[email protected]406027c02010-09-27 08:03:18481 // ExtensionHost of background page calls this method right after its render
482 // view has been created.
[email protected]3a1dc572012-07-31 22:25:13483 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host);
[email protected]406027c02010-09-27 08:03:18484
[email protected]8e4560b62011-01-14 10:09:14485 // 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]7f8f24f2012-11-15 19:40:14489 // Changes sequenced task runner for crx installation tasks to |task_runner|.
490 void SetFileTaskRunnerForTesting(base::SequencedTaskRunner* task_runner);
491
[email protected]5df038b2012-07-16 19:03:27492 // Clear all ExternalProviders.
[email protected]8e4560b62011-01-14 10:09:14493 void ClearProvidersForTesting();
494
[email protected]5df038b2012-07-16 19:03:27495 // 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]8e4560b62011-01-14 10:09:14499
[email protected]5df038b2012-07-16 19:03:27500 // ExternalProvider::Visitor implementation.
[email protected]1c321ee2012-05-21 03:02:34501 virtual bool OnExternalExtensionFileFound(
502 const std::string& id,
[email protected]1f04ef42013-04-22 07:35:50503 const base::Version* version,
[email protected]650b2d52013-02-10 03:41:45504 const base::FilePath& path,
[email protected]1d5e58b2013-01-31 08:41:40505 extensions::Manifest::Location location,
[email protected]1c321ee2012-05-21 03:02:34506 int creation_flags,
507 bool mark_acknowledged) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14508
[email protected]1c321ee2012-05-21 03:02:34509 virtual bool OnExternalExtensionUpdateUrlFound(
510 const std::string& id,
511 const GURL& update_url,
[email protected]464213a2013-10-15 01:06:48512 extensions::Manifest::Location location,
513 int creation_flags,
514 bool mark_acknowledged) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14515
[email protected]50067e52011-10-20 23:17:07516 virtual void OnExternalProviderReady(
[email protected]5df038b2012-07-16 19:03:27517 const extensions::ExternalProviderInterface* provider) OVERRIDE;
[email protected]50067e52011-10-20 23:17:07518
[email protected]94fde232012-04-27 10:22:30519 // Returns true when all the external extension providers are ready.
520 bool AreAllExternalProvidersReady() const;
521
[email protected]50067e52011-10-20 23:17:07522 void OnAllExternalProvidersReady();
[email protected]8e4560b62011-01-14 10:09:14523
[email protected]62433d32011-10-12 22:33:12524 // Once all external providers are done, generates any needed alerts about
[email protected]e5af875f2011-10-10 21:09:14525 // extensions.
526 void IdentifyAlertableExtensions();
527
[email protected]89226982012-07-16 20:09:18528 // Given an ExtensionErrorUI alert, populates it with any extensions that
[email protected]07c9f2f42012-02-29 18:45:22529 // need alerting. Returns true if the alert should be displayed at all.
530 //
[email protected]89226982012-07-16 20:09:18531 // This method takes the extension_error_ui argument rather than using
[email protected]07c9f2f42012-02-29 18:45:22532 // the member variable to make it easier to test the method in isolation.
[email protected]89226982012-07-16 20:09:18533 bool PopulateExtensionErrorUI(ExtensionErrorUI* extension_error_ui);
[email protected]07c9f2f42012-02-29 18:45:22534
[email protected]612a1cb12012-10-17 13:18:03535 // Checks if there are any new external extensions to notify the user about.
536 void UpdateExternalExtensionAlert();
[email protected]e5af875f2011-10-10 21:09:14537
[email protected]47fc70c2011-12-06 07:29:51538 // Given a (presumably just-installed) extension id, mark that extension as
539 // acknowledged.
540 void AcknowledgeExternalExtension(const std::string& id);
541
[email protected]d96eb512012-11-01 23:44:08542 // 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]59ee99d2013-10-11 15:46:16547 // Disable extensions that are known to be disabled yet are currently enabled.
548 void ReconcileKnownDisabled();
549
[email protected]62433d32011-10-12 22:33:12550 // Opens the Extensions page because the user wants to get more details
551 // about the alerts.
[email protected]89226982012-07-16 20:09:18552 void HandleExtensionAlertDetails();
[email protected]62433d32011-10-12 22:33:12553
[email protected]73a85e012013-04-04 10:45:30554 // Called when the extension alert is closed. Updates prefs and deletes
555 // the active |extension_error_ui_|.
[email protected]a9aa5932012-01-25 08:27:40556 void HandleExtensionAlertClosed();
[email protected]e5af875f2011-10-10 21:09:14557
[email protected]612a1cb12012-10-17 13:18:03558 // Marks alertable extensions as acknowledged, after the user presses the
559 // accept button.
560 void HandleExtensionAlertAccept();
561
[email protected]6c2381d2011-10-19 02:52:53562 // content::NotificationObserver
[email protected]432115822011-07-10 15:52:27563 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53564 const content::NotificationSource& source,
565 const content::NotificationDetails& details) OVERRIDE;
[email protected]4814b512009-11-07 00:12:29566
[email protected]ec5b50d2010-10-09 16:35:18567 // 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]1c321ee2012-05-21 03:02:34571 extensions::ExtensionIdSet GetAppIds() const;
[email protected]377011d2010-07-20 04:18:50572
[email protected]fe2dd7742011-04-19 22:52:49573 // 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]1c321ee2012-05-21 03:02:34578 const extensions::Extension* e, const char* histogram);
[email protected]fe2dd7742011-04-19 22:52:49579
[email protected]fa2416f2011-05-03 08:41:20580#if defined(UNIT_TEST)
[email protected]1c321ee2012-05-21 03:02:34581 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
[email protected]fa2416f2011-05-03 08:41:20582 TrackTerminatedExtension(extension);
583 }
[email protected]a51c9e92012-12-09 09:19:20584
585 void FinishInstallationForTest(const extensions::Extension* extension) {
586 FinishInstallation(extension);
587 }
[email protected]fa2416f2011-05-03 08:41:20588#endif
589
[email protected]77e4dc0882012-06-20 18:53:50590 base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); }
591
[email protected]3c4abc82012-10-22 22:25:54592 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]fc332ae2012-11-14 20:17:33599 // 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]75bdcb872013-03-13 00:41:45606 // Adds/Removes update observers.
607 void AddUpdateObserver(extensions::UpdateObserver* observer);
608 void RemoveUpdateObserver(extensions::UpdateObserver* observer);
609
[email protected]c04fd3dd2013-09-05 08:20:10610#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]14908b72011-04-20 06:54:36619 private:
[email protected]d7e9a862010-11-03 21:57:49620 // 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]39a5b532011-10-22 01:47:07629 // True if the extension has used the webRequest API.
630 bool has_used_webrequest;
631
[email protected]d7e9a862010-11-03 21:57:49632 ExtensionRuntimeData();
633 ~ExtensionRuntimeData();
634 };
635 typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap;
636
[email protected]4a10006a2013-05-17 23:18:35637 // Signals *ready_ and sends a notification to the listeners.
[email protected]820d9bd2013-04-03 03:46:03638 void SetReadyAndNotifyListeners();
639
[email protected]5db9ada2012-04-11 13:48:20640 // Return true if the sync type of |extension| matches |type|.
[email protected]90bb38d2012-11-14 18:36:03641 void OnExtensionInstallPrefChanged();
642
[email protected]fa2416f2011-05-03 08:41:20643 // Adds the given extension to the list of terminated extensions if
644 // it is not already there and unloads it.
[email protected]1c321ee2012-05-21 03:02:34645 void TrackTerminatedExtension(const extensions::Extension* extension);
[email protected]fa2416f2011-05-03 08:41:20646
647 // Removes the extension with the given id from the list of
648 // terminated extensions if it is there.
[email protected]bb7f40952011-01-13 00:21:20649 void UntrackTerminatedExtension(const std::string& id);
650
[email protected]8c484b742012-11-29 06:05:36651 // 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]9f3c8532013-07-31 19:52:07655 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]8c484b742012-11-29 06:05:36660
[email protected]62d30f42009-10-01 22:36:06661 // Handles sending notification that |extension| was loaded.
[email protected]1c321ee2012-05-21 03:02:34662 void NotifyExtensionLoaded(const extensions::Extension* extension);
[email protected]62d30f42009-10-01 22:36:06663
664 // Handles sending notification that |extension| was unloaded.
[email protected]b0af4792013-10-23 09:12:13665 void NotifyExtensionUnloaded(
666 const extensions::Extension* extension,
667 extensions::UnloadedExtensionInfo::Reason reason);
[email protected]62d30f42009-10-01 22:36:06668
[email protected]6f6101832012-11-27 22:10:48669 // Common helper to finish installing the given extension.
670 void FinishInstallation(const extensions::Extension* extension);
671
[email protected]b914e2952013-04-26 07:10:03672 // 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]116d40e2013-08-08 17:23:17680 bool is_extension_installed);
[email protected]b914e2952013-04-26 07:10:03681
[email protected]aab98a52009-12-02 03:22:35682 // Helper that updates the active extension list used for crash reporting.
683 void UpdateActiveExtensionsInCrashReporter();
684
[email protected]612a1cb12012-10-17 13:18:03685 // Helper to determine whether we should initially enable an installed
686 // (or upgraded) extension.
687 bool ShouldEnableOnInstall(const extensions::Extension* extension);
688
[email protected]0db124b02012-11-07 04:55:05689 // 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]e7aa7b7e2012-11-27 04:51:22693 // 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]399583b2012-12-11 09:33:42698 // 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]fdd679b2012-11-15 20:49:39704 // extensions::Blacklist::Observer implementation.
705 virtual void OnBlacklistUpdated() OVERRIDE;
706
[email protected]695b5712012-12-06 23:55:28707 // Manages the blacklisted extensions, intended as callback from
708 // Blacklist::GetBlacklistedIDs.
[email protected]3f2a2fa2013-09-24 02:55:25709 void ManageBlacklist(const std::set<std::string>& blacklisted_ids);
[email protected]695b5712012-12-06 23:55:28710
[email protected]9f4e4f082013-06-21 07:11:19711 // 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]399583b2012-12-11 09:33:42717
[email protected]31d8f5f22012-04-02 15:22:08718 // The normal profile associated with this ExtensionService.
[email protected]6ef635e42009-07-26 06:16:12719 Profile* profile_;
720
[email protected]31d8f5f22012-04-02 15:22:08721 // The ExtensionSystem for the profile above.
[email protected]bd306722012-07-11 20:43:59722 extensions::ExtensionSystem* system_;
[email protected]31d8f5f22012-04-02 15:22:08723
[email protected]695b5712012-12-06 23:55:28724 // Preferences for the owning profile.
[email protected]45759612012-07-10 17:21:23725 extensions::ExtensionPrefs* extension_prefs_;
[email protected]894bb502009-05-21 22:39:57726
[email protected]695b5712012-12-06 23:55:28727 // Blacklist for the owning profile.
728 extensions::Blacklist* blacklist_;
729
[email protected]adfc5462011-09-21 19:07:13730 // Settings for the owning profile.
[email protected]cccdf0aa2011-11-11 03:43:38731 scoped_ptr<extensions::SettingsFrontend> settings_frontend_;
[email protected]b7f853e282011-08-10 09:24:20732
[email protected]f8aefb132013-10-30 09:29:52733 // The ExtensionSyncService that is used by this ExtensionService.
734 ExtensionSyncService* extension_sync_service_;
735
[email protected]6014d672008-12-05 00:38:25736 // The current list of installed extensions.
[email protected]289c44b2013-12-17 03:26:57737 extensions::ExtensionSet extensions_;
[email protected]6014d672008-12-05 00:38:25738
[email protected]0c6da502009-08-14 22:32:39739 // The list of installed extensions that have been disabled.
[email protected]289c44b2013-12-17 03:26:57740 extensions::ExtensionSet disabled_extensions_;
[email protected]0c6da502009-08-14 22:32:39741
[email protected]bb7f40952011-01-13 00:21:20742 // The list of installed extensions that have been terminated.
[email protected]289c44b2013-12-17 03:26:57743 extensions::ExtensionSet terminated_extensions_;
[email protected]bb7f40952011-01-13 00:21:20744
[email protected]695b5712012-12-06 23:55:28745 // 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]289c44b2013-12-17 03:26:57749 extensions::ExtensionSet blacklisted_extensions_;
[email protected]695b5712012-12-06 23:55:28750
[email protected]9f4e4f082013-06-21 07:11:19751 // The list of extension installs delayed for various reasons. The reason
752 // for delayed install is stored in ExtensionPrefs.
[email protected]289c44b2013-12-17 03:26:57753 extensions::ExtensionSet delayed_installs_;
[email protected]0db124b02012-11-07 04:55:05754
[email protected]b2907fd2011-03-25 16:43:37755 // Hold the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41756 extensions::PendingExtensionManager pending_extension_manager_;
[email protected]aa142702010-03-26 01:26:33757
[email protected]d7e9a862010-11-03 21:57:49758 // The map of extension IDs to their runtime data.
759 ExtensionRuntimeDataMap extension_runtime_data_;
760
[email protected]6014d672008-12-05 00:38:25761 // The full path to the directory where extensions are installed.
[email protected]650b2d52013-02-10 03:41:45762 base::FilePath install_directory_;
[email protected]6014d672008-12-05 00:38:25763
[email protected]e2eb43112009-05-29 21:19:54764 // Whether or not extensions are enabled.
765 bool extensions_enabled_;
766
[email protected]0e34d7892009-06-05 19:17:40767 // Whether to notify users when they attempt to install an extension.
768 bool show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54769
[email protected]fc332ae2012-11-14 20:17:33770 // Whether to delay installing of extension updates until the extension is
771 // idle.
772 bool install_updates_when_idle_;
773
[email protected]d13950e2009-12-04 01:43:02774 // Used by dispatchers to limit API quota for individual extensions.
[email protected]38427a12013-11-09 17:34:20775 extensions::QuotaService quota_service_;
[email protected]d13950e2009-12-04 01:43:02776
[email protected]4a10006a2013-05-17 23:18:35777 // Signaled when all extensions are loaded.
778 extensions::OneShotEvent* const ready_;
[email protected]e81dba32009-06-19 20:19:13779
[email protected]93fd78f42009-07-10 16:43:17780 // Our extension updater, if updates are turned on.
[email protected]42a08162012-03-16 18:09:11781 scoped_ptr<extensions::ExtensionUpdater> updater_;
[email protected]93fd78f42009-07-10 16:43:17782
[email protected]1eb175082010-02-10 09:26:16783 // Map unloaded extensions' ids to their paths. When a temporarily loaded
[email protected]5fb889382011-06-03 00:29:20784 // extension is unloaded, we lose the information about it and don't have
[email protected]1eb175082010-02-10 09:26:16785 // any in the extension preferences file.
[email protected]650b2d52013-02-10 03:41:45786 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap;
[email protected]1eb175082010-02-10 09:26:16787 UnloadedExtensionPathMap unloaded_extension_paths_;
788
[email protected]b914e2952013-04-26 07:10:03789 // Store the ids of reloading extensions.
790 std::set<std::string> reloading_extensions_;
[email protected]f17dbd42010-08-16 23:21:10791
[email protected]04ea1bb2013-07-10 09:26:09792 // 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]4814b512009-11-07 00:12:29796 OrphanedDevTools orphaned_dev_tools_;
797
[email protected]6c2381d2011-10-19 02:52:53798 content::NotificationRegistrar registrar_;
[email protected]2fb7dc982010-09-29 12:24:28799 PrefChangeRegistrar pref_change_registrar_;
[email protected]4814b512009-11-07 00:12:29800
[email protected]d8c8f25f2011-11-02 18:18:01801 // Keeps track of loading and unloading component extensions.
802 scoped_ptr<extensions::ComponentLoader> component_loader_;
803
[email protected]8e4560b62011-01-14 10:09:14804 // 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]5df038b2012-07-16 19:03:27807 extensions::ProviderCollection external_extension_providers_;
[email protected]8e4560b62011-01-14 10:09:14808
809 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
[email protected]94fde232012-04-27 10:22:30810 // 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]8e4560b62011-01-14 10:09:14815
[email protected]3c4abc82012-10-22 22:25:54816 // 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]9f4e4f082013-06-21 07:11:19821 // 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]399583b2012-12-11 09:33:42826
[email protected]460c6712013-04-24 07:20:01827 // 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]6f371442011-11-09 06:45:46832 extensions::ProcessMap process_map_;
833
[email protected]e178ad92013-06-28 02:29:25834 // 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]89226982012-07-16 20:09:18838 scoped_ptr<ExtensionErrorUI> extension_error_ui_;
[email protected]7f8f24f2012-11-15 19:40:14839 // Sequenced task runner for extension related file operations.
840 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
[email protected]a9aa5932012-01-25 08:27:40841
[email protected]9ce11d22012-08-08 23:20:13842#if defined(ENABLE_EXTENSIONS)
[email protected]c77f2352012-08-08 22:07:58843 scoped_ptr<extensions::ExtensionActionStorageManager>
844 extension_action_storage_manager_;
[email protected]9ce11d22012-08-08 23:20:13845#endif
[email protected]4c9201c42013-08-16 04:56:21846 scoped_ptr<extensions::ManagementPolicy::Provider>
847 shared_module_policy_provider_;
[email protected]c77f2352012-08-08 22:07:58848
[email protected]75bdcb872013-03-13 00:41:45849 ObserverList<extensions::UpdateObserver, true> update_observers_;
850
[email protected]c04fd3dd2013-09-05 08:20:10851#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]eaa7dd182010-12-14 11:09:00859 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]c2c263c2010-08-13 21:59:48860 InstallAppsWithUnlimtedStorage);
[email protected]eaa7dd182010-12-14 11:09:00861 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]654512b2010-09-01 02:09:42862 InstallAppsAndCheckStorageProtection);
[email protected]eaa7dd182010-12-14 11:09:00863 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
[email protected]6014d672008-12-05 00:38:25864};
865
[email protected]eaa7dd182010-12-14 11:09:00866#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_