blob: 71ee1c2d1585287dc9bf0b55661968e5c2910088 [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]c51225632011-11-11 21:40:378#include <list>
[email protected]da50530a2009-06-15 17:43:019#include <map>
[email protected]b0beaa662009-02-26 00:04:1510#include <string>
[email protected]6014d672008-12-05 00:38:2511#include <vector>
12
[email protected]e0785902011-05-19 23:34:1713#include "base/compiler_specific.h"
[email protected]6014d672008-12-05 00:38:2514#include "base/file_path.h"
[email protected]a918f872010-06-01 14:30:5115#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1516#include "base/memory/linked_ptr.h"
17#include "base/memory/ref_counted.h"
[email protected]14908b72011-04-20 06:54:3618#include "base/memory/weak_ptr.h"
[email protected]45644f62011-11-23 00:58:2319#include "base/property_bag.h"
[email protected]65187152012-06-02 13:14:1420#include "base/string16.h"
[email protected]c6d474f82009-12-16 21:11:0621#include "base/time.h"
[email protected]f5c016b2009-06-16 17:12:3122#include "base/tuple.h"
[email protected]178f8512012-02-09 01:49:3623#include "chrome/browser/extensions/app_shortcut_manager.h"
[email protected]5db9ada2012-04-11 13:48:2024#include "chrome/browser/extensions/app_sync_bundle.h"
[email protected]b671760b2010-07-15 21:13:4725#include "chrome/browser/extensions/extension_icon_manager.h"
[email protected]c38831a12011-10-28 12:44:4926#include "chrome/browser/extensions/extension_prefs.h"
[email protected]c6e4a3412009-06-24 15:45:2927#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]5db9ada2012-04-11 13:48:2028#include "chrome/browser/extensions/extension_sync_bundle.h"
[email protected]e0360f2c2009-12-07 22:34:3129#include "chrome/browser/extensions/extension_toolbar_model.h"
[email protected]7c1490da2011-10-11 18:53:2530#include "chrome/browser/extensions/extension_warning_set.h"
[email protected]d13950e2009-12-04 01:43:0231#include "chrome/browser/extensions/extensions_quota_service.h"
[email protected]5df038b2012-07-16 19:03:2732#include "chrome/browser/extensions/external_provider_interface.h"
[email protected]5aeeae12012-07-05 19:13:1133#include "chrome/browser/extensions/menu_manager.h"
[email protected]b2907fd2011-03-25 16:43:3734#include "chrome/browser/extensions/pending_extension_manager.h"
[email protected]6f371442011-11-09 06:45:4635#include "chrome/browser/extensions/process_map.h"
[email protected]2fb7dc982010-09-29 12:24:2836#include "chrome/browser/prefs/pref_change_registrar.h"
[email protected]3bdba0d2011-08-23 07:17:3037#include "chrome/common/extensions/extension.h"
[email protected]814a7bf0f2011-08-13 05:30:5938#include "chrome/common/extensions/extension_constants.h"
[email protected]84df8332011-12-06 18:22:4639#include "chrome/common/extensions/extension_set.h"
[email protected]c38831a12011-10-28 12:44:4940#include "content/public/browser/browser_thread.h"
[email protected]6c2381d2011-10-19 02:52:5341#include "content/public/browser/notification_observer.h"
42#include "content/public/browser/notification_registrar.h"
[email protected]895a1e52012-05-15 02:50:1243#include "sync/api/sync_change.h"
44#include "sync/api/syncable_service.h"
[email protected]6014d672008-12-05 00:38:2545
[email protected]23d5f172011-10-25 05:49:5346class BookmarkExtensionEventRouter;
[email protected]dc9a74f72012-08-17 18:07:2147class CommandLine;
[email protected]89226982012-07-16 20:09:1848class ExtensionErrorUI;
[email protected]bdd34452012-04-16 15:58:4049class ExtensionFontSettingsEventRouter;
[email protected]f825df22011-06-28 17:36:1050class ExtensionManagementEventRouter;
[email protected]118de7892011-03-16 13:31:4051class ExtensionPreferenceEventRouter;
[email protected]3bdba0d2011-08-23 07:17:3052class ExtensionSyncData;
[email protected]e0360f2c2009-12-07 22:34:3153class ExtensionToolbarModel;
[email protected]d8c8f25f2011-11-02 18:18:0154class HistoryExtensionEventRouter;
[email protected]69f1be82009-04-16 22:27:2155class GURL;
[email protected]81e63782009-02-27 19:35:0956class Profile;
[email protected]aa142702010-03-26 01:26:3357class Version;
58
[email protected]771a6182011-10-05 16:32:5259namespace chromeos {
[email protected]f463bc92012-03-22 16:38:2360class ExtensionBluetoothEventRouter;
[email protected]771a6182011-10-05 16:32:5261class ExtensionInputMethodEventRouter;
[email protected]d8c8f25f2011-11-02 18:18:0162}
63
[email protected]9c70e0d92012-07-16 08:39:4464namespace extensions {
[email protected]8d92e0382012-08-01 18:06:5265class AppNotificationManager;
[email protected]5db9ada2012-04-11 13:48:2066class AppSyncData;
[email protected]5a38dfd2012-07-23 23:22:1067class BrowserEventRouter;
[email protected]d8c8f25f2011-11-02 18:18:0168class ComponentLoader;
[email protected]e2d720aa2012-05-17 00:11:3569class ContentSettingsStore;
[email protected]bf3d9df2012-07-24 23:20:2770class CrxInstaller;
[email protected]1c321ee2012-05-21 03:02:3471class Extension;
[email protected]c77f2352012-08-08 22:07:5872class ExtensionActionStorageManager;
[email protected]92ba7b012012-05-16 03:36:1773class ExtensionCookiesEventRouter;
[email protected]163ed192012-07-24 19:31:0774class ExtensionManagedModeEventRouter;
[email protected]91aa8a32012-08-07 10:35:3375class FontSettingsEventRouter;
[email protected]5ebd6a62012-08-01 23:54:3976class PushMessagingEventRouter;
[email protected]5db9ada2012-04-11 13:48:2077class ExtensionSyncData;
[email protected]bd306722012-07-11 20:43:5978class ExtensionSystem;
[email protected]42a08162012-03-16 18:09:1179class ExtensionUpdater;
[email protected]3f213ad2012-07-26 23:39:4180class PendingExtensionManager;
[email protected]cccdf0aa2011-11-11 03:43:3881class SettingsFrontend;
[email protected]017ecde92012-04-04 09:11:2682class WebNavigationEventRouter;
[email protected]163ed192012-07-24 19:31:0783class WindowEventRouter;
84}
85
86namespace syncer {
[email protected]163ed192012-07-24 19:31:0787class SyncErrorFactory;
[email protected]d8c8f25f2011-11-02 18:18:0188}
[email protected]771a6182011-10-05 16:32:5289
[email protected]d1ca0ed12009-07-01 18:24:3290// This is an interface class to encapsulate the dependencies that
[email protected]2859946f2011-04-04 18:18:0691// various classes have on ExtensionService. This allows easy mocking.
[email protected]65f173552012-06-28 22:43:5892class ExtensionServiceInterface : public syncer::SyncableService {
[email protected]d1ca0ed12009-07-01 18:24:3293 public:
[email protected]b05fb9ff2011-04-23 00:07:5694 // A function that returns true if the given extension should be
95 // included and false if it should be filtered out. Identical to
96 // PendingExtensionInfo::ShouldAllowInstallPredicate.
[email protected]1c321ee2012-05-21 03:02:3497 typedef bool (*ExtensionFilter)(const extensions::Extension&);
[email protected]b05fb9ff2011-04-23 00:07:5698
[email protected]2859946f2011-04-04 18:18:0699 virtual ~ExtensionServiceInterface() {}
[email protected]84df8332011-12-06 18:22:46100 virtual const ExtensionSet* extensions() const = 0;
[email protected]c38fd352012-03-28 04:06:12101 virtual const ExtensionSet* disabled_extensions() const = 0;
[email protected]3f213ad2012-07-26 23:39:41102 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0;
[email protected]420a0ec2011-06-01 01:07:03103
104 // Install an update. Return true if the install can be started.
105 // Set out_crx_installer to the installer if one was started.
106 virtual bool UpdateExtension(
107 const std::string& id,
108 const FilePath& path,
109 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:27110 extensions::CrxInstaller** out_crx_installer) = 0;
[email protected]1c321ee2012-05-21 03:02:34111 virtual const extensions::Extension* GetExtensionById(const std::string& id,
[email protected]b2907fd2011-03-25 16:43:37112 bool include_disabled) const = 0;
[email protected]1c321ee2012-05-21 03:02:34113 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:47114 const std::string& id) const = 0;
[email protected]2859946f2011-04-04 18:18:06115
[email protected]c3cfb012011-04-06 22:07:35116 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
117 virtual bool IsExternalExtensionUninstalled(
118 const std::string& extension_id) const = 0;
[email protected]2859946f2011-04-04 18:18:06119
[email protected]6b75ec32009-08-14 06:37:18120 virtual void UpdateExtensionBlacklist(
121 const std::vector<std::string>& blacklist) = 0;
[email protected]aa96d3a2010-08-21 08:45:25122 virtual void CheckAdminBlacklist() = 0;
[email protected]5ef47ec2010-01-28 05:58:05123
[email protected]31206602011-04-13 23:07:32124 // Safe to call multiple times in a row.
125 //
[email protected]90310d92011-04-17 07:35:04126 // TODO(akalin): Remove this method (and others) once we refactor
127 // themes sync to not use it directly.
[email protected]31206602011-04-13 23:07:32128 virtual void CheckForUpdatesSoon() = 0;
[email protected]25ae0152011-11-18 14:40:02129
[email protected]1c321ee2012-05-21 03:02:34130 virtual void AddExtension(const extensions::Extension* extension) = 0;
[email protected]25ae0152011-11-18 14:40:02131
132 virtual void UnloadExtension(
133 const std::string& extension_id,
134 extension_misc::UnloadedExtensionReason reason) = 0;
135
[email protected]1c321ee2012-05-21 03:02:34136 virtual void SyncExtensionChangeIfNeeded(
137 const extensions::Extension& extension) = 0;
[email protected]fb82dcd2012-03-21 14:15:46138
[email protected]25ae0152011-11-18 14:40:02139 virtual bool is_ready() = 0;
[email protected]d1ca0ed12009-07-01 18:24:32140};
[email protected]fbcc40302009-06-12 20:45:45141
[email protected]4f313d52009-05-21 00:42:29142// Manages installed and running Chromium extensions.
[email protected]eaa7dd182010-12-14 11:09:00143class ExtensionService
[email protected]14908b72011-04-20 06:54:36144 : public ExtensionServiceInterface,
[email protected]5df038b2012-07-16 19:03:27145 public extensions::ExternalProviderInterface::VisitorInterface,
[email protected]178f8512012-02-09 01:49:36146 public content::NotificationObserver {
[email protected]4f313d52009-05-21 00:42:29147 public:
[email protected]a9b00ac2009-06-25 21:03:23148 // The name of the directory inside the profile where extensions are
149 // installed to.
150 static const char* kInstallDirectoryName;
151
[email protected]93fd78f42009-07-10 16:43:17152 // If auto-updates are turned on, default to running every 5 hours.
153 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5;
154
[email protected]15d5b472011-11-24 04:17:24155 // The name of the directory inside the profile where per-app local settings
[email protected]b7f853e282011-08-10 09:24:20156 // are stored.
[email protected]15d5b472011-11-24 04:17:24157 static const char* kLocalAppSettingsDirectoryName;
[email protected]27cc7332011-11-01 01:56:43158
[email protected]15d5b472011-11-24 04:17:24159 // The name of the directory inside the profile where per-extension local
160 // settings are stored.
161 static const char* kLocalExtensionSettingsDirectoryName;
162
163 // The name of the directory inside the profile where per-app synced settings
[email protected]27cc7332011-11-01 01:56:43164 // are stored.
[email protected]15d5b472011-11-24 04:17:24165 static const char* kSyncAppSettingsDirectoryName;
166
167 // The name of the directory inside the profile where per-extension synced
168 // settings are stored.
169 static const char* kSyncExtensionSettingsDirectoryName;
[email protected]b7f853e282011-08-10 09:24:20170
[email protected]90e800c2012-06-12 23:11:00171 // The name of the database inside the profile where chrome-internal
172 // extension state resides.
173 static const char* kStateStoreName;
174
[email protected]d9696672011-03-15 22:45:09175 // Returns the Extension of hosted or packaged apps, NULL otherwise.
[email protected]dc9a74f72012-08-17 18:07:21176 const extensions::Extension* GetInstalledApp(const GURL& url) const;
[email protected]d9696672011-03-15 22:45:09177
[email protected]ffb204f22010-12-05 23:20:27178 // Returns whether the URL is from either a hosted or packaged app.
[email protected]dc9a74f72012-08-17 18:07:21179 bool IsInstalledApp(const GURL& url) const;
[email protected]ffb204f22010-12-05 23:20:27180
[email protected]da5683db2011-04-23 17:12:21181 // Associates a renderer process with the given installed app.
[email protected]1c321ee2012-05-21 03:02:34182 void SetInstalledAppForRenderer(int renderer_child_id,
183 const extensions::Extension* app);
[email protected]da5683db2011-04-23 17:12:21184
185 // If the renderer is hosting an installed app, returns it, otherwise returns
186 // NULL.
[email protected]1c321ee2012-05-21 03:02:34187 const extensions::Extension* GetInstalledAppForRenderer(
[email protected]dc9a74f72012-08-17 18:07:21188 int renderer_child_id) const;
[email protected]da5683db2011-04-23 17:12:21189
[email protected]6aeac8342010-10-01 20:21:18190 // Attempts to uninstall an extension from a given ExtensionService. Returns
191 // true iff the target extension exists.
[email protected]eaa7dd182010-12-14 11:09:00192 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
[email protected]6aeac8342010-10-01 20:21:18193 const std::string& extension_id);
194
[email protected]73c47932010-12-06 18:13:43195 // Constructor stores pointers to |profile| and |extension_prefs| but
196 // ownership remains at caller.
[email protected]eaa7dd182010-12-14 11:09:00197 ExtensionService(Profile* profile,
[email protected]a29a517a2011-01-21 21:11:12198 const CommandLine* command_line,
199 const FilePath& install_directory,
[email protected]45759612012-07-10 17:21:23200 extensions::ExtensionPrefs* extension_prefs,
[email protected]0436b102011-04-15 18:30:03201 bool autoupdate_enabled,
202 bool extensions_enabled);
[email protected]6014d672008-12-05 00:38:25203
[email protected]14908b72011-04-20 06:54:36204 virtual ~ExtensionService();
205
[email protected]6014d672008-12-05 00:38:25206 // Gets the list of currently installed extensions.
[email protected]84df8332011-12-06 18:22:46207 virtual const ExtensionSet* extensions() const OVERRIDE;
[email protected]c38fd352012-03-28 04:06:12208 virtual const ExtensionSet* disabled_extensions() const OVERRIDE;
[email protected]84df8332011-12-06 18:22:46209 const ExtensionSet* terminated_extensions() const;
[email protected]6014d672008-12-05 00:38:25210
[email protected]7f4308d2012-01-18 07:43:01211 // Retuns a set of all installed, disabled, and terminated extensions and
212 // transfers ownership to caller.
213 const ExtensionSet* GenerateInstalledExtensionsSet() const;
214
[email protected]b2907fd2011-03-25 16:43:37215 // Gets the object managing the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41216 virtual extensions::PendingExtensionManager*
217 pending_extension_manager() OVERRIDE;
[email protected]aa142702010-03-26 01:26:33218
[email protected]ec5b50d2010-10-09 16:35:18219 const FilePath& install_directory() const { return install_directory_; }
220
[email protected]6f371442011-11-09 06:45:46221 extensions::ProcessMap* process_map() { return &process_map_; }
222
[email protected]db7331a2010-02-25 22:10:50223 // Whether this extension can run in an incognito window.
[email protected]c3cfb012011-04-06 22:07:35224 virtual bool IsIncognitoEnabled(const std::string& extension_id) const;
225 virtual void SetIsIncognitoEnabled(const std::string& extension_id,
226 bool enabled);
[email protected]5ef47ec2010-01-28 05:58:05227
[email protected]b2689a902011-12-01 00:41:09228 // When app notification setup is done, we call this to save the developer's
229 // oauth client id which we'll need at uninstall time to revoke the oauth
230 // permission grant for sending notifications.
[email protected]aa7599d2011-10-28 07:24:32231 virtual void SetAppNotificationSetupDone(const std::string& extension_id,
[email protected]b2689a902011-12-01 00:41:09232 const std::string& oauth_client_id);
[email protected]aa7599d2011-10-28 07:24:32233
234 virtual void SetAppNotificationDisabled(const std::string& extension_id,
235 bool value);
236
[email protected]168389f2011-12-20 17:12:48237 // Updates the app launcher value for the moved extension so that it is now
238 // located after the given predecessor and before the successor. This will
239 // trigger a sync if needed. Empty strings are used to indicate no successor
240 // or predecessor.
241 void OnExtensionMoved(const std::string& moved_extension_id,
242 const std::string& predecessor_extension_id,
243 const std::string& successor_extension_id);
244
[email protected]2a8f24e2010-11-03 21:37:05245 // Returns true if the given extension can see events and data from another
246 // sub-profile (incognito to original profile, or vice versa).
[email protected]dc9a74f72012-08-17 18:07:21247 bool CanCrossIncognito(const extensions::Extension* extension) const;
[email protected]2a8f24e2010-11-03 21:37:05248
[email protected]5ef7b002011-05-12 23:16:20249 // Returns true if the given extension can be loaded in incognito.
[email protected]1c321ee2012-05-21 03:02:34250 bool CanLoadInIncognito(const extensions::Extension* extension) const;
[email protected]5ef7b002011-05-12 23:16:20251
[email protected]05c82182010-06-24 17:49:08252 // Whether this extension can inject scripts into pages with file URLs.
[email protected]dc9a74f72012-08-17 18:07:21253 bool AllowFileAccess(const extensions::Extension* extension) const;
[email protected]3aff9ad2011-04-01 20:26:48254 // Will reload the extension since this permission is applied at loading time
255 // only.
[email protected]1c321ee2012-05-21 03:02:34256 void SetAllowFileAccess(const extensions::Extension* extension, bool allow);
[email protected]05c82182010-06-24 17:49:08257
[email protected]720ad1312012-02-27 23:07:36258 // Whether the persistent background page, if any, is ready. We don't load
259 // other components until then. If there is no background page, or if it is
260 // non-persistent (lazy), we consider it to be ready.
[email protected]dc9a74f72012-08-17 18:07:21261 bool IsBackgroundPageReady(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34262 void SetBackgroundPageReady(const extensions::Extension* extension);
[email protected]d7e9a862010-11-03 21:57:49263
264 // Getter and setter for the flag that specifies whether the extension is
265 // being upgraded.
[email protected]dc9a74f72012-08-17 18:07:21266 bool IsBeingUpgraded(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34267 void SetBeingUpgraded(const extensions::Extension* extension, bool value);
[email protected]d7e9a862010-11-03 21:57:49268
[email protected]39a5b532011-10-22 01:47:07269 // Getter and setter for the flag that specifies if the extension has used
270 // the webrequest API.
271 // TODO(mpcomplete): remove. http://crbug.com/100411
[email protected]dc9a74f72012-08-17 18:07:21272 bool HasUsedWebRequest(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34273 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value);
[email protected]39a5b532011-10-22 01:47:07274
[email protected]1bead0712010-11-27 17:41:53275 // Getter for the extension's runtime data PropertyBag.
[email protected]1c321ee2012-05-21 03:02:34276 base::PropertyBag* GetPropertyBag(const extensions::Extension* extension);
[email protected]1bead0712010-11-27 17:41:53277
[email protected]6014d672008-12-05 00:38:25278 // Initialize and start all installed extensions.
[email protected]9f1087e2009-06-15 17:29:32279 void Init();
[email protected]6014d672008-12-05 00:38:25280
[email protected]cf593af2011-12-30 05:44:39281 // To delay some initialization until after import has finished, register
282 // for the notification.
283 // TODO(yoz): remove InitEventRoutersAterImport.
[email protected]d91268022011-08-26 13:17:37284 void InitEventRoutersAfterImport();
[email protected]cf593af2011-12-30 05:44:39285 void RegisterForImportFinished();
286
287 // Complete some initialization after being notified that import has finished.
288 void InitAfterImport();
[email protected]d91268022011-08-26 13:17:37289
[email protected]c5ae74ab2010-04-15 18:14:37290 // Start up the extension event routers.
291 void InitEventRouters();
292
[email protected]8001df22011-04-28 19:59:47293 // Look up an extension by ID. Does not include terminated
294 // extensions.
[email protected]1c321ee2012-05-21 03:02:34295 virtual const extensions::Extension* GetExtensionById(
[email protected]b05fb9ff2011-04-23 00:07:56296 const std::string& id, bool include_disabled) const OVERRIDE;
[email protected]0c6da502009-08-14 22:32:39297
[email protected]8001df22011-04-28 19:59:47298 // Looks up a terminated (crashed) extension by ID.
[email protected]1c321ee2012-05-21 03:02:34299 const extensions::Extension*
300 GetTerminatedExtension(const std::string& id) const;
[email protected]8001df22011-04-28 19:59:47301
302 // Looks up an extension by ID, regardless of whether it's enabled,
303 // disabled, or terminated.
[email protected]1c321ee2012-05-21 03:02:34304 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:47305 const std::string& id) const OVERRIDE;
[email protected]0dfe05c2011-02-23 23:03:36306
[email protected]e957fe52009-06-23 16:51:05307 // Updates a currently-installed extension with the contents from
[email protected]7577a5c52009-07-30 06:21:58308 // |extension_path|.
[email protected]2a464a92009-08-01 17:58:35309 // TODO(aa): This method can be removed. ExtensionUpdater could use
310 // CrxInstaller directly instead.
[email protected]420a0ec2011-06-01 01:07:03311 virtual bool UpdateExtension(
312 const std::string& id,
313 const FilePath& extension_path,
314 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:27315 extensions::CrxInstaller** out_crx_installer) OVERRIDE;
[email protected]e957fe52009-06-23 16:51:05316
[email protected]9cddd4702009-07-27 22:09:40317 // Reloads the specified extension.
318 void ReloadExtension(const std::string& extension_id);
319
[email protected]631cf822009-05-15 07:01:25320 // Uninstalls the specified extension. Callers should only call this method
[email protected]17c4f3c2009-07-04 16:36:25321 // with extensions that exist. |external_uninstall| is a magical parameter
322 // that is only used to send information to ExtensionPrefs, which external
323 // callers should never set to true.
[email protected]a12c706e2011-12-01 00:58:08324 //
325 // We pass the |extension_id| by value to avoid having it deleted from under
326 // us incase someone calls it with Extension::id() or another string that we
327 // are going to delete in this function.
328 //
[email protected]17c4f3c2009-07-04 16:36:25329 // TODO(aa): Remove |external_uninstall| -- this information should be passed
330 // to ExtensionPrefs some other way.
[email protected]a12c706e2011-12-01 00:58:08331 virtual bool UninstallExtension(std::string extension_id,
[email protected]d6ebc9792011-04-07 18:18:33332 bool external_uninstall,
[email protected]65187152012-06-02 13:14:14333 string16* error);
[email protected]631cf822009-05-15 07:01:25334
[email protected]b05fb9ff2011-04-23 00:07:56335 virtual bool IsExtensionEnabled(
336 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35337 virtual bool IsExternalExtensionUninstalled(
[email protected]b05fb9ff2011-04-23 00:07:56338 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35339
[email protected]06f92562011-04-29 19:27:31340 // Enables the extension. If the extension is already enabled, does
341 // nothing.
[email protected]2859946f2011-04-04 18:18:06342 virtual void EnableExtension(const std::string& extension_id);
[email protected]06f92562011-04-29 19:27:31343
344 // Disables the extension. If the extension is already disabled, or
345 // cannot be disabled, does nothing.
[email protected]44d62b62012-04-11 00:06:03346 virtual void DisableExtension(const std::string& extension_id,
[email protected]1c321ee2012-05-21 03:02:34347 extensions::Extension::DisableReason disable_reason);
[email protected]0c6da502009-08-14 22:32:39348
[email protected]8d888c12010-11-30 00:00:25349 // Updates the |extension|'s granted permissions lists to include all
[email protected]8d888c12010-11-30 00:00:25350 // permissions in the |extension|'s manifest and re-enables the
351 // extension.
[email protected]1c321ee2012-05-21 03:02:34352 void GrantPermissionsAndEnableExtension(
[email protected]b70a2d92012-06-28 19:51:21353 const extensions::Extension* extension,
354 bool record_oauth2_grant);
[email protected]8d888c12010-11-30 00:00:25355
[email protected]9f1087e2009-06-15 17:29:32356 // Check for updates (or potentially new extensions from external providers)
[email protected]93fd78f42009-07-10 16:43:17357 void CheckForExternalUpdates();
[email protected]9f1087e2009-06-15 17:29:32358
359 // Unload the specified extension.
[email protected]25ae0152011-11-18 14:40:02360 virtual void UnloadExtension(
361 const std::string& extension_id,
[email protected]1cc91fe2011-11-21 14:48:43362 extension_misc::UnloadedExtensionReason reason) OVERRIDE;
[email protected]9f1087e2009-06-15 17:29:32363
[email protected]57f71b92009-09-11 19:31:38364 // Unload all extensions. This is currently only called on shutdown, and
365 // does not send notifications.
[email protected]9f1087e2009-06-15 17:29:32366 void UnloadAllExtensions();
367
368 // Called only by testing.
369 void ReloadExtensions();
370
371 // Scan the extension directory and clean up the cruft.
372 void GarbageCollectExtensions();
373
[email protected]fb82dcd2012-03-21 14:15:46374 // Notifies Sync (if needed) of a newly-installed extension or a change to
375 // an existing extension.
[email protected]1c321ee2012-05-21 03:02:34376 virtual void SyncExtensionChangeIfNeeded(
377 const extensions::Extension& extension) OVERRIDE;
[email protected]fb82dcd2012-03-21 14:15:46378
[email protected]583d45c12010-08-31 02:48:12379 // Returns true if |url| should get extension api bindings and be permitted
380 // to make api calls. Note that this is independent of what extension
381 // permissions the given extension has been granted.
382 bool ExtensionBindingsAllowed(const GURL& url);
383
[email protected]b671760b2010-07-15 21:13:47384 // Returns the icon to display in the omnibox for the given extension.
385 const SkBitmap& GetOmniboxIcon(const std::string& extension_id);
386
[email protected]29d0d4ac2010-09-08 21:10:31387 // Returns the icon to display in the omnibox popup window for the given
388 // extension.
389 const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id);
390
[email protected]c6d474f82009-12-16 21:11:06391 // Called when the initial extensions load has completed.
392 virtual void OnLoadedInstalledExtensions();
[email protected]7577a5c52009-07-30 06:21:58393
[email protected]49cd1572011-02-08 21:38:45394 // Adds |extension| to this ExtensionService and notifies observers than an
395 // extension has been loaded. Called by the backend after an extension has
396 // been loaded from a file and installed.
[email protected]1c321ee2012-05-21 03:02:34397 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE;
[email protected]7577a5c52009-07-30 06:21:58398
399 // Called by the backend when an extension has been installed.
[email protected]8266d662011-07-12 21:53:26400 void OnExtensionInstalled(
[email protected]1c321ee2012-05-21 03:02:34401 const extensions::Extension* extension,
[email protected]36a5c4c2011-12-14 16:34:50402 bool from_webstore,
403 const StringOrdinal& page_ordinal);
[email protected]7577a5c52009-07-30 06:21:58404
[email protected]902fd7b2011-07-27 18:42:31405 // Initializes the |extension|'s active permission set and disables the
406 // extension if the privilege level has increased (e.g., due to an upgrade).
[email protected]1c321ee2012-05-21 03:02:34407 void InitializePermissions(const extensions::Extension* extension);
[email protected]8d888c12010-11-30 00:00:25408
[email protected]6b75ec32009-08-14 06:37:18409 // Go through each extensions in pref, unload blacklisted extensions
410 // and update the blacklist state in pref.
411 virtual void UpdateExtensionBlacklist(
[email protected]8266d662011-07-12 21:53:26412 const std::vector<std::string>& blacklist) OVERRIDE;
[email protected]6b75ec32009-08-14 06:37:18413
[email protected]aa96d3a2010-08-21 08:45:25414 // Go through each extension and unload those that the network admin has
[email protected]65187152012-06-02 13:14:14415 // put on the blacklist (not to be confused with the Google-managed blacklist)
[email protected]aa96d3a2010-08-21 08:45:25416 // set of extensions.
[email protected]b05fb9ff2011-04-23 00:07:56417 virtual void CheckAdminBlacklist() OVERRIDE;
[email protected]aa96d3a2010-08-21 08:45:25418
[email protected]b05fb9ff2011-04-23 00:07:56419 virtual void CheckForUpdatesSoon() OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35420
[email protected]65f173552012-06-28 22:43:58421 // syncer::SyncableService implementation.
422 virtual syncer::SyncError MergeDataAndStartSyncing(
[email protected]a4a147652012-07-03 23:41:32423 syncer::ModelType type,
[email protected]65f173552012-06-28 22:43:58424 const syncer::SyncDataList& initial_sync_data,
425 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
426 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
[email protected]a4a147652012-07-03 23:41:32427 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
[email protected]65f173552012-06-28 22:43:58428 virtual syncer::SyncDataList GetAllSyncData(
[email protected]a4a147652012-07-03 23:41:32429 syncer::ModelType type) const OVERRIDE;
[email protected]65f173552012-06-28 22:43:58430 virtual syncer::SyncError ProcessSyncChanges(
[email protected]3bdba0d2011-08-23 07:17:30431 const tracked_objects::Location& from_here,
[email protected]65f173552012-06-28 22:43:58432 const syncer::SyncChangeList& change_list) OVERRIDE;
[email protected]90310d92011-04-17 07:35:04433
[email protected]5db9ada2012-04-11 13:48:20434 // Gets the sync data for the given extension, assuming that the extension is
435 // syncable.
436 extensions::ExtensionSyncData GetExtensionSyncData(
[email protected]1c321ee2012-05-21 03:02:34437 const extensions::Extension& extension) const;
[email protected]5db9ada2012-04-11 13:48:20438
439 // Gets the sync data for the given app, assuming that the app is
440 // syncable.
[email protected]1c321ee2012-05-21 03:02:34441 extensions::AppSyncData GetAppSyncData(
442 const extensions::Extension& extension) const;
[email protected]5db9ada2012-04-11 13:48:20443
444 // Gets the ExtensionSyncData for all extensions.
445 std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const;
446
447 // Gets the AppSyncData for all extensions.
448 std::vector<extensions::AppSyncData> GetAppSyncDataList() const;
449
450 // Applies the change specified passed in by either ExtensionSyncData or
451 // AppSyncData to the current system.
452 // Returns false if the changes were not completely applied and were added
453 // to the pending list to be tried again.
454 bool ProcessExtensionSyncData(
455 const extensions::ExtensionSyncData& extension_sync_data);
456 bool ProcessAppSyncData(const extensions::AppSyncData& app_sync_data);
457
458
[email protected]7577a5c52009-07-30 06:21:58459 void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; }
[email protected]abe7a8942009-06-23 05:14:29460 bool extensions_enabled() { return extensions_enabled_; }
461
[email protected]0e34d7892009-06-05 19:17:40462 void set_show_extensions_prompts(bool enabled) {
463 show_extensions_prompts_ = enabled;
[email protected]e2eb43112009-05-29 21:19:54464 }
465
[email protected]0e34d7892009-06-05 19:17:40466 bool show_extensions_prompts() {
467 return show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54468 }
469
[email protected]c3cfb012011-04-06 22:07:35470 Profile* profile();
[email protected]24e7a9d2009-11-04 11:11:34471
[email protected]c3cfb012011-04-06 22:07:35472 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const,
473 // ExtensionPrefs* mutable_extension_prefs().
[email protected]45759612012-07-10 17:21:23474 extensions::ExtensionPrefs* extension_prefs();
[email protected]e81dba32009-06-19 20:19:13475
[email protected]0d9a2202011-11-09 13:48:41476 extensions::SettingsFrontend* settings_frontend();
[email protected]b7f853e282011-08-10 09:24:20477
[email protected]e2d720aa2012-05-17 00:11:35478 extensions::ContentSettingsStore* GetContentSettingsStore();
[email protected]b790b072011-05-20 09:46:44479
[email protected]3ecda252010-11-18 19:50:55480 // Whether the extension service is ready.
[email protected]25ae0152011-11-18 14:40:02481 virtual bool is_ready() OVERRIDE;
[email protected]3ecda252010-11-18 19:50:55482
[email protected]d8c8f25f2011-11-02 18:18:01483 extensions::ComponentLoader* component_loader() {
484 return component_loader_.get();
485 }
486
[email protected]1fab8452009-09-03 02:23:39487 // Note that this may return NULL if autoupdate is not turned on.
[email protected]42a08162012-03-16 18:09:11488 extensions::ExtensionUpdater* updater();
[email protected]1fab8452009-09-03 02:23:39489
[email protected]e0360f2c2009-12-07 22:34:31490 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; }
491
[email protected]d13950e2009-12-04 01:43:02492 ExtensionsQuotaService* quota_service() { return &quota_service_; }
493
[email protected]5aeeae12012-07-05 19:13:11494 extensions::MenuManager* menu_manager() { return &menu_manager_; }
[email protected]2e3b5202010-03-23 06:52:41495
[email protected]8d92e0382012-08-01 18:06:52496 extensions::AppNotificationManager* app_notification_manager() {
[email protected]af9db5f2011-10-05 05:13:15497 return app_notification_manager_.get();
[email protected]c1d05aa2011-06-28 02:07:30498 }
499
[email protected]5a38dfd2012-07-23 23:22:10500 extensions::BrowserEventRouter* browser_event_router() {
[email protected]97d2f1d2011-01-15 00:41:08501 return browser_event_router_.get();
502 }
503
[email protected]163ed192012-07-24 19:31:07504 extensions::WindowEventRouter* window_event_router() {
505 return window_event_router_.get();
506 }
507
[email protected]b16fc2e2011-07-21 21:32:58508#if defined(OS_CHROMEOS)
[email protected]f463bc92012-03-22 16:38:23509 chromeos::ExtensionBluetoothEventRouter* bluetooth_event_router() {
510 return bluetooth_event_router_.get();
511 }
[email protected]771a6182011-10-05 16:32:52512 chromeos::ExtensionInputMethodEventRouter* input_method_event_router() {
513 return input_method_event_router_.get();
514 }
[email protected]b16fc2e2011-07-21 21:32:58515#endif
516
[email protected]5ebd6a62012-08-01 23:54:39517 extensions::PushMessagingEventRouter* push_messaging_event_router() {
518 return push_messaging_event_router_.get();
519 }
520
[email protected]d11c8e92009-10-20 23:26:40521 // Notify the frontend that there was an error loading an extension.
[email protected]d8c8f25f2011-11-02 18:18:01522 // This method is public because UnpackedInstaller and InstalledLoader
523 // can post to here.
524 // TODO(aa): Remove this. It doesn't do enough to be worth the dependency
525 // of these classes on ExtensionService.
[email protected]d11c8e92009-10-20 23:26:40526 void ReportExtensionLoadError(const FilePath& extension_path,
527 const std::string& error,
[email protected]d11c8e92009-10-20 23:26:40528 bool be_noisy);
529
[email protected]406027c02010-09-27 08:03:18530 // ExtensionHost of background page calls this method right after its render
531 // view has been created.
[email protected]3a1dc572012-07-31 22:25:13532 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host);
[email protected]406027c02010-09-27 08:03:18533
[email protected]8e4560b62011-01-14 10:09:14534 // For the extension in |version_path| with |id|, check to see if it's an
535 // externally managed extension. If so, uninstall it.
536 void CheckExternalUninstall(const std::string& id);
537
[email protected]5df038b2012-07-16 19:03:27538 // Clear all ExternalProviders.
[email protected]8e4560b62011-01-14 10:09:14539 void ClearProvidersForTesting();
540
[email protected]5df038b2012-07-16 19:03:27541 // Adds an ExternalProviderInterface for the service to use during testing.
542 // Takes ownership of |test_provider|.
543 void AddProviderForTesting(
544 extensions::ExternalProviderInterface* test_provider);
[email protected]8e4560b62011-01-14 10:09:14545
[email protected]5df038b2012-07-16 19:03:27546 // ExternalProvider::Visitor implementation.
[email protected]1c321ee2012-05-21 03:02:34547 virtual bool OnExternalExtensionFileFound(
548 const std::string& id,
549 const Version* version,
550 const FilePath& path,
551 extensions::Extension::Location location,
552 int creation_flags,
553 bool mark_acknowledged) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14554
[email protected]1c321ee2012-05-21 03:02:34555 virtual bool OnExternalExtensionUpdateUrlFound(
556 const std::string& id,
557 const GURL& update_url,
558 extensions::Extension::Location location) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14559
[email protected]50067e52011-10-20 23:17:07560 virtual void OnExternalProviderReady(
[email protected]5df038b2012-07-16 19:03:27561 const extensions::ExternalProviderInterface* provider) OVERRIDE;
[email protected]50067e52011-10-20 23:17:07562
[email protected]94fde232012-04-27 10:22:30563 // Returns true when all the external extension providers are ready.
564 bool AreAllExternalProvidersReady() const;
565
[email protected]50067e52011-10-20 23:17:07566 void OnAllExternalProvidersReady();
[email protected]8e4560b62011-01-14 10:09:14567
[email protected]62433d32011-10-12 22:33:12568 // Once all external providers are done, generates any needed alerts about
[email protected]e5af875f2011-10-10 21:09:14569 // extensions.
570 void IdentifyAlertableExtensions();
571
[email protected]89226982012-07-16 20:09:18572 // Given an ExtensionErrorUI alert, populates it with any extensions that
[email protected]07c9f2f42012-02-29 18:45:22573 // need alerting. Returns true if the alert should be displayed at all.
574 //
[email protected]89226982012-07-16 20:09:18575 // This method takes the extension_error_ui argument rather than using
[email protected]07c9f2f42012-02-29 18:45:22576 // the member variable to make it easier to test the method in isolation.
[email protected]89226982012-07-16 20:09:18577 bool PopulateExtensionErrorUI(ExtensionErrorUI* extension_error_ui);
[email protected]07c9f2f42012-02-29 18:45:22578
[email protected]62433d32011-10-12 22:33:12579 // Marks alertable extensions as acknowledged, after the user presses the
580 // accept button.
[email protected]a9aa5932012-01-25 08:27:40581 void HandleExtensionAlertAccept();
[email protected]e5af875f2011-10-10 21:09:14582
[email protected]47fc70c2011-12-06 07:29:51583 // Given a (presumably just-installed) extension id, mark that extension as
584 // acknowledged.
585 void AcknowledgeExternalExtension(const std::string& id);
586
[email protected]62433d32011-10-12 22:33:12587 // Opens the Extensions page because the user wants to get more details
588 // about the alerts.
[email protected]89226982012-07-16 20:09:18589 void HandleExtensionAlertDetails();
[email protected]62433d32011-10-12 22:33:12590
[email protected]a9aa5932012-01-25 08:27:40591 // Called when the extension alert is closed.
592 void HandleExtensionAlertClosed();
[email protected]e5af875f2011-10-10 21:09:14593
[email protected]6c2381d2011-10-19 02:52:53594 // content::NotificationObserver
[email protected]432115822011-07-10 15:52:27595 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53596 const content::NotificationSource& source,
597 const content::NotificationDetails& details) OVERRIDE;
[email protected]4814b512009-11-07 00:12:29598
[email protected]ec5b50d2010-10-09 16:35:18599 // Whether there are any apps installed. Component apps are not included.
600 bool HasApps() const;
601
602 // Gets the set of loaded app ids. Component apps are not included.
[email protected]1c321ee2012-05-21 03:02:34603 extensions::ExtensionIdSet GetAppIds() const;
[email protected]377011d2010-07-20 04:18:50604
[email protected]fe2dd7742011-04-19 22:52:49605 // Record a histogram using the PermissionMessage enum values for each
606 // permission in |e|.
607 // NOTE: If this is ever called with high frequency, the implementation may
608 // need to be made more efficient.
609 static void RecordPermissionMessagesHistogram(
[email protected]1c321ee2012-05-21 03:02:34610 const extensions::Extension* e, const char* histogram);
[email protected]fe2dd7742011-04-19 22:52:49611
[email protected]fa2416f2011-05-03 08:41:20612#if defined(UNIT_TEST)
[email protected]1c321ee2012-05-21 03:02:34613 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
[email protected]fa2416f2011-05-03 08:41:20614 TrackTerminatedExtension(extension);
615 }
616#endif
617
[email protected]7c1490da2011-10-11 18:53:25618 ExtensionWarningSet* extension_warnings() {
619 return &extension_warnings_;
620 }
621
[email protected]b1912d592012-08-17 22:29:38622 extensions::AppShortcutManager* app_shortcut_manager() {
623 return &app_shortcut_manager_;
624 }
[email protected]178f8512012-02-09 01:49:36625
[email protected]65f173552012-06-28 22:43:58626 // Specialization of syncer::SyncableService::AsWeakPtr.
[email protected]77e4dc0882012-06-20 18:53:50627 base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); }
628
[email protected]14908b72011-04-20 06:54:36629 private:
[email protected]d7e9a862010-11-03 21:57:49630 // Contains Extension data that can change during the life of the process,
631 // but does not persist across restarts.
632 struct ExtensionRuntimeData {
633 // True if the background page is ready.
634 bool background_page_ready;
635
636 // True while the extension is being upgraded.
637 bool being_upgraded;
638
[email protected]39a5b532011-10-22 01:47:07639 // True if the extension has used the webRequest API.
640 bool has_used_webrequest;
641
[email protected]1bead0712010-11-27 17:41:53642 // Generic bag of runtime data that users can associate with extensions.
[email protected]45644f62011-11-23 00:58:23643 base::PropertyBag property_bag;
[email protected]1bead0712010-11-27 17:41:53644
[email protected]d7e9a862010-11-03 21:57:49645 ExtensionRuntimeData();
646 ~ExtensionRuntimeData();
647 };
648 typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap;
649
[email protected]cebc3dc2011-04-18 17:15:00650 struct NaClModuleInfo {
651 NaClModuleInfo();
652 ~NaClModuleInfo();
653
654 GURL url;
655 std::string mime_type;
656 };
657 typedef std::list<NaClModuleInfo> NaClModuleInfoList;
658
[email protected]5db9ada2012-04-11 13:48:20659 // Return true if the sync type of |extension| matches |type|.
[email protected]1c321ee2012-05-21 03:02:34660 bool IsCorrectSyncType(const extensions::Extension& extension,
[email protected]a4a147652012-07-03 23:41:32661 syncer::ModelType type)
[email protected]3bdba0d2011-08-23 07:17:30662 const;
663
[email protected]5db9ada2012-04-11 13:48:20664 // Handles setting the extension specific values in |extension_sync_data| to
665 // the current system.
666 // Returns false if the changes were not completely applied and need to be
667 // tried again later.
668 bool ProcessExtensionSyncDataHelper(
669 const extensions::ExtensionSyncData& extension_sync_data,
[email protected]a4a147652012-07-03 23:41:32670 syncer::ModelType type);
[email protected]3bdba0d2011-08-23 07:17:30671
[email protected]81f0d162012-08-15 04:21:47672 enum IncludeFlag {
673 INCLUDE_NONE = 0,
674 INCLUDE_ENABLED = 1 << 0,
675 INCLUDE_DISABLED = 1 << 1,
676 INCLUDE_TERMINATED = 1 << 2
677 };
678
[email protected]0c6da502009-08-14 22:32:39679 // Look up an extension by ID, optionally including either or both of enabled
680 // and disabled extensions.
[email protected]1c321ee2012-05-21 03:02:34681 const extensions::Extension* GetExtensionByIdInternal(
682 const std::string& id,
[email protected]81f0d162012-08-15 04:21:47683 int include_mask) const;
[email protected]0c6da502009-08-14 22:32:39684
[email protected]fa2416f2011-05-03 08:41:20685 // Adds the given extension to the list of terminated extensions if
686 // it is not already there and unloads it.
[email protected]1c321ee2012-05-21 03:02:34687 void TrackTerminatedExtension(const extensions::Extension* extension);
[email protected]fa2416f2011-05-03 08:41:20688
689 // Removes the extension with the given id from the list of
690 // terminated extensions if it is there.
[email protected]bb7f40952011-01-13 00:21:20691 void UntrackTerminatedExtension(const std::string& id);
692
[email protected]62d30f42009-10-01 22:36:06693 // Handles sending notification that |extension| was loaded.
[email protected]1c321ee2012-05-21 03:02:34694 void NotifyExtensionLoaded(const extensions::Extension* extension);
[email protected]62d30f42009-10-01 22:36:06695
696 // Handles sending notification that |extension| was unloaded.
[email protected]1c321ee2012-05-21 03:02:34697 void NotifyExtensionUnloaded(const extensions::Extension* extension,
[email protected]814a7bf0f2011-08-13 05:30:59698 extension_misc::UnloadedExtensionReason reason);
[email protected]62d30f42009-10-01 22:36:06699
[email protected]aab98a52009-12-02 03:22:35700 // Helper that updates the active extension list used for crash reporting.
701 void UpdateActiveExtensionsInCrashReporter();
702
[email protected]cebc3dc2011-04-18 17:15:00703 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
704 // strong sandbox. Typically, these NaCl modules are stored in extensions
705 // and registered here. Not all NaCl modules need to register for a MIME
706 // type, just the ones that are responsible for rendering a particular MIME
707 // type, like application/pdf. Note: We only register NaCl modules in the
708 // browser process.
709 void RegisterNaClModule(const GURL& url, const std::string& mime_type);
710 void UnregisterNaClModule(const GURL& url);
711
[email protected]ed0ba002011-05-26 16:55:13712 // Call UpdatePluginListWithNaClModules() after registering or unregistering
713 // a NaCl module to see those changes reflected in the PluginList.
714 void UpdatePluginListWithNaClModules();
715
[email protected]cebc3dc2011-04-18 17:15:00716 NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
717
[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]73c47932010-12-06 18:13:43724 // Preferences for the owning profile (weak reference).
[email protected]45759612012-07-10 17:21:23725 extensions::ExtensionPrefs* extension_prefs_;
[email protected]894bb502009-05-21 22:39:57726
[email protected]adfc5462011-09-21 19:07:13727 // Settings for the owning profile.
[email protected]cccdf0aa2011-11-11 03:43:38728 scoped_ptr<extensions::SettingsFrontend> settings_frontend_;
[email protected]b7f853e282011-08-10 09:24:20729
[email protected]6014d672008-12-05 00:38:25730 // The current list of installed extensions.
[email protected]84df8332011-12-06 18:22:46731 ExtensionSet extensions_;
[email protected]6014d672008-12-05 00:38:25732
[email protected]0c6da502009-08-14 22:32:39733 // The list of installed extensions that have been disabled.
[email protected]84df8332011-12-06 18:22:46734 ExtensionSet disabled_extensions_;
[email protected]0c6da502009-08-14 22:32:39735
[email protected]bb7f40952011-01-13 00:21:20736 // The list of installed extensions that have been terminated.
[email protected]84df8332011-12-06 18:22:46737 ExtensionSet terminated_extensions_;
[email protected]bb7f40952011-01-13 00:21:20738
[email protected]b2907fd2011-03-25 16:43:37739 // Hold the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41740 extensions::PendingExtensionManager pending_extension_manager_;
[email protected]aa142702010-03-26 01:26:33741
[email protected]d7e9a862010-11-03 21:57:49742 // The map of extension IDs to their runtime data.
743 ExtensionRuntimeDataMap extension_runtime_data_;
744
[email protected]da5683db2011-04-23 17:12:21745 // Holds a map between renderer process IDs that are associated with an
746 // installed app and their app.
[email protected]1c321ee2012-05-21 03:02:34747 typedef std::map<int, scoped_refptr<const extensions::Extension> >
748 InstalledAppMap;
[email protected]da5683db2011-04-23 17:12:21749 InstalledAppMap installed_app_hosts_;
750
[email protected]6014d672008-12-05 00:38:25751 // The full path to the directory where extensions are installed.
752 FilePath install_directory_;
753
[email protected]e2eb43112009-05-29 21:19:54754 // Whether or not extensions are enabled.
755 bool extensions_enabled_;
756
[email protected]0e34d7892009-06-05 19:17:40757 // Whether to notify users when they attempt to install an extension.
758 bool show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54759
[email protected]d13950e2009-12-04 01:43:02760 // Used by dispatchers to limit API quota for individual extensions.
761 ExtensionsQuotaService quota_service_;
762
[email protected]432115822011-07-10 15:52:27763 // Record that Init() has been called, and chrome::EXTENSIONS_READY
[email protected]fa6a9102010-11-22 15:38:50764 // has fired.
[email protected]3ecda252010-11-18 19:50:55765 bool ready_;
[email protected]e81dba32009-06-19 20:19:13766
[email protected]93fd78f42009-07-10 16:43:17767 // Our extension updater, if updates are turned on.
[email protected]42a08162012-03-16 18:09:11768 scoped_ptr<extensions::ExtensionUpdater> updater_;
[email protected]93fd78f42009-07-10 16:43:17769
[email protected]e0360f2c2009-12-07 22:34:31770 // The model that tracks extensions with BrowserAction buttons.
771 ExtensionToolbarModel toolbar_model_;
772
[email protected]1eb175082010-02-10 09:26:16773 // Map unloaded extensions' ids to their paths. When a temporarily loaded
[email protected]5fb889382011-06-03 00:29:20774 // extension is unloaded, we lose the information about it and don't have
[email protected]1eb175082010-02-10 09:26:16775 // any in the extension preferences file.
776 typedef std::map<std::string, FilePath> UnloadedExtensionPathMap;
777 UnloadedExtensionPathMap unloaded_extension_paths_;
778
[email protected]f17dbd42010-08-16 23:21:10779 // Map disabled extensions' ids to their paths. When a temporarily loaded
780 // extension is disabled before it is reloaded, keep track of the path so that
781 // it can be re-enabled upon a successful load.
782 typedef std::map<std::string, FilePath> DisabledExtensionPathMap;
783 DisabledExtensionPathMap disabled_extension_paths_;
784
[email protected]4814b512009-11-07 00:12:29785 // Map of inspector cookies that are detached, waiting for an extension to be
786 // reloaded.
787 typedef std::map<std::string, int> OrphanedDevTools;
788 OrphanedDevTools orphaned_dev_tools_;
789
[email protected]6c2381d2011-10-19 02:52:53790 content::NotificationRegistrar registrar_;
[email protected]2fb7dc982010-09-29 12:24:28791 PrefChangeRegistrar pref_change_registrar_;
[email protected]4814b512009-11-07 00:12:29792
[email protected]d8c8f25f2011-11-02 18:18:01793 // Keeps track of loading and unloading component extensions.
794 scoped_ptr<extensions::ComponentLoader> component_loader_;
795
[email protected]2e3b5202010-03-23 06:52:41796 // Keeps track of menu items added by extensions.
[email protected]5aeeae12012-07-05 19:13:11797 extensions::MenuManager menu_manager_;
[email protected]2e3b5202010-03-23 06:52:41798
[email protected]c1d05aa2011-06-28 02:07:30799 // Keeps track of app notifications.
[email protected]8d92e0382012-08-01 18:06:52800 scoped_refptr<extensions::AppNotificationManager> app_notification_manager_;
[email protected]c1d05aa2011-06-28 02:07:30801
[email protected]b671760b2010-07-15 21:13:47802 // Keeps track of favicon-sized omnibox icons for extensions.
803 ExtensionIconManager omnibox_icon_manager_;
[email protected]29d0d4ac2010-09-08 21:10:31804 ExtensionIconManager omnibox_popup_icon_manager_;
[email protected]b671760b2010-07-15 21:13:47805
[email protected]b3d62312b12010-10-14 21:10:18806 // Flag to make sure event routers are only initialized once.
807 bool event_routers_initialized_;
808
[email protected]d2e6bd62011-10-24 20:29:07809 scoped_ptr<HistoryExtensionEventRouter> history_event_router_;
[email protected]f825df22011-06-28 17:36:10810
[email protected]5a38dfd2012-07-23 23:22:10811 scoped_ptr<extensions::BrowserEventRouter> browser_event_router_;
[email protected]da55b8d2011-05-26 00:09:49812
[email protected]163ed192012-07-24 19:31:07813 scoped_ptr<extensions::WindowEventRouter> window_event_router_;
814
[email protected]7da9a8232011-05-27 21:07:11815 scoped_ptr<ExtensionPreferenceEventRouter> preference_event_router_;
[email protected]118de7892011-03-16 13:31:40816
[email protected]23d5f172011-10-25 05:49:53817 scoped_ptr<BookmarkExtensionEventRouter> bookmark_event_router_;
[email protected]f825df22011-06-28 17:36:10818
[email protected]92ba7b012012-05-16 03:36:17819 scoped_ptr<extensions::ExtensionCookiesEventRouter> cookies_event_router_;
[email protected]f825df22011-06-28 17:36:10820
821 scoped_ptr<ExtensionManagementEventRouter> management_event_router_;
822
[email protected]5ebd6a62012-08-01 23:54:39823 scoped_ptr<extensions::PushMessagingEventRouter>
824 push_messaging_event_router_;
825
[email protected]017ecde92012-04-04 09:11:26826 scoped_ptr<extensions::WebNavigationEventRouter> web_navigation_event_router_;
[email protected]f825df22011-06-28 17:36:10827
[email protected]91aa8a32012-08-07 10:35:33828 scoped_ptr<extensions::FontSettingsEventRouter> font_settings_event_router_;
[email protected]bdd34452012-04-16 15:58:40829
[email protected]9c70e0d92012-07-16 08:39:44830 scoped_ptr<extensions::ExtensionManagedModeEventRouter>
831 managed_mode_event_router_;
[email protected]8a4cf842012-05-16 13:35:30832
[email protected]b16fc2e2011-07-21 21:32:58833#if defined(OS_CHROMEOS)
[email protected]f463bc92012-03-22 16:38:23834 scoped_ptr<chromeos::ExtensionBluetoothEventRouter> bluetooth_event_router_;
[email protected]771a6182011-10-05 16:32:52835 scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
836 input_method_event_router_;
[email protected]b16fc2e2011-07-21 21:32:58837#endif
838
[email protected]8e4560b62011-01-14 10:09:14839 // A collection of external extension providers. Each provider reads
840 // a source of external extension information. Examples include the
841 // windows registry and external_extensions.json.
[email protected]5df038b2012-07-16 19:03:27842 extensions::ProviderCollection external_extension_providers_;
[email protected]8e4560b62011-01-14 10:09:14843
844 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
[email protected]94fde232012-04-27 10:22:30845 // extension URL is found, and by CheckForUpdatesSoon() when an update check
846 // has to wait for the external providers. Used in
847 // OnAllExternalProvidersReady() to determine if an update check is needed to
848 // install pending extensions.
849 bool update_once_all_providers_are_ready_;
[email protected]8e4560b62011-01-14 10:09:14850
[email protected]cebc3dc2011-04-18 17:15:00851 NaClModuleInfoList nacl_module_list_;
852
[email protected]5db9ada2012-04-11 13:48:20853 extensions::AppSyncBundle app_sync_bundle_;
854 extensions::ExtensionSyncBundle extension_sync_bundle_;
[email protected]3bdba0d2011-08-23 07:17:30855
[email protected]7c1490da2011-10-11 18:53:25856 // Contains an entry for each warning that shall be currently shown.
857 ExtensionWarningSet extension_warnings_;
858
[email protected]6f371442011-11-09 06:45:46859 extensions::ProcessMap process_map_;
860
[email protected]b1912d592012-08-17 22:29:38861 extensions::AppShortcutManager app_shortcut_manager_;
[email protected]9de83282011-12-12 11:06:37862
[email protected]89226982012-07-16 20:09:18863 scoped_ptr<ExtensionErrorUI> extension_error_ui_;
[email protected]a9aa5932012-01-25 08:27:40864
[email protected]9ce11d22012-08-08 23:20:13865#if defined(ENABLE_EXTENSIONS)
[email protected]c77f2352012-08-08 22:07:58866 scoped_ptr<extensions::ExtensionActionStorageManager>
867 extension_action_storage_manager_;
[email protected]9ce11d22012-08-08 23:20:13868#endif
[email protected]c77f2352012-08-08 22:07:58869
[email protected]eaa7dd182010-12-14 11:09:00870 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]c2c263c2010-08-13 21:59:48871 InstallAppsWithUnlimtedStorage);
[email protected]eaa7dd182010-12-14 11:09:00872 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]654512b2010-09-01 02:09:42873 InstallAppsAndCheckStorageProtection);
[email protected]eaa7dd182010-12-14 11:09:00874 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
[email protected]6014d672008-12-05 00:38:25875};
876
[email protected]eaa7dd182010-12-14 11:09:00877#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_