[email protected] | c333e79 | 2012-01-06 16:57:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 7 | |
[email protected] | c5122563 | 2011-11-11 21:40:37 | [diff] [blame] | 8 | #include <list> |
[email protected] | da50530a | 2009-06-15 17:43:01 | [diff] [blame] | 9 | #include <map> |
[email protected] | 94b4ffc | 2011-02-04 05:55:17 | [diff] [blame] | 10 | #include <set> |
[email protected] | b0beaa66 | 2009-02-26 00:04:15 | [diff] [blame] | 11 | #include <string> |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
[email protected] | 36a784c | 2009-06-23 06:21:08 | [diff] [blame] | 14 | #include "base/command_line.h" |
[email protected] | e078590 | 2011-05-19 23:34:17 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 16 | #include "base/file_path.h" |
[email protected] | a918f87 | 2010-06-01 14:30:51 | [diff] [blame] | 17 | #include "base/gtest_prod_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 18 | #include "base/memory/linked_ptr.h" |
| 19 | #include "base/memory/ref_counted.h" |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 20 | #include "base/memory/weak_ptr.h" |
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 21 | #include "base/property_bag.h" |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 22 | #include "base/string16.h" |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 23 | #include "base/time.h" |
[email protected] | f5c016b | 2009-06-16 17:12:31 | [diff] [blame] | 24 | #include "base/tuple.h" |
[email protected] | 2404a2827 | 2012-05-30 02:31:14 | [diff] [blame] | 25 | #include "chrome/browser/extensions/api/api_resource_controller.h" |
[email protected] | 178f851 | 2012-02-09 01:49:36 | [diff] [blame] | 26 | #include "chrome/browser/extensions/app_shortcut_manager.h" |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 27 | #include "chrome/browser/extensions/app_sync_bundle.h" |
[email protected] | 18cc5a5 | 2011-04-15 16:03:38 | [diff] [blame] | 28 | #include "chrome/browser/extensions/apps_promo.h" |
[email protected] | b671760b | 2010-07-15 21:13:47 | [diff] [blame] | 29 | #include "chrome/browser/extensions/extension_icon_manager.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 30 | #include "chrome/browser/extensions/extension_prefs.h" |
[email protected] | c6e4a341 | 2009-06-24 15:45:29 | [diff] [blame] | 31 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 32 | #include "chrome/browser/extensions/extension_sync_bundle.h" |
[email protected] | e0360f2c | 2009-12-07 22:34:31 | [diff] [blame] | 33 | #include "chrome/browser/extensions/extension_toolbar_model.h" |
[email protected] | 7c1490da | 2011-10-11 18:53:25 | [diff] [blame] | 34 | #include "chrome/browser/extensions/extension_warning_set.h" |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 35 | #include "chrome/browser/extensions/extensions_quota_service.h" |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 36 | #include "chrome/browser/extensions/external_extension_provider_interface.h" |
[email protected] | 5aeeae1 | 2012-07-05 19:13:11 | [diff] [blame] | 37 | #include "chrome/browser/extensions/menu_manager.h" |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 38 | #include "chrome/browser/extensions/pending_extension_manager.h" |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 39 | #include "chrome/browser/extensions/process_map.h" |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 40 | #include "chrome/browser/prefs/pref_change_registrar.h" |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 41 | #include "chrome/common/extensions/extension.h" |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 42 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 43 | #include "chrome/common/extensions/extension_set.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 44 | #include "content/public/browser/browser_thread.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 45 | #include "content/public/browser/notification_observer.h" |
| 46 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 895a1e5 | 2012-05-15 02:50:12 | [diff] [blame] | 47 | #include "sync/api/sync_change.h" |
| 48 | #include "sync/api/syncable_service.h" |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 49 | |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 50 | class AppNotificationManager; |
[email protected] | 23d5f17 | 2011-10-25 05:49:53 | [diff] [blame] | 51 | class BookmarkExtensionEventRouter; |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 52 | class CrxInstaller; |
[email protected] | 97d2f1d | 2011-01-15 00:41:08 | [diff] [blame] | 53 | class ExtensionBrowserEventRouter; |
[email protected] | bdd3445 | 2012-04-16 15:58:40 | [diff] [blame] | 54 | class ExtensionFontSettingsEventRouter; |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 55 | class ExtensionGlobalError; |
[email protected] | 8a4cf84 | 2012-05-16 13:35:30 | [diff] [blame] | 56 | class ExtensionManagedModeEventRouter; |
[email protected] | f825df2 | 2011-06-28 17:36:10 | [diff] [blame] | 57 | class ExtensionManagementEventRouter; |
[email protected] | 118de789 | 2011-03-16 13:31:40 | [diff] [blame] | 58 | class ExtensionPreferenceEventRouter; |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 59 | class ExtensionSyncData; |
[email protected] | e0360f2c | 2009-12-07 22:34:31 | [diff] [blame] | 60 | class ExtensionToolbarModel; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 61 | class HistoryExtensionEventRouter; |
[email protected] | 69f1be8 | 2009-04-16 22:27:21 | [diff] [blame] | 62 | class GURL; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 63 | class PendingExtensionManager; |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 64 | class Profile; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 65 | class Version; |
| 66 | |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 67 | namespace chromeos { |
[email protected] | f463bc9 | 2012-03-22 16:38:23 | [diff] [blame] | 68 | class ExtensionBluetoothEventRouter; |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 69 | class ExtensionInputMethodEventRouter; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 70 | } |
| 71 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 72 | namespace syncer { |
[email protected] | cb02f61 | 2012-06-27 03:15:50 | [diff] [blame] | 73 | class SyncData; |
| 74 | class SyncErrorFactory; |
| 75 | } |
| 76 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 77 | namespace extensions { |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 78 | class AppSyncData; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 79 | class ComponentLoader; |
[email protected] | e2d720aa | 2012-05-17 00:11:35 | [diff] [blame] | 80 | class ContentSettingsStore; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 81 | class Extension; |
[email protected] | 92ba7b01 | 2012-05-16 03:36:17 | [diff] [blame] | 82 | class ExtensionCookiesEventRouter; |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 83 | class ExtensionSyncData; |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame^] | 84 | class ExtensionSystem; |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 85 | class ExtensionUpdater; |
[email protected] | cccdf0aa | 2011-11-11 03:43:38 | [diff] [blame] | 86 | class SettingsFrontend; |
[email protected] | 017ecde9 | 2012-04-04 09:11:26 | [diff] [blame] | 87 | class WebNavigationEventRouter; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 88 | } |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 89 | |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 90 | // This is an interface class to encapsulate the dependencies that |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 91 | // various classes have on ExtensionService. This allows easy mocking. |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 92 | class ExtensionServiceInterface : public syncer::SyncableService { |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 93 | public: |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 94 | // 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] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 97 | typedef bool (*ExtensionFilter)(const extensions::Extension&); |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 98 | |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 99 | virtual ~ExtensionServiceInterface() {} |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 100 | virtual const ExtensionSet* extensions() const = 0; |
[email protected] | c38fd35 | 2012-03-28 04:06:12 | [diff] [blame] | 101 | virtual const ExtensionSet* disabled_extensions() const = 0; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 102 | virtual PendingExtensionManager* pending_extension_manager() = 0; |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 103 | |
| 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, |
| 110 | CrxInstaller** out_crx_installer) = 0; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 111 | virtual const extensions::Extension* GetExtensionById(const std::string& id, |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 112 | bool include_disabled) const = 0; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 113 | virtual const extensions::Extension* GetInstalledExtension( |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 114 | const std::string& id) const = 0; |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 115 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 116 | virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; |
| 117 | virtual bool IsExternalExtensionUninstalled( |
| 118 | const std::string& extension_id) const = 0; |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 119 | |
[email protected] | 6b75ec3 | 2009-08-14 06:37:18 | [diff] [blame] | 120 | virtual void UpdateExtensionBlacklist( |
| 121 | const std::vector<std::string>& blacklist) = 0; |
[email protected] | aa96d3a | 2010-08-21 08:45:25 | [diff] [blame] | 122 | virtual void CheckAdminBlacklist() = 0; |
[email protected] | 5ef47ec | 2010-01-28 05:58:05 | [diff] [blame] | 123 | |
[email protected] | 3120660 | 2011-04-13 23:07:32 | [diff] [blame] | 124 | // Safe to call multiple times in a row. |
| 125 | // |
[email protected] | 90310d9 | 2011-04-17 07:35:04 | [diff] [blame] | 126 | // TODO(akalin): Remove this method (and others) once we refactor |
| 127 | // themes sync to not use it directly. |
[email protected] | 3120660 | 2011-04-13 23:07:32 | [diff] [blame] | 128 | virtual void CheckForUpdatesSoon() = 0; |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 129 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 130 | virtual void AddExtension(const extensions::Extension* extension) = 0; |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 131 | |
| 132 | virtual void UnloadExtension( |
| 133 | const std::string& extension_id, |
| 134 | extension_misc::UnloadedExtensionReason reason) = 0; |
| 135 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 136 | virtual void SyncExtensionChangeIfNeeded( |
| 137 | const extensions::Extension& extension) = 0; |
[email protected] | fb82dcd | 2012-03-21 14:15:46 | [diff] [blame] | 138 | |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 139 | virtual bool is_ready() = 0; |
[email protected] | d1ca0ed1 | 2009-07-01 18:24:32 | [diff] [blame] | 140 | }; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 141 | |
[email protected] | 4f313d5 | 2009-05-21 00:42:29 | [diff] [blame] | 142 | // Manages installed and running Chromium extensions. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 143 | class ExtensionService |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 144 | : public ExtensionServiceInterface, |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 145 | public ExternalExtensionProviderInterface::VisitorInterface, |
[email protected] | 178f851 | 2012-02-09 01:49:36 | [diff] [blame] | 146 | public content::NotificationObserver { |
[email protected] | 4f313d5 | 2009-05-21 00:42:29 | [diff] [blame] | 147 | public: |
[email protected] | a9b00ac | 2009-06-25 21:03:23 | [diff] [blame] | 148 | // The name of the directory inside the profile where extensions are |
| 149 | // installed to. |
| 150 | static const char* kInstallDirectoryName; |
| 151 | |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 152 | // If auto-updates are turned on, default to running every 5 hours. |
| 153 | static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
| 154 | |
[email protected] | 15d5b47 | 2011-11-24 04:17:24 | [diff] [blame] | 155 | // The name of the directory inside the profile where per-app local settings |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 156 | // are stored. |
[email protected] | 15d5b47 | 2011-11-24 04:17:24 | [diff] [blame] | 157 | static const char* kLocalAppSettingsDirectoryName; |
[email protected] | 27cc733 | 2011-11-01 01:56:43 | [diff] [blame] | 158 | |
[email protected] | 15d5b47 | 2011-11-24 04:17:24 | [diff] [blame] | 159 | // 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] | 27cc733 | 2011-11-01 01:56:43 | [diff] [blame] | 164 | // are stored. |
[email protected] | 15d5b47 | 2011-11-24 04:17:24 | [diff] [blame] | 165 | 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] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 170 | |
[email protected] | 90e800c | 2012-06-12 23:11:00 | [diff] [blame] | 171 | // The name of the database inside the profile where chrome-internal |
| 172 | // extension state resides. |
| 173 | static const char* kStateStoreName; |
| 174 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 175 | // Returns the Extension of hosted or packaged apps, NULL otherwise. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 176 | const extensions::Extension* GetInstalledApp(const GURL& url); |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 177 | |
[email protected] | ffb204f2 | 2010-12-05 23:20:27 | [diff] [blame] | 178 | // Returns whether the URL is from either a hosted or packaged app. |
| 179 | bool IsInstalledApp(const GURL& url); |
| 180 | |
[email protected] | da5683db | 2011-04-23 17:12:21 | [diff] [blame] | 181 | // Associates a renderer process with the given installed app. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 182 | void SetInstalledAppForRenderer(int renderer_child_id, |
| 183 | const extensions::Extension* app); |
[email protected] | da5683db | 2011-04-23 17:12:21 | [diff] [blame] | 184 | |
| 185 | // If the renderer is hosting an installed app, returns it, otherwise returns |
| 186 | // NULL. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 187 | const extensions::Extension* GetInstalledAppForRenderer( |
| 188 | int renderer_child_id); |
[email protected] | da5683db | 2011-04-23 17:12:21 | [diff] [blame] | 189 | |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 190 | // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 191 | // true iff the target extension exists. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 192 | static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 193 | const std::string& extension_id); |
| 194 | |
[email protected] | 73c4793 | 2010-12-06 18:13:43 | [diff] [blame] | 195 | // Constructor stores pointers to |profile| and |extension_prefs| but |
| 196 | // ownership remains at caller. |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 197 | ExtensionService(Profile* profile, |
[email protected] | a29a517a | 2011-01-21 21:11:12 | [diff] [blame] | 198 | const CommandLine* command_line, |
| 199 | const FilePath& install_directory, |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 200 | extensions::ExtensionPrefs* extension_prefs, |
[email protected] | 0436b10 | 2011-04-15 18:30:03 | [diff] [blame] | 201 | bool autoupdate_enabled, |
| 202 | bool extensions_enabled); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 203 | |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 204 | virtual ~ExtensionService(); |
| 205 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 206 | // Gets the list of currently installed extensions. |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 207 | virtual const ExtensionSet* extensions() const OVERRIDE; |
[email protected] | c38fd35 | 2012-03-28 04:06:12 | [diff] [blame] | 208 | virtual const ExtensionSet* disabled_extensions() const OVERRIDE; |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 209 | const ExtensionSet* terminated_extensions() const; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 210 | |
[email protected] | 7f4308d | 2012-01-18 07:43:01 | [diff] [blame] | 211 | // Retuns a set of all installed, disabled, and terminated extensions and |
| 212 | // transfers ownership to caller. |
| 213 | const ExtensionSet* GenerateInstalledExtensionsSet() const; |
| 214 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 215 | // Gets the object managing the set of pending extensions. |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 216 | virtual PendingExtensionManager* pending_extension_manager() OVERRIDE; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 217 | |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 218 | const FilePath& install_directory() const { return install_directory_; } |
| 219 | |
[email protected] | 18cc5a5 | 2011-04-15 16:03:38 | [diff] [blame] | 220 | AppsPromo* apps_promo() { return &apps_promo_; } |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 221 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 222 | extensions::ProcessMap* process_map() { return &process_map_; } |
| 223 | |
[email protected] | db7331a | 2010-02-25 22:10:50 | [diff] [blame] | 224 | // Whether this extension can run in an incognito window. |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 225 | virtual bool IsIncognitoEnabled(const std::string& extension_id) const; |
| 226 | virtual void SetIsIncognitoEnabled(const std::string& extension_id, |
| 227 | bool enabled); |
[email protected] | 5ef47ec | 2010-01-28 05:58:05 | [diff] [blame] | 228 | |
[email protected] | b2689a90 | 2011-12-01 00:41:09 | [diff] [blame] | 229 | // When app notification setup is done, we call this to save the developer's |
| 230 | // oauth client id which we'll need at uninstall time to revoke the oauth |
| 231 | // permission grant for sending notifications. |
[email protected] | aa7599d | 2011-10-28 07:24:32 | [diff] [blame] | 232 | virtual void SetAppNotificationSetupDone(const std::string& extension_id, |
[email protected] | b2689a90 | 2011-12-01 00:41:09 | [diff] [blame] | 233 | const std::string& oauth_client_id); |
[email protected] | aa7599d | 2011-10-28 07:24:32 | [diff] [blame] | 234 | |
| 235 | virtual void SetAppNotificationDisabled(const std::string& extension_id, |
| 236 | bool value); |
| 237 | |
[email protected] | 168389f | 2011-12-20 17:12:48 | [diff] [blame] | 238 | // Updates the app launcher value for the moved extension so that it is now |
| 239 | // located after the given predecessor and before the successor. This will |
| 240 | // trigger a sync if needed. Empty strings are used to indicate no successor |
| 241 | // or predecessor. |
| 242 | void OnExtensionMoved(const std::string& moved_extension_id, |
| 243 | const std::string& predecessor_extension_id, |
| 244 | const std::string& successor_extension_id); |
| 245 | |
[email protected] | 2a8f24e | 2010-11-03 21:37:05 | [diff] [blame] | 246 | // Returns true if the given extension can see events and data from another |
| 247 | // sub-profile (incognito to original profile, or vice versa). |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 248 | bool CanCrossIncognito(const extensions::Extension* extension); |
[email protected] | 2a8f24e | 2010-11-03 21:37:05 | [diff] [blame] | 249 | |
[email protected] | 5ef7b00 | 2011-05-12 23:16:20 | [diff] [blame] | 250 | // Returns true if the given extension can be loaded in incognito. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 251 | bool CanLoadInIncognito(const extensions::Extension* extension) const; |
[email protected] | 5ef7b00 | 2011-05-12 23:16:20 | [diff] [blame] | 252 | |
[email protected] | 05c8218 | 2010-06-24 17:49:08 | [diff] [blame] | 253 | // Whether this extension can inject scripts into pages with file URLs. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 254 | bool AllowFileAccess(const extensions::Extension* extension); |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 255 | // Will reload the extension since this permission is applied at loading time |
| 256 | // only. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 257 | void SetAllowFileAccess(const extensions::Extension* extension, bool allow); |
[email protected] | 05c8218 | 2010-06-24 17:49:08 | [diff] [blame] | 258 | |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 259 | // Whether the persistent background page, if any, is ready. We don't load |
| 260 | // other components until then. If there is no background page, or if it is |
| 261 | // non-persistent (lazy), we consider it to be ready. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 262 | bool IsBackgroundPageReady(const extensions::Extension* extension); |
| 263 | void SetBackgroundPageReady(const extensions::Extension* extension); |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 264 | |
| 265 | // Getter and setter for the flag that specifies whether the extension is |
| 266 | // being upgraded. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 267 | bool IsBeingUpgraded(const extensions::Extension* extension); |
| 268 | void SetBeingUpgraded(const extensions::Extension* extension, bool value); |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 269 | |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 270 | // Getter and setter for the flag that specifies if the extension has used |
| 271 | // the webrequest API. |
| 272 | // TODO(mpcomplete): remove. http://crbug.com/100411 |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 273 | bool HasUsedWebRequest(const extensions::Extension* extension); |
| 274 | void SetHasUsedWebRequest(const extensions::Extension* extension, bool value); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 275 | |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 276 | // Getter for the extension's runtime data PropertyBag. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 277 | base::PropertyBag* GetPropertyBag(const extensions::Extension* extension); |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 278 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 279 | // Initialize and start all installed extensions. |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 280 | void Init(); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 281 | |
[email protected] | cf593af | 2011-12-30 05:44:39 | [diff] [blame] | 282 | // To delay some initialization until after import has finished, register |
| 283 | // for the notification. |
| 284 | // TODO(yoz): remove InitEventRoutersAterImport. |
[email protected] | d9126802 | 2011-08-26 13:17:37 | [diff] [blame] | 285 | void InitEventRoutersAfterImport(); |
[email protected] | cf593af | 2011-12-30 05:44:39 | [diff] [blame] | 286 | void RegisterForImportFinished(); |
| 287 | |
| 288 | // Complete some initialization after being notified that import has finished. |
| 289 | void InitAfterImport(); |
[email protected] | d9126802 | 2011-08-26 13:17:37 | [diff] [blame] | 290 | |
[email protected] | c5ae74ab | 2010-04-15 18:14:37 | [diff] [blame] | 291 | // Start up the extension event routers. |
| 292 | void InitEventRouters(); |
| 293 | |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 294 | // Look up an extension by ID. Does not include terminated |
| 295 | // extensions. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 296 | virtual const extensions::Extension* GetExtensionById( |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 297 | const std::string& id, bool include_disabled) const OVERRIDE; |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 298 | |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 299 | // Looks up a terminated (crashed) extension by ID. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 300 | const extensions::Extension* |
| 301 | GetTerminatedExtension(const std::string& id) const; |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 302 | |
| 303 | // Looks up an extension by ID, regardless of whether it's enabled, |
| 304 | // disabled, or terminated. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 305 | virtual const extensions::Extension* GetInstalledExtension( |
[email protected] | 8001df2 | 2011-04-28 19:59:47 | [diff] [blame] | 306 | const std::string& id) const OVERRIDE; |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 307 | |
[email protected] | e957fe5 | 2009-06-23 16:51:05 | [diff] [blame] | 308 | // Updates a currently-installed extension with the contents from |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 309 | // |extension_path|. |
[email protected] | 2a464a9 | 2009-08-01 17:58:35 | [diff] [blame] | 310 | // TODO(aa): This method can be removed. ExtensionUpdater could use |
| 311 | // CrxInstaller directly instead. |
[email protected] | 420a0ec | 2011-06-01 01:07:03 | [diff] [blame] | 312 | virtual bool UpdateExtension( |
| 313 | const std::string& id, |
| 314 | const FilePath& extension_path, |
| 315 | const GURL& download_url, |
| 316 | CrxInstaller** out_crx_installer) OVERRIDE; |
[email protected] | e957fe5 | 2009-06-23 16:51:05 | [diff] [blame] | 317 | |
[email protected] | 9cddd470 | 2009-07-27 22:09:40 | [diff] [blame] | 318 | // Reloads the specified extension. |
| 319 | void ReloadExtension(const std::string& extension_id); |
| 320 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 321 | // Uninstalls the specified extension. Callers should only call this method |
[email protected] | 17c4f3c | 2009-07-04 16:36:25 | [diff] [blame] | 322 | // with extensions that exist. |external_uninstall| is a magical parameter |
| 323 | // that is only used to send information to ExtensionPrefs, which external |
| 324 | // callers should never set to true. |
[email protected] | a12c706e | 2011-12-01 00:58:08 | [diff] [blame] | 325 | // |
| 326 | // We pass the |extension_id| by value to avoid having it deleted from under |
| 327 | // us incase someone calls it with Extension::id() or another string that we |
| 328 | // are going to delete in this function. |
| 329 | // |
[email protected] | 17c4f3c | 2009-07-04 16:36:25 | [diff] [blame] | 330 | // TODO(aa): Remove |external_uninstall| -- this information should be passed |
| 331 | // to ExtensionPrefs some other way. |
[email protected] | a12c706e | 2011-12-01 00:58:08 | [diff] [blame] | 332 | virtual bool UninstallExtension(std::string extension_id, |
[email protected] | d6ebc979 | 2011-04-07 18:18:33 | [diff] [blame] | 333 | bool external_uninstall, |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 334 | string16* error); |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 335 | |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 336 | virtual bool IsExtensionEnabled( |
| 337 | const std::string& extension_id) const OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 338 | virtual bool IsExternalExtensionUninstalled( |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 339 | const std::string& extension_id) const OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 340 | |
[email protected] | 06f9256 | 2011-04-29 19:27:31 | [diff] [blame] | 341 | // Enables the extension. If the extension is already enabled, does |
| 342 | // nothing. |
[email protected] | 2859946f | 2011-04-04 18:18:06 | [diff] [blame] | 343 | virtual void EnableExtension(const std::string& extension_id); |
[email protected] | 06f9256 | 2011-04-29 19:27:31 | [diff] [blame] | 344 | |
| 345 | // Disables the extension. If the extension is already disabled, or |
| 346 | // cannot be disabled, does nothing. |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 347 | virtual void DisableExtension(const std::string& extension_id, |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 348 | extensions::Extension::DisableReason disable_reason); |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 349 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 350 | // Updates the |extension|'s granted permissions lists to include all |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 351 | // permissions in the |extension|'s manifest and re-enables the |
| 352 | // extension. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 353 | void GrantPermissionsAndEnableExtension( |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 354 | const extensions::Extension* extension, |
| 355 | bool record_oauth2_grant); |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 356 | |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 357 | // Check for updates (or potentially new extensions from external providers) |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 358 | void CheckForExternalUpdates(); |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 359 | |
| 360 | // Unload the specified extension. |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 361 | virtual void UnloadExtension( |
| 362 | const std::string& extension_id, |
[email protected] | 1cc91fe | 2011-11-21 14:48:43 | [diff] [blame] | 363 | extension_misc::UnloadedExtensionReason reason) OVERRIDE; |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 364 | |
[email protected] | 57f71b9 | 2009-09-11 19:31:38 | [diff] [blame] | 365 | // Unload all extensions. This is currently only called on shutdown, and |
| 366 | // does not send notifications. |
[email protected] | 9f1087e | 2009-06-15 17:29:32 | [diff] [blame] | 367 | void UnloadAllExtensions(); |
| 368 | |
| 369 | // Called only by testing. |
| 370 | void ReloadExtensions(); |
| 371 | |
| 372 | // Scan the extension directory and clean up the cruft. |
| 373 | void GarbageCollectExtensions(); |
| 374 | |
[email protected] | fb82dcd | 2012-03-21 14:15:46 | [diff] [blame] | 375 | // Notifies Sync (if needed) of a newly-installed extension or a change to |
| 376 | // an existing extension. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 377 | virtual void SyncExtensionChangeIfNeeded( |
| 378 | const extensions::Extension& extension) OVERRIDE; |
[email protected] | fb82dcd | 2012-03-21 14:15:46 | [diff] [blame] | 379 | |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 380 | // Returns true if |url| should get extension api bindings and be permitted |
| 381 | // to make api calls. Note that this is independent of what extension |
| 382 | // permissions the given extension has been granted. |
| 383 | bool ExtensionBindingsAllowed(const GURL& url); |
| 384 | |
[email protected] | b671760b | 2010-07-15 21:13:47 | [diff] [blame] | 385 | // Returns the icon to display in the omnibox for the given extension. |
| 386 | const SkBitmap& GetOmniboxIcon(const std::string& extension_id); |
| 387 | |
[email protected] | 29d0d4ac | 2010-09-08 21:10:31 | [diff] [blame] | 388 | // Returns the icon to display in the omnibox popup window for the given |
| 389 | // extension. |
| 390 | const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id); |
| 391 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 392 | // Called when the initial extensions load has completed. |
| 393 | virtual void OnLoadedInstalledExtensions(); |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 394 | |
[email protected] | 49cd157 | 2011-02-08 21:38:45 | [diff] [blame] | 395 | // Adds |extension| to this ExtensionService and notifies observers than an |
| 396 | // extension has been loaded. Called by the backend after an extension has |
| 397 | // been loaded from a file and installed. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 398 | virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 399 | |
| 400 | // Called by the backend when an extension has been installed. |
[email protected] | 8266d66 | 2011-07-12 21:53:26 | [diff] [blame] | 401 | void OnExtensionInstalled( |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 402 | const extensions::Extension* extension, |
[email protected] | 36a5c4c | 2011-12-14 16:34:50 | [diff] [blame] | 403 | bool from_webstore, |
| 404 | const StringOrdinal& page_ordinal); |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 405 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 406 | // Initializes the |extension|'s active permission set and disables the |
| 407 | // extension if the privilege level has increased (e.g., due to an upgrade). |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 408 | void InitializePermissions(const extensions::Extension* extension); |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 409 | |
[email protected] | 6b75ec3 | 2009-08-14 06:37:18 | [diff] [blame] | 410 | // Go through each extensions in pref, unload blacklisted extensions |
| 411 | // and update the blacklist state in pref. |
| 412 | virtual void UpdateExtensionBlacklist( |
[email protected] | 8266d66 | 2011-07-12 21:53:26 | [diff] [blame] | 413 | const std::vector<std::string>& blacklist) OVERRIDE; |
[email protected] | 6b75ec3 | 2009-08-14 06:37:18 | [diff] [blame] | 414 | |
[email protected] | aa96d3a | 2010-08-21 08:45:25 | [diff] [blame] | 415 | // Go through each extension and unload those that the network admin has |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 416 | // put on the blacklist (not to be confused with the Google-managed blacklist) |
[email protected] | aa96d3a | 2010-08-21 08:45:25 | [diff] [blame] | 417 | // set of extensions. |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 418 | virtual void CheckAdminBlacklist() OVERRIDE; |
[email protected] | aa96d3a | 2010-08-21 08:45:25 | [diff] [blame] | 419 | |
[email protected] | b05fb9ff | 2011-04-23 00:07:56 | [diff] [blame] | 420 | virtual void CheckForUpdatesSoon() OVERRIDE; |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 421 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 422 | // syncer::SyncableService implementation. |
| 423 | virtual syncer::SyncError MergeDataAndStartSyncing( |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 424 | syncer::ModelType type, |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 425 | const syncer::SyncDataList& initial_sync_data, |
| 426 | scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 427 | scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 428 | virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 429 | virtual syncer::SyncDataList GetAllSyncData( |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 430 | syncer::ModelType type) const OVERRIDE; |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 431 | virtual syncer::SyncError ProcessSyncChanges( |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 432 | const tracked_objects::Location& from_here, |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 433 | const syncer::SyncChangeList& change_list) OVERRIDE; |
[email protected] | 90310d9 | 2011-04-17 07:35:04 | [diff] [blame] | 434 | |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 435 | // Gets the sync data for the given extension, assuming that the extension is |
| 436 | // syncable. |
| 437 | extensions::ExtensionSyncData GetExtensionSyncData( |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 438 | const extensions::Extension& extension) const; |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 439 | |
| 440 | // Gets the sync data for the given app, assuming that the app is |
| 441 | // syncable. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 442 | extensions::AppSyncData GetAppSyncData( |
| 443 | const extensions::Extension& extension) const; |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 444 | |
| 445 | // Gets the ExtensionSyncData for all extensions. |
| 446 | std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const; |
| 447 | |
| 448 | // Gets the AppSyncData for all extensions. |
| 449 | std::vector<extensions::AppSyncData> GetAppSyncDataList() const; |
| 450 | |
| 451 | // Applies the change specified passed in by either ExtensionSyncData or |
| 452 | // AppSyncData to the current system. |
| 453 | // Returns false if the changes were not completely applied and were added |
| 454 | // to the pending list to be tried again. |
| 455 | bool ProcessExtensionSyncData( |
| 456 | const extensions::ExtensionSyncData& extension_sync_data); |
| 457 | bool ProcessAppSyncData(const extensions::AppSyncData& app_sync_data); |
| 458 | |
| 459 | |
[email protected] | 7577a5c5 | 2009-07-30 06:21:58 | [diff] [blame] | 460 | void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; } |
[email protected] | abe7a894 | 2009-06-23 05:14:29 | [diff] [blame] | 461 | bool extensions_enabled() { return extensions_enabled_; } |
| 462 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 463 | void set_show_extensions_prompts(bool enabled) { |
| 464 | show_extensions_prompts_ = enabled; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 465 | } |
| 466 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 467 | bool show_extensions_prompts() { |
| 468 | return show_extensions_prompts_; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 469 | } |
| 470 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 471 | Profile* profile(); |
[email protected] | 24e7a9d | 2009-11-04 11:11:34 | [diff] [blame] | 472 | |
[email protected] | c3cfb01 | 2011-04-06 22:07:35 | [diff] [blame] | 473 | // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, |
| 474 | // ExtensionPrefs* mutable_extension_prefs(). |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 475 | extensions::ExtensionPrefs* extension_prefs(); |
[email protected] | e81dba3 | 2009-06-19 20:19:13 | [diff] [blame] | 476 | |
[email protected] | 0d9a220 | 2011-11-09 13:48:41 | [diff] [blame] | 477 | extensions::SettingsFrontend* settings_frontend(); |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 478 | |
[email protected] | e2d720aa | 2012-05-17 00:11:35 | [diff] [blame] | 479 | extensions::ContentSettingsStore* GetContentSettingsStore(); |
[email protected] | b790b07 | 2011-05-20 09:46:44 | [diff] [blame] | 480 | |
[email protected] | 3ecda25 | 2010-11-18 19:50:55 | [diff] [blame] | 481 | // Whether the extension service is ready. |
[email protected] | 25ae015 | 2011-11-18 14:40:02 | [diff] [blame] | 482 | virtual bool is_ready() OVERRIDE; |
[email protected] | 3ecda25 | 2010-11-18 19:50:55 | [diff] [blame] | 483 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 484 | extensions::ComponentLoader* component_loader() { |
| 485 | return component_loader_.get(); |
| 486 | } |
| 487 | |
[email protected] | 1fab845 | 2009-09-03 02:23:39 | [diff] [blame] | 488 | // Note that this may return NULL if autoupdate is not turned on. |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 489 | extensions::ExtensionUpdater* updater(); |
[email protected] | 1fab845 | 2009-09-03 02:23:39 | [diff] [blame] | 490 | |
[email protected] | e0360f2c | 2009-12-07 22:34:31 | [diff] [blame] | 491 | ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } |
| 492 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 493 | ExtensionsQuotaService* quota_service() { return "a_service_; } |
| 494 | |
[email protected] | 5aeeae1 | 2012-07-05 19:13:11 | [diff] [blame] | 495 | extensions::MenuManager* menu_manager() { return &menu_manager_; } |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 496 | |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 497 | AppNotificationManager* app_notification_manager() { |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 498 | return app_notification_manager_.get(); |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 499 | } |
| 500 | |
[email protected] | 97d2f1d | 2011-01-15 00:41:08 | [diff] [blame] | 501 | ExtensionBrowserEventRouter* browser_event_router() { |
| 502 | return browser_event_router_.get(); |
| 503 | } |
| 504 | |
[email protected] | b16fc2e | 2011-07-21 21:32:58 | [diff] [blame] | 505 | #if defined(OS_CHROMEOS) |
[email protected] | f463bc9 | 2012-03-22 16:38:23 | [diff] [blame] | 506 | chromeos::ExtensionBluetoothEventRouter* bluetooth_event_router() { |
| 507 | return bluetooth_event_router_.get(); |
| 508 | } |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 509 | chromeos::ExtensionInputMethodEventRouter* input_method_event_router() { |
| 510 | return input_method_event_router_.get(); |
| 511 | } |
[email protected] | b16fc2e | 2011-07-21 21:32:58 | [diff] [blame] | 512 | #endif |
| 513 | |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 514 | // Notify the frontend that there was an error loading an extension. |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 515 | // This method is public because UnpackedInstaller and InstalledLoader |
| 516 | // can post to here. |
| 517 | // TODO(aa): Remove this. It doesn't do enough to be worth the dependency |
| 518 | // of these classes on ExtensionService. |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 519 | void ReportExtensionLoadError(const FilePath& extension_path, |
| 520 | const std::string& error, |
[email protected] | d11c8e9 | 2009-10-20 23:26:40 | [diff] [blame] | 521 | bool be_noisy); |
| 522 | |
[email protected] | 406027c0 | 2010-09-27 08:03:18 | [diff] [blame] | 523 | // ExtensionHost of background page calls this method right after its render |
| 524 | // view has been created. |
| 525 | void DidCreateRenderViewForBackgroundPage(ExtensionHost* host); |
| 526 | |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 527 | // For the extension in |version_path| with |id|, check to see if it's an |
| 528 | // externally managed extension. If so, uninstall it. |
| 529 | void CheckExternalUninstall(const std::string& id); |
| 530 | |
| 531 | // Clear all ExternalExtensionProviders. |
| 532 | void ClearProvidersForTesting(); |
| 533 | |
| 534 | // Adds an ExternalExtensionProviderInterface for the service to use during |
| 535 | // testing. Takes ownership of |test_provider|. |
| 536 | void AddProviderForTesting(ExternalExtensionProviderInterface* test_provider); |
| 537 | |
| 538 | // ExternalExtensionProvider::Visitor implementation. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 539 | virtual bool OnExternalExtensionFileFound( |
| 540 | const std::string& id, |
| 541 | const Version* version, |
| 542 | const FilePath& path, |
| 543 | extensions::Extension::Location location, |
| 544 | int creation_flags, |
| 545 | bool mark_acknowledged) OVERRIDE; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 546 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 547 | virtual bool OnExternalExtensionUpdateUrlFound( |
| 548 | const std::string& id, |
| 549 | const GURL& update_url, |
| 550 | extensions::Extension::Location location) OVERRIDE; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 551 | |
[email protected] | 50067e5 | 2011-10-20 23:17:07 | [diff] [blame] | 552 | virtual void OnExternalProviderReady( |
| 553 | const ExternalExtensionProviderInterface* provider) OVERRIDE; |
| 554 | |
[email protected] | 94fde23 | 2012-04-27 10:22:30 | [diff] [blame] | 555 | // Returns true when all the external extension providers are ready. |
| 556 | bool AreAllExternalProvidersReady() const; |
| 557 | |
[email protected] | 50067e5 | 2011-10-20 23:17:07 | [diff] [blame] | 558 | void OnAllExternalProvidersReady(); |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 559 | |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 560 | // Once all external providers are done, generates any needed alerts about |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 561 | // extensions. |
| 562 | void IdentifyAlertableExtensions(); |
| 563 | |
[email protected] | 07c9f2f4 | 2012-02-29 18:45:22 | [diff] [blame] | 564 | // Given an ExtensionGlobalError alert, populates it with any extensions that |
| 565 | // need alerting. Returns true if the alert should be displayed at all. |
| 566 | // |
| 567 | // This method takes the extension_global_error argument rather than using |
| 568 | // the member variable to make it easier to test the method in isolation. |
| 569 | bool PopulateExtensionGlobalError( |
| 570 | ExtensionGlobalError* extension_global_error); |
| 571 | |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 572 | // Marks alertable extensions as acknowledged, after the user presses the |
| 573 | // accept button. |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 574 | void HandleExtensionAlertAccept(); |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 575 | |
[email protected] | 47fc70c | 2011-12-06 07:29:51 | [diff] [blame] | 576 | // Given a (presumably just-installed) extension id, mark that extension as |
| 577 | // acknowledged. |
| 578 | void AcknowledgeExternalExtension(const std::string& id); |
| 579 | |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 580 | // Opens the Extensions page because the user wants to get more details |
| 581 | // about the alerts. |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 582 | void HandleExtensionAlertDetails(Browser* browser); |
[email protected] | 62433d3 | 2011-10-12 22:33:12 | [diff] [blame] | 583 | |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 584 | // Called when the extension alert is closed. |
| 585 | void HandleExtensionAlertClosed(); |
[email protected] | e5af875f | 2011-10-10 21:09:14 | [diff] [blame] | 586 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 587 | // content::NotificationObserver |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 588 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 589 | const content::NotificationSource& source, |
| 590 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 591 | |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 592 | // Whether there are any apps installed. Component apps are not included. |
| 593 | bool HasApps() const; |
| 594 | |
| 595 | // Gets the set of loaded app ids. Component apps are not included. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 596 | extensions::ExtensionIdSet GetAppIds() const; |
[email protected] | 377011d | 2010-07-20 04:18:50 | [diff] [blame] | 597 | |
[email protected] | fe2dd774 | 2011-04-19 22:52:49 | [diff] [blame] | 598 | // Record a histogram using the PermissionMessage enum values for each |
| 599 | // permission in |e|. |
| 600 | // NOTE: If this is ever called with high frequency, the implementation may |
| 601 | // need to be made more efficient. |
| 602 | static void RecordPermissionMessagesHistogram( |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 603 | const extensions::Extension* e, const char* histogram); |
[email protected] | fe2dd774 | 2011-04-19 22:52:49 | [diff] [blame] | 604 | |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 605 | #if defined(UNIT_TEST) |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 606 | void TrackTerminatedExtensionForTest(const extensions::Extension* extension) { |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 607 | TrackTerminatedExtension(extension); |
| 608 | } |
| 609 | #endif |
| 610 | |
[email protected] | 7c1490da | 2011-10-11 18:53:25 | [diff] [blame] | 611 | ExtensionWarningSet* extension_warnings() { |
| 612 | return &extension_warnings_; |
| 613 | } |
| 614 | |
[email protected] | e1fae1c | 2011-12-13 22:17:17 | [diff] [blame] | 615 | // Call only from IO thread. |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 616 | extensions::APIResourceController* api_resource_controller(); |
[email protected] | a1755bd | 2011-12-09 00:40:20 | [diff] [blame] | 617 | |
[email protected] | 178f851 | 2012-02-09 01:49:36 | [diff] [blame] | 618 | AppShortcutManager* app_shortcut_manager() { return &app_shortcut_manager_; } |
| 619 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 620 | // Specialization of syncer::SyncableService::AsWeakPtr. |
[email protected] | 77e4dc088 | 2012-06-20 18:53:50 | [diff] [blame] | 621 | base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); } |
| 622 | |
[email protected] | 14908b7 | 2011-04-20 06:54:36 | [diff] [blame] | 623 | private: |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 624 | // Contains Extension data that can change during the life of the process, |
| 625 | // but does not persist across restarts. |
| 626 | struct ExtensionRuntimeData { |
| 627 | // True if the background page is ready. |
| 628 | bool background_page_ready; |
| 629 | |
| 630 | // True while the extension is being upgraded. |
| 631 | bool being_upgraded; |
| 632 | |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 633 | // True if the extension has used the webRequest API. |
| 634 | bool has_used_webrequest; |
| 635 | |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 636 | // Generic bag of runtime data that users can associate with extensions. |
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 637 | base::PropertyBag property_bag; |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 638 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 639 | ExtensionRuntimeData(); |
| 640 | ~ExtensionRuntimeData(); |
| 641 | }; |
| 642 | typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap; |
| 643 | |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 644 | struct NaClModuleInfo { |
| 645 | NaClModuleInfo(); |
| 646 | ~NaClModuleInfo(); |
| 647 | |
| 648 | GURL url; |
| 649 | std::string mime_type; |
| 650 | }; |
| 651 | typedef std::list<NaClModuleInfo> NaClModuleInfoList; |
| 652 | |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 653 | // Return true if the sync type of |extension| matches |type|. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 654 | bool IsCorrectSyncType(const extensions::Extension& extension, |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 655 | syncer::ModelType type) |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 656 | const; |
| 657 | |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 658 | // Handles setting the extension specific values in |extension_sync_data| to |
| 659 | // the current system. |
| 660 | // Returns false if the changes were not completely applied and need to be |
| 661 | // tried again later. |
| 662 | bool ProcessExtensionSyncDataHelper( |
| 663 | const extensions::ExtensionSyncData& extension_sync_data, |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 664 | syncer::ModelType type); |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 665 | |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 666 | // Look up an extension by ID, optionally including either or both of enabled |
| 667 | // and disabled extensions. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 668 | const extensions::Extension* GetExtensionByIdInternal( |
| 669 | const std::string& id, |
| 670 | bool include_enabled, |
| 671 | bool include_disabled, |
| 672 | bool include_terminated) const; |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 673 | |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 674 | // Adds the given extension to the list of terminated extensions if |
| 675 | // it is not already there and unloads it. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 676 | void TrackTerminatedExtension(const extensions::Extension* extension); |
[email protected] | fa2416f | 2011-05-03 08:41:20 | [diff] [blame] | 677 | |
| 678 | // Removes the extension with the given id from the list of |
| 679 | // terminated extensions if it is there. |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 680 | void UntrackTerminatedExtension(const std::string& id); |
| 681 | |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 682 | // Handles sending notification that |extension| was loaded. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 683 | void NotifyExtensionLoaded(const extensions::Extension* extension); |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 684 | |
| 685 | // Handles sending notification that |extension| was unloaded. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 686 | void NotifyExtensionUnloaded(const extensions::Extension* extension, |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 687 | extension_misc::UnloadedExtensionReason reason); |
[email protected] | 62d30f4 | 2009-10-01 22:36:06 | [diff] [blame] | 688 | |
[email protected] | aab98a5 | 2009-12-02 03:22:35 | [diff] [blame] | 689 | // Helper that updates the active extension list used for crash reporting. |
| 690 | void UpdateActiveExtensionsInCrashReporter(); |
| 691 | |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 692 | // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's |
| 693 | // strong sandbox. Typically, these NaCl modules are stored in extensions |
| 694 | // and registered here. Not all NaCl modules need to register for a MIME |
| 695 | // type, just the ones that are responsible for rendering a particular MIME |
| 696 | // type, like application/pdf. Note: We only register NaCl modules in the |
| 697 | // browser process. |
| 698 | void RegisterNaClModule(const GURL& url, const std::string& mime_type); |
| 699 | void UnregisterNaClModule(const GURL& url); |
| 700 | |
[email protected] | ed0ba00 | 2011-05-26 16:55:13 | [diff] [blame] | 701 | // Call UpdatePluginListWithNaClModules() after registering or unregistering |
| 702 | // a NaCl module to see those changes reflected in the PluginList. |
| 703 | void UpdatePluginListWithNaClModules(); |
| 704 | |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 705 | NaClModuleInfoList::iterator FindNaClModule(const GURL& url); |
| 706 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 707 | // The normal profile associated with this ExtensionService. |
[email protected] | 6ef635e4 | 2009-07-26 06:16:12 | [diff] [blame] | 708 | Profile* profile_; |
| 709 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 710 | // The ExtensionSystem for the profile above. |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame^] | 711 | extensions::ExtensionSystem* system_; |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 712 | |
[email protected] | 73c4793 | 2010-12-06 18:13:43 | [diff] [blame] | 713 | // Preferences for the owning profile (weak reference). |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 714 | extensions::ExtensionPrefs* extension_prefs_; |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 715 | |
[email protected] | adfc546 | 2011-09-21 19:07:13 | [diff] [blame] | 716 | // Settings for the owning profile. |
[email protected] | cccdf0aa | 2011-11-11 03:43:38 | [diff] [blame] | 717 | scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 718 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 719 | // The current list of installed extensions. |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 720 | ExtensionSet extensions_; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 721 | |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 722 | // The list of installed extensions that have been disabled. |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 723 | ExtensionSet disabled_extensions_; |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 724 | |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 725 | // The list of installed extensions that have been terminated. |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 726 | ExtensionSet terminated_extensions_; |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 727 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 728 | // Hold the set of pending extensions. |
| 729 | PendingExtensionManager pending_extension_manager_; |
[email protected] | aa14270 | 2010-03-26 01:26:33 | [diff] [blame] | 730 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 731 | // The map of extension IDs to their runtime data. |
| 732 | ExtensionRuntimeDataMap extension_runtime_data_; |
| 733 | |
[email protected] | da5683db | 2011-04-23 17:12:21 | [diff] [blame] | 734 | // Holds a map between renderer process IDs that are associated with an |
| 735 | // installed app and their app. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 736 | typedef std::map<int, scoped_refptr<const extensions::Extension> > |
| 737 | InstalledAppMap; |
[email protected] | da5683db | 2011-04-23 17:12:21 | [diff] [blame] | 738 | InstalledAppMap installed_app_hosts_; |
| 739 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 740 | // The full path to the directory where extensions are installed. |
| 741 | FilePath install_directory_; |
| 742 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 743 | // Whether or not extensions are enabled. |
| 744 | bool extensions_enabled_; |
| 745 | |
[email protected] | 0e34d789 | 2009-06-05 19:17:40 | [diff] [blame] | 746 | // Whether to notify users when they attempt to install an extension. |
| 747 | bool show_extensions_prompts_; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 748 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 749 | // Used by dispatchers to limit API quota for individual extensions. |
| 750 | ExtensionsQuotaService quota_service_; |
| 751 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 752 | // Record that Init() has been called, and chrome::EXTENSIONS_READY |
[email protected] | fa6a910 | 2010-11-22 15:38:50 | [diff] [blame] | 753 | // has fired. |
[email protected] | 3ecda25 | 2010-11-18 19:50:55 | [diff] [blame] | 754 | bool ready_; |
[email protected] | e81dba3 | 2009-06-19 20:19:13 | [diff] [blame] | 755 | |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 756 | // Our extension updater, if updates are turned on. |
[email protected] | 42a0816 | 2012-03-16 18:09:11 | [diff] [blame] | 757 | scoped_ptr<extensions::ExtensionUpdater> updater_; |
[email protected] | 93fd78f4 | 2009-07-10 16:43:17 | [diff] [blame] | 758 | |
[email protected] | e0360f2c | 2009-12-07 22:34:31 | [diff] [blame] | 759 | // The model that tracks extensions with BrowserAction buttons. |
| 760 | ExtensionToolbarModel toolbar_model_; |
| 761 | |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 762 | // Map unloaded extensions' ids to their paths. When a temporarily loaded |
[email protected] | 5fb88938 | 2011-06-03 00:29:20 | [diff] [blame] | 763 | // extension is unloaded, we lose the information about it and don't have |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 764 | // any in the extension preferences file. |
| 765 | typedef std::map<std::string, FilePath> UnloadedExtensionPathMap; |
| 766 | UnloadedExtensionPathMap unloaded_extension_paths_; |
| 767 | |
[email protected] | f17dbd4 | 2010-08-16 23:21:10 | [diff] [blame] | 768 | // Map disabled extensions' ids to their paths. When a temporarily loaded |
| 769 | // extension is disabled before it is reloaded, keep track of the path so that |
| 770 | // it can be re-enabled upon a successful load. |
| 771 | typedef std::map<std::string, FilePath> DisabledExtensionPathMap; |
| 772 | DisabledExtensionPathMap disabled_extension_paths_; |
| 773 | |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 774 | // Map of inspector cookies that are detached, waiting for an extension to be |
| 775 | // reloaded. |
| 776 | typedef std::map<std::string, int> OrphanedDevTools; |
| 777 | OrphanedDevTools orphaned_dev_tools_; |
| 778 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 779 | content::NotificationRegistrar registrar_; |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 780 | PrefChangeRegistrar pref_change_registrar_; |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 781 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 782 | // Keeps track of loading and unloading component extensions. |
| 783 | scoped_ptr<extensions::ComponentLoader> component_loader_; |
| 784 | |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 785 | // Keeps track of menu items added by extensions. |
[email protected] | 5aeeae1 | 2012-07-05 19:13:11 | [diff] [blame] | 786 | extensions::MenuManager menu_manager_; |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 787 | |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 788 | // Keeps track of app notifications. |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 789 | scoped_refptr<AppNotificationManager> app_notification_manager_; |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 790 | |
[email protected] | b671760b | 2010-07-15 21:13:47 | [diff] [blame] | 791 | // Keeps track of favicon-sized omnibox icons for extensions. |
| 792 | ExtensionIconManager omnibox_icon_manager_; |
[email protected] | 29d0d4ac | 2010-09-08 21:10:31 | [diff] [blame] | 793 | ExtensionIconManager omnibox_popup_icon_manager_; |
[email protected] | b671760b | 2010-07-15 21:13:47 | [diff] [blame] | 794 | |
[email protected] | 18cc5a5 | 2011-04-15 16:03:38 | [diff] [blame] | 795 | // Manages the promotion of the web store. |
| 796 | AppsPromo apps_promo_; |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 797 | |
[email protected] | b3d62312b1 | 2010-10-14 21:10:18 | [diff] [blame] | 798 | // Flag to make sure event routers are only initialized once. |
| 799 | bool event_routers_initialized_; |
| 800 | |
[email protected] | d2e6bd6 | 2011-10-24 20:29:07 | [diff] [blame] | 801 | scoped_ptr<HistoryExtensionEventRouter> history_event_router_; |
[email protected] | f825df2 | 2011-06-28 17:36:10 | [diff] [blame] | 802 | |
[email protected] | 97d2f1d | 2011-01-15 00:41:08 | [diff] [blame] | 803 | scoped_ptr<ExtensionBrowserEventRouter> browser_event_router_; |
[email protected] | da55b8d | 2011-05-26 00:09:49 | [diff] [blame] | 804 | |
[email protected] | 7da9a823 | 2011-05-27 21:07:11 | [diff] [blame] | 805 | scoped_ptr<ExtensionPreferenceEventRouter> preference_event_router_; |
[email protected] | 118de789 | 2011-03-16 13:31:40 | [diff] [blame] | 806 | |
[email protected] | 23d5f17 | 2011-10-25 05:49:53 | [diff] [blame] | 807 | scoped_ptr<BookmarkExtensionEventRouter> bookmark_event_router_; |
[email protected] | f825df2 | 2011-06-28 17:36:10 | [diff] [blame] | 808 | |
[email protected] | 92ba7b01 | 2012-05-16 03:36:17 | [diff] [blame] | 809 | scoped_ptr<extensions::ExtensionCookiesEventRouter> cookies_event_router_; |
[email protected] | f825df2 | 2011-06-28 17:36:10 | [diff] [blame] | 810 | |
| 811 | scoped_ptr<ExtensionManagementEventRouter> management_event_router_; |
| 812 | |
[email protected] | 017ecde9 | 2012-04-04 09:11:26 | [diff] [blame] | 813 | scoped_ptr<extensions::WebNavigationEventRouter> web_navigation_event_router_; |
[email protected] | f825df2 | 2011-06-28 17:36:10 | [diff] [blame] | 814 | |
[email protected] | bdd3445 | 2012-04-16 15:58:40 | [diff] [blame] | 815 | scoped_ptr<ExtensionFontSettingsEventRouter> font_settings_event_router_; |
| 816 | |
[email protected] | 8a4cf84 | 2012-05-16 13:35:30 | [diff] [blame] | 817 | scoped_ptr<ExtensionManagedModeEventRouter> managed_mode_event_router_; |
| 818 | |
[email protected] | b16fc2e | 2011-07-21 21:32:58 | [diff] [blame] | 819 | #if defined(OS_CHROMEOS) |
[email protected] | f463bc9 | 2012-03-22 16:38:23 | [diff] [blame] | 820 | scoped_ptr<chromeos::ExtensionBluetoothEventRouter> bluetooth_event_router_; |
[email protected] | 771a618 | 2011-10-05 16:32:52 | [diff] [blame] | 821 | scoped_ptr<chromeos::ExtensionInputMethodEventRouter> |
| 822 | input_method_event_router_; |
[email protected] | b16fc2e | 2011-07-21 21:32:58 | [diff] [blame] | 823 | #endif |
| 824 | |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 825 | // A collection of external extension providers. Each provider reads |
| 826 | // a source of external extension information. Examples include the |
| 827 | // windows registry and external_extensions.json. |
| 828 | ProviderCollection external_extension_providers_; |
| 829 | |
| 830 | // Set to true by OnExternalExtensionUpdateUrlFound() when an external |
[email protected] | 94fde23 | 2012-04-27 10:22:30 | [diff] [blame] | 831 | // extension URL is found, and by CheckForUpdatesSoon() when an update check |
| 832 | // has to wait for the external providers. Used in |
| 833 | // OnAllExternalProvidersReady() to determine if an update check is needed to |
| 834 | // install pending extensions. |
| 835 | bool update_once_all_providers_are_ready_; |
[email protected] | 8e4560b6 | 2011-01-14 10:09:14 | [diff] [blame] | 836 | |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 837 | NaClModuleInfoList nacl_module_list_; |
| 838 | |
[email protected] | 5db9ada | 2012-04-11 13:48:20 | [diff] [blame] | 839 | extensions::AppSyncBundle app_sync_bundle_; |
| 840 | extensions::ExtensionSyncBundle extension_sync_bundle_; |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 841 | |
[email protected] | 7c1490da | 2011-10-11 18:53:25 | [diff] [blame] | 842 | // Contains an entry for each warning that shall be currently shown. |
| 843 | ExtensionWarningSet extension_warnings_; |
| 844 | |
[email protected] | 2404a2827 | 2012-05-30 02:31:14 | [diff] [blame] | 845 | scoped_ptr<extensions::APIResourceController> api_resource_controller_; |
[email protected] | a1755bd | 2011-12-09 00:40:20 | [diff] [blame] | 846 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 847 | extensions::ProcessMap process_map_; |
| 848 | |
[email protected] | 178f851 | 2012-02-09 01:49:36 | [diff] [blame] | 849 | AppShortcutManager app_shortcut_manager_; |
[email protected] | 9de8328 | 2011-12-12 11:06:37 | [diff] [blame] | 850 | |
[email protected] | a9aa593 | 2012-01-25 08:27:40 | [diff] [blame] | 851 | scoped_ptr<ExtensionGlobalError> extension_global_error_; |
| 852 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 853 | FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
[email protected] | c2c263c | 2010-08-13 21:59:48 | [diff] [blame] | 854 | InstallAppsWithUnlimtedStorage); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 855 | FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
[email protected] | 654512b | 2010-09-01 02:09:42 | [diff] [blame] | 856 | InstallAppsAndCheckStorageProtection); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 857 | DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 858 | }; |
| 859 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 860 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |