blob: 2df033e211f5ad1aaff5209fa849f0e0cb1d2613 [file] [log] [blame]
[email protected]eb75f7b2012-01-04 09:07:281// Copyright (c) 2012 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]7713d632008-12-02 07:52:337
[email protected]8629c542012-04-20 03:40:038#include <algorithm>
[email protected]18049dc2012-06-19 23:12:559#include <iosfwd>
[email protected]300cc58db2009-08-19 20:45:1410#include <map>
[email protected]facd7a7652009-06-05 23:15:0211#include <set>
[email protected]7713d632008-12-02 07:52:3312#include <string>
[email protected]58f62cf2012-03-09 10:45:1113#include <utility>
[email protected]7713d632008-12-02 07:52:3314#include <vector>
15
[email protected]6014d672008-12-05 00:38:2516#include "base/file_path.h"
[email protected]19118d52010-07-26 22:13:4217#include "base/gtest_prod_util.h"
[email protected]8f270be2011-12-21 21:15:2218#include "base/hash_tables.h"
[email protected]b6b805e92011-04-16 09:24:1419#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1520#include "base/memory/ref_counted.h"
21#include "base/memory/scoped_ptr.h"
[email protected]902fd7b2011-07-27 18:42:3122#include "base/synchronization/lock.h"
[email protected]65907942012-05-22 19:59:4723#include "chrome/common/extensions/command.h"
[email protected]3349b592012-04-26 12:35:2824#include "chrome/common/extensions/extension_action.h"
[email protected]d83a5602010-09-16 00:22:4825#include "chrome/common/extensions/extension_constants.h"
[email protected]807871f2010-09-16 01:04:4826#include "chrome/common/extensions/extension_icon_set.h"
[email protected]bebe1d02012-08-02 20:17:0927#include "chrome/common/extensions/permissions/api_permission.h"
[email protected]1d8b79a2012-08-16 20:22:5428#include "chrome/common/extensions/permissions/api_permission_set.h"
[email protected]bebe1d02012-08-02 20:17:0929#include "chrome/common/extensions/permissions/permission_message.h"
[email protected]42b6f0f82009-09-18 21:07:3930#include "chrome/common/extensions/user_script.h"
[email protected]7197f4992009-03-23 05:05:4931#include "chrome/common/extensions/url_pattern.h"
[email protected]cced75a2011-05-20 08:31:1232#include "chrome/common/extensions/url_pattern_set.h"
[email protected]eab9b452009-01-23 20:48:5933#include "googleurl/src/gurl.h"
[email protected]f5532472012-02-23 13:00:5534#include "ui/base/accelerators/accelerator.h"
[email protected]08397d52011-02-05 01:53:3835#include "ui/gfx/size.h"
[email protected]eab9b452009-01-23 20:48:5936
[email protected]942690b132010-05-11 06:42:1437class ExtensionResource;
[email protected]b6b805e92011-04-16 09:24:1438class FileBrowserHandler;
[email protected]12802702010-07-09 19:43:0939class SkBitmap;
[email protected]daf66aa2010-08-06 06:24:2840class Version;
[email protected]942690b132010-05-11 06:42:1441
[email protected]f3a1c642011-07-12 19:15:0342namespace base {
43class DictionaryValue;
44class ListValue;
45}
46
[email protected]f0cc7242011-12-13 04:26:1747namespace webkit_glue {
48struct WebIntentServiceData;
49}
50
[email protected]1c321ee2012-05-21 03:02:3451FORWARD_DECLARE_TEST(TabStripModelTest, Apps);
52
53namespace extensions {
54
55class Manifest;
[email protected]bebe1d02012-08-02 20:17:0956class PermissionSet;
[email protected]1c321ee2012-05-21 03:02:3457
[email protected]d4a37f1c2012-07-09 21:36:1358typedef std::set<std::string> OAuth2Scopes;
59
[email protected]f0755532010-06-22 07:27:2560// Represents a Chrome extension.
[email protected]66e4eb32010-10-27 20:37:4161class Extension : public base::RefCountedThreadSafe<Extension> {
[email protected]7713d632008-12-02 07:52:3362 public:
[email protected]1e0f45a2012-06-13 00:31:0663 struct InstallWarning;
64
[email protected]d3cfa482009-10-17 13:54:5765 typedef std::map<const std::string, GURL> URLOverrideMap;
[email protected]10fb1992010-10-08 09:00:1766 typedef std::vector<std::string> ScriptingWhitelist;
[email protected]b6b805e92011-04-16 09:24:1467 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
[email protected]1e0f45a2012-06-13 00:31:0668 typedef std::vector<InstallWarning> InstallWarningVector;
[email protected]b24d8312009-08-27 06:47:4669
[email protected]631cf822009-05-15 07:01:2570 // What an extension was loaded from.
[email protected]9b217652010-10-08 22:04:2371 // NOTE: These values are stored as integers in the preferences and used
72 // in histograms so don't remove or reorder existing items. Just append
73 // to the end.
[email protected]631cf822009-05-15 07:01:2574 enum Location {
75 INVALID,
[email protected]25b34332009-06-05 21:53:1976 INTERNAL, // A crx file from the internal Extensions directory.
77 EXTERNAL_PREF, // A crx file from an external directory (via prefs).
78 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the
79 // registry on Windows).
[email protected]1952c7d2010-03-04 23:48:3480 LOAD, // --load-extension.
[email protected]8ef78fd2010-08-19 17:14:3281 COMPONENT, // An integral component of Chrome itself, which
82 // happens to be implemented as an extension. We don't
83 // show these in the management UI.
[email protected]4d2913e32010-11-30 00:28:5584 EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via
85 // prefs), installed from an update URL.
86 EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via
87 // admin policies), installed from an update URL.
[email protected]04cb7542010-10-25 10:50:0688
89 NUM_LOCATIONS
[email protected]25b34332009-06-05 21:53:1990 };
91
92 enum State {
[email protected]0c6da502009-08-14 22:32:3993 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1994 ENABLED,
[email protected]79c833b52011-04-05 18:31:0195 // An external extension that the user uninstalled. We should not reinstall
96 // such extensions on startup.
97 EXTERNAL_EXTENSION_UNINSTALLED,
[email protected]0c6da502009-08-14 22:32:3998 NUM_STATES
[email protected]631cf822009-05-15 07:01:2599 };
[email protected]7713d632008-12-02 07:52:33100
[email protected]44d62b62012-04-11 00:06:03101 // Used to record the reason an extension was disabled.
[email protected]eb5e4f92012-08-15 23:33:28102 enum DeprecatedDisableReason {
103 DEPRECATED_DISABLE_UNKNOWN,
104 DEPRECATED_DISABLE_USER_ACTION,
105 DEPRECATED_DISABLE_PERMISSIONS_INCREASE,
106 DEPRECATED_DISABLE_RELOAD,
107 DEPRECATED_DISABLE_LAST, // Not used.
108 };
109
[email protected]44d62b62012-04-11 00:06:03110 enum DisableReason {
[email protected]eb5e4f92012-08-15 23:33:28111 DISABLE_NONE = 0,
112 DISABLE_USER_ACTION = 1 << 0,
113 DISABLE_PERMISSIONS_INCREASE = 1 << 1,
114 DISABLE_RELOAD = 1 << 2,
[email protected]98270432012-09-11 20:51:24115 DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3
[email protected]44d62b62012-04-11 00:06:03116 };
117
[email protected]fbcc40302009-06-12 20:45:45118 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:37119 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:45120 DOWNGRADE,
121 REINSTALL,
122 UPGRADE,
123 NEW_INSTALL
124 };
125
[email protected]7fa19f82010-12-21 19:40:08126 // Do not change the order of entries or remove entries in this list
127 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions.
128 enum Type {
[email protected]9b217652010-10-08 22:04:23129 TYPE_UNKNOWN = 0,
130 TYPE_EXTENSION,
131 TYPE_THEME,
132 TYPE_USER_SCRIPT,
133 TYPE_HOSTED_APP,
[email protected]c4f459d2012-09-28 04:40:10134 // This is marked legacy because platform apps are preferred. For
135 // backwards compatibility, we can't remove support for packaged apps
136 TYPE_LEGACY_PACKAGED_APP,
[email protected]7d3ed2f2011-11-07 23:33:19137 TYPE_PLATFORM_APP
[email protected]9b217652010-10-08 22:04:23138 };
139
[email protected]3bdba0d2011-08-23 07:17:30140 enum SyncType {
141 SYNC_TYPE_NONE = 0,
142 SYNC_TYPE_EXTENSION,
143 SYNC_TYPE_APP
144 };
145
[email protected]98270432012-09-11 20:51:24146 // Declared requirements for the extension.
147 struct Requirements {
148 Requirements();
149 ~Requirements();
150
151 bool webgl;
152 bool css3d;
153 bool npapi;
154 };
155
[email protected]92888082010-10-18 19:24:57156 // An NPAPI plugin included in the extension.
157 struct PluginInfo {
158 FilePath path; // Path to the plugin.
159 bool is_public; // False if only this extension can load this plugin.
160 };
161
[email protected]65378f52011-04-08 02:31:23162 // An NaCl module included in the extension.
163 struct NaClModuleInfo {
[email protected]84396dbc2011-04-14 06:33:42164 GURL url;
[email protected]65378f52011-04-08 02:31:23165 std::string mime_type;
166 };
167
[email protected]b0820372011-06-03 07:05:27168 enum InputComponentType {
[email protected]d45f7512011-06-21 21:18:27169 INPUT_COMPONENT_TYPE_NONE = -1,
170 INPUT_COMPONENT_TYPE_IME,
[email protected]b0820372011-06-03 07:05:27171 INPUT_COMPONENT_TYPE_COUNT
172 };
173
174 struct InputComponentInfo {
175 // Define out of line constructor/destructor to please Clang.
176 InputComponentInfo();
177 ~InputComponentInfo();
178
179 std::string name;
180 InputComponentType type;
181 std::string id;
182 std::string description;
183 std::string language;
184 std::set<std::string> layouts;
185 std::string shortcut_keycode;
186 bool shortcut_alt;
187 bool shortcut_ctrl;
188 bool shortcut_shift;
189 };
190
[email protected]a4a38c12010-12-23 16:43:56191 struct TtsVoice {
[email protected]77a3ecac2011-07-07 05:56:33192 // Define out of line constructor/destructor to please Clang.
193 TtsVoice();
194 ~TtsVoice();
195
[email protected]a4a38c12010-12-23 16:43:56196 std::string voice_name;
[email protected]c63f2b72011-07-07 05:25:00197 std::string lang;
[email protected]a4a38c12010-12-23 16:43:56198 std::string gender;
[email protected]c63f2b72011-07-07 05:25:00199 std::set<std::string> event_types;
[email protected]a4a38c12010-12-23 16:43:56200 };
201
[email protected]a79be1f2012-03-23 22:14:00202 // OAuth2 info included in the extension.
203 struct OAuth2Info {
204 OAuth2Info();
205 ~OAuth2Info();
206
[email protected]c2e66e12012-06-27 06:27:06207 OAuth2Scopes GetScopesAsSet();
[email protected]b6f38622012-04-25 03:20:19208
[email protected]a79be1f2012-03-23 22:14:00209 std::string client_id;
210 std::vector<std::string> scopes;
211 };
212
[email protected]1e0f45a2012-06-13 00:31:06213 struct InstallWarning {
214 enum Format {
215 // IMPORTANT: Do not build HTML strings from user or developer-supplied
216 // input.
217 FORMAT_TEXT,
218 FORMAT_HTML,
219 };
220 InstallWarning(Format format, const std::string& message)
221 : format(format), message(message) {
222 }
[email protected]18049dc2012-06-19 23:12:55223 bool operator==(const InstallWarning& other) const;
[email protected]1e0f45a2012-06-13 00:31:06224 Format format;
225 std::string message;
226 };
227
[email protected]83048a22011-03-29 00:14:13228 enum InitFromValueFlags {
229 NO_FLAGS = 0,
230
231 // Usually, the id of an extension is generated by the "key" property of
232 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
233 // generated based on the path.
234 REQUIRE_KEY = 1 << 0,
235
[email protected]3f53dfe2011-11-30 01:18:29236 // Requires the extension to have an up-to-date manifest version.
237 // Typically, we'll support multiple manifest versions during a version
238 // transition. This flag signals that we want to require the most modern
239 // manifest version that Chrome understands.
240 REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1,
241
[email protected]3aff9ad2011-04-01 20:26:48242 // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension
243 // to have file access. If it's not present, then permissions and content
244 // scripts that match file:/// URLs will be filtered out.
[email protected]ed3b9b12012-05-31 18:37:51245 ALLOW_FILE_ACCESS = 1 << 2,
[email protected]620db1762011-07-15 21:57:34246
247 // |FROM_WEBSTORE| indicates that the extension was installed from the
248 // Chrome Web Store.
[email protected]ed3b9b12012-05-31 18:37:51249 FROM_WEBSTORE = 1 << 3,
[email protected]e805baf2011-07-26 18:23:05250
251 // |FROM_BOOKMARK| indicates the extension was created using a mock App
252 // created from a bookmark.
[email protected]ed3b9b12012-05-31 18:37:51253 FROM_BOOKMARK = 1 << 4,
[email protected]3d41d432012-04-20 20:47:58254
255 // |FOLLOW_SYMLINKS_ANYWHERE| means that resources can be symlinks to
256 // anywhere in the filesystem, rather than being restricted to the
257 // extension directory.
[email protected]ed3b9b12012-05-31 18:37:51258 FOLLOW_SYMLINKS_ANYWHERE = 1 << 5,
[email protected]ab55c2b2012-06-01 23:55:03259
260 // |ERROR_ON_PRIVATE_KEY| means that private keys inside an
261 // extension should be errors rather than warnings.
262 ERROR_ON_PRIVATE_KEY = 1 << 6,
[email protected]e33bbc22012-08-27 22:05:46263
264 // |WAS_INSTALLED_BY_DEFAULT| installed by default when the profile was
265 // created.
266 WAS_INSTALLED_BY_DEFAULT = 1 << 7,
[email protected]83048a22011-03-29 00:14:13267 };
268
[email protected]66e4eb32010-10-27 20:37:41269 static scoped_refptr<Extension> Create(const FilePath& path,
270 Location location,
[email protected]f3a1c642011-07-12 19:15:03271 const base::DictionaryValue& value,
[email protected]83048a22011-03-29 00:14:13272 int flags,
[email protected]66e4eb32010-10-27 20:37:41273 std::string* error);
274
[email protected]87c655e2011-07-01 21:42:00275 // In a few special circumstances, we want to create an Extension and give it
[email protected]f5bf1842012-02-15 02:52:26276 // an explicit id. Most consumers should just use the other Create() method.
277 static scoped_refptr<Extension> Create(const FilePath& path,
[email protected]58f62cf2012-03-09 10:45:11278 Location location,
279 const base::DictionaryValue& value,
280 int flags,
281 const std::string& explicit_id,
282 std::string* error);
[email protected]87c655e2011-07-01 21:42:00283
[email protected]145a317b2011-04-12 16:03:46284 // Given two install sources, return the one which should take priority
285 // over the other. If an extension is installed from two sources A and B,
286 // its install source should be set to GetHigherPriorityLocation(A, B).
287 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
288
[email protected]4c4f8192009-10-17 01:03:26289 // Max size (both dimensions) for browser and page actions.
290 static const int kPageActionIconMaxSize;
291 static const int kBrowserActionIconMaxSize;
292
[email protected]8d888c12010-11-30 00:00:25293 // Valid schemes for web extent URLPatterns.
294 static const int kValidWebExtentSchemes;
295
[email protected]f71f7e62010-12-07 03:45:33296 // Valid schemes for host permission URLPatterns.
297 static const int kValidHostPermissionSchemes;
298
[email protected]6014d672008-12-05 00:38:25299 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16300 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25301
[email protected]300cc58db2009-08-19 20:45:14302 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16303 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14304
305 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16306 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14307
[email protected]25b34332009-06-05 21:53:19308#if defined(OS_WIN)
[email protected]9dcf8f12010-09-02 20:39:19309 static const char kExtensionRegistryPath[];
[email protected]25b34332009-06-05 21:53:19310#endif
311
[email protected]37eeb5a2009-02-26 23:36:17312 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48313 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17314
[email protected]e435d6b72009-07-25 03:15:58315 // The mimetype used for extensions.
316 static const char kMimeType[];
317
[email protected]25b34332009-06-05 21:53:19318 // Checks to see if the extension has a valid ID.
319 static bool IdIsValid(const std::string& id);
320
[email protected]4ead6f72010-10-13 19:54:18321 // Generate an ID for an extension in the given path.
[email protected]28d7479b2011-03-09 21:33:27322 // Used while developing extensions, before they have a key.
[email protected]4ead6f72010-10-13 19:54:18323 static std::string GenerateIdForPath(const FilePath& file_name);
324
[email protected]e435d6b72009-07-25 03:15:58325 // Returns true if the specified file is an extension.
326 static bool IsExtension(const FilePath& file_name);
327
[email protected]25b34332009-06-05 21:53:19328 // Whether the |location| is external or not.
329 static inline bool IsExternalLocation(Location location) {
330 return location == Extension::EXTERNAL_PREF ||
[email protected]8ef78fd2010-08-19 17:14:32331 location == Extension::EXTERNAL_REGISTRY ||
[email protected]04cb7542010-10-25 10:50:06332 location == Extension::EXTERNAL_PREF_DOWNLOAD ||
333 location == Extension::EXTERNAL_POLICY_DOWNLOAD;
334 }
335
336 // Whether extensions with |location| are auto-updatable or not.
337 static inline bool IsAutoUpdateableLocation(Location location) {
338 // Only internal and external extensions can be autoupdated.
339 return location == Extension::INTERNAL ||
340 IsExternalLocation(location);
[email protected]25b34332009-06-05 21:53:19341 }
342
[email protected]65187152012-06-02 13:14:14343 // Policy-required extensions are silently auto-installed and updated, and
344 // cannot be disabled or modified by the user in any way. The same applies
345 // to internal components.
346 // This method is not generally called directly; instead, it is accessed
347 // through the ManagementPolicy held by the ExtensionSystem.
348 static inline bool IsRequired(Location location) {
349 return location == Extension::EXTERNAL_POLICY_DOWNLOAD ||
350 location == Extension::COMPONENT;
[email protected]95da88c42011-03-31 10:07:33351 }
352
[email protected]cdfca9702011-08-08 16:07:01353 // Unpacked extensions start off with file access since they are a developer
354 // feature.
355 static inline bool ShouldAlwaysAllowFileAccess(Location location) {
356 return location == Extension::LOAD;
357 }
358
[email protected]fc6b0612012-03-29 13:40:06359 // Fills the |info| dictionary with basic information about the extension.
360 // |enabled| is injected for easier testing.
361 void GetBasicInfo(bool enabled, base::DictionaryValue* info) const;
362
[email protected]7fa19f82010-12-21 19:40:08363 // See Type definition above.
364 Type GetType() const;
[email protected]9b217652010-10-08 22:04:23365
[email protected]07c00d992009-03-04 20:27:04366 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59367 // |extension_url| argument should be the url() from an Extension object. The
368 // |relative_path| can be untrusted user input. The returned URL will either
369 // be invalid() or a child of |extension_url|.
370 // NOTE: Static so that it can be used from multiple threads.
371 static GURL GetResourceURL(const GURL& extension_url,
372 const std::string& relative_path);
[email protected]cffd7892010-08-26 17:43:28373 GURL GetResourceURL(const std::string& relative_path) const {
[email protected]3cfbd0e2009-03-18 21:26:24374 return GetResourceURL(url(), relative_path);
375 }
[email protected]eab9b452009-01-23 20:48:59376
[email protected]f59a8052012-06-20 22:25:00377 // Returns true if the resource matches a pattern in the pattern_set.
378 bool ResourceMatches(const URLPatternSet& pattern_set,
379 const std::string& resource) const;
380
[email protected]8f270be2011-12-21 21:15:22381 // Returns true if the specified resource is web accessible.
382 bool IsResourceWebAccessible(const std::string& relative_path) const;
383
[email protected]dbb24162012-06-06 01:41:22384 // Returns true if the specified page is sandboxed (served in a unique
385 // origin).
386 bool IsSandboxedPage(const std::string& relative_path) const;
387
388 // Returns the Content Security Policy that the specified resource should be
389 // served with.
390 std::string GetResourceContentSecurityPolicy(const std::string& relative_path)
391 const;
392
[email protected]8f270be2011-12-21 21:15:22393 // Returns true when 'web_accessible_resources' are defined for the extension.
394 bool HasWebAccessibleResources() const;
395
[email protected]99efb7b12009-12-18 02:39:16396 // Returns an extension resource object. |relative_path| should be UTF8
397 // encoded.
[email protected]9adb9692010-10-29 23:14:02398 ExtensionResource GetResource(const std::string& relative_path) const;
[email protected]99efb7b12009-12-18 02:39:16399
400 // As above, but with |relative_path| following the file system's encoding.
[email protected]9adb9692010-10-29 23:14:02401 ExtensionResource GetResource(const FilePath& relative_path) const;
[email protected]eab9b452009-01-23 20:48:59402
[email protected]a17f9462009-06-09 02:56:41403 // |input| is expected to be the text of an rsa public or private key. It
404 // tolerates the presence or absence of bracking header/footer like this:
405 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
406 // and may contain newlines.
407 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
408
409 // Does a simple base64 encoding of |input| into |output|.
410 static bool ProducePEM(const std::string& input, std::string* output);
411
[email protected]84ac7f32009-10-06 06:17:54412 // Generates an extension ID from arbitrary input. The same input string will
413 // always generate the same output ID.
[email protected]af9db5f2011-10-05 05:13:15414 static bool GenerateId(const std::string& input,
415 std::string* output) WARN_UNUSED_RESULT;
[email protected]fbcc40302009-06-12 20:45:45416
[email protected]a17f9462009-06-09 02:56:41417 // Expects base64 encoded |input| and formats into |output| including
418 // the appropriate header & footer.
[email protected]e0d08192011-03-29 19:02:50419 static bool FormatPEMForFileOutput(const std::string& input,
420 std::string* output,
421 bool is_public);
[email protected]a17f9462009-06-09 02:56:41422
[email protected]58f62cf2012-03-09 10:45:11423 // Given an extension, icon size, and match type, read a valid icon if present
[email protected]e3c0bc22012-02-24 01:34:15424 // and decode it into result. In the browser process, this will DCHECK if not
425 // called on the file thread. To easily load extension images on the UI
426 // thread, see ImageLoadingTracker.
427 static void DecodeIcon(const Extension* extension,
[email protected]faf87192012-08-17 00:07:59428 int icon_size,
[email protected]e3c0bc22012-02-24 01:34:15429 ExtensionIconSet::MatchType match_type,
430 scoped_ptr<SkBitmap>* result);
431
[email protected]c690a9812009-12-17 05:55:32432 // Given an extension and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23433 // result. In the browser process, this will DCHECK if not called on the
434 // file thread. To easily load extension images on the UI thread, see
435 // ImageLoadingTracker.
[email protected]9adb9692010-10-29 23:14:02436 static void DecodeIcon(const Extension* extension,
[email protected]faf87192012-08-17 00:07:59437 int icon_size,
[email protected]c690a9812009-12-17 05:55:32438 scoped_ptr<SkBitmap>* result);
439
440 // Given an icon_path and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23441 // result. In the browser process, this will DCHECK if not called on the
442 // file thread. To easily load extension images on the UI thread, see
443 // ImageLoadingTracker.
[email protected]c690a9812009-12-17 05:55:32444 static void DecodeIconFromPath(const FilePath& icon_path,
[email protected]faf87192012-08-17 00:07:59445 int icon_size,
[email protected]c690a9812009-12-17 05:55:32446 scoped_ptr<SkBitmap>* result);
447
[email protected]5349ac6d2011-04-05 22:20:17448 // Returns the default extension/app icon (for extensions or apps that don't
449 // have one).
[email protected]dd46a4ce2012-09-15 10:50:50450 static const gfx::ImageSkia& GetDefaultIcon(bool is_app);
[email protected]5349ac6d2011-04-05 22:20:17451
[email protected]a807bbe2010-04-14 10:51:19452 // Returns the base extension url for a given |extension_id|.
453 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
454
[email protected]be7e5cb2010-10-04 12:53:17455 // Adds an extension to the scripting whitelist. Used for testing only.
[email protected]10fb1992010-10-08 09:00:17456 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
[email protected]2a521c52011-01-26 18:45:21457 static const ScriptingWhitelist* GetScriptingWhitelist();
[email protected]be7e5cb2010-10-04 12:53:17458
[email protected]902fd7b2011-07-27 18:42:31459 // Parses the host and api permissions from the specified permission |key|
[email protected]d41e2152012-02-24 04:20:27460 // from |manifest_|.
461 bool ParsePermissions(const char* key,
[email protected]fc670822011-12-17 09:33:49462 string16* error,
[email protected]c2e66e12012-06-27 06:27:06463 APIPermissionSet* api_permissions,
[email protected]902fd7b2011-07-27 18:42:31464 URLPatternSet* host_permissions);
465
[email protected]c2e66e12012-06-27 06:27:06466 bool HasAPIPermission(APIPermission::ID permission) const;
[email protected]0d3e4a22011-06-23 19:02:52467 bool HasAPIPermission(const std::string& function_name) const;
[email protected]3d0e2262012-08-02 15:32:16468 bool HasAPIPermissionForTab(int tab_id, APIPermission::ID permission) const;
[email protected]583d45c12010-08-31 02:48:12469
[email protected]ecb9ad12012-08-21 13:02:15470 bool CheckAPIPermissionWithParam(APIPermission::ID permission,
471 const APIPermission::CheckParam* param) const;
[email protected]1d8b79a2012-08-16 20:22:54472
[email protected]0d3e4a22011-06-23 19:02:52473 const URLPatternSet& GetEffectiveHostPermissions() const;
[email protected]b24d8312009-08-27 06:47:46474
[email protected]902fd7b2011-07-27 18:42:31475 // Returns true if the extension can silently increase its permission level.
[email protected]0d904312012-01-25 23:00:16476 // Users must approve permissions for unpacked and packed extensions in the
477 // following situations:
478 // - when installing or upgrading packed extensions
479 // - when installing unpacked extensions that have NPAPI plugins
480 // - when either type of extension requests optional permissions
[email protected]902fd7b2011-07-27 18:42:31481 bool CanSilentlyIncreasePermissions() const;
482
[email protected]584b8e3f2010-04-10 00:23:37483 // Whether the extension has access to the given URL.
484 bool HasHostPermission(const GURL& url) const;
485
[email protected]0df165f2010-09-28 16:49:40486 // Whether the extension has effective access to all hosts. This is true if
487 // there is a content script that matches all hosts, if there is a host
488 // permission grants access to all hosts (like <all_urls>) or an api
489 // permission that effectively grants access to all hosts (e.g. proxy,
490 // network, etc.)
491 bool HasEffectiveAccessToAllHosts() const;
[email protected]b24d8312009-08-27 06:47:46492
[email protected]8d888c12010-11-30 00:00:25493 // Whether the extension effectively has all permissions (for example, by
494 // having an NPAPI plugin).
495 bool HasFullPermissions() const;
496
[email protected]902fd7b2011-07-27 18:42:31497 // Returns the full list of permission messages that this extension
498 // should display at install time.
[email protected]c2e66e12012-06-27 06:27:06499 PermissionMessages GetPermissionMessages() const;
[email protected]902fd7b2011-07-27 18:42:31500
501 // Returns the full list of permission messages that this extension
502 // should display at install time. The messages are returned as strings
503 // for convenience.
504 std::vector<string16> GetPermissionMessageStrings() const;
505
506 // Sets the active |permissions|.
[email protected]c2e66e12012-06-27 06:27:06507 void SetActivePermissions(const PermissionSet* permissions) const;
[email protected]902fd7b2011-07-27 18:42:31508
509 // Gets the extension's active permission set.
[email protected]c2e66e12012-06-27 06:27:06510 scoped_refptr<const PermissionSet> GetActivePermissions() const;
[email protected]902fd7b2011-07-27 18:42:31511
[email protected]5df6a5d2011-01-26 07:39:12512 // Whether context menu should be shown for page and browser actions.
513 bool ShowConfigureContextMenus() const;
514
[email protected]37cd64d2010-10-25 18:17:58515 // Returns the Homepage URL for this extension. If homepage_url was not
516 // specified in the manifest, this returns the Google Gallery URL. For
[email protected]bfa90a3a2010-04-28 15:43:23517 // third-party extensions, this returns a blank GURL.
[email protected]37cd64d2010-10-25 18:17:58518 GURL GetHomepageURL() const;
[email protected]bfa90a3a2010-04-28 15:43:23519
[email protected]facd7a7652009-06-05 23:15:02520 // Returns a list of paths (relative to the extension dir) for images that
521 // the browser might load (like themes and page action icons).
[email protected]9adb9692010-10-29 23:14:02522 std::set<FilePath> GetBrowserImages() const;
[email protected]facd7a7652009-06-05 23:15:02523
[email protected]807871f2010-09-16 01:04:48524 // Get an extension icon as a resource or URL.
[email protected]9adb9692010-10-29 23:14:02525 ExtensionResource GetIconResource(
526 int size, ExtensionIconSet::MatchType match_type) const;
527 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
[email protected]f34e79632010-03-17 02:34:08528
[email protected]867a73e12010-03-19 20:45:46529 // Gets the fully resolved absolute launch URL.
530 GURL GetFullLaunchURL() const;
[email protected]2a521c52011-01-26 18:45:21531
[email protected]6f229e82010-11-02 17:47:26532 // Image cache related methods. These are only valid on the UI thread and
533 // not maintained by this class. See ImageLoadingTracker for usage. The
534 // |original_size| parameter should be the size of the image at |source|
535 // before any scaling may have been done to produce the pixels in |image|.
536 void SetCachedImage(const ExtensionResource& source,
537 const SkBitmap& image,
538 const gfx::Size& original_size) const;
539 bool HasCachedImage(const ExtensionResource& source,
540 const gfx::Size& max_size) const;
541 SkBitmap GetCachedImage(const ExtensionResource& source,
542 const gfx::Size& max_size) const;
[email protected]2a521c52011-01-26 18:45:21543
544 // Returns true if this extension can execute script on a page. If a
545 // UserScript object is passed, permission to run that specific script is
546 // checked (using its matches list). Otherwise, permission to execute script
547 // programmatically is checked (using the extension's host permission).
548 //
549 // This method is also aware of certain special pages that extensions are
550 // usually not allowed to run script on.
[email protected]78bdfd662012-08-23 05:53:18551 bool CanExecuteScriptOnPage(const GURL& document_url,
552 const GURL& top_document_url,
[email protected]fc5e65d6b2012-06-13 00:22:57553 int tab_id,
[email protected]3aff9ad2011-04-01 20:26:48554 const UserScript* script,
[email protected]2a521c52011-01-26 18:45:21555 std::string* error) const;
556
[email protected]6f229e82010-11-02 17:47:26557 // Returns true if this extension is a COMPONENT extension, or if it is
558 // on the whitelist of extensions that can script all pages.
559 bool CanExecuteScriptEverywhere() const;
560
[email protected]5efbfe012011-02-22 23:07:18561 // Returns true if this extension is allowed to obtain the contents of a
562 // page as an image. Since a page may contain sensitive information, this
563 // is restricted to the extension's host permissions as well as the
564 // extension page itself.
[email protected]fc5e65d6b2012-06-13 00:22:57565 bool CanCaptureVisiblePage(const GURL& page_url,
566 int tab_id,
567 std::string* error) const;
[email protected]5efbfe012011-02-22 23:07:18568
[email protected]a65882c2010-11-12 15:15:09569 // Returns true if this extension updates itself using the extension
570 // gallery.
571 bool UpdatesFromGallery() const;
572
[email protected]cca147172011-02-17 01:29:29573 // Returns true if this extension or app includes areas within |origin|.
574 bool OverlapsWithOrigin(const GURL& origin) const;
575
[email protected]3bdba0d2011-08-23 07:17:30576 // Returns the sync bucket to use for this extension.
577 SyncType GetSyncType() const;
578
[email protected]b873cd92012-02-09 21:51:48579 // Returns true if the extension should be synced.
580 bool IsSyncable() const;
581
582 // Returns true if the extension should be displayed in the launcher.
583 bool ShouldDisplayInLauncher() const;
584
[email protected]e0b3de72012-05-01 01:21:34585 // Returns true if the extension should be displayed in the extension
586 // settings page (i.e. chrome://extensions).
587 bool ShouldDisplayInExtensionSettings() const;
588
[email protected]4f886012012-05-19 03:51:10589 // Returns true if the extension has a content script declared at |url|.
590 bool HasContentScriptAtURL(const GURL& url) const;
591
[email protected]fc5e65d6b2012-06-13 00:22:57592 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
593 // aren't any.
[email protected]3d0e2262012-08-02 15:32:16594 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
595 const;
[email protected]fc5e65d6b2012-06-13 00:22:57596
[email protected]3d0e2262012-08-02 15:32:16597 // Updates the tab-specific permissions of |tab_id| to include those from
598 // |permissions|.
[email protected]6144057e2012-08-02 19:02:37599 void UpdateTabSpecificPermissions(
600 int tab_id,
601 scoped_refptr<const PermissionSet> permissions) const;
[email protected]fc5e65d6b2012-06-13 00:22:57602
[email protected]3d0e2262012-08-02 15:32:16603 // Clears the tab-specific permissions of |tab_id|.
604 void ClearTabSpecificPermissions(int tab_id) const;
[email protected]fc5e65d6b2012-06-13 00:22:57605
[email protected]6f229e82010-11-02 17:47:26606 // Accessors:
607
[email protected]98270432012-09-11 20:51:24608 const Requirements& requirements() const { return requirements_; }
[email protected]6f229e82010-11-02 17:47:26609 const FilePath& path() const { return path_; }
610 const GURL& url() const { return extension_url_; }
[email protected]d41e2152012-02-24 04:20:27611 Location location() const;
612 const std::string& id() const;
[email protected]6f229e82010-11-02 17:47:26613 const Version* version() const { return version_.get(); }
614 const std::string VersionString() const;
615 const std::string& name() const { return name_; }
[email protected]701d1e82012-05-14 05:34:19616 const std::string& non_localized_name() const { return non_localized_name_; }
[email protected]200423d2012-06-05 01:16:06617 // Base64-encoded version of the key used to sign this extension.
618 // In pseudocode, returns
619 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()).
620 const std::string& public_key() const { return public_key_; }
[email protected]6f229e82010-11-02 17:47:26621 const std::string& description() const { return description_; }
[email protected]a47c8a22011-11-17 18:40:31622 int manifest_version() const { return manifest_version_; }
[email protected]6f229e82010-11-02 17:47:26623 bool converted_from_user_script() const {
624 return converted_from_user_script_;
625 }
626 const UserScriptList& content_scripts() const { return content_scripts_; }
[email protected]18049dc2012-06-19 23:12:55627 ExtensionAction* script_badge() const { return script_badge_.get(); }
[email protected]6f229e82010-11-02 17:47:26628 ExtensionAction* page_action() const { return page_action_.get(); }
629 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]5d414702012-08-28 13:03:09630 bool is_verbose_install_message() const {
631 return !omnibox_keyword().empty() ||
632 browser_action() ||
633 (page_action() &&
[email protected]684cc6a2012-09-18 05:53:45634 (page_action_command() || page_action()->default_icon()));
[email protected]5d414702012-08-28 13:03:09635 }
[email protected]b6b805e92011-04-16 09:24:14636 const FileBrowserHandlerList* file_browser_handlers() const {
637 return file_browser_handlers_.get();
638 }
[email protected]6f229e82010-11-02 17:47:26639 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]65378f52011-04-08 02:31:23640 const std::vector<NaClModuleInfo>& nacl_modules() const {
641 return nacl_modules_;
642 }
[email protected]b0820372011-06-03 07:05:27643 const std::vector<InputComponentInfo>& input_components() const {
644 return input_components_;
645 }
[email protected]7c519ab2012-05-04 10:02:51646 // The browser action command that the extension wants to use, which is not
647 // necessarily the one it can use, as it might be inactive (see also
[email protected]d179cdd2012-08-03 08:32:52648 // GetBrowserActionCommand in CommandService).
[email protected]3fc5f6a2012-05-04 14:23:59649 const extensions::Command* browser_action_command() const {
[email protected]9c8b54d2012-04-02 10:17:30650 return browser_action_command_.get();
651 }
[email protected]7c519ab2012-05-04 10:02:51652 // The page action command that the extension wants to use, which is not
653 // necessarily the one it can use, as it might be inactive (see also
[email protected]d179cdd2012-08-03 08:32:52654 // GetPageActionCommand in CommandService).
[email protected]3fc5f6a2012-05-04 14:23:59655 const extensions::Command* page_action_command() const {
[email protected]9c8b54d2012-04-02 10:17:30656 return page_action_command_.get();
657 }
[email protected]d179cdd2012-08-03 08:32:52658 // The script badge command that the extension wants to use, which is not
659 // necessarily the one it can use, as it might be inactive (see also
660 // GetScriptBadgeCommand in CommandService).
661 const extensions::Command* script_badge_command() const {
662 return script_badge_command_.get();
663 }
[email protected]7c519ab2012-05-04 10:02:51664 // The map (of command names to commands) that the extension wants to use,
[email protected]422656932012-05-03 09:31:51665 // which is not necessarily the one it can use, as they might be inactive
[email protected]d179cdd2012-08-03 08:32:52666 // (see also GetNamedCommands in CommandService).
[email protected]3fc5f6a2012-05-04 14:23:59667 const extensions::CommandMap& named_commands() const {
[email protected]9c8b54d2012-04-02 10:17:30668 return named_commands_;
[email protected]f5532472012-02-23 13:00:55669 }
[email protected]a03d4448f2012-01-10 23:25:28670 bool has_background_page() const {
671 return background_url_.is_valid() || !background_scripts_.empty();
672 }
[email protected]7b54ca02012-03-02 18:06:53673 bool allow_background_js_access() const {
674 return allow_background_js_access_;
675 }
[email protected]a03d4448f2012-01-10 23:25:28676 const std::vector<std::string>& background_scripts() const {
677 return background_scripts_;
678 }
[email protected]d2aa06b2012-03-21 20:57:26679 bool has_persistent_background_page() const {
[email protected]dd62fa802012-04-25 18:37:00680 return has_background_page() && background_page_is_persistent_;
[email protected]d2aa06b2012-03-21 20:57:26681 }
682 bool has_lazy_background_page() const {
[email protected]dd62fa802012-04-25 18:37:00683 return has_background_page() && !background_page_is_persistent_;
[email protected]d2aa06b2012-03-21 20:57:26684 }
[email protected]6f229e82010-11-02 17:47:26685 const GURL& options_url() const { return options_url_; }
686 const GURL& devtools_url() const { return devtools_url_; }
[email protected]81ca71652012-08-23 22:28:26687 const GURL& details_url() const { return details_url_;}
[email protected]c2e66e12012-06-27 06:27:06688 const PermissionSet* optional_permission_set() const {
[email protected]902fd7b2011-07-27 18:42:31689 return optional_permission_set_.get();
690 }
[email protected]c2e66e12012-06-27 06:27:06691 const PermissionSet* required_permission_set() const {
[email protected]902fd7b2011-07-27 18:42:31692 return required_permission_set_.get();
[email protected]6f229e82010-11-02 17:47:26693 }
[email protected]ab55c2b2012-06-01 23:55:03694 // Appends |new_warnings| to install_warnings().
[email protected]1e0f45a2012-06-13 00:31:06695 void AddInstallWarnings(const InstallWarningVector& new_warnings);
696 const InstallWarningVector& install_warnings() const {
[email protected]8629c542012-04-20 03:40:03697 return install_warnings_;
698 }
[email protected]6f229e82010-11-02 17:47:26699 const GURL& update_url() const { return update_url_; }
700 const ExtensionIconSet& icons() const { return icons_; }
[email protected]953620b2011-12-04 00:55:32701 const extensions::Manifest* manifest() const {
[email protected]e9629d772012-08-06 19:44:46702 return manifest_.get();
[email protected]6f229e82010-11-02 17:47:26703 }
704 const std::string default_locale() const { return default_locale_; }
705 const URLOverrideMap& GetChromeURLOverrides() const {
706 return chrome_url_overrides_;
707 }
708 const std::string omnibox_keyword() const { return omnibox_keyword_; }
709 bool incognito_split_mode() const { return incognito_split_mode_; }
[email protected]1abdf4f2011-08-16 21:11:55710 bool offline_enabled() const { return offline_enabled_; }
[email protected]a4a38c12010-12-23 16:43:56711 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
[email protected]a79be1f2012-03-23 22:14:00712 const OAuth2Info& oauth2_info() const { return oauth2_info_; }
[email protected]56624422011-11-01 22:11:27713 const std::vector<webkit_glue::WebIntentServiceData>&
714 intents_services() const {
715 return intents_services_;
716 }
[email protected]6f229e82010-11-02 17:47:26717
[email protected]3aff9ad2011-04-01 20:26:48718 bool wants_file_access() const { return wants_file_access_; }
[email protected]2af352b2011-07-22 08:21:23719 int creation_flags() const { return creation_flags_; }
720 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
[email protected]e805baf2011-07-26 18:23:05721 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; }
[email protected]e33bbc22012-08-27 22:05:46722 bool was_installed_by_default() const {
723 return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0;
724 }
[email protected]3aff9ad2011-04-01 20:26:48725
[email protected]6f229e82010-11-02 17:47:26726 // App-related.
[email protected]953620b2011-12-04 00:55:32727 bool is_app() const {
[email protected]c4f459d2012-09-28 04:40:10728 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app();
[email protected]23690872011-12-01 22:02:39729 }
[email protected]d41e2152012-02-24 04:20:27730 bool is_platform_app() const;
731 bool is_hosted_app() const;
[email protected]c4f459d2012-09-28 04:40:10732 bool is_legacy_packaged_app() const;
[email protected]605fb8102012-05-04 01:36:55733 bool is_storage_isolated() const { return is_storage_isolated_; }
[email protected]cced75a2011-05-20 08:31:12734 const URLPatternSet& web_extent() const { return extent_; }
[email protected]6f229e82010-11-02 17:47:26735 const std::string& launch_local_path() const { return launch_local_path_; }
736 const std::string& launch_web_url() const { return launch_web_url_; }
737 extension_misc::LaunchContainer launch_container() const {
738 return launch_container_;
739 }
[email protected]dc37b002012-04-23 23:02:26740 int launch_width() const { return launch_width_; }
741 int launch_height() const { return launch_height_; }
[email protected]6f229e82010-11-02 17:47:26742
743 // Theme-related.
[email protected]d41e2152012-02-24 04:20:27744 bool is_theme() const;
[email protected]f3a1c642011-07-12 19:15:03745 base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
746 base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); }
747 base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
748 base::DictionaryValue* GetThemeDisplayProperties() const {
[email protected]6f229e82010-11-02 17:47:26749 return theme_display_properties_.get();
750 }
751
[email protected]a03d4448f2012-01-10 23:25:28752 GURL GetBackgroundURL() const;
753
[email protected]4a8d3272009-03-10 19:15:08754 private:
[email protected]66e4eb32010-10-27 20:37:41755 friend class base::RefCountedThreadSafe<Extension>;
756
[email protected]d7e9a862010-11-03 21:57:49757 // We keep a cache of images loaded from extension resources based on their
758 // path and a string representation of a size that may have been used to
759 // scale it (or the empty string if the image is at its original size).
760 typedef std::pair<FilePath, std::string> ImageCacheKey;
761 typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
762
[email protected]902fd7b2011-07-27 18:42:31763 class RuntimeData {
764 public:
765 RuntimeData();
[email protected]c2e66e12012-06-27 06:27:06766 explicit RuntimeData(const PermissionSet* active);
[email protected]902fd7b2011-07-27 18:42:31767 ~RuntimeData();
768
[email protected]c2e66e12012-06-27 06:27:06769 void SetActivePermissions(const PermissionSet* active);
770 scoped_refptr<const PermissionSet> GetActivePermissions() const;
[email protected]902fd7b2011-07-27 18:42:31771
[email protected]3d0e2262012-08-02 15:32:16772 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
773 const;
[email protected]6144057e2012-08-02 19:02:37774 void UpdateTabSpecificPermissions(
775 int tab_id,
776 scoped_refptr<const PermissionSet> permissions);
[email protected]3d0e2262012-08-02 15:32:16777 void ClearTabSpecificPermissions(int tab_id);
[email protected]fc5e65d6b2012-06-13 00:22:57778
[email protected]902fd7b2011-07-27 18:42:31779 private:
780 friend class base::RefCountedThreadSafe<RuntimeData>;
[email protected]fc5e65d6b2012-06-13 00:22:57781
[email protected]c2e66e12012-06-27 06:27:06782 scoped_refptr<const PermissionSet> active_permissions_;
[email protected]fc5e65d6b2012-06-13 00:22:57783
[email protected]3d0e2262012-08-02 15:32:16784 typedef std::map<int, scoped_refptr<const PermissionSet> >
785 TabPermissionsMap;
786 TabPermissionsMap tab_specific_permissions_;
[email protected]902fd7b2011-07-27 18:42:31787 };
788
[email protected]d41e2152012-02-24 04:20:27789 // Chooses the extension ID for an extension based on a variety of criteria.
790 // The chosen ID will be set in |manifest|.
791 static bool InitExtensionID(extensions::Manifest* manifest,
792 const FilePath& path,
793 const std::string& explicit_id,
794 int creation_flags,
795 string16* error);
796
[email protected]4ead6f72010-10-13 19:54:18797 // Normalize the path for use by the extension. On Windows, this will make
798 // sure the drive letter is uppercase.
799 static FilePath MaybeNormalizePath(const FilePath& path);
800
[email protected]87c655e2011-07-01 21:42:00801 // Returns true if this extension id is from a trusted provider.
802 static bool IsTrustedId(const std::string& id);
803
[email protected]d41e2152012-02-24 04:20:27804 Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest);
[email protected]66e4eb32010-10-27 20:37:41805 ~Extension();
806
807 // Initialize the extension from a parsed manifest.
[email protected]d41e2152012-02-24 04:20:27808 // TODO(aa): Rename to just Init()? There's no Value here anymore.
809 // TODO(aa): It is really weird the way this class essentially contains a copy
810 // of the underlying DictionaryValue in its members. We should decide to
811 // either wrap the DictionaryValue and go with that only, or we should parse
812 // into strong types and discard the value. But doing both is bad.
813 bool InitFromValue(int flags, string16* error);
[email protected]66e4eb32010-10-27 20:37:41814
[email protected]58f62cf2012-03-09 10:45:11815 // The following are helpers for InitFromValue to load various features of the
816 // extension from the manifest.
817
[email protected]c2e66e12012-06-27 06:27:06818 bool LoadAppIsolation(const APIPermissionSet& api_permissions,
[email protected]605fb8102012-05-04 01:36:55819 string16* error);
[email protected]58f62cf2012-03-09 10:45:11820
821 bool LoadRequiredFeatures(string16* error);
822 bool LoadName(string16* error);
823 bool LoadVersion(string16* error);
824
825 bool LoadAppFeatures(string16* error);
[email protected]d41e2152012-02-24 04:20:27826 bool LoadExtent(const char* key,
827 URLPatternSet* extent,
828 const char* list_error,
829 const char* value_error,
830 string16* error);
831 bool LoadLaunchContainer(string16* error);
832 bool LoadLaunchURL(string16* error);
[email protected]10253da2012-03-09 04:06:42833
[email protected]c2e66e12012-06-27 06:27:06834 bool LoadSharedFeatures(const APIPermissionSet& api_permissions,
[email protected]58f62cf2012-03-09 10:45:11835 string16* error);
836 bool LoadDescription(string16* error);
837 bool LoadManifestVersion(string16* error);
838 bool LoadHomepageURL(string16* error);
839 bool LoadUpdateURL(string16* error);
840 bool LoadIcons(string16* error);
841 bool LoadCommands(string16* error);
842 bool LoadPlugins(string16* error);
843 bool LoadNaClModules(string16* error);
844 bool LoadWebAccessibleResources(string16* error);
[email protected]dbb24162012-06-06 01:41:22845 bool LoadSandboxedPages(string16* error);
[email protected]98270432012-09-11 20:51:24846 // Must be called after LoadPlugins().
847 bool LoadRequirements(string16* error);
[email protected]58f62cf2012-03-09 10:45:11848 bool LoadDefaultLocale(string16* error);
849 bool LoadOfflineEnabled(string16* error);
850 bool LoadOptionsPage(string16* error);
[email protected]d41e2152012-02-24 04:20:27851 bool LoadBackgroundScripts(string16* error);
[email protected]756038532012-06-08 05:45:03852 bool LoadBackgroundScripts(const std::string& key, string16* error);
[email protected]c2e66e12012-06-27 06:27:06853 bool LoadBackgroundPage(const APIPermissionSet& api_permissions,
[email protected]d41e2152012-02-24 04:20:27854 string16* error);
[email protected]756038532012-06-08 05:45:03855 bool LoadBackgroundPage(const std::string& key,
[email protected]c2e66e12012-06-27 06:27:06856 const APIPermissionSet& api_permissions,
[email protected]756038532012-06-08 05:45:03857 string16* error);
[email protected]dd62fa802012-04-25 18:37:00858 bool LoadBackgroundPersistent(
[email protected]c2e66e12012-06-27 06:27:06859 const APIPermissionSet& api_permissions,
[email protected]d41e2152012-02-24 04:20:27860 string16* error);
[email protected]58f62cf2012-03-09 10:45:11861 bool LoadBackgroundAllowJSAccess(
[email protected]c2e66e12012-06-27 06:27:06862 const APIPermissionSet& api_permissions,
[email protected]7b54ca02012-03-02 18:06:53863 string16* error);
[email protected]58f62cf2012-03-09 10:45:11864 // Parses a single action in the manifest.
865 bool LoadWebIntentAction(const std::string& action_name,
866 const base::DictionaryValue& intent_service,
867 string16* error);
868 bool LoadWebIntentServices(string16* error);
[email protected]c2e66e12012-06-27 06:27:06869 bool LoadExtensionFeatures(const APIPermissionSet& api_permissions,
[email protected]58f62cf2012-03-09 10:45:11870 string16* error);
871 bool LoadDevToolsPage(string16* error);
[email protected]c2e66e12012-06-27 06:27:06872 bool LoadInputComponents(const APIPermissionSet& api_permissions,
[email protected]58f62cf2012-03-09 10:45:11873 string16* error);
874 bool LoadContentScripts(string16* error);
875 bool LoadPageAction(string16* error);
876 bool LoadBrowserAction(string16* error);
[email protected]18049dc2012-06-19 23:12:55877 bool LoadScriptBadge(string16* error);
[email protected]58f62cf2012-03-09 10:45:11878 bool LoadFileBrowserHandlers(string16* error);
879 // Helper method to load a FileBrowserHandlerList from the manifest.
880 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
881 const base::ListValue* extension_actions, string16* error);
882 // Helper method to load an FileBrowserHandler from manifest.
883 FileBrowserHandler* LoadFileBrowserHandler(
884 const base::DictionaryValue* file_browser_handlers, string16* error);
885 bool LoadChromeURLOverrides(string16* error);
886 bool LoadOmnibox(string16* error);
887 bool LoadTextToSpeechVoices(string16* error);
888 bool LoadIncognitoMode(string16* error);
889 bool LoadContentSecurityPolicy(string16* error);
890
891 bool LoadThemeFeatures(string16* error);
892 bool LoadThemeImages(const base::DictionaryValue* theme_value,
893 string16* error);
894 bool LoadThemeColors(const base::DictionaryValue* theme_value,
895 string16* error);
896 bool LoadThemeTints(const base::DictionaryValue* theme_value,
897 string16* error);
898 bool LoadThemeDisplayProperties(const base::DictionaryValue* theme_value,
899 string16* error);
900
901 // Helper function for implementing HasCachedImage/GetCachedImage. A return
902 // value of NULL means there is no matching image cached (we allow caching an
903 // empty SkBitmap).
904 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
905 const gfx::Size& max_size) const;
[email protected]d9ad80f2010-03-30 20:40:18906
[email protected]3cfbd0e2009-03-18 21:26:24907 // Helper method that loads a UserScript object from a
908 // dictionary in the content_script list of the manifest.
[email protected]f3a1c642011-07-12 19:15:03909 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
[email protected]3cfbd0e2009-03-18 21:26:24910 int definition_index,
[email protected]fc670822011-12-17 09:33:49911 string16* error,
[email protected]3cfbd0e2009-03-18 21:26:24912 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34913
[email protected]6657afa62009-11-04 02:15:20914 // Helper method that loads either the include_globs or exclude_globs list
915 // from an entry in the content_script lists of the manifest.
[email protected]f3a1c642011-07-12 19:15:03916 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
[email protected]6657afa62009-11-04 02:15:20917 int content_script_index,
[email protected]e2194742010-08-12 05:54:34918 const char* globs_property_name,
[email protected]fc670822011-12-17 09:33:49919 string16* error,
[email protected]11f4857282009-11-13 19:56:17920 void(UserScript::*add_method)(const std::string& glob),
[email protected]488e6502012-09-07 14:17:34921 UserScript* instance);
[email protected]6657afa62009-11-04 02:15:20922
[email protected]5d246db22009-10-27 06:17:57923 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08924 // browser_action entries in the manifest.
[email protected]3349b592012-04-26 12:35:28925 scoped_ptr<ExtensionAction> LoadExtensionActionHelper(
[email protected]18049dc2012-06-19 23:12:55926 const base::DictionaryValue* extension_action,
927 ExtensionAction::Type action_type,
928 string16* error);
[email protected]92c6f9b92009-10-24 04:35:08929
[email protected]a79be1f2012-03-23 22:14:00930 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key.
931 bool LoadOAuth2Info(string16* error);
932
[email protected]2f6698b2010-10-14 00:58:21933 // Returns true if the extension has more than one "UI surface". For example,
934 // an extension that has a browser action and a page action.
935 bool HasMultipleUISurfaces() const;
936
[email protected]be9d9c82011-07-13 04:17:31937 // Updates the launch URL and extents for the extension using the given
938 // |override_url|.
939 void OverrideLaunchUrl(const GURL& override_url);
940
[email protected]ae655e4e2012-03-16 21:47:55941 // Custom checks for the experimental permission that can't be expressed in
942 // _permission_features.json.
[email protected]5eddc3e2011-10-26 04:33:31943 bool CanSpecifyExperimentalPermission() const;
[email protected]5eddc3e2011-10-26 04:33:31944
945 // Checks whether the host |pattern| is allowed for this extension, given API
946 // permissions |permissions|.
947 bool CanSpecifyHostPermission(const URLPattern& pattern,
[email protected]c2e66e12012-06-27 06:27:06948 const APIPermissionSet& permissions) const;
[email protected]5eddc3e2011-10-26 04:33:31949
[email protected]488e6502012-09-07 14:17:34950 bool CheckMinimumChromeVersion(string16* error) const;
[email protected]488e6502012-09-07 14:17:34951
[email protected]e92169e2012-05-04 22:49:32952 // Check that platform app features are valid. Called after InitFromValue.
[email protected]488e6502012-09-07 14:17:34953 bool CheckPlatformAppFeatures(std::string* utf8_error) const;
[email protected]e92169e2012-05-04 22:49:32954
[email protected]f1bab9c92012-05-11 21:15:10955 // Check that features don't conflict. Called after InitFromValue.
[email protected]488e6502012-09-07 14:17:34956 bool CheckConflictingFeatures(std::string* utf8_error) const;
[email protected]f1bab9c92012-05-11 21:15:10957
[email protected]d7e9a862010-11-03 21:57:49958 // Cached images for this extension. This should only be touched on the UI
959 // thread.
960 mutable ImageCache image_cache_;
[email protected]1e8c93f2010-02-08 22:58:31961
[email protected]6f229e82010-11-02 17:47:26962 // The extension's human-readable name. Name is used for display purpose. It
963 // might be wrapped with unicode bidi control characters so that it is
964 // displayed correctly in RTL context.
965 // NOTE: Name is UTF-8 and may contain non-ascii characters.
966 std::string name_;
967
[email protected]701d1e82012-05-14 05:34:19968 // A non-localized version of the extension's name. This is useful for
969 // debug output.
970 std::string non_localized_name_;
971
[email protected]a47c8a22011-11-17 18:40:31972 // The version of this extension's manifest. We increase the manifest
973 // version when making breaking changes to the extension system.
974 // Version 1 was the first manifest version (implied by a lack of a
975 // manifest_version attribute in the extension's manifest). We initialize
976 // this member variable to 0 to distinguish the "uninitialized" case from
977 // the case when we know the manifest version actually is 1.
978 int manifest_version_;
979
[email protected]98270432012-09-11 20:51:24980 // The requirements declared in the manifest.
981 Requirements requirements_;
982
[email protected]d41e2152012-02-24 04:20:27983 // The absolute path to the directory the extension is stored in.
984 FilePath path_;
985
[email protected]6f229e82010-11-02 17:47:26986 // Default locale for fall back. Can be empty if extension is not localized.
987 std::string default_locale_;
988
989 // If true, a separate process will be used for the extension in incognito
990 // mode.
991 bool incognito_split_mode_;
992
[email protected]1abdf4f2011-08-16 21:11:55993 // Whether the extension or app should be enabled when offline.
994 bool offline_enabled_;
995
[email protected]6f229e82010-11-02 17:47:26996 // Defines the set of URLs in the extension's web content.
[email protected]cced75a2011-05-20 08:31:12997 URLPatternSet extent_;
[email protected]6f229e82010-11-02 17:47:26998
[email protected]902fd7b2011-07-27 18:42:31999 // The extension runtime data.
1000 mutable base::Lock runtime_data_lock_;
1001 mutable RuntimeData runtime_data_;
1002
1003 // The set of permissions the extension can request at runtime.
[email protected]c2e66e12012-06-27 06:27:061004 scoped_refptr<const PermissionSet> optional_permission_set_;
[email protected]902fd7b2011-07-27 18:42:311005
1006 // The extension's required / default set of permissions.
[email protected]c2e66e12012-06-27 06:27:061007 scoped_refptr<const PermissionSet> required_permission_set_;
[email protected]6f229e82010-11-02 17:47:261008
[email protected]8629c542012-04-20 03:40:031009 // Any warnings that occurred when trying to create/parse the extension.
[email protected]1e0f45a2012-06-13 00:31:061010 InstallWarningVector install_warnings_;
[email protected]8629c542012-04-20 03:40:031011
[email protected]6f229e82010-11-02 17:47:261012 // The icons for the extension.
1013 ExtensionIconSet icons_;
1014
1015 // The base extension url for the extension.
1016 GURL extension_url_;
1017
[email protected]6f229e82010-11-02 17:47:261018 // The extension's version.
1019 scoped_ptr<Version> version_;
1020
1021 // An optional longer description of the extension.
1022 std::string description_;
1023
1024 // True if the extension was generated from a user script. (We show slightly
1025 // different UI if so).
1026 bool converted_from_user_script_;
1027
1028 // Paths to the content scripts the extension contains.
1029 UserScriptList content_scripts_;
1030
1031 // The extension's page action, if any.
1032 scoped_ptr<ExtensionAction> page_action_;
1033
1034 // The extension's browser action, if any.
1035 scoped_ptr<ExtensionAction> browser_action_;
1036
[email protected]18049dc2012-06-19 23:12:551037 // The extension's script badge. Never NULL.
1038 scoped_ptr<ExtensionAction> script_badge_;
[email protected]0f156a62012-05-28 16:36:361039
[email protected]b6b805e92011-04-16 09:24:141040 // The extension's file browser actions, if any.
1041 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
1042
[email protected]6f229e82010-11-02 17:47:261043 // Optional list of NPAPI plugins and associated properties.
1044 std::vector<PluginInfo> plugins_;
1045
[email protected]65378f52011-04-08 02:31:231046 // Optional list of NaCl modules and associated properties.
1047 std::vector<NaClModuleInfo> nacl_modules_;
1048
[email protected]b0820372011-06-03 07:05:271049 // Optional list of input components and associated properties.
1050 std::vector<InputComponentInfo> input_components_;
1051
[email protected]f5532472012-02-23 13:00:551052 // Optional list of commands (keyboard shortcuts).
[email protected]3fc5f6a2012-05-04 14:23:591053 scoped_ptr<extensions::Command> browser_action_command_;
1054 scoped_ptr<extensions::Command> page_action_command_;
[email protected]d179cdd2012-08-03 08:32:521055 scoped_ptr<extensions::Command> script_badge_command_;
[email protected]3fc5f6a2012-05-04 14:23:591056 extensions::CommandMap named_commands_;
[email protected]f5532472012-02-23 13:00:551057
[email protected]8f270be2011-12-21 21:15:221058 // Optional list of web accessible extension resources.
[email protected]f59a8052012-06-20 22:25:001059 URLPatternSet web_accessible_resources_;
[email protected]8f270be2011-12-21 21:15:221060
[email protected]dbb24162012-06-06 01:41:221061 // Optional list of extension pages that are sandboxed (served from a unique
1062 // origin with a different Content Security Policy).
[email protected]f59a8052012-06-20 22:25:001063 URLPatternSet sandboxed_pages_;
[email protected]dbb24162012-06-06 01:41:221064
1065 // Content Security Policy that should be used to enforce the sandbox used
1066 // by sandboxed pages (guaranteed to have the "sandbox" directive without the
1067 // "allow-same-origin" token).
1068 std::string sandboxed_pages_content_security_policy_;
1069
[email protected]6f229e82010-11-02 17:47:261070 // Optional URL to a master page of which a single instance should be always
1071 // loaded in the background.
1072 GURL background_url_;
1073
[email protected]a03d4448f2012-01-10 23:25:281074 // Optional list of scripts to use to generate a background page. If this is
1075 // present, background_url_ will be empty and generated by GetBackgroundURL().
1076 std::vector<std::string> background_scripts_;
1077
[email protected]dd62fa802012-04-25 18:37:001078 // True if the background page should stay loaded forever; false if it should
1079 // load on-demand (when it needs to handle an event). Defaults to true.
1080 bool background_page_is_persistent_;
[email protected]9e6720a2012-01-24 02:30:561081
[email protected]7b54ca02012-03-02 18:06:531082 // True if the background page can be scripted by pages of the app or
1083 // extension, in which case all such pages must run in the same process.
1084 // False if such pages are not permitted to script the background page,
1085 // allowing them to run in different processes.
1086 bool allow_background_js_access_;
1087
[email protected]6f229e82010-11-02 17:47:261088 // Optional URL to a page for setting options/preferences.
1089 GURL options_url_;
1090
1091 // Optional URL to a devtools extension page.
1092 GURL devtools_url_;
1093
[email protected]81ca71652012-08-23 22:28:261094 // URL to the webstore page of the extension.
1095 GURL details_url_;
1096
[email protected]6f229e82010-11-02 17:47:261097 // The public key used to sign the contents of the crx package.
1098 std::string public_key_;
1099
1100 // A map of resource id's to relative file paths.
[email protected]f3a1c642011-07-12 19:15:031101 scoped_ptr<base::DictionaryValue> theme_images_;
[email protected]6f229e82010-11-02 17:47:261102
1103 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:031104 scoped_ptr<base::DictionaryValue> theme_colors_;
[email protected]6f229e82010-11-02 17:47:261105
1106 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:031107 scoped_ptr<base::DictionaryValue> theme_tints_;
[email protected]6f229e82010-11-02 17:47:261108
1109 // A map of display properties.
[email protected]f3a1c642011-07-12 19:15:031110 scoped_ptr<base::DictionaryValue> theme_display_properties_;
[email protected]6f229e82010-11-02 17:47:261111
[email protected]6f229e82010-11-02 17:47:261112 // The homepage for this extension. Useful if it is not hosted by Google and
1113 // therefore does not have a Gallery URL.
1114 GURL homepage_url_;
1115
1116 // URL for fetching an update manifest
1117 GURL update_url_;
1118
[email protected]58f62cf2012-03-09 10:45:111119 // The manifest from which this extension was created.
[email protected]e9629d772012-08-06 19:44:461120 scoped_ptr<Manifest> manifest_;
[email protected]6f229e82010-11-02 17:47:261121
1122 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
1123 // which override the handling of those URLs. (see ExtensionOverrideUI).
1124 URLOverrideMap chrome_url_overrides_;
1125
[email protected]d9696672011-03-15 22:45:091126 // Whether this extension requests isolated storage.
1127 bool is_storage_isolated_;
1128
[email protected]6f229e82010-11-02 17:47:261129 // The local path inside the extension to use with the launcher.
1130 std::string launch_local_path_;
1131
1132 // A web url to use with the launcher. Note that this might be relative or
1133 // absolute. If relative, it is relative to web_origin.
1134 std::string launch_web_url_;
1135
[email protected]4e595682011-02-09 17:07:021136 // The window type that an app's manifest specifies to launch into.
1137 // This is not always the window type an app will open into, because
1138 // users can override the way each app launches. See
1139 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
1140 // to decide what container an app will launch in.
[email protected]6f229e82010-11-02 17:47:261141 extension_misc::LaunchContainer launch_container_;
1142
1143 // The default size of the container when launching. Only respected for
1144 // containers like panels and windows.
1145 int launch_width_;
1146 int launch_height_;
1147
[email protected]ed1a204f2012-09-22 00:28:441148 // Should this app be shown in a launcher.
1149 bool display_in_launcher_;
1150
[email protected]6f229e82010-11-02 17:47:261151 // The Omnibox keyword for this extension, or empty if there is none.
1152 std::string omnibox_keyword_;
1153
[email protected]a4a38c12010-12-23 16:43:561154 // List of text-to-speech voices that this extension provides, if any.
1155 std::vector<TtsVoice> tts_voices_;
1156
[email protected]a79be1f2012-03-23 22:14:001157 // The OAuth2 client id and scopes, if specified by the extension.
1158 OAuth2Info oauth2_info_;
1159
[email protected]56624422011-11-01 22:11:271160 // List of intent services that this extension provides, if any.
1161 std::vector<webkit_glue::WebIntentServiceData> intents_services_;
[email protected]be5f007862011-09-23 00:35:131162
[email protected]3aff9ad2011-04-01 20:26:481163 // Whether the extension has host permissions or user script patterns that
1164 // imply access to file:/// scheme URLs (the user may not have actually
1165 // granted it that access).
1166 bool wants_file_access_;
1167
[email protected]2af352b2011-07-22 08:21:231168 // The flags that were passed to InitFromValue.
1169 int creation_flags_;
[email protected]620db1762011-07-15 21:57:341170
[email protected]7f7b9d932011-04-20 16:13:261171 // The Content-Security-Policy for this extension. Extensions can use
1172 // Content-Security-Policies to mitigate cross-site scripting and other
1173 // vulnerabilities.
1174 std::string content_security_policy_;
1175
[email protected]19118d52010-07-26 22:13:421176 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
[email protected]1c321ee2012-05-21 03:02:341177 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:581178
[email protected]894bb502009-05-21 22:39:571179 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:331180};
1181
[email protected]9adb9692010-10-29 23:14:021182typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
[email protected]ec5b50d2010-10-09 16:35:181183typedef std::set<std::string> ExtensionIdSet;
[email protected]82590cb2012-09-28 04:14:081184typedef std::vector<std::string> ExtensionIdList;
[email protected]b1748b1d82009-11-30 20:32:561185
[email protected]18049dc2012-06-19 23:12:551186// Let gtest print InstallWarnings.
1187void PrintTo(const Extension::InstallWarning&, ::std::ostream* os);
1188
[email protected]c6d474f82009-12-16 21:11:061189// Handy struct to pass core extension info around.
1190struct ExtensionInfo {
[email protected]f3a1c642011-07-12 19:15:031191 ExtensionInfo(const base::DictionaryValue* manifest,
[email protected]c6d474f82009-12-16 21:11:061192 const std::string& id,
1193 const FilePath& path,
[email protected]3bb84992010-08-26 17:23:461194 Extension::Location location);
1195 ~ExtensionInfo();
[email protected]c6d474f82009-12-16 21:11:061196
[email protected]f3a1c642011-07-12 19:15:031197 scoped_ptr<base::DictionaryValue> extension_manifest;
[email protected]c6d474f82009-12-16 21:11:061198 std::string extension_id;
1199 FilePath extension_path;
1200 Extension::Location extension_location;
1201
1202 private:
1203 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
1204};
1205
[email protected]a9f39a312010-12-23 22:14:271206struct UnloadedExtensionInfo {
[email protected]814a7bf0f2011-08-13 05:30:591207 extension_misc::UnloadedExtensionReason reason;
[email protected]a9f39a312010-12-23 22:14:271208
1209 // Was the extension already disabled?
1210 bool already_disabled;
1211
1212 // The extension being unloaded - this should always be non-NULL.
1213 const Extension* extension;
1214
[email protected]814a7bf0f2011-08-13 05:30:591215 UnloadedExtensionInfo(
1216 const Extension* extension,
1217 extension_misc::UnloadedExtensionReason reason);
[email protected]a9f39a312010-12-23 22:14:271218};
1219
[email protected]902fd7b2011-07-27 18:42:311220// The details sent for EXTENSION_PERMISSIONS_UPDATED notifications.
1221struct UpdatedExtensionPermissionsInfo {
1222 enum Reason {
[email protected]f5532472012-02-23 13:00:551223 ADDED, // The permissions were added to the extension.
1224 REMOVED, // The permissions were removed from the extension.
[email protected]902fd7b2011-07-27 18:42:311225 };
1226
1227 Reason reason;
1228
1229 // The extension who's permissions have changed.
1230 const Extension* extension;
1231
1232 // The permissions that have changed. For Reason::ADDED, this would contain
1233 // only the permissions that have added, and for Reason::REMOVED, this would
1234 // only contain the removed permissions.
[email protected]c2e66e12012-06-27 06:27:061235 const PermissionSet* permissions;
[email protected]902fd7b2011-07-27 18:42:311236
1237 UpdatedExtensionPermissionsInfo(
1238 const Extension* extension,
[email protected]c2e66e12012-06-27 06:27:061239 const PermissionSet* permissions,
[email protected]902fd7b2011-07-27 18:42:311240 Reason reason);
1241};
1242
[email protected]488e6502012-09-07 14:17:341243} // namespace extensions
[email protected]1c321ee2012-05-21 03:02:341244
[email protected]5b1a0e22009-05-26 19:00:581245#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_