blob: f18d5e01e7a5cf8880cb7de2004bbba66256fa19 [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]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]6014d672008-12-05 00:38:2515#include "base/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]03b9b4e2012-10-22 20:01:5219#include "base/prefs/public/pref_change_registrar.h"
[email protected]65187152012-06-02 13:14:1420#include "base/string16.h"
[email protected]178f8512012-02-09 01:49:3621#include "chrome/browser/extensions/app_shortcut_manager.h"
[email protected]5db9ada2012-04-11 13:48:2022#include "chrome/browser/extensions/app_sync_bundle.h"
[email protected]b671760b2010-07-15 21:13:4723#include "chrome/browser/extensions/extension_icon_manager.h"
[email protected]c38831a12011-10-28 12:44:4924#include "chrome/browser/extensions/extension_prefs.h"
[email protected]c6e4a3412009-06-24 15:45:2925#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]5db9ada2012-04-11 13:48:2026#include "chrome/browser/extensions/extension_sync_bundle.h"
[email protected]e0360f2c2009-12-07 22:34:3127#include "chrome/browser/extensions/extension_toolbar_model.h"
[email protected]7c1490da2011-10-11 18:53:2528#include "chrome/browser/extensions/extension_warning_set.h"
[email protected]d13950e2009-12-04 01:43:0229#include "chrome/browser/extensions/extensions_quota_service.h"
[email protected]5df038b2012-07-16 19:03:2730#include "chrome/browser/extensions/external_provider_interface.h"
[email protected]5aeeae12012-07-05 19:13:1131#include "chrome/browser/extensions/menu_manager.h"
[email protected]b2907fd2011-03-25 16:43:3732#include "chrome/browser/extensions/pending_extension_manager.h"
[email protected]6f371442011-11-09 06:45:4633#include "chrome/browser/extensions/process_map.h"
[email protected]3bdba0d2011-08-23 07:17:3034#include "chrome/common/extensions/extension.h"
[email protected]814a7bf0f2011-08-13 05:30:5935#include "chrome/common/extensions/extension_constants.h"
[email protected]84df8332011-12-06 18:22:4636#include "chrome/common/extensions/extension_set.h"
[email protected]6c2381d2011-10-19 02:52:5337#include "content/public/browser/notification_observer.h"
38#include "content/public/browser/notification_registrar.h"
[email protected]36b643212012-09-07 12:53:0039#include "sync/api/string_ordinal.h"
[email protected]895a1e52012-05-15 02:50:1240#include "sync/api/sync_change.h"
41#include "sync/api/syncable_service.h"
[email protected]6014d672008-12-05 00:38:2542
[email protected]23d5f172011-10-25 05:49:5343class BookmarkExtensionEventRouter;
[email protected]dc9a74f72012-08-17 18:07:2144class CommandLine;
[email protected]89226982012-07-16 20:09:1845class ExtensionErrorUI;
[email protected]f825df22011-06-28 17:36:1046class ExtensionManagementEventRouter;
[email protected]3bdba0d2011-08-23 07:17:3047class ExtensionSyncData;
[email protected]e0360f2c2009-12-07 22:34:3148class ExtensionToolbarModel;
[email protected]d8c8f25f2011-11-02 18:18:0149class HistoryExtensionEventRouter;
[email protected]69f1be82009-04-16 22:27:2150class GURL;
[email protected]81e63782009-02-27 19:35:0951class Profile;
[email protected]aa142702010-03-26 01:26:3352class Version;
53
[email protected]771a6182011-10-05 16:32:5254namespace chromeos {
55class ExtensionInputMethodEventRouter;
[email protected]d8c8f25f2011-11-02 18:18:0156}
57
[email protected]9c70e0d92012-07-16 08:39:4458namespace extensions {
[email protected]8d92e0382012-08-01 18:06:5259class AppNotificationManager;
[email protected]5db9ada2012-04-11 13:48:2060class AppSyncData;
[email protected]5a38dfd2012-07-23 23:22:1061class BrowserEventRouter;
[email protected]d8c8f25f2011-11-02 18:18:0162class ComponentLoader;
[email protected]e2d720aa2012-05-17 00:11:3563class ContentSettingsStore;
[email protected]bf3d9df2012-07-24 23:20:2764class CrxInstaller;
[email protected]1c321ee2012-05-21 03:02:3465class Extension;
[email protected]c77f2352012-08-08 22:07:5866class ExtensionActionStorageManager;
[email protected]cab208eb02012-10-18 22:15:2367class ExtensionBluetoothEventRouter;
[email protected]92ba7b012012-05-16 03:36:1768class ExtensionCookiesEventRouter;
[email protected]163ed192012-07-24 19:31:0769class ExtensionManagedModeEventRouter;
[email protected]5db9ada2012-04-11 13:48:2070class ExtensionSyncData;
[email protected]bd306722012-07-11 20:43:5971class ExtensionSystem;
[email protected]42a08162012-03-16 18:09:1172class ExtensionUpdater;
[email protected]31bb5ee62012-09-12 22:58:4073class FontSettingsEventRouter;
74class MediaGalleriesPrivateEventRouter;
[email protected]3f213ad2012-07-26 23:39:4175class PendingExtensionManager;
[email protected]135e4782012-09-19 20:36:5276class PreferenceEventRouter;
[email protected]31bb5ee62012-09-12 22:58:4077class PushMessagingEventRouter;
[email protected]cccdf0aa2011-11-11 03:43:3878class SettingsFrontend;
[email protected]017ecde92012-04-04 09:11:2679class WebNavigationEventRouter;
[email protected]163ed192012-07-24 19:31:0780class WindowEventRouter;
81}
82
83namespace syncer {
[email protected]163ed192012-07-24 19:31:0784class SyncErrorFactory;
[email protected]d8c8f25f2011-11-02 18:18:0185}
[email protected]771a6182011-10-05 16:32:5286
[email protected]d1ca0ed12009-07-01 18:24:3287// This is an interface class to encapsulate the dependencies that
[email protected]2859946f2011-04-04 18:18:0688// various classes have on ExtensionService. This allows easy mocking.
[email protected]65f173552012-06-28 22:43:5889class ExtensionServiceInterface : public syncer::SyncableService {
[email protected]d1ca0ed12009-07-01 18:24:3290 public:
[email protected]b05fb9ff2011-04-23 00:07:5691 // A function that returns true if the given extension should be
92 // included and false if it should be filtered out. Identical to
93 // PendingExtensionInfo::ShouldAllowInstallPredicate.
[email protected]1c321ee2012-05-21 03:02:3494 typedef bool (*ExtensionFilter)(const extensions::Extension&);
[email protected]b05fb9ff2011-04-23 00:07:5695
[email protected]2859946f2011-04-04 18:18:0696 virtual ~ExtensionServiceInterface() {}
[email protected]84df8332011-12-06 18:22:4697 virtual const ExtensionSet* extensions() const = 0;
[email protected]c38fd352012-03-28 04:06:1298 virtual const ExtensionSet* disabled_extensions() const = 0;
[email protected]3f213ad2012-07-26 23:39:4199 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0;
[email protected]420a0ec2011-06-01 01:07:03100
101 // Install an update. Return true if the install can be started.
102 // Set out_crx_installer to the installer if one was started.
103 virtual bool UpdateExtension(
104 const std::string& id,
105 const FilePath& path,
106 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:27107 extensions::CrxInstaller** out_crx_installer) = 0;
[email protected]1c321ee2012-05-21 03:02:34108 virtual const extensions::Extension* GetExtensionById(const std::string& id,
[email protected]b2907fd2011-03-25 16:43:37109 bool include_disabled) const = 0;
[email protected]1c321ee2012-05-21 03:02:34110 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:47111 const std::string& id) const = 0;
[email protected]2859946f2011-04-04 18:18:06112
[email protected]c3cfb012011-04-06 22:07:35113 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
114 virtual bool IsExternalExtensionUninstalled(
115 const std::string& extension_id) const = 0;
[email protected]2859946f2011-04-04 18:18:06116
[email protected]6b75ec32009-08-14 06:37:18117 virtual void UpdateExtensionBlacklist(
118 const std::vector<std::string>& blacklist) = 0;
[email protected]4ee07c62012-08-21 12:40:42119 virtual void CheckManagementPolicy() = 0;
[email protected]5ef47ec2010-01-28 05:58:05120
[email protected]31206602011-04-13 23:07:32121 // Safe to call multiple times in a row.
122 //
[email protected]90310d92011-04-17 07:35:04123 // TODO(akalin): Remove this method (and others) once we refactor
124 // themes sync to not use it directly.
[email protected]31206602011-04-13 23:07:32125 virtual void CheckForUpdatesSoon() = 0;
[email protected]25ae0152011-11-18 14:40:02126
[email protected]1c321ee2012-05-21 03:02:34127 virtual void AddExtension(const extensions::Extension* extension) = 0;
[email protected]25ae0152011-11-18 14:40:02128
129 virtual void UnloadExtension(
130 const std::string& extension_id,
131 extension_misc::UnloadedExtensionReason reason) = 0;
132
[email protected]1c321ee2012-05-21 03:02:34133 virtual void SyncExtensionChangeIfNeeded(
134 const extensions::Extension& extension) = 0;
[email protected]fb82dcd2012-03-21 14:15:46135
[email protected]25ae0152011-11-18 14:40:02136 virtual bool is_ready() = 0;
[email protected]d1ca0ed12009-07-01 18:24:32137};
[email protected]fbcc40302009-06-12 20:45:45138
[email protected]4f313d52009-05-21 00:42:29139// Manages installed and running Chromium extensions.
[email protected]eaa7dd182010-12-14 11:09:00140class ExtensionService
[email protected]14908b72011-04-20 06:54:36141 : public ExtensionServiceInterface,
[email protected]5df038b2012-07-16 19:03:27142 public extensions::ExternalProviderInterface::VisitorInterface,
[email protected]178f8512012-02-09 01:49:36143 public content::NotificationObserver {
[email protected]4f313d52009-05-21 00:42:29144 public:
[email protected]a9b00ac2009-06-25 21:03:23145 // The name of the directory inside the profile where extensions are
146 // installed to.
[email protected]31bb5ee62012-09-12 22:58:40147 static const char kInstallDirectoryName[];
[email protected]a9b00ac2009-06-25 21:03:23148
[email protected]93fd78f42009-07-10 16:43:17149 // If auto-updates are turned on, default to running every 5 hours.
150 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5;
151
[email protected]15d5b472011-11-24 04:17:24152 // The name of the directory inside the profile where per-app local settings
[email protected]b7f853e282011-08-10 09:24:20153 // are stored.
[email protected]31bb5ee62012-09-12 22:58:40154 static const char kLocalAppSettingsDirectoryName[];
[email protected]27cc7332011-11-01 01:56:43155
[email protected]15d5b472011-11-24 04:17:24156 // The name of the directory inside the profile where per-extension local
157 // settings are stored.
[email protected]31bb5ee62012-09-12 22:58:40158 static const char kLocalExtensionSettingsDirectoryName[];
[email protected]15d5b472011-11-24 04:17:24159
160 // The name of the directory inside the profile where per-app synced settings
[email protected]27cc7332011-11-01 01:56:43161 // are stored.
[email protected]31bb5ee62012-09-12 22:58:40162 static const char kSyncAppSettingsDirectoryName[];
[email protected]15d5b472011-11-24 04:17:24163
164 // The name of the directory inside the profile where per-extension synced
165 // settings are stored.
[email protected]31bb5ee62012-09-12 22:58:40166 static const char kSyncExtensionSettingsDirectoryName[];
[email protected]b7f853e282011-08-10 09:24:20167
[email protected]90e800c2012-06-12 23:11:00168 // The name of the database inside the profile where chrome-internal
169 // extension state resides.
[email protected]31bb5ee62012-09-12 22:58:40170 static const char kStateStoreName[];
[email protected]90e800c2012-06-12 23:11:00171
[email protected]d9696672011-03-15 22:45:09172 // Returns the Extension of hosted or packaged apps, NULL otherwise.
[email protected]dc9a74f72012-08-17 18:07:21173 const extensions::Extension* GetInstalledApp(const GURL& url) const;
[email protected]d9696672011-03-15 22:45:09174
[email protected]ffb204f22010-12-05 23:20:27175 // Returns whether the URL is from either a hosted or packaged app.
[email protected]dc9a74f72012-08-17 18:07:21176 bool IsInstalledApp(const GURL& url) const;
[email protected]ffb204f22010-12-05 23:20:27177
[email protected]404fb002012-10-02 21:06:17178 // If the renderer is hosting an installed app with isolated storage,
179 // returns it, otherwise returns NULL.
180 const extensions::Extension* GetIsolatedAppForRenderer(
[email protected]dc9a74f72012-08-17 18:07:21181 int renderer_child_id) const;
[email protected]da5683db2011-04-23 17:12:21182
[email protected]6aeac8342010-10-01 20:21:18183 // Attempts to uninstall an extension from a given ExtensionService. Returns
184 // true iff the target extension exists.
[email protected]eaa7dd182010-12-14 11:09:00185 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
[email protected]6aeac8342010-10-01 20:21:18186 const std::string& extension_id);
187
[email protected]73c47932010-12-06 18:13:43188 // Constructor stores pointers to |profile| and |extension_prefs| but
189 // ownership remains at caller.
[email protected]eaa7dd182010-12-14 11:09:00190 ExtensionService(Profile* profile,
[email protected]a29a517a2011-01-21 21:11:12191 const CommandLine* command_line,
192 const FilePath& install_directory,
[email protected]45759612012-07-10 17:21:23193 extensions::ExtensionPrefs* extension_prefs,
[email protected]0436b102011-04-15 18:30:03194 bool autoupdate_enabled,
195 bool extensions_enabled);
[email protected]6014d672008-12-05 00:38:25196
[email protected]14908b72011-04-20 06:54:36197 virtual ~ExtensionService();
198
[email protected]6014d672008-12-05 00:38:25199 // Gets the list of currently installed extensions.
[email protected]84df8332011-12-06 18:22:46200 virtual const ExtensionSet* extensions() const OVERRIDE;
[email protected]c38fd352012-03-28 04:06:12201 virtual const ExtensionSet* disabled_extensions() const OVERRIDE;
[email protected]84df8332011-12-06 18:22:46202 const ExtensionSet* terminated_extensions() const;
[email protected]6014d672008-12-05 00:38:25203
[email protected]215a7be2012-10-22 19:53:42204 // Returns a set of all installed, disabled, and terminated extensions and
[email protected]7f4308d2012-01-18 07:43:01205 // transfers ownership to caller.
206 const ExtensionSet* GenerateInstalledExtensionsSet() const;
207
[email protected]215a7be2012-10-22 19:53:42208 // Returns a set of all extensions disabled by the sideload wipeout
209 // initiative.
210 const ExtensionSet* GetWipedOutExtensions() const;
211
[email protected]b2907fd2011-03-25 16:43:37212 // Gets the object managing the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41213 virtual extensions::PendingExtensionManager*
214 pending_extension_manager() OVERRIDE;
[email protected]aa142702010-03-26 01:26:33215
[email protected]ec5b50d2010-10-09 16:35:18216 const FilePath& install_directory() const { return install_directory_; }
217
[email protected]6f371442011-11-09 06:45:46218 extensions::ProcessMap* process_map() { return &process_map_; }
219
[email protected]db7331a2010-02-25 22:10:50220 // Whether this extension can run in an incognito window.
[email protected]c3cfb012011-04-06 22:07:35221 virtual bool IsIncognitoEnabled(const std::string& extension_id) const;
222 virtual void SetIsIncognitoEnabled(const std::string& extension_id,
223 bool enabled);
[email protected]5ef47ec2010-01-28 05:58:05224
[email protected]b2689a902011-12-01 00:41:09225 // When app notification setup is done, we call this to save the developer's
226 // oauth client id which we'll need at uninstall time to revoke the oauth
227 // permission grant for sending notifications.
[email protected]aa7599d2011-10-28 07:24:32228 virtual void SetAppNotificationSetupDone(const std::string& extension_id,
[email protected]b2689a902011-12-01 00:41:09229 const std::string& oauth_client_id);
[email protected]aa7599d2011-10-28 07:24:32230
231 virtual void SetAppNotificationDisabled(const std::string& extension_id,
232 bool value);
233
[email protected]168389f2011-12-20 17:12:48234 // Updates the app launcher value for the moved extension so that it is now
235 // located after the given predecessor and before the successor. This will
236 // trigger a sync if needed. Empty strings are used to indicate no successor
237 // or predecessor.
238 void OnExtensionMoved(const std::string& moved_extension_id,
239 const std::string& predecessor_extension_id,
240 const std::string& successor_extension_id);
241
[email protected]2a8f24e2010-11-03 21:37:05242 // Returns true if the given extension can see events and data from another
243 // sub-profile (incognito to original profile, or vice versa).
[email protected]dc9a74f72012-08-17 18:07:21244 bool CanCrossIncognito(const extensions::Extension* extension) const;
[email protected]2a8f24e2010-11-03 21:37:05245
[email protected]5ef7b002011-05-12 23:16:20246 // Returns true if the given extension can be loaded in incognito.
[email protected]1c321ee2012-05-21 03:02:34247 bool CanLoadInIncognito(const extensions::Extension* extension) const;
[email protected]5ef7b002011-05-12 23:16:20248
[email protected]05c82182010-06-24 17:49:08249 // Whether this extension can inject scripts into pages with file URLs.
[email protected]dc9a74f72012-08-17 18:07:21250 bool AllowFileAccess(const extensions::Extension* extension) const;
[email protected]3aff9ad2011-04-01 20:26:48251 // Will reload the extension since this permission is applied at loading time
252 // only.
[email protected]1c321ee2012-05-21 03:02:34253 void SetAllowFileAccess(const extensions::Extension* extension, bool allow);
[email protected]05c82182010-06-24 17:49:08254
[email protected]720ad1312012-02-27 23:07:36255 // Whether the persistent background page, if any, is ready. We don't load
256 // other components until then. If there is no background page, or if it is
257 // non-persistent (lazy), we consider it to be ready.
[email protected]dc9a74f72012-08-17 18:07:21258 bool IsBackgroundPageReady(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34259 void SetBackgroundPageReady(const extensions::Extension* extension);
[email protected]d7e9a862010-11-03 21:57:49260
261 // Getter and setter for the flag that specifies whether the extension is
262 // being upgraded.
[email protected]dc9a74f72012-08-17 18:07:21263 bool IsBeingUpgraded(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34264 void SetBeingUpgraded(const extensions::Extension* extension, bool value);
[email protected]d7e9a862010-11-03 21:57:49265
[email protected]39a5b532011-10-22 01:47:07266 // Getter and setter for the flag that specifies if the extension has used
267 // the webrequest API.
268 // TODO(mpcomplete): remove. http://crbug.com/100411
[email protected]dc9a74f72012-08-17 18:07:21269 bool HasUsedWebRequest(const extensions::Extension* extension) const;
[email protected]1c321ee2012-05-21 03:02:34270 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value);
[email protected]39a5b532011-10-22 01:47:07271
[email protected]6014d672008-12-05 00:38:25272 // Initialize and start all installed extensions.
[email protected]9f1087e2009-06-15 17:29:32273 void Init();
[email protected]6014d672008-12-05 00:38:25274
[email protected]cf593af2011-12-30 05:44:39275 // To delay some initialization until after import has finished, register
276 // for the notification.
277 // TODO(yoz): remove InitEventRoutersAterImport.
[email protected]d91268022011-08-26 13:17:37278 void InitEventRoutersAfterImport();
[email protected]cf593af2011-12-30 05:44:39279 void RegisterForImportFinished();
280
281 // Complete some initialization after being notified that import has finished.
282 void InitAfterImport();
[email protected]d91268022011-08-26 13:17:37283
[email protected]c5ae74ab2010-04-15 18:14:37284 // Start up the extension event routers.
285 void InitEventRouters();
286
[email protected]037228a2012-10-05 01:36:16287 // Called when the ProfileSyncService for the associated Profile is
288 // going to be destroyed. This is guaranteed to be called exactly
289 // once before Shutdown() is called.
290 //
291 // TODO(akalin): Remove this once http://crbug.com/153827 is fixed.
292 void OnProfileSyncServiceShutdown();
293
[email protected]47b896562012-08-22 23:55:15294 // Called when the associated Profile is going to be destroyed.
295 void Shutdown();
296
[email protected]8001df22011-04-28 19:59:47297 // Look up an extension by ID. Does not include terminated
298 // extensions.
[email protected]1c321ee2012-05-21 03:02:34299 virtual const extensions::Extension* GetExtensionById(
[email protected]b05fb9ff2011-04-23 00:07:56300 const std::string& id, bool include_disabled) const OVERRIDE;
[email protected]0c6da502009-08-14 22:32:39301
[email protected]8001df22011-04-28 19:59:47302 // Looks up a terminated (crashed) extension by ID.
[email protected]1c321ee2012-05-21 03:02:34303 const extensions::Extension*
304 GetTerminatedExtension(const std::string& id) const;
[email protected]8001df22011-04-28 19:59:47305
306 // Looks up an extension by ID, regardless of whether it's enabled,
307 // disabled, or terminated.
[email protected]1c321ee2012-05-21 03:02:34308 virtual const extensions::Extension* GetInstalledExtension(
[email protected]8001df22011-04-28 19:59:47309 const std::string& id) const OVERRIDE;
[email protected]0dfe05c2011-02-23 23:03:36310
[email protected]e957fe52009-06-23 16:51:05311 // Updates a currently-installed extension with the contents from
[email protected]7577a5c52009-07-30 06:21:58312 // |extension_path|.
[email protected]2a464a92009-08-01 17:58:35313 // TODO(aa): This method can be removed. ExtensionUpdater could use
314 // CrxInstaller directly instead.
[email protected]420a0ec2011-06-01 01:07:03315 virtual bool UpdateExtension(
316 const std::string& id,
317 const FilePath& extension_path,
318 const GURL& download_url,
[email protected]bf3d9df2012-07-24 23:20:27319 extensions::CrxInstaller** out_crx_installer) OVERRIDE;
[email protected]e957fe52009-06-23 16:51:05320
[email protected]9cddd4702009-07-27 22:09:40321 // Reloads the specified extension.
322 void ReloadExtension(const std::string& extension_id);
323
[email protected]631cf822009-05-15 07:01:25324 // Uninstalls the specified extension. Callers should only call this method
[email protected]17c4f3c2009-07-04 16:36:25325 // with extensions that exist. |external_uninstall| is a magical parameter
326 // that is only used to send information to ExtensionPrefs, which external
327 // callers should never set to true.
[email protected]a12c706e2011-12-01 00:58:08328 //
329 // We pass the |extension_id| by value to avoid having it deleted from under
330 // us incase someone calls it with Extension::id() or another string that we
331 // are going to delete in this function.
332 //
[email protected]17c4f3c2009-07-04 16:36:25333 // TODO(aa): Remove |external_uninstall| -- this information should be passed
334 // to ExtensionPrefs some other way.
[email protected]a12c706e2011-12-01 00:58:08335 virtual bool UninstallExtension(std::string extension_id,
[email protected]d6ebc9792011-04-07 18:18:33336 bool external_uninstall,
[email protected]65187152012-06-02 13:14:14337 string16* error);
[email protected]631cf822009-05-15 07:01:25338
[email protected]b05fb9ff2011-04-23 00:07:56339 virtual bool IsExtensionEnabled(
340 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35341 virtual bool IsExternalExtensionUninstalled(
[email protected]b05fb9ff2011-04-23 00:07:56342 const std::string& extension_id) const OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35343
[email protected]06f92562011-04-29 19:27:31344 // Enables the extension. If the extension is already enabled, does
345 // nothing.
[email protected]2859946f2011-04-04 18:18:06346 virtual void EnableExtension(const std::string& extension_id);
[email protected]06f92562011-04-29 19:27:31347
348 // Disables the extension. If the extension is already disabled, or
349 // cannot be disabled, does nothing.
[email protected]44d62b62012-04-11 00:06:03350 virtual void DisableExtension(const std::string& extension_id,
[email protected]1c321ee2012-05-21 03:02:34351 extensions::Extension::DisableReason disable_reason);
[email protected]0c6da502009-08-14 22:32:39352
[email protected]8d888c12010-11-30 00:00:25353 // Updates the |extension|'s granted permissions lists to include all
[email protected]8d888c12010-11-30 00:00:25354 // permissions in the |extension|'s manifest and re-enables the
355 // extension.
[email protected]1c321ee2012-05-21 03:02:34356 void GrantPermissionsAndEnableExtension(
[email protected]b70a2d92012-06-28 19:51:21357 const extensions::Extension* extension,
358 bool record_oauth2_grant);
[email protected]8d888c12010-11-30 00:00:25359
[email protected]be083862012-09-01 03:53:45360 // Updates the |extension|'s granted permissions lists to include all
361 // permissions in the |extensions|'s manifest.
362 void GrantPermissions(
363 const extensions::Extension* extension,
364 bool record_oauth2_grant);
365
[email protected]9f1087e2009-06-15 17:29:32366 // Check for updates (or potentially new extensions from external providers)
[email protected]93fd78f42009-07-10 16:43:17367 void CheckForExternalUpdates();
[email protected]9f1087e2009-06-15 17:29:32368
369 // Unload the specified extension.
[email protected]25ae0152011-11-18 14:40:02370 virtual void UnloadExtension(
371 const std::string& extension_id,
[email protected]1cc91fe2011-11-21 14:48:43372 extension_misc::UnloadedExtensionReason reason) OVERRIDE;
[email protected]9f1087e2009-06-15 17:29:32373
[email protected]57f71b92009-09-11 19:31:38374 // Unload all extensions. This is currently only called on shutdown, and
375 // does not send notifications.
[email protected]9f1087e2009-06-15 17:29:32376 void UnloadAllExtensions();
377
378 // Called only by testing.
379 void ReloadExtensions();
380
381 // Scan the extension directory and clean up the cruft.
382 void GarbageCollectExtensions();
383
[email protected]fb82dcd2012-03-21 14:15:46384 // Notifies Sync (if needed) of a newly-installed extension or a change to
385 // an existing extension.
[email protected]1c321ee2012-05-21 03:02:34386 virtual void SyncExtensionChangeIfNeeded(
387 const extensions::Extension& extension) OVERRIDE;
[email protected]fb82dcd2012-03-21 14:15:46388
[email protected]583d45c12010-08-31 02:48:12389 // Returns true if |url| should get extension api bindings and be permitted
390 // to make api calls. Note that this is independent of what extension
391 // permissions the given extension has been granted.
392 bool ExtensionBindingsAllowed(const GURL& url);
393
[email protected]4d007b312012-10-17 03:00:48394 // Returns true if a normal browser window should avoid showing |url| in a
395 // tab. In this case, |url| is also rewritten to an error URL.
396 bool ShouldBlockUrlInBrowserTab(GURL* url);
397
[email protected]b671760b2010-07-15 21:13:47398 // Returns the icon to display in the omnibox for the given extension.
[email protected]e8476c992012-08-20 20:27:59399 gfx::Image GetOmniboxIcon(const std::string& extension_id);
[email protected]b671760b2010-07-15 21:13:47400
[email protected]29d0d4ac2010-09-08 21:10:31401 // Returns the icon to display in the omnibox popup window for the given
402 // extension.
[email protected]e8476c992012-08-20 20:27:59403 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
[email protected]29d0d4ac2010-09-08 21:10:31404
[email protected]c6d474f82009-12-16 21:11:06405 // Called when the initial extensions load has completed.
406 virtual void OnLoadedInstalledExtensions();
[email protected]7577a5c52009-07-30 06:21:58407
[email protected]49cd1572011-02-08 21:38:45408 // Adds |extension| to this ExtensionService and notifies observers than an
409 // extension has been loaded. Called by the backend after an extension has
410 // been loaded from a file and installed.
[email protected]1c321ee2012-05-21 03:02:34411 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE;
[email protected]7577a5c52009-07-30 06:21:58412
413 // Called by the backend when an extension has been installed.
[email protected]8266d662011-07-12 21:53:26414 void OnExtensionInstalled(
[email protected]1c321ee2012-05-21 03:02:34415 const extensions::Extension* extension,
[email protected]98270432012-09-11 20:51:24416 const syncer::StringOrdinal& page_ordinal,
417 bool has_requirement_errors);
[email protected]7577a5c52009-07-30 06:21:58418
[email protected]902fd7b2011-07-27 18:42:31419 // Initializes the |extension|'s active permission set and disables the
420 // extension if the privilege level has increased (e.g., due to an upgrade).
[email protected]1c321ee2012-05-21 03:02:34421 void InitializePermissions(const extensions::Extension* extension);
[email protected]8d888c12010-11-30 00:00:25422
[email protected]215a7be2012-10-22 19:53:42423 // Check to see if this extension needs to be disabled, as per the sideload
424 // wipeout initiative.
425 void MaybeWipeout(const extensions::Extension* extension);
426
[email protected]6b75ec32009-08-14 06:37:18427 // Go through each extensions in pref, unload blacklisted extensions
428 // and update the blacklist state in pref.
429 virtual void UpdateExtensionBlacklist(
[email protected]8266d662011-07-12 21:53:26430 const std::vector<std::string>& blacklist) OVERRIDE;
[email protected]6b75ec32009-08-14 06:37:18431
[email protected]4ee07c62012-08-21 12:40:42432 // Go through each extension and unload those that are not allowed to run by
433 // management policy providers (ie. network admin and Google-managed
434 // blacklist).
435 virtual void CheckManagementPolicy() OVERRIDE;
[email protected]aa96d3a2010-08-21 08:45:25436
[email protected]b05fb9ff2011-04-23 00:07:56437 virtual void CheckForUpdatesSoon() OVERRIDE;
[email protected]c3cfb012011-04-06 22:07:35438
[email protected]65f173552012-06-28 22:43:58439 // syncer::SyncableService implementation.
440 virtual syncer::SyncError MergeDataAndStartSyncing(
[email protected]a4a147652012-07-03 23:41:32441 syncer::ModelType type,
[email protected]65f173552012-06-28 22:43:58442 const syncer::SyncDataList& initial_sync_data,
443 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
444 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
[email protected]a4a147652012-07-03 23:41:32445 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
[email protected]65f173552012-06-28 22:43:58446 virtual syncer::SyncDataList GetAllSyncData(
[email protected]a4a147652012-07-03 23:41:32447 syncer::ModelType type) const OVERRIDE;
[email protected]65f173552012-06-28 22:43:58448 virtual syncer::SyncError ProcessSyncChanges(
[email protected]3bdba0d2011-08-23 07:17:30449 const tracked_objects::Location& from_here,
[email protected]65f173552012-06-28 22:43:58450 const syncer::SyncChangeList& change_list) OVERRIDE;
[email protected]90310d92011-04-17 07:35:04451
[email protected]5db9ada2012-04-11 13:48:20452 // Gets the sync data for the given extension, assuming that the extension is
453 // syncable.
454 extensions::ExtensionSyncData GetExtensionSyncData(
[email protected]1c321ee2012-05-21 03:02:34455 const extensions::Extension& extension) const;
[email protected]5db9ada2012-04-11 13:48:20456
457 // Gets the sync data for the given app, assuming that the app is
458 // syncable.
[email protected]1c321ee2012-05-21 03:02:34459 extensions::AppSyncData GetAppSyncData(
460 const extensions::Extension& extension) const;
[email protected]5db9ada2012-04-11 13:48:20461
462 // Gets the ExtensionSyncData for all extensions.
463 std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const;
464
465 // Gets the AppSyncData for all extensions.
466 std::vector<extensions::AppSyncData> GetAppSyncDataList() const;
467
468 // Applies the change specified passed in by either ExtensionSyncData or
469 // AppSyncData to the current system.
470 // Returns false if the changes were not completely applied and were added
471 // to the pending list to be tried again.
472 bool ProcessExtensionSyncData(
473 const extensions::ExtensionSyncData& extension_sync_data);
474 bool ProcessAppSyncData(const extensions::AppSyncData& app_sync_data);
475
476
[email protected]7577a5c52009-07-30 06:21:58477 void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; }
[email protected]abe7a8942009-06-23 05:14:29478 bool extensions_enabled() { return extensions_enabled_; }
479
[email protected]0e34d7892009-06-05 19:17:40480 void set_show_extensions_prompts(bool enabled) {
481 show_extensions_prompts_ = enabled;
[email protected]e2eb43112009-05-29 21:19:54482 }
483
[email protected]0e34d7892009-06-05 19:17:40484 bool show_extensions_prompts() {
485 return show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54486 }
487
[email protected]c3cfb012011-04-06 22:07:35488 Profile* profile();
[email protected]24e7a9d2009-11-04 11:11:34489
[email protected]c3cfb012011-04-06 22:07:35490 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const,
491 // ExtensionPrefs* mutable_extension_prefs().
[email protected]45759612012-07-10 17:21:23492 extensions::ExtensionPrefs* extension_prefs();
[email protected]e81dba32009-06-19 20:19:13493
[email protected]0d9a2202011-11-09 13:48:41494 extensions::SettingsFrontend* settings_frontend();
[email protected]b7f853e282011-08-10 09:24:20495
[email protected]e2d720aa2012-05-17 00:11:35496 extensions::ContentSettingsStore* GetContentSettingsStore();
[email protected]b790b072011-05-20 09:46:44497
[email protected]3ecda252010-11-18 19:50:55498 // Whether the extension service is ready.
[email protected]25ae0152011-11-18 14:40:02499 virtual bool is_ready() OVERRIDE;
[email protected]3ecda252010-11-18 19:50:55500
[email protected]d8c8f25f2011-11-02 18:18:01501 extensions::ComponentLoader* component_loader() {
502 return component_loader_.get();
503 }
504
[email protected]1fab8452009-09-03 02:23:39505 // Note that this may return NULL if autoupdate is not turned on.
[email protected]42a08162012-03-16 18:09:11506 extensions::ExtensionUpdater* updater();
[email protected]1fab8452009-09-03 02:23:39507
[email protected]e0360f2c2009-12-07 22:34:31508 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; }
509
[email protected]d13950e2009-12-04 01:43:02510 ExtensionsQuotaService* quota_service() { return &quota_service_; }
511
[email protected]5aeeae12012-07-05 19:13:11512 extensions::MenuManager* menu_manager() { return &menu_manager_; }
[email protected]2e3b5202010-03-23 06:52:41513
[email protected]8d92e0382012-08-01 18:06:52514 extensions::AppNotificationManager* app_notification_manager() {
[email protected]af9db5f2011-10-05 05:13:15515 return app_notification_manager_.get();
[email protected]c1d05aa2011-06-28 02:07:30516 }
517
[email protected]5a38dfd2012-07-23 23:22:10518 extensions::BrowserEventRouter* browser_event_router() {
[email protected]97d2f1d2011-01-15 00:41:08519 return browser_event_router_.get();
520 }
521
[email protected]163ed192012-07-24 19:31:07522 extensions::WindowEventRouter* window_event_router() {
523 return window_event_router_.get();
524 }
525
[email protected]cab208eb02012-10-18 22:15:23526 extensions::ExtensionBluetoothEventRouter* bluetooth_event_router() {
[email protected]f463bc92012-03-22 16:38:23527 return bluetooth_event_router_.get();
528 }
[email protected]cab208eb02012-10-18 22:15:23529
530#if defined(OS_CHROMEOS)
[email protected]771a6182011-10-05 16:32:52531 chromeos::ExtensionInputMethodEventRouter* input_method_event_router() {
532 return input_method_event_router_.get();
533 }
[email protected]b16fc2e2011-07-21 21:32:58534#endif
535
[email protected]5ebd6a62012-08-01 23:54:39536 extensions::PushMessagingEventRouter* push_messaging_event_router() {
537 return push_messaging_event_router_.get();
538 }
539
[email protected]d11c8e92009-10-20 23:26:40540 // Notify the frontend that there was an error loading an extension.
[email protected]d8c8f25f2011-11-02 18:18:01541 // This method is public because UnpackedInstaller and InstalledLoader
542 // can post to here.
543 // TODO(aa): Remove this. It doesn't do enough to be worth the dependency
544 // of these classes on ExtensionService.
[email protected]d11c8e92009-10-20 23:26:40545 void ReportExtensionLoadError(const FilePath& extension_path,
546 const std::string& error,
[email protected]d11c8e92009-10-20 23:26:40547 bool be_noisy);
548
[email protected]406027c02010-09-27 08:03:18549 // ExtensionHost of background page calls this method right after its render
550 // view has been created.
[email protected]3a1dc572012-07-31 22:25:13551 void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host);
[email protected]406027c02010-09-27 08:03:18552
[email protected]8e4560b62011-01-14 10:09:14553 // For the extension in |version_path| with |id|, check to see if it's an
554 // externally managed extension. If so, uninstall it.
555 void CheckExternalUninstall(const std::string& id);
556
[email protected]5df038b2012-07-16 19:03:27557 // Clear all ExternalProviders.
[email protected]8e4560b62011-01-14 10:09:14558 void ClearProvidersForTesting();
559
[email protected]5df038b2012-07-16 19:03:27560 // Adds an ExternalProviderInterface for the service to use during testing.
561 // Takes ownership of |test_provider|.
562 void AddProviderForTesting(
563 extensions::ExternalProviderInterface* test_provider);
[email protected]8e4560b62011-01-14 10:09:14564
[email protected]5df038b2012-07-16 19:03:27565 // ExternalProvider::Visitor implementation.
[email protected]1c321ee2012-05-21 03:02:34566 virtual bool OnExternalExtensionFileFound(
567 const std::string& id,
568 const Version* version,
569 const FilePath& path,
570 extensions::Extension::Location location,
571 int creation_flags,
572 bool mark_acknowledged) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14573
[email protected]1c321ee2012-05-21 03:02:34574 virtual bool OnExternalExtensionUpdateUrlFound(
575 const std::string& id,
576 const GURL& update_url,
577 extensions::Extension::Location location) OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:14578
[email protected]50067e52011-10-20 23:17:07579 virtual void OnExternalProviderReady(
[email protected]5df038b2012-07-16 19:03:27580 const extensions::ExternalProviderInterface* provider) OVERRIDE;
[email protected]50067e52011-10-20 23:17:07581
[email protected]94fde232012-04-27 10:22:30582 // Returns true when all the external extension providers are ready.
583 bool AreAllExternalProvidersReady() const;
584
[email protected]50067e52011-10-20 23:17:07585 void OnAllExternalProvidersReady();
[email protected]8e4560b62011-01-14 10:09:14586
[email protected]62433d32011-10-12 22:33:12587 // Once all external providers are done, generates any needed alerts about
[email protected]e5af875f2011-10-10 21:09:14588 // extensions.
589 void IdentifyAlertableExtensions();
590
[email protected]89226982012-07-16 20:09:18591 // Given an ExtensionErrorUI alert, populates it with any extensions that
[email protected]07c9f2f42012-02-29 18:45:22592 // need alerting. Returns true if the alert should be displayed at all.
593 //
[email protected]89226982012-07-16 20:09:18594 // This method takes the extension_error_ui argument rather than using
[email protected]07c9f2f42012-02-29 18:45:22595 // the member variable to make it easier to test the method in isolation.
[email protected]89226982012-07-16 20:09:18596 bool PopulateExtensionErrorUI(ExtensionErrorUI* extension_error_ui);
[email protected]07c9f2f42012-02-29 18:45:22597
[email protected]612a1cb12012-10-17 13:18:03598 // Checks if there are any new external extensions to notify the user about.
599 void UpdateExternalExtensionAlert();
[email protected]e5af875f2011-10-10 21:09:14600
[email protected]47fc70c2011-12-06 07:29:51601 // Given a (presumably just-installed) extension id, mark that extension as
602 // acknowledged.
603 void AcknowledgeExternalExtension(const std::string& id);
604
[email protected]62433d32011-10-12 22:33:12605 // Opens the Extensions page because the user wants to get more details
606 // about the alerts.
[email protected]89226982012-07-16 20:09:18607 void HandleExtensionAlertDetails();
[email protected]62433d32011-10-12 22:33:12608
[email protected]a9aa5932012-01-25 08:27:40609 // Called when the extension alert is closed.
610 void HandleExtensionAlertClosed();
[email protected]e5af875f2011-10-10 21:09:14611
[email protected]612a1cb12012-10-17 13:18:03612 // Marks alertable extensions as acknowledged, after the user presses the
613 // accept button.
614 void HandleExtensionAlertAccept();
615
[email protected]6c2381d2011-10-19 02:52:53616 // content::NotificationObserver
[email protected]432115822011-07-10 15:52:27617 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53618 const content::NotificationSource& source,
619 const content::NotificationDetails& details) OVERRIDE;
[email protected]4814b512009-11-07 00:12:29620
[email protected]ec5b50d2010-10-09 16:35:18621 // Whether there are any apps installed. Component apps are not included.
622 bool HasApps() const;
623
624 // Gets the set of loaded app ids. Component apps are not included.
[email protected]1c321ee2012-05-21 03:02:34625 extensions::ExtensionIdSet GetAppIds() const;
[email protected]377011d2010-07-20 04:18:50626
[email protected]fe2dd7742011-04-19 22:52:49627 // Record a histogram using the PermissionMessage enum values for each
628 // permission in |e|.
629 // NOTE: If this is ever called with high frequency, the implementation may
630 // need to be made more efficient.
631 static void RecordPermissionMessagesHistogram(
[email protected]1c321ee2012-05-21 03:02:34632 const extensions::Extension* e, const char* histogram);
[email protected]fe2dd7742011-04-19 22:52:49633
[email protected]65992d52012-09-19 23:05:31634 // Open a dev tools window for the background page for the given extension,
635 // starting the background page first if necesary.
636 void InspectBackgroundPage(const extensions::Extension* extension);
637
[email protected]fa2416f2011-05-03 08:41:20638#if defined(UNIT_TEST)
[email protected]1c321ee2012-05-21 03:02:34639 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
[email protected]fa2416f2011-05-03 08:41:20640 TrackTerminatedExtension(extension);
641 }
642#endif
643
[email protected]7c1490da2011-10-11 18:53:25644 ExtensionWarningSet* extension_warnings() {
645 return &extension_warnings_;
646 }
647
[email protected]b1912d592012-08-17 22:29:38648 extensions::AppShortcutManager* app_shortcut_manager() {
649 return &app_shortcut_manager_;
650 }
[email protected]178f8512012-02-09 01:49:36651
[email protected]65f173552012-06-28 22:43:58652 // Specialization of syncer::SyncableService::AsWeakPtr.
[email protected]77e4dc0882012-06-20 18:53:50653 base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); }
654
[email protected]3c4abc82012-10-22 22:25:54655 bool browser_terminating() const { return browser_terminating_; }
656
657 // For testing.
658 void set_browser_terminating_for_test(bool value) {
659 browser_terminating_ = value;
660 }
661
[email protected]14908b72011-04-20 06:54:36662 private:
[email protected]d7e9a862010-11-03 21:57:49663 // Contains Extension data that can change during the life of the process,
664 // but does not persist across restarts.
665 struct ExtensionRuntimeData {
666 // True if the background page is ready.
667 bool background_page_ready;
668
669 // True while the extension is being upgraded.
670 bool being_upgraded;
671
[email protected]39a5b532011-10-22 01:47:07672 // True if the extension has used the webRequest API.
673 bool has_used_webrequest;
674
[email protected]d7e9a862010-11-03 21:57:49675 ExtensionRuntimeData();
676 ~ExtensionRuntimeData();
677 };
678 typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap;
679
[email protected]cebc3dc2011-04-18 17:15:00680 struct NaClModuleInfo {
681 NaClModuleInfo();
682 ~NaClModuleInfo();
683
684 GURL url;
685 std::string mime_type;
686 };
687 typedef std::list<NaClModuleInfo> NaClModuleInfoList;
688
[email protected]5db9ada2012-04-11 13:48:20689 // Return true if the sync type of |extension| matches |type|.
[email protected]1c321ee2012-05-21 03:02:34690 bool IsCorrectSyncType(const extensions::Extension& extension,
[email protected]a4a147652012-07-03 23:41:32691 syncer::ModelType type)
[email protected]3bdba0d2011-08-23 07:17:30692 const;
693
[email protected]5db9ada2012-04-11 13:48:20694 // Handles setting the extension specific values in |extension_sync_data| to
695 // the current system.
696 // Returns false if the changes were not completely applied and need to be
697 // tried again later.
698 bool ProcessExtensionSyncDataHelper(
699 const extensions::ExtensionSyncData& extension_sync_data,
[email protected]a4a147652012-07-03 23:41:32700 syncer::ModelType type);
[email protected]3bdba0d2011-08-23 07:17:30701
[email protected]81f0d162012-08-15 04:21:47702 enum IncludeFlag {
703 INCLUDE_NONE = 0,
704 INCLUDE_ENABLED = 1 << 0,
705 INCLUDE_DISABLED = 1 << 1,
706 INCLUDE_TERMINATED = 1 << 2
707 };
708
[email protected]0c6da502009-08-14 22:32:39709 // Look up an extension by ID, optionally including either or both of enabled
710 // and disabled extensions.
[email protected]1c321ee2012-05-21 03:02:34711 const extensions::Extension* GetExtensionByIdInternal(
712 const std::string& id,
[email protected]81f0d162012-08-15 04:21:47713 int include_mask) const;
[email protected]0c6da502009-08-14 22:32:39714
[email protected]fa2416f2011-05-03 08:41:20715 // Adds the given extension to the list of terminated extensions if
716 // it is not already there and unloads it.
[email protected]1c321ee2012-05-21 03:02:34717 void TrackTerminatedExtension(const extensions::Extension* extension);
[email protected]fa2416f2011-05-03 08:41:20718
719 // Removes the extension with the given id from the list of
720 // terminated extensions if it is there.
[email protected]bb7f40952011-01-13 00:21:20721 void UntrackTerminatedExtension(const std::string& id);
722
[email protected]62d30f42009-10-01 22:36:06723 // Handles sending notification that |extension| was loaded.
[email protected]1c321ee2012-05-21 03:02:34724 void NotifyExtensionLoaded(const extensions::Extension* extension);
[email protected]62d30f42009-10-01 22:36:06725
726 // Handles sending notification that |extension| was unloaded.
[email protected]1c321ee2012-05-21 03:02:34727 void NotifyExtensionUnloaded(const extensions::Extension* extension,
[email protected]814a7bf0f2011-08-13 05:30:59728 extension_misc::UnloadedExtensionReason reason);
[email protected]62d30f42009-10-01 22:36:06729
[email protected]aab98a52009-12-02 03:22:35730 // Helper that updates the active extension list used for crash reporting.
731 void UpdateActiveExtensionsInCrashReporter();
732
[email protected]cebc3dc2011-04-18 17:15:00733 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
734 // strong sandbox. Typically, these NaCl modules are stored in extensions
735 // and registered here. Not all NaCl modules need to register for a MIME
736 // type, just the ones that are responsible for rendering a particular MIME
737 // type, like application/pdf. Note: We only register NaCl modules in the
738 // browser process.
739 void RegisterNaClModule(const GURL& url, const std::string& mime_type);
740 void UnregisterNaClModule(const GURL& url);
741
[email protected]ed0ba002011-05-26 16:55:13742 // Call UpdatePluginListWithNaClModules() after registering or unregistering
743 // a NaCl module to see those changes reflected in the PluginList.
744 void UpdatePluginListWithNaClModules();
745
[email protected]cebc3dc2011-04-18 17:15:00746 NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
747
[email protected]6cafe35a2012-08-27 22:40:50748 // Enqueues a launch task in the lazy background page queue.
749 void QueueRestoreAppWindow(const extensions::Extension* extension);
750 // Launches the platform app associated with |extension_host|.
751 static void LaunchApplication(extensions::ExtensionHost* extension_host);
752
[email protected]65992d52012-09-19 23:05:31753 // Helper to inspect an ExtensionHost after it has been loaded.
754 void InspectExtensionHost(extensions::ExtensionHost* host);
755
[email protected]612a1cb12012-10-17 13:18:03756 // Helper to determine whether we should initially enable an installed
757 // (or upgraded) extension.
758 bool ShouldEnableOnInstall(const extensions::Extension* extension);
759
[email protected]31d8f5f22012-04-02 15:22:08760 // The normal profile associated with this ExtensionService.
[email protected]6ef635e42009-07-26 06:16:12761 Profile* profile_;
762
[email protected]31d8f5f22012-04-02 15:22:08763 // The ExtensionSystem for the profile above.
[email protected]bd306722012-07-11 20:43:59764 extensions::ExtensionSystem* system_;
[email protected]31d8f5f22012-04-02 15:22:08765
[email protected]73c47932010-12-06 18:13:43766 // Preferences for the owning profile (weak reference).
[email protected]45759612012-07-10 17:21:23767 extensions::ExtensionPrefs* extension_prefs_;
[email protected]894bb502009-05-21 22:39:57768
[email protected]adfc5462011-09-21 19:07:13769 // Settings for the owning profile.
[email protected]cccdf0aa2011-11-11 03:43:38770 scoped_ptr<extensions::SettingsFrontend> settings_frontend_;
[email protected]b7f853e282011-08-10 09:24:20771
[email protected]6014d672008-12-05 00:38:25772 // The current list of installed extensions.
[email protected]84df8332011-12-06 18:22:46773 ExtensionSet extensions_;
[email protected]6014d672008-12-05 00:38:25774
[email protected]0c6da502009-08-14 22:32:39775 // The list of installed extensions that have been disabled.
[email protected]84df8332011-12-06 18:22:46776 ExtensionSet disabled_extensions_;
[email protected]0c6da502009-08-14 22:32:39777
[email protected]bb7f40952011-01-13 00:21:20778 // The list of installed extensions that have been terminated.
[email protected]84df8332011-12-06 18:22:46779 ExtensionSet terminated_extensions_;
[email protected]bb7f40952011-01-13 00:21:20780
[email protected]b2907fd2011-03-25 16:43:37781 // Hold the set of pending extensions.
[email protected]3f213ad2012-07-26 23:39:41782 extensions::PendingExtensionManager pending_extension_manager_;
[email protected]aa142702010-03-26 01:26:33783
[email protected]d7e9a862010-11-03 21:57:49784 // The map of extension IDs to their runtime data.
785 ExtensionRuntimeDataMap extension_runtime_data_;
786
[email protected]6014d672008-12-05 00:38:25787 // The full path to the directory where extensions are installed.
788 FilePath install_directory_;
789
[email protected]e2eb43112009-05-29 21:19:54790 // Whether or not extensions are enabled.
791 bool extensions_enabled_;
792
[email protected]0e34d7892009-06-05 19:17:40793 // Whether to notify users when they attempt to install an extension.
794 bool show_extensions_prompts_;
[email protected]e2eb43112009-05-29 21:19:54795
[email protected]d13950e2009-12-04 01:43:02796 // Used by dispatchers to limit API quota for individual extensions.
797 ExtensionsQuotaService quota_service_;
798
[email protected]432115822011-07-10 15:52:27799 // Record that Init() has been called, and chrome::EXTENSIONS_READY
[email protected]fa6a9102010-11-22 15:38:50800 // has fired.
[email protected]3ecda252010-11-18 19:50:55801 bool ready_;
[email protected]e81dba32009-06-19 20:19:13802
[email protected]93fd78f42009-07-10 16:43:17803 // Our extension updater, if updates are turned on.
[email protected]42a08162012-03-16 18:09:11804 scoped_ptr<extensions::ExtensionUpdater> updater_;
[email protected]93fd78f42009-07-10 16:43:17805
[email protected]e0360f2c2009-12-07 22:34:31806 // The model that tracks extensions with BrowserAction buttons.
807 ExtensionToolbarModel toolbar_model_;
808
[email protected]1eb175082010-02-10 09:26:16809 // Map unloaded extensions' ids to their paths. When a temporarily loaded
[email protected]5fb889382011-06-03 00:29:20810 // extension is unloaded, we lose the information about it and don't have
[email protected]1eb175082010-02-10 09:26:16811 // any in the extension preferences file.
812 typedef std::map<std::string, FilePath> UnloadedExtensionPathMap;
813 UnloadedExtensionPathMap unloaded_extension_paths_;
814
[email protected]f17dbd42010-08-16 23:21:10815 // Map disabled extensions' ids to their paths. When a temporarily loaded
816 // extension is disabled before it is reloaded, keep track of the path so that
817 // it can be re-enabled upon a successful load.
818 typedef std::map<std::string, FilePath> DisabledExtensionPathMap;
819 DisabledExtensionPathMap disabled_extension_paths_;
820
[email protected]4814b512009-11-07 00:12:29821 // Map of inspector cookies that are detached, waiting for an extension to be
822 // reloaded.
823 typedef std::map<std::string, int> OrphanedDevTools;
824 OrphanedDevTools orphaned_dev_tools_;
825
[email protected]6cafe35a2012-08-27 22:40:50826 // A set of apps that had an open window the last time they were reloaded.
827 // A new window will be launched when the app is succesfully reloaded.
828 std::set<std::string> relaunch_app_ids_;
829
[email protected]6c2381d2011-10-19 02:52:53830 content::NotificationRegistrar registrar_;
[email protected]2fb7dc982010-09-29 12:24:28831 PrefChangeRegistrar pref_change_registrar_;
[email protected]4814b512009-11-07 00:12:29832
[email protected]d8c8f25f2011-11-02 18:18:01833 // Keeps track of loading and unloading component extensions.
834 scoped_ptr<extensions::ComponentLoader> component_loader_;
835
[email protected]2e3b5202010-03-23 06:52:41836 // Keeps track of menu items added by extensions.
[email protected]5aeeae12012-07-05 19:13:11837 extensions::MenuManager menu_manager_;
[email protected]2e3b5202010-03-23 06:52:41838
[email protected]c1d05aa2011-06-28 02:07:30839 // Keeps track of app notifications.
[email protected]8d92e0382012-08-01 18:06:52840 scoped_refptr<extensions::AppNotificationManager> app_notification_manager_;
[email protected]c1d05aa2011-06-28 02:07:30841
[email protected]b671760b2010-07-15 21:13:47842 // Keeps track of favicon-sized omnibox icons for extensions.
843 ExtensionIconManager omnibox_icon_manager_;
[email protected]29d0d4ac2010-09-08 21:10:31844 ExtensionIconManager omnibox_popup_icon_manager_;
[email protected]b671760b2010-07-15 21:13:47845
[email protected]b3d62312b12010-10-14 21:10:18846 // Flag to make sure event routers are only initialized once.
847 bool event_routers_initialized_;
848
[email protected]d2e6bd62011-10-24 20:29:07849 scoped_ptr<HistoryExtensionEventRouter> history_event_router_;
[email protected]f825df22011-06-28 17:36:10850
[email protected]5a38dfd2012-07-23 23:22:10851 scoped_ptr<extensions::BrowserEventRouter> browser_event_router_;
[email protected]da55b8d2011-05-26 00:09:49852
[email protected]163ed192012-07-24 19:31:07853 scoped_ptr<extensions::WindowEventRouter> window_event_router_;
854
[email protected]135e4782012-09-19 20:36:52855 scoped_ptr<extensions::PreferenceEventRouter> preference_event_router_;
[email protected]118de7892011-03-16 13:31:40856
[email protected]23d5f172011-10-25 05:49:53857 scoped_ptr<BookmarkExtensionEventRouter> bookmark_event_router_;
[email protected]f825df22011-06-28 17:36:10858
[email protected]92ba7b012012-05-16 03:36:17859 scoped_ptr<extensions::ExtensionCookiesEventRouter> cookies_event_router_;
[email protected]f825df22011-06-28 17:36:10860
861 scoped_ptr<ExtensionManagementEventRouter> management_event_router_;
862
[email protected]31bb5ee62012-09-12 22:58:40863 scoped_ptr<extensions::MediaGalleriesPrivateEventRouter>
864 media_galleries_private_event_router_;
865
[email protected]5ebd6a62012-08-01 23:54:39866 scoped_ptr<extensions::PushMessagingEventRouter>
867 push_messaging_event_router_;
868
[email protected]017ecde92012-04-04 09:11:26869 scoped_ptr<extensions::WebNavigationEventRouter> web_navigation_event_router_;
[email protected]f825df22011-06-28 17:36:10870
[email protected]91aa8a32012-08-07 10:35:33871 scoped_ptr<extensions::FontSettingsEventRouter> font_settings_event_router_;
[email protected]bdd34452012-04-16 15:58:40872
[email protected]9c70e0d92012-07-16 08:39:44873 scoped_ptr<extensions::ExtensionManagedModeEventRouter>
874 managed_mode_event_router_;
[email protected]8a4cf842012-05-16 13:35:30875
[email protected]cab208eb02012-10-18 22:15:23876 scoped_ptr<extensions::ExtensionBluetoothEventRouter> bluetooth_event_router_;
877
[email protected]b16fc2e2011-07-21 21:32:58878#if defined(OS_CHROMEOS)
[email protected]771a6182011-10-05 16:32:52879 scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
880 input_method_event_router_;
[email protected]b16fc2e2011-07-21 21:32:58881#endif
882
[email protected]8e4560b62011-01-14 10:09:14883 // A collection of external extension providers. Each provider reads
884 // a source of external extension information. Examples include the
885 // windows registry and external_extensions.json.
[email protected]5df038b2012-07-16 19:03:27886 extensions::ProviderCollection external_extension_providers_;
[email protected]8e4560b62011-01-14 10:09:14887
888 // Set to true by OnExternalExtensionUpdateUrlFound() when an external
[email protected]94fde232012-04-27 10:22:30889 // extension URL is found, and by CheckForUpdatesSoon() when an update check
890 // has to wait for the external providers. Used in
891 // OnAllExternalProvidersReady() to determine if an update check is needed to
892 // install pending extensions.
893 bool update_once_all_providers_are_ready_;
[email protected]8e4560b62011-01-14 10:09:14894
[email protected]3c4abc82012-10-22 22:25:54895 // Set when the browser is terminating. Prevents us from installing or
896 // updating additional extensions and allows in-progress installations to
897 // decide to abort.
898 bool browser_terminating_;
899
[email protected]cebc3dc2011-04-18 17:15:00900 NaClModuleInfoList nacl_module_list_;
901
[email protected]5db9ada2012-04-11 13:48:20902 extensions::AppSyncBundle app_sync_bundle_;
903 extensions::ExtensionSyncBundle extension_sync_bundle_;
[email protected]3bdba0d2011-08-23 07:17:30904
[email protected]7c1490da2011-10-11 18:53:25905 // Contains an entry for each warning that shall be currently shown.
906 ExtensionWarningSet extension_warnings_;
907
[email protected]6f371442011-11-09 06:45:46908 extensions::ProcessMap process_map_;
909
[email protected]b1912d592012-08-17 22:29:38910 extensions::AppShortcutManager app_shortcut_manager_;
[email protected]9de83282011-12-12 11:06:37911
[email protected]89226982012-07-16 20:09:18912 scoped_ptr<ExtensionErrorUI> extension_error_ui_;
[email protected]a9aa5932012-01-25 08:27:40913
[email protected]9ce11d22012-08-08 23:20:13914#if defined(ENABLE_EXTENSIONS)
[email protected]c77f2352012-08-08 22:07:58915 scoped_ptr<extensions::ExtensionActionStorageManager>
916 extension_action_storage_manager_;
[email protected]9ce11d22012-08-08 23:20:13917#endif
[email protected]c77f2352012-08-08 22:07:58918
[email protected]eaa7dd182010-12-14 11:09:00919 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]c2c263c2010-08-13 21:59:48920 InstallAppsWithUnlimtedStorage);
[email protected]eaa7dd182010-12-14 11:09:00921 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]654512b2010-09-01 02:09:42922 InstallAppsAndCheckStorageProtection);
[email protected]eaa7dd182010-12-14 11:09:00923 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
[email protected]6014d672008-12-05 00:38:25924};
925
[email protected]eaa7dd182010-12-14 11:09:00926#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_