blob: c1543da75029d57380877dec85a0bb0aab4f02cd [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]7713d632008-12-02 07:52:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5b1a0e22009-05-26 19:00:585#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_
6#define CHROME_COMMON_EXTENSIONS_EXTENSION_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]7713d632008-12-02 07:52:338
[email protected]300cc58db2009-08-19 20:45:149#include <map>
[email protected]facd7a7652009-06-05 23:15:0210#include <set>
[email protected]7713d632008-12-02 07:52:3311#include <string>
12#include <vector>
13
[email protected]6014d672008-12-05 00:38:2514#include "base/file_path.h"
[email protected]19118d52010-07-26 22:13:4215#include "base/gtest_prod_util.h"
[email protected]b6b805e92011-04-16 09:24:1416#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1517#include "base/memory/ref_counted.h"
18#include "base/memory/scoped_ptr.h"
[email protected]d83a5602010-09-16 00:22:4819#include "chrome/common/extensions/extension_constants.h"
[email protected]807871f2010-09-16 01:04:4820#include "chrome/common/extensions/extension_icon_set.h"
[email protected]0d3e4a22011-06-23 19:02:5221#include "chrome/common/extensions/extension_permission_set.h"
[email protected]42b6f0f82009-09-18 21:07:3922#include "chrome/common/extensions/user_script.h"
[email protected]7197f4992009-03-23 05:05:4923#include "chrome/common/extensions/url_pattern.h"
[email protected]cced75a2011-05-20 08:31:1224#include "chrome/common/extensions/url_pattern_set.h"
[email protected]eab9b452009-01-23 20:48:5925#include "googleurl/src/gurl.h"
[email protected]08397d52011-02-05 01:53:3826#include "ui/gfx/size.h"
[email protected]eab9b452009-01-23 20:48:5927
[email protected]942690b132010-05-11 06:42:1428class ExtensionAction;
29class ExtensionResource;
[email protected]e2dffe02011-01-20 20:30:0630class ExtensionSidebarDefaults;
[email protected]b6b805e92011-04-16 09:24:1431class FileBrowserHandler;
[email protected]12802702010-07-09 19:43:0932class SkBitmap;
[email protected]daf66aa2010-08-06 06:24:2833class Version;
[email protected]942690b132010-05-11 06:42:1434
[email protected]f3a1c642011-07-12 19:15:0335namespace base {
36class DictionaryValue;
37class ListValue;
38}
39
[email protected]f0755532010-06-22 07:27:2540// Represents a Chrome extension.
[email protected]66e4eb32010-10-27 20:37:4141class Extension : public base::RefCountedThreadSafe<Extension> {
[email protected]7713d632008-12-02 07:52:3342 public:
[email protected]d3cfa482009-10-17 13:54:5743 typedef std::map<const std::string, GURL> URLOverrideMap;
[email protected]10fb1992010-10-08 09:00:1744 typedef std::vector<std::string> ScriptingWhitelist;
[email protected]b6b805e92011-04-16 09:24:1445 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
[email protected]b24d8312009-08-27 06:47:4646
[email protected]631cf822009-05-15 07:01:2547 // What an extension was loaded from.
[email protected]9b217652010-10-08 22:04:2348 // NOTE: These values are stored as integers in the preferences and used
49 // in histograms so don't remove or reorder existing items. Just append
50 // to the end.
[email protected]631cf822009-05-15 07:01:2551 enum Location {
52 INVALID,
[email protected]25b34332009-06-05 21:53:1953 INTERNAL, // A crx file from the internal Extensions directory.
54 EXTERNAL_PREF, // A crx file from an external directory (via prefs).
55 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the
56 // registry on Windows).
[email protected]1952c7d2010-03-04 23:48:3457 LOAD, // --load-extension.
[email protected]8ef78fd2010-08-19 17:14:3258 COMPONENT, // An integral component of Chrome itself, which
59 // happens to be implemented as an extension. We don't
60 // show these in the management UI.
[email protected]4d2913e32010-11-30 00:28:5561 EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via
62 // prefs), installed from an update URL.
63 EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via
64 // admin policies), installed from an update URL.
[email protected]04cb7542010-10-25 10:50:0665
66 NUM_LOCATIONS
[email protected]25b34332009-06-05 21:53:1967 };
68
69 enum State {
[email protected]0c6da502009-08-14 22:32:3970 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1971 ENABLED,
[email protected]79c833b52011-04-05 18:31:0172 // An external extension that the user uninstalled. We should not reinstall
73 // such extensions on startup.
74 EXTERNAL_EXTENSION_UNINSTALLED,
[email protected]0c6da502009-08-14 22:32:3975 NUM_STATES
[email protected]631cf822009-05-15 07:01:2576 };
[email protected]7713d632008-12-02 07:52:3377
[email protected]fbcc40302009-06-12 20:45:4578 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:3779 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:4580 DOWNGRADE,
81 REINSTALL,
82 UPGRADE,
83 NEW_INSTALL
84 };
85
[email protected]d2817012009-08-04 06:46:2186 // NOTE: If you change this list, you should also change kIconSizes in the cc
87 // file.
88 enum Icons {
89 EXTENSION_ICON_LARGE = 128,
90 EXTENSION_ICON_MEDIUM = 48,
91 EXTENSION_ICON_SMALL = 32,
[email protected]39382942010-03-23 15:57:0992 EXTENSION_ICON_SMALLISH = 24,
[email protected]d2817012009-08-04 06:46:2193 EXTENSION_ICON_BITTY = 16,
94 };
95
[email protected]7fa19f82010-12-21 19:40:0896 // Do not change the order of entries or remove entries in this list
97 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions.
98 enum Type {
[email protected]9b217652010-10-08 22:04:2399 TYPE_UNKNOWN = 0,
100 TYPE_EXTENSION,
101 TYPE_THEME,
102 TYPE_USER_SCRIPT,
103 TYPE_HOSTED_APP,
104 TYPE_PACKAGED_APP
105 };
106
[email protected]92888082010-10-18 19:24:57107 // An NPAPI plugin included in the extension.
108 struct PluginInfo {
109 FilePath path; // Path to the plugin.
110 bool is_public; // False if only this extension can load this plugin.
111 };
112
[email protected]65378f52011-04-08 02:31:23113 // An NaCl module included in the extension.
114 struct NaClModuleInfo {
[email protected]84396dbc2011-04-14 06:33:42115 GURL url;
[email protected]65378f52011-04-08 02:31:23116 std::string mime_type;
117 };
118
[email protected]b0820372011-06-03 07:05:27119 enum InputComponentType {
[email protected]d45f7512011-06-21 21:18:27120 INPUT_COMPONENT_TYPE_NONE = -1,
121 INPUT_COMPONENT_TYPE_IME,
[email protected]b0820372011-06-03 07:05:27122 INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD,
123 INPUT_COMPONENT_TYPE_COUNT
124 };
125
126 struct InputComponentInfo {
127 // Define out of line constructor/destructor to please Clang.
128 InputComponentInfo();
129 ~InputComponentInfo();
130
131 std::string name;
132 InputComponentType type;
133 std::string id;
134 std::string description;
135 std::string language;
136 std::set<std::string> layouts;
137 std::string shortcut_keycode;
138 bool shortcut_alt;
139 bool shortcut_ctrl;
140 bool shortcut_shift;
141 };
142
[email protected]a4a38c12010-12-23 16:43:56143 struct TtsVoice {
[email protected]77a3ecac2011-07-07 05:56:33144 // Define out of line constructor/destructor to please Clang.
145 TtsVoice();
146 ~TtsVoice();
147
[email protected]a4a38c12010-12-23 16:43:56148 std::string voice_name;
[email protected]c63f2b72011-07-07 05:25:00149 std::string lang;
[email protected]a4a38c12010-12-23 16:43:56150 std::string gender;
[email protected]c63f2b72011-07-07 05:25:00151 std::set<std::string> event_types;
[email protected]a4a38c12010-12-23 16:43:56152 };
153
[email protected]83048a22011-03-29 00:14:13154 enum InitFromValueFlags {
155 NO_FLAGS = 0,
156
157 // Usually, the id of an extension is generated by the "key" property of
158 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
159 // generated based on the path.
160 REQUIRE_KEY = 1 << 0,
161
162 // |STRICT_ERROR_CHECKS| enables extra error checking, such as
163 // checks that URL patterns do not contain ports. This error
164 // checking may find an error that a previous version of
165 // Chrome did not flag. To avoid errors in installed extensions
166 // when Chrome is upgraded, strict error checking is only enabled
167 // when loading extensions as a developer would (such as loading
168 // an unpacked extension), or when loading an extension that is
169 // tied to a specific version of Chrome (such as a component
170 // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when
171 // Extension::ShouldDoStrictErrorChecking(location) returns true.
172 STRICT_ERROR_CHECKS = 1 << 1,
[email protected]3aff9ad2011-04-01 20:26:48173
174 // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension
175 // to have file access. If it's not present, then permissions and content
176 // scripts that match file:/// URLs will be filtered out.
177 ALLOW_FILE_ACCESS = 1 << 2,
[email protected]83048a22011-03-29 00:14:13178 };
179
[email protected]66e4eb32010-10-27 20:37:41180 static scoped_refptr<Extension> Create(const FilePath& path,
181 Location location,
[email protected]f3a1c642011-07-12 19:15:03182 const base::DictionaryValue& value,
[email protected]83048a22011-03-29 00:14:13183 int flags,
[email protected]66e4eb32010-10-27 20:37:41184 std::string* error);
185
[email protected]87c655e2011-07-01 21:42:00186 // In a few special circumstances, we want to create an Extension and give it
187 // an explicit id. Most consumers should just use the plain Create() method.
[email protected]f3a1c642011-07-12 19:15:03188 static scoped_refptr<Extension> CreateWithId(
189 const FilePath& path,
190 Location location,
191 const base::DictionaryValue& value,
192 int flags,
193 const std::string& explicit_id,
194 std::string* error);
[email protected]87c655e2011-07-01 21:42:00195
[email protected]4d2913e32010-11-30 00:28:55196 // Return the update url used by gallery/webstore extensions.
197 static GURL GalleryUpdateUrl(bool secure);
198
[email protected]145a317b2011-04-12 16:03:46199 // Given two install sources, return the one which should take priority
200 // over the other. If an extension is installed from two sources A and B,
201 // its install source should be set to GetHigherPriorityLocation(A, B).
202 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
203
[email protected]a2a098d2010-09-29 19:42:55204 // Returns the full list of permission messages that this extension
205 // should display at install time.
[email protected]0d3e4a22011-06-23 19:02:52206 ExtensionPermissionMessages GetPermissionMessages() const;
[email protected]fe2dd7742011-04-19 22:52:49207
208 // Returns the full list of permission messages that this extension
209 // should display at install time. The messages are returned as strings
210 // for convenience.
211 std::vector<string16> GetPermissionMessageStrings() const;
[email protected]a2a098d2010-09-29 19:42:55212
[email protected]c3e3def742009-07-17 07:51:06213 // Icon sizes used by the extension system.
[email protected]d2817012009-08-04 06:46:21214 static const int kIconSizes[];
[email protected]c3e3def742009-07-17 07:51:06215
[email protected]4c4f8192009-10-17 01:03:26216 // Max size (both dimensions) for browser and page actions.
217 static const int kPageActionIconMaxSize;
218 static const int kBrowserActionIconMaxSize;
[email protected]e2dffe02011-01-20 20:30:06219 static const int kSidebarIconMaxSize;
[email protected]4c4f8192009-10-17 01:03:26220
[email protected]8d888c12010-11-30 00:00:25221 // Valid schemes for web extent URLPatterns.
222 static const int kValidWebExtentSchemes;
223
[email protected]f71f7e62010-12-07 03:45:33224 // Valid schemes for host permission URLPatterns.
225 static const int kValidHostPermissionSchemes;
226
[email protected]6014d672008-12-05 00:38:25227 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16228 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25229
[email protected]300cc58db2009-08-19 20:45:14230 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16231 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14232
233 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16234 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14235
[email protected]25b34332009-06-05 21:53:19236#if defined(OS_WIN)
[email protected]9dcf8f12010-09-02 20:39:19237 static const char kExtensionRegistryPath[];
[email protected]25b34332009-06-05 21:53:19238#endif
239
[email protected]37eeb5a2009-02-26 23:36:17240 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48241 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17242
[email protected]e435d6b72009-07-25 03:15:58243 // The mimetype used for extensions.
244 static const char kMimeType[];
245
[email protected]25b34332009-06-05 21:53:19246 // Checks to see if the extension has a valid ID.
247 static bool IdIsValid(const std::string& id);
248
[email protected]4ead6f72010-10-13 19:54:18249 // Generate an ID for an extension in the given path.
[email protected]28d7479b2011-03-09 21:33:27250 // Used while developing extensions, before they have a key.
[email protected]4ead6f72010-10-13 19:54:18251 static std::string GenerateIdForPath(const FilePath& file_name);
252
[email protected]e435d6b72009-07-25 03:15:58253 // Returns true if the specified file is an extension.
254 static bool IsExtension(const FilePath& file_name);
255
[email protected]25b34332009-06-05 21:53:19256 // Whether the |location| is external or not.
257 static inline bool IsExternalLocation(Location location) {
258 return location == Extension::EXTERNAL_PREF ||
[email protected]8ef78fd2010-08-19 17:14:32259 location == Extension::EXTERNAL_REGISTRY ||
[email protected]04cb7542010-10-25 10:50:06260 location == Extension::EXTERNAL_PREF_DOWNLOAD ||
261 location == Extension::EXTERNAL_POLICY_DOWNLOAD;
262 }
263
264 // Whether extensions with |location| are auto-updatable or not.
265 static inline bool IsAutoUpdateableLocation(Location location) {
266 // Only internal and external extensions can be autoupdated.
267 return location == Extension::INTERNAL ||
268 IsExternalLocation(location);
[email protected]25b34332009-06-05 21:53:19269 }
270
[email protected]95da88c42011-03-31 10:07:33271 // Whether extensions with |location| can be uninstalled or not. Policy
272 // controlled extensions are silently auto-installed and updated, and cannot
273 // be disabled by the user. The same applies for internal components.
274 static inline bool UserMayDisable(Location location) {
275 return location != Extension::EXTERNAL_POLICY_DOWNLOAD &&
276 location != Extension::COMPONENT;
277 }
278
[email protected]542258c2011-03-04 21:25:31279 // Whether extensions with |location| should be loaded with strict
280 // error checking. Strict error checks may flag errors older versions
281 // of chrome did not detect. To avoid breaking installed extensions,
282 // strict checks are disabled unless the location indicates that the
283 // developer is loading the extension, or the extension is a component
284 // of chrome.
285 static inline bool ShouldDoStrictErrorChecking(Location location) {
286 return location == Extension::LOAD ||
287 location == Extension::COMPONENT;
288 }
289
[email protected]3aff9ad2011-04-01 20:26:48290 // Unpacked extensions start off with file access since they are a developer
291 // feature.
292 static inline bool ShouldAlwaysAllowFileAccess(Location location) {
293 return location == Extension::LOAD;
294 }
295
[email protected]7fa19f82010-12-21 19:40:08296 // See Type definition above.
297 Type GetType() const;
[email protected]9b217652010-10-08 22:04:23298
[email protected]07c00d992009-03-04 20:27:04299 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59300 // |extension_url| argument should be the url() from an Extension object. The
301 // |relative_path| can be untrusted user input. The returned URL will either
302 // be invalid() or a child of |extension_url|.
303 // NOTE: Static so that it can be used from multiple threads.
304 static GURL GetResourceURL(const GURL& extension_url,
305 const std::string& relative_path);
[email protected]cffd7892010-08-26 17:43:28306 GURL GetResourceURL(const std::string& relative_path) const {
[email protected]3cfbd0e2009-03-18 21:26:24307 return GetResourceURL(url(), relative_path);
308 }
[email protected]eab9b452009-01-23 20:48:59309
[email protected]99efb7b12009-12-18 02:39:16310 // Returns an extension resource object. |relative_path| should be UTF8
311 // encoded.
[email protected]9adb9692010-10-29 23:14:02312 ExtensionResource GetResource(const std::string& relative_path) const;
[email protected]99efb7b12009-12-18 02:39:16313
314 // As above, but with |relative_path| following the file system's encoding.
[email protected]9adb9692010-10-29 23:14:02315 ExtensionResource GetResource(const FilePath& relative_path) const;
[email protected]eab9b452009-01-23 20:48:59316
[email protected]a17f9462009-06-09 02:56:41317 // |input| is expected to be the text of an rsa public or private key. It
318 // tolerates the presence or absence of bracking header/footer like this:
319 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
320 // and may contain newlines.
321 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
322
323 // Does a simple base64 encoding of |input| into |output|.
324 static bool ProducePEM(const std::string& input, std::string* output);
325
[email protected]84ac7f32009-10-06 06:17:54326 // Generates an extension ID from arbitrary input. The same input string will
327 // always generate the same output ID.
328 static bool GenerateId(const std::string& input, std::string* output);
[email protected]fbcc40302009-06-12 20:45:45329
[email protected]a17f9462009-06-09 02:56:41330 // Expects base64 encoded |input| and formats into |output| including
331 // the appropriate header & footer.
[email protected]e0d08192011-03-29 19:02:50332 static bool FormatPEMForFileOutput(const std::string& input,
333 std::string* output,
334 bool is_public);
[email protected]a17f9462009-06-09 02:56:41335
[email protected]c690a9812009-12-17 05:55:32336 // Given an extension and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23337 // result. In the browser process, this will DCHECK if not called on the
338 // file thread. To easily load extension images on the UI thread, see
339 // ImageLoadingTracker.
[email protected]9adb9692010-10-29 23:14:02340 static void DecodeIcon(const Extension* extension,
[email protected]c690a9812009-12-17 05:55:32341 Icons icon_size,
342 scoped_ptr<SkBitmap>* result);
343
344 // Given an icon_path and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23345 // result. In the browser process, this will DCHECK if not called on the
346 // file thread. To easily load extension images on the UI thread, see
347 // ImageLoadingTracker.
[email protected]c690a9812009-12-17 05:55:32348 static void DecodeIconFromPath(const FilePath& icon_path,
349 Icons icon_size,
350 scoped_ptr<SkBitmap>* result);
351
[email protected]5349ac6d2011-04-05 22:20:17352 // Returns the default extension/app icon (for extensions or apps that don't
353 // have one).
354 static const SkBitmap& GetDefaultIcon(bool is_app);
355
[email protected]a807bbe2010-04-14 10:51:19356 // Returns the base extension url for a given |extension_id|.
357 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
358
[email protected]ec5b50d2010-10-09 16:35:18359 // Returns the url prefix for the extension/apps gallery. Can be set via the
[email protected]ce3eb7b62010-09-14 13:57:44360 // --apps-gallery-url switch. The URL returned will not contain a trailing
[email protected]d3071992010-10-08 15:24:07361 // slash. Do not use this as a prefix/extent for the store. Instead see
[email protected]eaa7dd182010-12-14 11:09:00362 // ExtensionService::GetWebStoreApp or
363 // ExtensionService::IsDownloadFromGallery
[email protected]d3071992010-10-08 15:24:07364 static std::string ChromeStoreLaunchURL();
[email protected]a0cf04a2010-06-23 03:29:55365
[email protected]be7e5cb2010-10-04 12:53:17366 // Adds an extension to the scripting whitelist. Used for testing only.
[email protected]10fb1992010-10-08 09:00:17367 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
[email protected]2a521c52011-01-26 18:45:21368 static const ScriptingWhitelist* GetScriptingWhitelist();
[email protected]be7e5cb2010-10-04 12:53:17369
[email protected]0d3e4a22011-06-23 19:02:52370 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const;
371 bool HasAPIPermission(const std::string& function_name) const;
[email protected]583d45c12010-08-31 02:48:12372
[email protected]0d3e4a22011-06-23 19:02:52373 const URLPatternSet& GetEffectiveHostPermissions() const;
[email protected]b24d8312009-08-27 06:47:46374
[email protected]fbd17cf2010-04-28 23:52:56375 // Whether or not the extension is allowed permission for a URL pattern from
376 // the manifest. http, https, and chrome://favicon/ is allowed for all
377 // extensions, while component extensions are allowed access to
378 // chrome://resources.
[email protected]a3caa822010-10-26 18:10:00379 bool CanSpecifyHostPermission(const URLPattern& pattern) const;
[email protected]fbd17cf2010-04-28 23:52:56380
[email protected]584b8e3f2010-04-10 00:23:37381 // Whether the extension has access to the given URL.
382 bool HasHostPermission(const GURL& url) const;
383
[email protected]0df165f2010-09-28 16:49:40384 // Whether the extension has effective access to all hosts. This is true if
385 // there is a content script that matches all hosts, if there is a host
386 // permission grants access to all hosts (like <all_urls>) or an api
387 // permission that effectively grants access to all hosts (e.g. proxy,
388 // network, etc.)
389 bool HasEffectiveAccessToAllHosts() const;
[email protected]b24d8312009-08-27 06:47:46390
[email protected]8d888c12010-11-30 00:00:25391 // Whether the extension effectively has all permissions (for example, by
392 // having an NPAPI plugin).
393 bool HasFullPermissions() const;
394
[email protected]5df6a5d2011-01-26 07:39:12395 // Whether context menu should be shown for page and browser actions.
396 bool ShowConfigureContextMenus() const;
397
[email protected]37cd64d2010-10-25 18:17:58398 // Returns the Homepage URL for this extension. If homepage_url was not
399 // specified in the manifest, this returns the Google Gallery URL. For
[email protected]bfa90a3a2010-04-28 15:43:23400 // third-party extensions, this returns a blank GURL.
[email protected]37cd64d2010-10-25 18:17:58401 GURL GetHomepageURL() const;
[email protected]bfa90a3a2010-04-28 15:43:23402
[email protected]facd7a7652009-06-05 23:15:02403 // Returns a list of paths (relative to the extension dir) for images that
404 // the browser might load (like themes and page action icons).
[email protected]9adb9692010-10-29 23:14:02405 std::set<FilePath> GetBrowserImages() const;
[email protected]facd7a7652009-06-05 23:15:02406
[email protected]807871f2010-09-16 01:04:48407 // Get an extension icon as a resource or URL.
[email protected]9adb9692010-10-29 23:14:02408 ExtensionResource GetIconResource(
409 int size, ExtensionIconSet::MatchType match_type) const;
410 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
[email protected]f34e79632010-03-17 02:34:08411
[email protected]867a73e12010-03-19 20:45:46412 // Gets the fully resolved absolute launch URL.
413 GURL GetFullLaunchURL() const;
[email protected]2a521c52011-01-26 18:45:21414
[email protected]6f229e82010-11-02 17:47:26415 // Image cache related methods. These are only valid on the UI thread and
416 // not maintained by this class. See ImageLoadingTracker for usage. The
417 // |original_size| parameter should be the size of the image at |source|
418 // before any scaling may have been done to produce the pixels in |image|.
419 void SetCachedImage(const ExtensionResource& source,
420 const SkBitmap& image,
421 const gfx::Size& original_size) const;
422 bool HasCachedImage(const ExtensionResource& source,
423 const gfx::Size& max_size) const;
424 SkBitmap GetCachedImage(const ExtensionResource& source,
425 const gfx::Size& max_size) const;
[email protected]2a521c52011-01-26 18:45:21426
427 // Returns true if this extension can execute script on a page. If a
428 // UserScript object is passed, permission to run that specific script is
429 // checked (using its matches list). Otherwise, permission to execute script
430 // programmatically is checked (using the extension's host permission).
431 //
432 // This method is also aware of certain special pages that extensions are
433 // usually not allowed to run script on.
434 bool CanExecuteScriptOnPage(const GURL& page_url,
[email protected]3aff9ad2011-04-01 20:26:48435 const UserScript* script,
[email protected]2a521c52011-01-26 18:45:21436 std::string* error) const;
437
[email protected]6f229e82010-11-02 17:47:26438 // Returns true if this extension is a COMPONENT extension, or if it is
439 // on the whitelist of extensions that can script all pages.
440 bool CanExecuteScriptEverywhere() const;
441
[email protected]5efbfe012011-02-22 23:07:18442 // Returns true if this extension is allowed to obtain the contents of a
443 // page as an image. Since a page may contain sensitive information, this
444 // is restricted to the extension's host permissions as well as the
445 // extension page itself.
446 bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const;
447
[email protected]a65882c2010-11-12 15:15:09448 // Returns true if this extension updates itself using the extension
449 // gallery.
450 bool UpdatesFromGallery() const;
451
[email protected]cca147172011-02-17 01:29:29452 // Returns true if this extension or app includes areas within |origin|.
453 bool OverlapsWithOrigin(const GURL& origin) const;
454
[email protected]6f229e82010-11-02 17:47:26455 // Accessors:
456
457 const FilePath& path() const { return path_; }
458 const GURL& url() const { return extension_url_; }
459 Location location() const { return location_; }
460 const std::string& id() const { return id_; }
461 const Version* version() const { return version_.get(); }
462 const std::string VersionString() const;
463 const std::string& name() const { return name_; }
464 const std::string& public_key() const { return public_key_; }
465 const std::string& description() const { return description_; }
466 bool converted_from_user_script() const {
467 return converted_from_user_script_;
468 }
469 const UserScriptList& content_scripts() const { return content_scripts_; }
470 ExtensionAction* page_action() const { return page_action_.get(); }
471 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]e2dffe02011-01-20 20:30:06472 ExtensionSidebarDefaults* sidebar_defaults() const {
473 return sidebar_defaults_.get();
474 }
[email protected]b6b805e92011-04-16 09:24:14475 const FileBrowserHandlerList* file_browser_handlers() const {
476 return file_browser_handlers_.get();
477 }
[email protected]6f229e82010-11-02 17:47:26478 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]65378f52011-04-08 02:31:23479 const std::vector<NaClModuleInfo>& nacl_modules() const {
480 return nacl_modules_;
481 }
[email protected]b0820372011-06-03 07:05:27482 const std::vector<InputComponentInfo>& input_components() const {
483 return input_components_;
484 }
[email protected]6f229e82010-11-02 17:47:26485 const GURL& background_url() const { return background_url_; }
486 const GURL& options_url() const { return options_url_; }
487 const GURL& devtools_url() const { return devtools_url_; }
488 const std::vector<GURL>& toolstrips() const { return toolstrips_; }
[email protected]0d3e4a22011-06-23 19:02:52489 const ExtensionPermissionSet* permission_set() const {
490 return permission_set_.get();
[email protected]6f229e82010-11-02 17:47:26491 }
[email protected]6f229e82010-11-02 17:47:26492 const GURL& update_url() const { return update_url_; }
493 const ExtensionIconSet& icons() const { return icons_; }
[email protected]f3a1c642011-07-12 19:15:03494 const base::DictionaryValue* manifest_value() const {
[email protected]6f229e82010-11-02 17:47:26495 return manifest_value_.get();
496 }
497 const std::string default_locale() const { return default_locale_; }
498 const URLOverrideMap& GetChromeURLOverrides() const {
499 return chrome_url_overrides_;
500 }
501 const std::string omnibox_keyword() const { return omnibox_keyword_; }
502 bool incognito_split_mode() const { return incognito_split_mode_; }
[email protected]a4a38c12010-12-23 16:43:56503 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
[email protected]6f229e82010-11-02 17:47:26504
[email protected]3aff9ad2011-04-01 20:26:48505 bool wants_file_access() const { return wants_file_access_; }
506
[email protected]7f7b9d932011-04-20 16:13:26507 const std::string& content_security_policy() const {
508 return content_security_policy_;
509 }
510
[email protected]6f229e82010-11-02 17:47:26511 // App-related.
512 bool is_app() const { return is_app_; }
513 bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); }
514 bool is_packaged_app() const { return is_app() && web_extent().is_empty(); }
[email protected]d9696672011-03-15 22:45:09515 bool is_storage_isolated() const { return is_app() && is_storage_isolated_; }
[email protected]cced75a2011-05-20 08:31:12516 const URLPatternSet& web_extent() const { return extent_; }
[email protected]6f229e82010-11-02 17:47:26517 const std::string& launch_local_path() const { return launch_local_path_; }
518 const std::string& launch_web_url() const { return launch_web_url_; }
519 extension_misc::LaunchContainer launch_container() const {
520 return launch_container_;
521 }
522 int launch_width() const { return launch_width_; }
523 int launch_height() const { return launch_height_; }
524
525 // Theme-related.
526 bool is_theme() const { return is_theme_; }
[email protected]f3a1c642011-07-12 19:15:03527 base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
528 base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); }
529 base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
530 base::DictionaryValue* GetThemeDisplayProperties() const {
[email protected]6f229e82010-11-02 17:47:26531 return theme_display_properties_.get();
532 }
533
[email protected]4a8d3272009-03-10 19:15:08534 private:
[email protected]66e4eb32010-10-27 20:37:41535 friend class base::RefCountedThreadSafe<Extension>;
536
[email protected]d7e9a862010-11-03 21:57:49537 // We keep a cache of images loaded from extension resources based on their
538 // path and a string representation of a size that may have been used to
539 // scale it (or the empty string if the image is at its original size).
540 typedef std::pair<FilePath, std::string> ImageCacheKey;
541 typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
542
[email protected]4ead6f72010-10-13 19:54:18543 // Normalize the path for use by the extension. On Windows, this will make
544 // sure the drive letter is uppercase.
545 static FilePath MaybeNormalizePath(const FilePath& path);
546
[email protected]d6a5c78c2010-12-07 05:18:15547 // Returns the distinct hosts that can be displayed in the install UI or be
548 // used for privilege comparisons. This discards some of the detail that is
549 // present in the manifest to make it as easy as possible to process by users.
550 // In particular we disregard the scheme and path components of URLPatterns
551 // and de-dupe the result, which includes filtering out common hosts with
552 // differing RCDs. If |include_rcd| is true, then the de-duped result
553 // will be the first full entry, including its RCD. So if the list was
554 // "*.google.co.uk" and "*.google.com", the returned value would just be
555 // "*.google.co.uk". Keeping the RCD in the result is useful for display
556 // purposes when you want to show the user one sample hostname from the list.
557 // If you need to compare two URLPatternLists for security equality, then set
558 // |include_rcd| to false, which will return a result like "*.google.",
559 // regardless of the order of the patterns.
560 static std::vector<std::string> GetDistinctHosts(
561 const URLPatternList& host_patterns, bool include_rcd);
562
[email protected]87c655e2011-07-01 21:42:00563 // Returns true if this extension id is from a trusted provider.
564 static bool IsTrustedId(const std::string& id);
565
[email protected]66e4eb32010-10-27 20:37:41566 Extension(const FilePath& path, Location location);
567 ~Extension();
568
569 // Initialize the extension from a parsed manifest.
[email protected]f3a1c642011-07-12 19:15:03570 bool InitFromValue(const base::DictionaryValue& value, int flags,
[email protected]83048a22011-03-29 00:14:13571 std::string* error);
[email protected]66e4eb32010-10-27 20:37:41572
[email protected]052c92702010-06-25 07:25:52573 // Helper function for implementing HasCachedImage/GetCachedImage. A return
574 // value of NULL means there is no matching image cached (we allow caching an
575 // empty SkBitmap).
576 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
[email protected]9adb9692010-10-29 23:14:02577 const gfx::Size& max_size) const;
[email protected]d9ad80f2010-03-30 20:40:18578
[email protected]3cfbd0e2009-03-18 21:26:24579 // Helper method that loads a UserScript object from a
580 // dictionary in the content_script list of the manifest.
[email protected]f3a1c642011-07-12 19:15:03581 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
[email protected]3cfbd0e2009-03-18 21:26:24582 int definition_index,
[email protected]3aff9ad2011-04-01 20:26:48583 int flags,
[email protected]3cfbd0e2009-03-18 21:26:24584 std::string* error,
585 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34586
[email protected]6657afa62009-11-04 02:15:20587 // Helper method that loads either the include_globs or exclude_globs list
588 // from an entry in the content_script lists of the manifest.
[email protected]f3a1c642011-07-12 19:15:03589 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
[email protected]6657afa62009-11-04 02:15:20590 int content_script_index,
[email protected]e2194742010-08-12 05:54:34591 const char* globs_property_name,
[email protected]6657afa62009-11-04 02:15:20592 std::string* error,
[email protected]11f4857282009-11-13 19:56:17593 void(UserScript::*add_method)(const std::string& glob),
[email protected]6657afa62009-11-04 02:15:20594 UserScript *instance);
595
[email protected]867a73e12010-03-19 20:45:46596 // Helpers to load various chunks of the manifest.
[email protected]f3a1c642011-07-12 19:15:03597 bool LoadIsApp(const base::DictionaryValue* manifest, std::string* error);
598 bool LoadExtent(const base::DictionaryValue* manifest,
[email protected]542258c2011-03-04 21:25:31599 const char* key,
[email protected]cced75a2011-05-20 08:31:12600 URLPatternSet* extent,
[email protected]542258c2011-03-04 21:25:31601 const char* list_error,
602 const char* value_error,
603 URLPattern::ParseOption parse_strictness,
604 std::string* error);
[email protected]f3a1c642011-07-12 19:15:03605 bool LoadLaunchContainer(const base::DictionaryValue* manifest,
606 std::string* error);
607 bool LoadLaunchURL(const base::DictionaryValue* manifest,
608 std::string* error);
609 bool LoadAppIsolation(const base::DictionaryValue* manifest,
610 std::string* error);
611 bool EnsureNotHybridApp(const base::DictionaryValue* manifest,
612 std::string* error);
[email protected]867a73e12010-03-19 20:45:46613
[email protected]5d246db22009-10-27 06:17:57614 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08615 // browser_action entries in the manifest.
[email protected]5d246db22009-10-27 06:17:57616 ExtensionAction* LoadExtensionActionHelper(
[email protected]f3a1c642011-07-12 19:15:03617 const base::DictionaryValue* extension_action, std::string* error);
[email protected]92c6f9b92009-10-24 04:35:08618
[email protected]b6b805e92011-04-16 09:24:14619 // Helper method to load an FileBrowserHandlerList from the manifest.
620 FileBrowserHandlerList* LoadFileBrowserHandlers(
[email protected]f3a1c642011-07-12 19:15:03621 const base::ListValue* extension_actions, std::string* error);
[email protected]b6b805e92011-04-16 09:24:14622 // Helper method to load an FileBrowserHandler from manifest.
623 FileBrowserHandler* LoadFileBrowserHandler(
[email protected]f3a1c642011-07-12 19:15:03624 const base::DictionaryValue* file_browser_handlers, std::string* error);
[email protected]b6b805e92011-04-16 09:24:14625
[email protected]e2dffe02011-01-20 20:30:06626 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
627 // entry.
628 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
[email protected]f3a1c642011-07-12 19:15:03629 const base::DictionaryValue* sidebar, std::string* error);
[email protected]e2dffe02011-01-20 20:30:06630
[email protected]2f6698b2010-10-14 00:58:21631 // Returns true if the extension has more than one "UI surface". For example,
632 // an extension that has a browser action and a page action.
633 bool HasMultipleUISurfaces() const;
634
[email protected]e2eb43112009-05-29 21:19:54635 // Figures out if a source contains keys not associated with themes - we
636 // don't want to allow scripts and such to be bundled with themes.
[email protected]f3a1c642011-07-12 19:15:03637 bool ContainsNonThemeKeys(const base::DictionaryValue& source) const;
[email protected]e2eb43112009-05-29 21:19:54638
[email protected]311e4cc12011-06-07 01:40:40639 // Only allow the experimental API permission if the command line
640 // flag is present.
[email protected]0d3e4a22011-06-23 19:02:52641 bool IsDisallowedExperimentalPermission(
642 ExtensionAPIPermission::ID permission) const;
[email protected]1952c7d2010-03-04 23:48:34643
[email protected]9d4c2c52011-04-07 18:53:10644 // Returns true if this is a component, or we are not attempting to access a
645 // component-private permission.
[email protected]0d3e4a22011-06-23 19:02:52646 bool IsComponentOnlyPermission(const ExtensionAPIPermission* api) const;
[email protected]a2a098d2010-09-29 19:42:55647
[email protected]d7e9a862010-11-03 21:57:49648 // Cached images for this extension. This should only be touched on the UI
649 // thread.
650 mutable ImageCache image_cache_;
[email protected]1e8c93f2010-02-08 22:58:31651
[email protected]6f229e82010-11-02 17:47:26652 // A persistent, globally unique ID. An extension's ID is used in things
653 // like directory structures and URLs, and is expected to not change across
654 // versions. It is generated as a SHA-256 hash of the extension's public
655 // key, or as a hash of the path in the case of unpacked extensions.
656 std::string id_;
657
658 // The extension's human-readable name. Name is used for display purpose. It
659 // might be wrapped with unicode bidi control characters so that it is
660 // displayed correctly in RTL context.
661 // NOTE: Name is UTF-8 and may contain non-ascii characters.
662 std::string name_;
663
664 // The absolute path to the directory the extension is stored in.
665 FilePath path_;
666
667 // Default locale for fall back. Can be empty if extension is not localized.
668 std::string default_locale_;
669
670 // If true, a separate process will be used for the extension in incognito
671 // mode.
672 bool incognito_split_mode_;
673
674 // Defines the set of URLs in the extension's web content.
[email protected]cced75a2011-05-20 08:31:12675 URLPatternSet extent_;
[email protected]6f229e82010-11-02 17:47:26676
[email protected]0d3e4a22011-06-23 19:02:52677 // The set of permissions that the extension effectively has access to.
678 scoped_ptr<ExtensionPermissionSet> permission_set_;
[email protected]6f229e82010-11-02 17:47:26679
680 // The icons for the extension.
681 ExtensionIconSet icons_;
682
683 // The base extension url for the extension.
684 GURL extension_url_;
685
686 // The location the extension was loaded from.
687 Location location_;
688
689 // The extension's version.
690 scoped_ptr<Version> version_;
691
692 // An optional longer description of the extension.
693 std::string description_;
694
695 // True if the extension was generated from a user script. (We show slightly
696 // different UI if so).
697 bool converted_from_user_script_;
698
699 // Paths to the content scripts the extension contains.
700 UserScriptList content_scripts_;
701
702 // The extension's page action, if any.
703 scoped_ptr<ExtensionAction> page_action_;
704
705 // The extension's browser action, if any.
706 scoped_ptr<ExtensionAction> browser_action_;
707
[email protected]b6b805e92011-04-16 09:24:14708 // The extension's file browser actions, if any.
709 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
710
[email protected]e2dffe02011-01-20 20:30:06711 // The extension's sidebar, if any.
712 scoped_ptr<ExtensionSidebarDefaults> sidebar_defaults_;
713
[email protected]6f229e82010-11-02 17:47:26714 // Optional list of NPAPI plugins and associated properties.
715 std::vector<PluginInfo> plugins_;
716
[email protected]65378f52011-04-08 02:31:23717 // Optional list of NaCl modules and associated properties.
718 std::vector<NaClModuleInfo> nacl_modules_;
719
[email protected]b0820372011-06-03 07:05:27720 // Optional list of input components and associated properties.
721 std::vector<InputComponentInfo> input_components_;
722
[email protected]6f229e82010-11-02 17:47:26723 // Optional URL to a master page of which a single instance should be always
724 // loaded in the background.
725 GURL background_url_;
726
727 // Optional URL to a page for setting options/preferences.
728 GURL options_url_;
729
730 // Optional URL to a devtools extension page.
731 GURL devtools_url_;
732
733 // Optional list of toolstrips and associated properties.
734 std::vector<GURL> toolstrips_;
735
736 // The public key used to sign the contents of the crx package.
737 std::string public_key_;
738
739 // A map of resource id's to relative file paths.
[email protected]f3a1c642011-07-12 19:15:03740 scoped_ptr<base::DictionaryValue> theme_images_;
[email protected]6f229e82010-11-02 17:47:26741
742 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03743 scoped_ptr<base::DictionaryValue> theme_colors_;
[email protected]6f229e82010-11-02 17:47:26744
745 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03746 scoped_ptr<base::DictionaryValue> theme_tints_;
[email protected]6f229e82010-11-02 17:47:26747
748 // A map of display properties.
[email protected]f3a1c642011-07-12 19:15:03749 scoped_ptr<base::DictionaryValue> theme_display_properties_;
[email protected]6f229e82010-11-02 17:47:26750
751 // Whether the extension is a theme.
752 bool is_theme_;
753
[email protected]6f229e82010-11-02 17:47:26754 // The homepage for this extension. Useful if it is not hosted by Google and
755 // therefore does not have a Gallery URL.
756 GURL homepage_url_;
757
758 // URL for fetching an update manifest
759 GURL update_url_;
760
761 // A copy of the manifest that this extension was created from.
[email protected]f3a1c642011-07-12 19:15:03762 scoped_ptr<base::DictionaryValue> manifest_value_;
[email protected]6f229e82010-11-02 17:47:26763
764 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
765 // which override the handling of those URLs. (see ExtensionOverrideUI).
766 URLOverrideMap chrome_url_overrides_;
767
768 // Whether this extension uses app features.
769 bool is_app_;
770
[email protected]d9696672011-03-15 22:45:09771 // Whether this extension requests isolated storage.
772 bool is_storage_isolated_;
773
[email protected]6f229e82010-11-02 17:47:26774 // The local path inside the extension to use with the launcher.
775 std::string launch_local_path_;
776
777 // A web url to use with the launcher. Note that this might be relative or
778 // absolute. If relative, it is relative to web_origin.
779 std::string launch_web_url_;
780
[email protected]4e595682011-02-09 17:07:02781 // The window type that an app's manifest specifies to launch into.
782 // This is not always the window type an app will open into, because
783 // users can override the way each app launches. See
784 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
785 // to decide what container an app will launch in.
[email protected]6f229e82010-11-02 17:47:26786 extension_misc::LaunchContainer launch_container_;
787
788 // The default size of the container when launching. Only respected for
789 // containers like panels and windows.
790 int launch_width_;
791 int launch_height_;
792
793 // The Omnibox keyword for this extension, or empty if there is none.
794 std::string omnibox_keyword_;
795
[email protected]a4a38c12010-12-23 16:43:56796 // List of text-to-speech voices that this extension provides, if any.
797 std::vector<TtsVoice> tts_voices_;
798
[email protected]3aff9ad2011-04-01 20:26:48799 // Whether the extension has host permissions or user script patterns that
800 // imply access to file:/// scheme URLs (the user may not have actually
801 // granted it that access).
802 bool wants_file_access_;
803
[email protected]7f7b9d932011-04-20 16:13:26804 // The Content-Security-Policy for this extension. Extensions can use
805 // Content-Security-Policies to mitigate cross-site scripting and other
806 // vulnerabilities.
807 std::string content_security_policy_;
808
[email protected]eaa7dd182010-12-14 11:09:00809 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]5eb375e92010-11-26 07:50:41810 UpdateExtensionPreservesLocation);
[email protected]19118d52010-07-26 22:13:42811 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
812 FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58813
[email protected]894bb502009-05-21 22:39:57814 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33815};
816
[email protected]9adb9692010-10-29 23:14:02817typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
[email protected]ec5b50d2010-10-09 16:35:18818typedef std::set<std::string> ExtensionIdSet;
[email protected]b1748b1d82009-11-30 20:32:56819
[email protected]c6d474f82009-12-16 21:11:06820// Handy struct to pass core extension info around.
821struct ExtensionInfo {
[email protected]f3a1c642011-07-12 19:15:03822 ExtensionInfo(const base::DictionaryValue* manifest,
[email protected]c6d474f82009-12-16 21:11:06823 const std::string& id,
824 const FilePath& path,
[email protected]3bb84992010-08-26 17:23:46825 Extension::Location location);
826 ~ExtensionInfo();
[email protected]c6d474f82009-12-16 21:11:06827
[email protected]f3a1c642011-07-12 19:15:03828 scoped_ptr<base::DictionaryValue> extension_manifest;
[email protected]c6d474f82009-12-16 21:11:06829 std::string extension_id;
830 FilePath extension_path;
831 Extension::Location extension_location;
832
833 private:
834 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
835};
836
[email protected]211030342010-09-30 18:41:06837// Struct used for the details of the EXTENSION_UNINSTALLED
838// notification.
[email protected]b05fb9ff2011-04-23 00:07:56839//
840// TODO(akalin): Now that sync doesn't need to listen to
841// EXTENSION_UNINSTALLED, everything but |extension_id| can be
842// removed.
[email protected]211030342010-09-30 18:41:06843struct UninstalledExtensionInfo {
844 explicit UninstalledExtensionInfo(const Extension& extension);
[email protected]9b2331d92010-10-04 23:11:19845 ~UninstalledExtensionInfo();
[email protected]211030342010-09-30 18:41:06846
847 std::string extension_id;
848 std::set<std::string> extension_api_permissions;
[email protected]7fa19f82010-12-21 19:40:08849 Extension::Type extension_type;
[email protected]76c25112010-10-01 22:37:21850 GURL update_url;
[email protected]211030342010-09-30 18:41:06851};
852
[email protected]a9f39a312010-12-23 22:14:27853struct UnloadedExtensionInfo {
854 enum Reason {
855 DISABLE, // The extension is being disabled.
856 UPDATE, // The extension is being updated to a newer version.
857 UNINSTALL, // The extension is being uninstalled.
858 };
859
860 Reason reason;
861
862 // Was the extension already disabled?
863 bool already_disabled;
864
865 // The extension being unloaded - this should always be non-NULL.
866 const Extension* extension;
867
868 UnloadedExtensionInfo(const Extension* extension, Reason reason);
869};
870
[email protected]5b1a0e22009-05-26 19:00:58871#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_