blob: b85c7cd03bf396e44c324d3a9f56b00a84ee2738 [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]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]8f270be2011-12-21 21:15:2216#include "base/hash_tables.h"
[email protected]b6b805e92011-04-16 09:24:1417#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1518#include "base/memory/ref_counted.h"
19#include "base/memory/scoped_ptr.h"
[email protected]902fd7b2011-07-27 18:42:3120#include "base/synchronization/lock.h"
[email protected]d83a5602010-09-16 00:22:4821#include "chrome/common/extensions/extension_constants.h"
[email protected]807871f2010-09-16 01:04:4822#include "chrome/common/extensions/extension_icon_set.h"
[email protected]0d3e4a22011-06-23 19:02:5223#include "chrome/common/extensions/extension_permission_set.h"
[email protected]953620b2011-12-04 00:55:3224#include "chrome/common/extensions/manifest.h"
[email protected]42b6f0f82009-09-18 21:07:3925#include "chrome/common/extensions/user_script.h"
[email protected]7197f4992009-03-23 05:05:4926#include "chrome/common/extensions/url_pattern.h"
[email protected]cced75a2011-05-20 08:31:1227#include "chrome/common/extensions/url_pattern_set.h"
[email protected]eab9b452009-01-23 20:48:5928#include "googleurl/src/gurl.h"
[email protected]08397d52011-02-05 01:53:3829#include "ui/gfx/size.h"
[email protected]eab9b452009-01-23 20:48:5930
[email protected]942690b132010-05-11 06:42:1431class ExtensionAction;
32class ExtensionResource;
[email protected]b6b805e92011-04-16 09:24:1433class FileBrowserHandler;
[email protected]12802702010-07-09 19:43:0934class SkBitmap;
[email protected]daf66aa2010-08-06 06:24:2835class Version;
[email protected]942690b132010-05-11 06:42:1436
[email protected]f3a1c642011-07-12 19:15:0337namespace base {
38class DictionaryValue;
39class ListValue;
40}
41
[email protected]f0cc7242011-12-13 04:26:1742namespace webkit_glue {
43struct WebIntentServiceData;
44}
45
[email protected]f0755532010-06-22 07:27:2546// Represents a Chrome extension.
[email protected]66e4eb32010-10-27 20:37:4147class Extension : public base::RefCountedThreadSafe<Extension> {
[email protected]7713d632008-12-02 07:52:3348 public:
[email protected]d3cfa482009-10-17 13:54:5749 typedef std::map<const std::string, GURL> URLOverrideMap;
[email protected]10fb1992010-10-08 09:00:1750 typedef std::vector<std::string> ScriptingWhitelist;
[email protected]b6b805e92011-04-16 09:24:1451 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
[email protected]b24d8312009-08-27 06:47:4652
[email protected]631cf822009-05-15 07:01:2553 // What an extension was loaded from.
[email protected]9b217652010-10-08 22:04:2354 // NOTE: These values are stored as integers in the preferences and used
55 // in histograms so don't remove or reorder existing items. Just append
56 // to the end.
[email protected]631cf822009-05-15 07:01:2557 enum Location {
58 INVALID,
[email protected]25b34332009-06-05 21:53:1959 INTERNAL, // A crx file from the internal Extensions directory.
60 EXTERNAL_PREF, // A crx file from an external directory (via prefs).
61 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the
62 // registry on Windows).
[email protected]1952c7d2010-03-04 23:48:3463 LOAD, // --load-extension.
[email protected]8ef78fd2010-08-19 17:14:3264 COMPONENT, // An integral component of Chrome itself, which
65 // happens to be implemented as an extension. We don't
66 // show these in the management UI.
[email protected]4d2913e32010-11-30 00:28:5567 EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via
68 // prefs), installed from an update URL.
69 EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via
70 // admin policies), installed from an update URL.
[email protected]04cb7542010-10-25 10:50:0671
72 NUM_LOCATIONS
[email protected]25b34332009-06-05 21:53:1973 };
74
75 enum State {
[email protected]0c6da502009-08-14 22:32:3976 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1977 ENABLED,
[email protected]79c833b52011-04-05 18:31:0178 // An external extension that the user uninstalled. We should not reinstall
79 // such extensions on startup.
80 EXTERNAL_EXTENSION_UNINSTALLED,
[email protected]0c6da502009-08-14 22:32:3981 NUM_STATES
[email protected]631cf822009-05-15 07:01:2582 };
[email protected]7713d632008-12-02 07:52:3383
[email protected]fbcc40302009-06-12 20:45:4584 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:3785 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:4586 DOWNGRADE,
87 REINSTALL,
88 UPGRADE,
89 NEW_INSTALL
90 };
91
[email protected]d2817012009-08-04 06:46:2192 // NOTE: If you change this list, you should also change kIconSizes in the cc
93 // file.
94 enum Icons {
95 EXTENSION_ICON_LARGE = 128,
96 EXTENSION_ICON_MEDIUM = 48,
97 EXTENSION_ICON_SMALL = 32,
[email protected]39382942010-03-23 15:57:0998 EXTENSION_ICON_SMALLISH = 24,
[email protected]d2817012009-08-04 06:46:2199 EXTENSION_ICON_BITTY = 16,
100 };
101
[email protected]7fa19f82010-12-21 19:40:08102 // Do not change the order of entries or remove entries in this list
103 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions.
104 enum Type {
[email protected]9b217652010-10-08 22:04:23105 TYPE_UNKNOWN = 0,
106 TYPE_EXTENSION,
107 TYPE_THEME,
108 TYPE_USER_SCRIPT,
109 TYPE_HOSTED_APP,
[email protected]7d3ed2f2011-11-07 23:33:19110 TYPE_PACKAGED_APP,
111 TYPE_PLATFORM_APP
[email protected]9b217652010-10-08 22:04:23112 };
113
[email protected]3bdba0d2011-08-23 07:17:30114 enum SyncType {
115 SYNC_TYPE_NONE = 0,
116 SYNC_TYPE_EXTENSION,
117 SYNC_TYPE_APP
118 };
119
[email protected]92888082010-10-18 19:24:57120 // An NPAPI plugin included in the extension.
121 struct PluginInfo {
122 FilePath path; // Path to the plugin.
123 bool is_public; // False if only this extension can load this plugin.
124 };
125
[email protected]65378f52011-04-08 02:31:23126 // An NaCl module included in the extension.
127 struct NaClModuleInfo {
[email protected]84396dbc2011-04-14 06:33:42128 GURL url;
[email protected]65378f52011-04-08 02:31:23129 std::string mime_type;
130 };
131
[email protected]b0820372011-06-03 07:05:27132 enum InputComponentType {
[email protected]d45f7512011-06-21 21:18:27133 INPUT_COMPONENT_TYPE_NONE = -1,
134 INPUT_COMPONENT_TYPE_IME,
[email protected]b0820372011-06-03 07:05:27135 INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD,
136 INPUT_COMPONENT_TYPE_COUNT
137 };
138
139 struct InputComponentInfo {
140 // Define out of line constructor/destructor to please Clang.
141 InputComponentInfo();
142 ~InputComponentInfo();
143
144 std::string name;
145 InputComponentType type;
146 std::string id;
147 std::string description;
148 std::string language;
149 std::set<std::string> layouts;
150 std::string shortcut_keycode;
151 bool shortcut_alt;
152 bool shortcut_ctrl;
153 bool shortcut_shift;
154 };
155
[email protected]a4a38c12010-12-23 16:43:56156 struct TtsVoice {
[email protected]77a3ecac2011-07-07 05:56:33157 // Define out of line constructor/destructor to please Clang.
158 TtsVoice();
159 ~TtsVoice();
160
[email protected]a4a38c12010-12-23 16:43:56161 std::string voice_name;
[email protected]c63f2b72011-07-07 05:25:00162 std::string lang;
[email protected]a4a38c12010-12-23 16:43:56163 std::string gender;
[email protected]c63f2b72011-07-07 05:25:00164 std::set<std::string> event_types;
[email protected]a4a38c12010-12-23 16:43:56165 };
166
[email protected]83048a22011-03-29 00:14:13167 enum InitFromValueFlags {
168 NO_FLAGS = 0,
169
170 // Usually, the id of an extension is generated by the "key" property of
171 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
172 // generated based on the path.
173 REQUIRE_KEY = 1 << 0,
174
[email protected]3f53dfe2011-11-30 01:18:29175 // Requires the extension to have an up-to-date manifest version.
176 // Typically, we'll support multiple manifest versions during a version
177 // transition. This flag signals that we want to require the most modern
178 // manifest version that Chrome understands.
179 REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1,
180
[email protected]83048a22011-03-29 00:14:13181 // |STRICT_ERROR_CHECKS| enables extra error checking, such as
182 // checks that URL patterns do not contain ports. This error
183 // checking may find an error that a previous version of
184 // Chrome did not flag. To avoid errors in installed extensions
185 // when Chrome is upgraded, strict error checking is only enabled
186 // when loading extensions as a developer would (such as loading
187 // an unpacked extension), or when loading an extension that is
188 // tied to a specific version of Chrome (such as a component
189 // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when
190 // Extension::ShouldDoStrictErrorChecking(location) returns true.
[email protected]3f53dfe2011-11-30 01:18:29191 STRICT_ERROR_CHECKS = 1 << 2,
[email protected]3aff9ad2011-04-01 20:26:48192
193 // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension
194 // to have file access. If it's not present, then permissions and content
195 // scripts that match file:/// URLs will be filtered out.
[email protected]3f53dfe2011-11-30 01:18:29196 ALLOW_FILE_ACCESS = 1 << 3,
[email protected]620db1762011-07-15 21:57:34197
198 // |FROM_WEBSTORE| indicates that the extension was installed from the
199 // Chrome Web Store.
[email protected]3f53dfe2011-11-30 01:18:29200 FROM_WEBSTORE = 1 << 4,
[email protected]e805baf2011-07-26 18:23:05201
202 // |FROM_BOOKMARK| indicates the extension was created using a mock App
203 // created from a bookmark.
[email protected]3f53dfe2011-11-30 01:18:29204 FROM_BOOKMARK = 1 << 5,
[email protected]83048a22011-03-29 00:14:13205 };
206
[email protected]66e4eb32010-10-27 20:37:41207 static scoped_refptr<Extension> Create(const FilePath& path,
208 Location location,
[email protected]f3a1c642011-07-12 19:15:03209 const base::DictionaryValue& value,
[email protected]83048a22011-03-29 00:14:13210 int flags,
[email protected]66e4eb32010-10-27 20:37:41211 std::string* error);
212
[email protected]87c655e2011-07-01 21:42:00213 // In a few special circumstances, we want to create an Extension and give it
[email protected]f5bf1842012-02-15 02:52:26214 // an explicit id. Most consumers should just use the other Create() method.
215 static scoped_refptr<Extension> Create(const FilePath& path,
216 Location location,
217 const base::DictionaryValue& value,
218 int flags,
219 const std::string& explicit_id,
220 std::string* error);
[email protected]87c655e2011-07-01 21:42:00221
[email protected]145a317b2011-04-12 16:03:46222 // Given two install sources, return the one which should take priority
223 // over the other. If an extension is installed from two sources A and B,
224 // its install source should be set to GetHigherPriorityLocation(A, B).
225 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
226
[email protected]c3e3def742009-07-17 07:51:06227 // Icon sizes used by the extension system.
[email protected]d2817012009-08-04 06:46:21228 static const int kIconSizes[];
[email protected]c3e3def742009-07-17 07:51:06229
[email protected]4c4f8192009-10-17 01:03:26230 // Max size (both dimensions) for browser and page actions.
231 static const int kPageActionIconMaxSize;
232 static const int kBrowserActionIconMaxSize;
233
[email protected]8d888c12010-11-30 00:00:25234 // Valid schemes for web extent URLPatterns.
235 static const int kValidWebExtentSchemes;
236
[email protected]f71f7e62010-12-07 03:45:33237 // Valid schemes for host permission URLPatterns.
238 static const int kValidHostPermissionSchemes;
239
[email protected]6014d672008-12-05 00:38:25240 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16241 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25242
[email protected]300cc58db2009-08-19 20:45:14243 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16244 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14245
246 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16247 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14248
[email protected]25b34332009-06-05 21:53:19249#if defined(OS_WIN)
[email protected]9dcf8f12010-09-02 20:39:19250 static const char kExtensionRegistryPath[];
[email protected]25b34332009-06-05 21:53:19251#endif
252
[email protected]37eeb5a2009-02-26 23:36:17253 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48254 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17255
[email protected]e435d6b72009-07-25 03:15:58256 // The mimetype used for extensions.
257 static const char kMimeType[];
258
[email protected]25b34332009-06-05 21:53:19259 // Checks to see if the extension has a valid ID.
260 static bool IdIsValid(const std::string& id);
261
[email protected]4ead6f72010-10-13 19:54:18262 // Generate an ID for an extension in the given path.
[email protected]28d7479b2011-03-09 21:33:27263 // Used while developing extensions, before they have a key.
[email protected]4ead6f72010-10-13 19:54:18264 static std::string GenerateIdForPath(const FilePath& file_name);
265
[email protected]e435d6b72009-07-25 03:15:58266 // Returns true if the specified file is an extension.
267 static bool IsExtension(const FilePath& file_name);
268
[email protected]25b34332009-06-05 21:53:19269 // Whether the |location| is external or not.
270 static inline bool IsExternalLocation(Location location) {
271 return location == Extension::EXTERNAL_PREF ||
[email protected]8ef78fd2010-08-19 17:14:32272 location == Extension::EXTERNAL_REGISTRY ||
[email protected]04cb7542010-10-25 10:50:06273 location == Extension::EXTERNAL_PREF_DOWNLOAD ||
274 location == Extension::EXTERNAL_POLICY_DOWNLOAD;
275 }
276
277 // Whether extensions with |location| are auto-updatable or not.
278 static inline bool IsAutoUpdateableLocation(Location location) {
279 // Only internal and external extensions can be autoupdated.
280 return location == Extension::INTERNAL ||
281 IsExternalLocation(location);
[email protected]25b34332009-06-05 21:53:19282 }
283
[email protected]95da88c42011-03-31 10:07:33284 // Whether extensions with |location| can be uninstalled or not. Policy
285 // controlled extensions are silently auto-installed and updated, and cannot
286 // be disabled by the user. The same applies for internal components.
287 static inline bool UserMayDisable(Location location) {
288 return location != Extension::EXTERNAL_POLICY_DOWNLOAD &&
289 location != Extension::COMPONENT;
290 }
291
[email protected]542258c2011-03-04 21:25:31292 // Whether extensions with |location| should be loaded with strict
293 // error checking. Strict error checks may flag errors older versions
294 // of chrome did not detect. To avoid breaking installed extensions,
295 // strict checks are disabled unless the location indicates that the
296 // developer is loading the extension, or the extension is a component
297 // of chrome.
298 static inline bool ShouldDoStrictErrorChecking(Location location) {
299 return location == Extension::LOAD ||
300 location == Extension::COMPONENT;
301 }
302
[email protected]cdfca9702011-08-08 16:07:01303 // Unpacked extensions start off with file access since they are a developer
304 // feature.
305 static inline bool ShouldAlwaysAllowFileAccess(Location location) {
306 return location == Extension::LOAD;
307 }
308
[email protected]7fa19f82010-12-21 19:40:08309 // See Type definition above.
310 Type GetType() const;
[email protected]9b217652010-10-08 22:04:23311
[email protected]07c00d992009-03-04 20:27:04312 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59313 // |extension_url| argument should be the url() from an Extension object. The
314 // |relative_path| can be untrusted user input. The returned URL will either
315 // be invalid() or a child of |extension_url|.
316 // NOTE: Static so that it can be used from multiple threads.
317 static GURL GetResourceURL(const GURL& extension_url,
318 const std::string& relative_path);
[email protected]cffd7892010-08-26 17:43:28319 GURL GetResourceURL(const std::string& relative_path) const {
[email protected]3cfbd0e2009-03-18 21:26:24320 return GetResourceURL(url(), relative_path);
321 }
[email protected]eab9b452009-01-23 20:48:59322
[email protected]8f270be2011-12-21 21:15:22323 // Returns true if the specified resource is web accessible.
324 bool IsResourceWebAccessible(const std::string& relative_path) const;
325
326 // Returns true when 'web_accessible_resources' are defined for the extension.
327 bool HasWebAccessibleResources() const;
328
[email protected]99efb7b12009-12-18 02:39:16329 // Returns an extension resource object. |relative_path| should be UTF8
330 // encoded.
[email protected]9adb9692010-10-29 23:14:02331 ExtensionResource GetResource(const std::string& relative_path) const;
[email protected]99efb7b12009-12-18 02:39:16332
333 // As above, but with |relative_path| following the file system's encoding.
[email protected]9adb9692010-10-29 23:14:02334 ExtensionResource GetResource(const FilePath& relative_path) const;
[email protected]eab9b452009-01-23 20:48:59335
[email protected]a17f9462009-06-09 02:56:41336 // |input| is expected to be the text of an rsa public or private key. It
337 // tolerates the presence or absence of bracking header/footer like this:
338 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
339 // and may contain newlines.
340 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
341
342 // Does a simple base64 encoding of |input| into |output|.
343 static bool ProducePEM(const std::string& input, std::string* output);
344
[email protected]84ac7f32009-10-06 06:17:54345 // Generates an extension ID from arbitrary input. The same input string will
346 // always generate the same output ID.
[email protected]af9db5f2011-10-05 05:13:15347 static bool GenerateId(const std::string& input,
348 std::string* output) WARN_UNUSED_RESULT;
[email protected]fbcc40302009-06-12 20:45:45349
[email protected]a17f9462009-06-09 02:56:41350 // Expects base64 encoded |input| and formats into |output| including
351 // the appropriate header & footer.
[email protected]e0d08192011-03-29 19:02:50352 static bool FormatPEMForFileOutput(const std::string& input,
353 std::string* output,
354 bool is_public);
[email protected]a17f9462009-06-09 02:56:41355
[email protected]c690a9812009-12-17 05:55:32356 // Given an extension and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23357 // result. In the browser process, this will DCHECK if not called on the
358 // file thread. To easily load extension images on the UI thread, see
359 // ImageLoadingTracker.
[email protected]9adb9692010-10-29 23:14:02360 static void DecodeIcon(const Extension* extension,
[email protected]c690a9812009-12-17 05:55:32361 Icons icon_size,
362 scoped_ptr<SkBitmap>* result);
363
364 // Given an icon_path and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23365 // result. In the browser process, this will DCHECK if not called on the
366 // file thread. To easily load extension images on the UI thread, see
367 // ImageLoadingTracker.
[email protected]c690a9812009-12-17 05:55:32368 static void DecodeIconFromPath(const FilePath& icon_path,
369 Icons icon_size,
370 scoped_ptr<SkBitmap>* result);
371
[email protected]5349ac6d2011-04-05 22:20:17372 // Returns the default extension/app icon (for extensions or apps that don't
373 // have one).
374 static const SkBitmap& GetDefaultIcon(bool is_app);
375
[email protected]a807bbe2010-04-14 10:51:19376 // Returns the base extension url for a given |extension_id|.
377 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
378
[email protected]be7e5cb2010-10-04 12:53:17379 // Adds an extension to the scripting whitelist. Used for testing only.
[email protected]10fb1992010-10-08 09:00:17380 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
[email protected]2a521c52011-01-26 18:45:21381 static const ScriptingWhitelist* GetScriptingWhitelist();
[email protected]be7e5cb2010-10-04 12:53:17382
[email protected]902fd7b2011-07-27 18:42:31383 // Parses the host and api permissions from the specified permission |key|
384 // in the manifest |source|.
[email protected]953620b2011-12-04 00:55:32385 bool ParsePermissions(const extensions::Manifest* source,
[email protected]902fd7b2011-07-27 18:42:31386 const char* key,
387 int flags,
[email protected]fc670822011-12-17 09:33:49388 string16* error,
[email protected]902fd7b2011-07-27 18:42:31389 ExtensionAPIPermissionSet* api_permissions,
390 URLPatternSet* host_permissions);
391
[email protected]0d3e4a22011-06-23 19:02:52392 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const;
393 bool HasAPIPermission(const std::string& function_name) const;
[email protected]583d45c12010-08-31 02:48:12394
[email protected]0d3e4a22011-06-23 19:02:52395 const URLPatternSet& GetEffectiveHostPermissions() const;
[email protected]b24d8312009-08-27 06:47:46396
[email protected]902fd7b2011-07-27 18:42:31397 // Returns true if the extension can silently increase its permission level.
[email protected]0d904312012-01-25 23:00:16398 // Users must approve permissions for unpacked and packed extensions in the
399 // following situations:
400 // - when installing or upgrading packed extensions
401 // - when installing unpacked extensions that have NPAPI plugins
402 // - when either type of extension requests optional permissions
[email protected]902fd7b2011-07-27 18:42:31403 bool CanSilentlyIncreasePermissions() const;
404
[email protected]584b8e3f2010-04-10 00:23:37405 // Whether the extension has access to the given URL.
406 bool HasHostPermission(const GURL& url) const;
407
[email protected]0df165f2010-09-28 16:49:40408 // Whether the extension has effective access to all hosts. This is true if
409 // there is a content script that matches all hosts, if there is a host
410 // permission grants access to all hosts (like <all_urls>) or an api
411 // permission that effectively grants access to all hosts (e.g. proxy,
412 // network, etc.)
413 bool HasEffectiveAccessToAllHosts() const;
[email protected]b24d8312009-08-27 06:47:46414
[email protected]8d888c12010-11-30 00:00:25415 // Whether the extension effectively has all permissions (for example, by
416 // having an NPAPI plugin).
417 bool HasFullPermissions() const;
418
[email protected]902fd7b2011-07-27 18:42:31419 // Returns the full list of permission messages that this extension
420 // should display at install time.
421 ExtensionPermissionMessages GetPermissionMessages() const;
422
423 // Returns the full list of permission messages that this extension
424 // should display at install time. The messages are returned as strings
425 // for convenience.
426 std::vector<string16> GetPermissionMessageStrings() const;
427
428 // Sets the active |permissions|.
429 void SetActivePermissions(const ExtensionPermissionSet* permissions) const;
430
431 // Gets the extension's active permission set.
432 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
433
[email protected]5df6a5d2011-01-26 07:39:12434 // Whether context menu should be shown for page and browser actions.
435 bool ShowConfigureContextMenus() const;
436
[email protected]b6cf240f2011-10-15 22:09:53437 // Whether network requests should be delayed on browser startup until the
438 // extension's background page has loaded, even if the extension doesn't
439 // explicitly request a delay.
440 bool ImplicitlyDelaysNetworkStartup() const;
441
[email protected]37cd64d2010-10-25 18:17:58442 // Returns the Homepage URL for this extension. If homepage_url was not
443 // specified in the manifest, this returns the Google Gallery URL. For
[email protected]bfa90a3a2010-04-28 15:43:23444 // third-party extensions, this returns a blank GURL.
[email protected]37cd64d2010-10-25 18:17:58445 GURL GetHomepageURL() const;
[email protected]bfa90a3a2010-04-28 15:43:23446
[email protected]facd7a7652009-06-05 23:15:02447 // Returns a list of paths (relative to the extension dir) for images that
448 // the browser might load (like themes and page action icons).
[email protected]9adb9692010-10-29 23:14:02449 std::set<FilePath> GetBrowserImages() const;
[email protected]facd7a7652009-06-05 23:15:02450
[email protected]807871f2010-09-16 01:04:48451 // Get an extension icon as a resource or URL.
[email protected]9adb9692010-10-29 23:14:02452 ExtensionResource GetIconResource(
453 int size, ExtensionIconSet::MatchType match_type) const;
454 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
[email protected]f34e79632010-03-17 02:34:08455
[email protected]867a73e12010-03-19 20:45:46456 // Gets the fully resolved absolute launch URL.
457 GURL GetFullLaunchURL() const;
[email protected]2a521c52011-01-26 18:45:21458
[email protected]6f229e82010-11-02 17:47:26459 // Image cache related methods. These are only valid on the UI thread and
460 // not maintained by this class. See ImageLoadingTracker for usage. The
461 // |original_size| parameter should be the size of the image at |source|
462 // before any scaling may have been done to produce the pixels in |image|.
463 void SetCachedImage(const ExtensionResource& source,
464 const SkBitmap& image,
465 const gfx::Size& original_size) const;
466 bool HasCachedImage(const ExtensionResource& source,
467 const gfx::Size& max_size) const;
468 SkBitmap GetCachedImage(const ExtensionResource& source,
469 const gfx::Size& max_size) const;
[email protected]2a521c52011-01-26 18:45:21470
471 // Returns true if this extension can execute script on a page. If a
472 // UserScript object is passed, permission to run that specific script is
473 // checked (using its matches list). Otherwise, permission to execute script
474 // programmatically is checked (using the extension's host permission).
475 //
476 // This method is also aware of certain special pages that extensions are
477 // usually not allowed to run script on.
478 bool CanExecuteScriptOnPage(const GURL& page_url,
[email protected]3aff9ad2011-04-01 20:26:48479 const UserScript* script,
[email protected]2a521c52011-01-26 18:45:21480 std::string* error) const;
481
[email protected]6f229e82010-11-02 17:47:26482 // Returns true if this extension is a COMPONENT extension, or if it is
483 // on the whitelist of extensions that can script all pages.
484 bool CanExecuteScriptEverywhere() const;
485
[email protected]5efbfe012011-02-22 23:07:18486 // Returns true if this extension is allowed to obtain the contents of a
487 // page as an image. Since a page may contain sensitive information, this
488 // is restricted to the extension's host permissions as well as the
489 // extension page itself.
490 bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const;
491
[email protected]a65882c2010-11-12 15:15:09492 // Returns true if this extension updates itself using the extension
493 // gallery.
494 bool UpdatesFromGallery() const;
495
[email protected]cca147172011-02-17 01:29:29496 // Returns true if this extension or app includes areas within |origin|.
497 bool OverlapsWithOrigin(const GURL& origin) const;
498
[email protected]3bdba0d2011-08-23 07:17:30499 // Returns the sync bucket to use for this extension.
500 SyncType GetSyncType() const;
501
[email protected]b873cd92012-02-09 21:51:48502 // Returns true if the extension should be synced.
503 bool IsSyncable() const;
504
505 // Returns true if the extension should be displayed in the launcher.
506 bool ShouldDisplayInLauncher() const;
507
[email protected]6f229e82010-11-02 17:47:26508 // Accessors:
509
510 const FilePath& path() const { return path_; }
511 const GURL& url() const { return extension_url_; }
512 Location location() const { return location_; }
513 const std::string& id() const { return id_; }
514 const Version* version() const { return version_.get(); }
515 const std::string VersionString() const;
516 const std::string& name() const { return name_; }
517 const std::string& public_key() const { return public_key_; }
518 const std::string& description() const { return description_; }
[email protected]a47c8a22011-11-17 18:40:31519 int manifest_version() const { return manifest_version_; }
[email protected]6f229e82010-11-02 17:47:26520 bool converted_from_user_script() const {
521 return converted_from_user_script_;
522 }
523 const UserScriptList& content_scripts() const { return content_scripts_; }
524 ExtensionAction* page_action() const { return page_action_.get(); }
525 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]b6b805e92011-04-16 09:24:14526 const FileBrowserHandlerList* file_browser_handlers() const {
527 return file_browser_handlers_.get();
528 }
[email protected]6f229e82010-11-02 17:47:26529 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]65378f52011-04-08 02:31:23530 const std::vector<NaClModuleInfo>& nacl_modules() const {
531 return nacl_modules_;
532 }
[email protected]b0820372011-06-03 07:05:27533 const std::vector<InputComponentInfo>& input_components() const {
534 return input_components_;
535 }
[email protected]a03d4448f2012-01-10 23:25:28536 bool has_background_page() const {
537 return background_url_.is_valid() || !background_scripts_.empty();
538 }
539 const std::vector<std::string>& background_scripts() const {
540 return background_scripts_;
541 }
[email protected]9e6720a2012-01-24 02:30:56542 bool background_page_persists() const { return background_page_persists_; }
[email protected]6f229e82010-11-02 17:47:26543 const GURL& options_url() const { return options_url_; }
544 const GURL& devtools_url() const { return devtools_url_; }
[email protected]902fd7b2011-07-27 18:42:31545 const ExtensionPermissionSet* optional_permission_set() const {
546 return optional_permission_set_.get();
547 }
548 const ExtensionPermissionSet* required_permission_set() const {
549 return required_permission_set_.get();
[email protected]6f229e82010-11-02 17:47:26550 }
[email protected]6f229e82010-11-02 17:47:26551 const GURL& update_url() const { return update_url_; }
552 const ExtensionIconSet& icons() const { return icons_; }
[email protected]953620b2011-12-04 00:55:32553 const extensions::Manifest* manifest() const {
554 return manifest_.get();
[email protected]6f229e82010-11-02 17:47:26555 }
556 const std::string default_locale() const { return default_locale_; }
557 const URLOverrideMap& GetChromeURLOverrides() const {
558 return chrome_url_overrides_;
559 }
560 const std::string omnibox_keyword() const { return omnibox_keyword_; }
561 bool incognito_split_mode() const { return incognito_split_mode_; }
[email protected]1abdf4f2011-08-16 21:11:55562 bool offline_enabled() const { return offline_enabled_; }
[email protected]a4a38c12010-12-23 16:43:56563 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
[email protected]56624422011-11-01 22:11:27564 const std::vector<webkit_glue::WebIntentServiceData>&
565 intents_services() const {
566 return intents_services_;
567 }
[email protected]6f229e82010-11-02 17:47:26568
[email protected]3aff9ad2011-04-01 20:26:48569 bool wants_file_access() const { return wants_file_access_; }
[email protected]2af352b2011-07-22 08:21:23570 int creation_flags() const { return creation_flags_; }
571 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
[email protected]e805baf2011-07-26 18:23:05572 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; }
[email protected]3aff9ad2011-04-01 20:26:48573
[email protected]7f7b9d932011-04-20 16:13:26574 const std::string& content_security_policy() const {
575 return content_security_policy_;
576 }
577
[email protected]6f229e82010-11-02 17:47:26578 // App-related.
[email protected]953620b2011-12-04 00:55:32579 bool is_app() const {
580 return is_packaged_app() || is_hosted_app() || is_platform_app();
[email protected]23690872011-12-01 22:02:39581 }
[email protected]953620b2011-12-04 00:55:32582 bool is_platform_app() const { return manifest()->IsPlatformApp(); }
583 bool is_hosted_app() const { return manifest()->IsHostedApp(); }
584 bool is_packaged_app() const { return manifest()->IsPackagedApp(); }
[email protected]d9696672011-03-15 22:45:09585 bool is_storage_isolated() const { return is_app() && is_storage_isolated_; }
[email protected]cced75a2011-05-20 08:31:12586 const URLPatternSet& web_extent() const { return extent_; }
[email protected]6f229e82010-11-02 17:47:26587 const std::string& launch_local_path() const { return launch_local_path_; }
588 const std::string& launch_web_url() const { return launch_web_url_; }
589 extension_misc::LaunchContainer launch_container() const {
590 return launch_container_;
591 }
592 int launch_width() const { return launch_width_; }
593 int launch_height() const { return launch_height_; }
594
595 // Theme-related.
[email protected]953620b2011-12-04 00:55:32596 bool is_theme() const { return manifest()->IsTheme(); }
[email protected]f3a1c642011-07-12 19:15:03597 base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
598 base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); }
599 base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
600 base::DictionaryValue* GetThemeDisplayProperties() const {
[email protected]6f229e82010-11-02 17:47:26601 return theme_display_properties_.get();
602 }
603
[email protected]a03d4448f2012-01-10 23:25:28604 GURL GetBackgroundURL() const;
605
[email protected]4a8d3272009-03-10 19:15:08606 private:
[email protected]66e4eb32010-10-27 20:37:41607 friend class base::RefCountedThreadSafe<Extension>;
608
[email protected]d7e9a862010-11-03 21:57:49609 // We keep a cache of images loaded from extension resources based on their
610 // path and a string representation of a size that may have been used to
611 // scale it (or the empty string if the image is at its original size).
612 typedef std::pair<FilePath, std::string> ImageCacheKey;
613 typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
614
[email protected]902fd7b2011-07-27 18:42:31615 class RuntimeData {
616 public:
617 RuntimeData();
618 explicit RuntimeData(const ExtensionPermissionSet* active);
619 ~RuntimeData();
620
621 void SetActivePermissions(const ExtensionPermissionSet* active);
622 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
623
624 private:
625 friend class base::RefCountedThreadSafe<RuntimeData>;
626 scoped_refptr<const ExtensionPermissionSet> active_permissions_;
627 };
628
[email protected]4ead6f72010-10-13 19:54:18629 // Normalize the path for use by the extension. On Windows, this will make
630 // sure the drive letter is uppercase.
631 static FilePath MaybeNormalizePath(const FilePath& path);
632
[email protected]87c655e2011-07-01 21:42:00633 // Returns true if this extension id is from a trusted provider.
634 static bool IsTrustedId(const std::string& id);
635
[email protected]66e4eb32010-10-27 20:37:41636 Extension(const FilePath& path, Location location);
637 ~Extension();
638
639 // Initialize the extension from a parsed manifest.
[email protected]953620b2011-12-04 00:55:32640 // Takes ownership of the manifest |value|.
641 bool InitFromValue(extensions::Manifest* value, int flags,
[email protected]fc670822011-12-17 09:33:49642 string16* error);
[email protected]66e4eb32010-10-27 20:37:41643
[email protected]052c92702010-06-25 07:25:52644 // Helper function for implementing HasCachedImage/GetCachedImage. A return
645 // value of NULL means there is no matching image cached (we allow caching an
646 // empty SkBitmap).
647 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
[email protected]9adb9692010-10-29 23:14:02648 const gfx::Size& max_size) const;
[email protected]d9ad80f2010-03-30 20:40:18649
[email protected]3cfbd0e2009-03-18 21:26:24650 // Helper method that loads a UserScript object from a
651 // dictionary in the content_script list of the manifest.
[email protected]f3a1c642011-07-12 19:15:03652 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
[email protected]3cfbd0e2009-03-18 21:26:24653 int definition_index,
[email protected]3aff9ad2011-04-01 20:26:48654 int flags,
[email protected]fc670822011-12-17 09:33:49655 string16* error,
[email protected]3cfbd0e2009-03-18 21:26:24656 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34657
[email protected]6657afa62009-11-04 02:15:20658 // Helper method that loads either the include_globs or exclude_globs list
659 // from an entry in the content_script lists of the manifest.
[email protected]f3a1c642011-07-12 19:15:03660 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
[email protected]6657afa62009-11-04 02:15:20661 int content_script_index,
[email protected]e2194742010-08-12 05:54:34662 const char* globs_property_name,
[email protected]fc670822011-12-17 09:33:49663 string16* error,
[email protected]11f4857282009-11-13 19:56:17664 void(UserScript::*add_method)(const std::string& glob),
[email protected]6657afa62009-11-04 02:15:20665 UserScript *instance);
666
[email protected]867a73e12010-03-19 20:45:46667 // Helpers to load various chunks of the manifest.
[email protected]953620b2011-12-04 00:55:32668 bool LoadExtent(const extensions::Manifest* manifest,
[email protected]542258c2011-03-04 21:25:31669 const char* key,
[email protected]cced75a2011-05-20 08:31:12670 URLPatternSet* extent,
[email protected]542258c2011-03-04 21:25:31671 const char* list_error,
672 const char* value_error,
[email protected]fc670822011-12-17 09:33:49673 string16* error);
[email protected]953620b2011-12-04 00:55:32674 bool LoadLaunchContainer(const extensions::Manifest* manifest,
[email protected]fc670822011-12-17 09:33:49675 string16* error);
[email protected]953620b2011-12-04 00:55:32676 bool LoadLaunchURL(const extensions::Manifest* manifest,
[email protected]fc670822011-12-17 09:33:49677 string16* error);
[email protected]953620b2011-12-04 00:55:32678 bool LoadAppIsolation(const extensions::Manifest* manifest,
[email protected]fc670822011-12-17 09:33:49679 string16* error);
[email protected]953620b2011-12-04 00:55:32680 bool LoadWebIntentServices(const extensions::Manifest* manifest,
[email protected]fc670822011-12-17 09:33:49681 string16* error);
[email protected]a03d4448f2012-01-10 23:25:28682 bool LoadBackgroundScripts(const extensions::Manifest* manifest,
683 string16* error);
[email protected]eb75f7b2012-01-04 09:07:28684 bool LoadBackgroundPage(const extensions::Manifest* manifest,
685 const ExtensionAPIPermissionSet& api_permissions,
686 string16* error);
[email protected]9e6720a2012-01-24 02:30:56687 bool LoadBackgroundPersistent(
688 const extensions::Manifest* manifest,
689 const ExtensionAPIPermissionSet& api_permissions,
690 string16* error);
[email protected]867a73e12010-03-19 20:45:46691
[email protected]5d246db22009-10-27 06:17:57692 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08693 // browser_action entries in the manifest.
[email protected]5d246db22009-10-27 06:17:57694 ExtensionAction* LoadExtensionActionHelper(
[email protected]fc670822011-12-17 09:33:49695 const base::DictionaryValue* extension_action, string16* error);
[email protected]92c6f9b92009-10-24 04:35:08696
[email protected]b6b805e92011-04-16 09:24:14697 // Helper method to load an FileBrowserHandlerList from the manifest.
698 FileBrowserHandlerList* LoadFileBrowserHandlers(
[email protected]fc670822011-12-17 09:33:49699 const base::ListValue* extension_actions, string16* error);
[email protected]b6b805e92011-04-16 09:24:14700 // Helper method to load an FileBrowserHandler from manifest.
701 FileBrowserHandler* LoadFileBrowserHandler(
[email protected]fc670822011-12-17 09:33:49702 const base::DictionaryValue* file_browser_handlers, string16* error);
[email protected]b6b805e92011-04-16 09:24:14703
[email protected]2f6698b2010-10-14 00:58:21704 // Returns true if the extension has more than one "UI surface". For example,
705 // an extension that has a browser action and a page action.
706 bool HasMultipleUISurfaces() const;
707
[email protected]be9d9c82011-07-13 04:17:31708 // Updates the launch URL and extents for the extension using the given
709 // |override_url|.
710 void OverrideLaunchUrl(const GURL& override_url);
711
[email protected]5eddc3e2011-10-26 04:33:31712 // Returns true if this extension can specify |api|.
713 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api,
[email protected]fc670822011-12-17 09:33:49714 string16* error) const;
[email protected]5eddc3e2011-10-26 04:33:31715 bool CanSpecifyExperimentalPermission() const;
[email protected]5eddc3e2011-10-26 04:33:31716
717 // Checks whether the host |pattern| is allowed for this extension, given API
718 // permissions |permissions|.
719 bool CanSpecifyHostPermission(const URLPattern& pattern,
720 const ExtensionAPIPermissionSet& permissions) const;
721
[email protected]d7e9a862010-11-03 21:57:49722 // Cached images for this extension. This should only be touched on the UI
723 // thread.
724 mutable ImageCache image_cache_;
[email protected]1e8c93f2010-02-08 22:58:31725
[email protected]6f229e82010-11-02 17:47:26726 // A persistent, globally unique ID. An extension's ID is used in things
727 // like directory structures and URLs, and is expected to not change across
728 // versions. It is generated as a SHA-256 hash of the extension's public
729 // key, or as a hash of the path in the case of unpacked extensions.
730 std::string id_;
731
732 // The extension's human-readable name. Name is used for display purpose. It
733 // might be wrapped with unicode bidi control characters so that it is
734 // displayed correctly in RTL context.
735 // NOTE: Name is UTF-8 and may contain non-ascii characters.
736 std::string name_;
737
738 // The absolute path to the directory the extension is stored in.
739 FilePath path_;
740
[email protected]a47c8a22011-11-17 18:40:31741 // The version of this extension's manifest. We increase the manifest
742 // version when making breaking changes to the extension system.
743 // Version 1 was the first manifest version (implied by a lack of a
744 // manifest_version attribute in the extension's manifest). We initialize
745 // this member variable to 0 to distinguish the "uninitialized" case from
746 // the case when we know the manifest version actually is 1.
747 int manifest_version_;
748
[email protected]6f229e82010-11-02 17:47:26749 // Default locale for fall back. Can be empty if extension is not localized.
750 std::string default_locale_;
751
752 // If true, a separate process will be used for the extension in incognito
753 // mode.
754 bool incognito_split_mode_;
755
[email protected]1abdf4f2011-08-16 21:11:55756 // Whether the extension or app should be enabled when offline.
757 bool offline_enabled_;
758
[email protected]6f229e82010-11-02 17:47:26759 // Defines the set of URLs in the extension's web content.
[email protected]cced75a2011-05-20 08:31:12760 URLPatternSet extent_;
[email protected]6f229e82010-11-02 17:47:26761
[email protected]902fd7b2011-07-27 18:42:31762 // The extension runtime data.
763 mutable base::Lock runtime_data_lock_;
764 mutable RuntimeData runtime_data_;
765
766 // The set of permissions the extension can request at runtime.
767 scoped_refptr<const ExtensionPermissionSet> optional_permission_set_;
768
769 // The extension's required / default set of permissions.
770 scoped_refptr<const ExtensionPermissionSet> required_permission_set_;
[email protected]6f229e82010-11-02 17:47:26771
772 // The icons for the extension.
773 ExtensionIconSet icons_;
774
775 // The base extension url for the extension.
776 GURL extension_url_;
777
778 // The location the extension was loaded from.
779 Location location_;
780
781 // The extension's version.
782 scoped_ptr<Version> version_;
783
784 // An optional longer description of the extension.
785 std::string description_;
786
787 // True if the extension was generated from a user script. (We show slightly
788 // different UI if so).
789 bool converted_from_user_script_;
790
791 // Paths to the content scripts the extension contains.
792 UserScriptList content_scripts_;
793
794 // The extension's page action, if any.
795 scoped_ptr<ExtensionAction> page_action_;
796
797 // The extension's browser action, if any.
798 scoped_ptr<ExtensionAction> browser_action_;
799
[email protected]b6b805e92011-04-16 09:24:14800 // The extension's file browser actions, if any.
801 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
802
[email protected]6f229e82010-11-02 17:47:26803 // Optional list of NPAPI plugins and associated properties.
804 std::vector<PluginInfo> plugins_;
805
[email protected]65378f52011-04-08 02:31:23806 // Optional list of NaCl modules and associated properties.
807 std::vector<NaClModuleInfo> nacl_modules_;
808
[email protected]b0820372011-06-03 07:05:27809 // Optional list of input components and associated properties.
810 std::vector<InputComponentInfo> input_components_;
811
[email protected]8f270be2011-12-21 21:15:22812 // Optional list of web accessible extension resources.
813 base::hash_set<std::string> web_accessible_resources_;
814
[email protected]6f229e82010-11-02 17:47:26815 // Optional URL to a master page of which a single instance should be always
816 // loaded in the background.
817 GURL background_url_;
818
[email protected]a03d4448f2012-01-10 23:25:28819 // Optional list of scripts to use to generate a background page. If this is
820 // present, background_url_ will be empty and generated by GetBackgroundURL().
821 std::vector<std::string> background_scripts_;
822
[email protected]9e6720a2012-01-24 02:30:56823 // True if the background page should stay loaded forever; false if it should
824 // load on-demand (when it needs to handle an event). Defaults to true.
825 bool background_page_persists_;
826
[email protected]6f229e82010-11-02 17:47:26827 // Optional URL to a page for setting options/preferences.
828 GURL options_url_;
829
830 // Optional URL to a devtools extension page.
831 GURL devtools_url_;
832
[email protected]6f229e82010-11-02 17:47:26833 // The public key used to sign the contents of the crx package.
834 std::string public_key_;
835
836 // A map of resource id's to relative file paths.
[email protected]f3a1c642011-07-12 19:15:03837 scoped_ptr<base::DictionaryValue> theme_images_;
[email protected]6f229e82010-11-02 17:47:26838
839 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03840 scoped_ptr<base::DictionaryValue> theme_colors_;
[email protected]6f229e82010-11-02 17:47:26841
842 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03843 scoped_ptr<base::DictionaryValue> theme_tints_;
[email protected]6f229e82010-11-02 17:47:26844
845 // A map of display properties.
[email protected]f3a1c642011-07-12 19:15:03846 scoped_ptr<base::DictionaryValue> theme_display_properties_;
[email protected]6f229e82010-11-02 17:47:26847
[email protected]6f229e82010-11-02 17:47:26848 // The homepage for this extension. Useful if it is not hosted by Google and
849 // therefore does not have a Gallery URL.
850 GURL homepage_url_;
851
852 // URL for fetching an update manifest
853 GURL update_url_;
854
[email protected]953620b2011-12-04 00:55:32855 // The manifest that this extension was created from.
856 scoped_ptr<extensions::Manifest> manifest_;
[email protected]6f229e82010-11-02 17:47:26857
858 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
859 // which override the handling of those URLs. (see ExtensionOverrideUI).
860 URLOverrideMap chrome_url_overrides_;
861
[email protected]d9696672011-03-15 22:45:09862 // Whether this extension requests isolated storage.
863 bool is_storage_isolated_;
864
[email protected]6f229e82010-11-02 17:47:26865 // The local path inside the extension to use with the launcher.
866 std::string launch_local_path_;
867
868 // A web url to use with the launcher. Note that this might be relative or
869 // absolute. If relative, it is relative to web_origin.
870 std::string launch_web_url_;
871
[email protected]4e595682011-02-09 17:07:02872 // The window type that an app's manifest specifies to launch into.
873 // This is not always the window type an app will open into, because
874 // users can override the way each app launches. See
875 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
876 // to decide what container an app will launch in.
[email protected]6f229e82010-11-02 17:47:26877 extension_misc::LaunchContainer launch_container_;
878
879 // The default size of the container when launching. Only respected for
880 // containers like panels and windows.
881 int launch_width_;
882 int launch_height_;
883
884 // The Omnibox keyword for this extension, or empty if there is none.
885 std::string omnibox_keyword_;
886
[email protected]a4a38c12010-12-23 16:43:56887 // List of text-to-speech voices that this extension provides, if any.
888 std::vector<TtsVoice> tts_voices_;
889
[email protected]56624422011-11-01 22:11:27890 // List of intent services that this extension provides, if any.
891 std::vector<webkit_glue::WebIntentServiceData> intents_services_;
[email protected]be5f007862011-09-23 00:35:13892
[email protected]3aff9ad2011-04-01 20:26:48893 // Whether the extension has host permissions or user script patterns that
894 // imply access to file:/// scheme URLs (the user may not have actually
895 // granted it that access).
896 bool wants_file_access_;
897
[email protected]2af352b2011-07-22 08:21:23898 // The flags that were passed to InitFromValue.
899 int creation_flags_;
[email protected]620db1762011-07-15 21:57:34900
[email protected]7f7b9d932011-04-20 16:13:26901 // The Content-Security-Policy for this extension. Extensions can use
902 // Content-Security-Policies to mitigate cross-site scripting and other
903 // vulnerabilities.
904 std::string content_security_policy_;
905
[email protected]eaa7dd182010-12-14 11:09:00906 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]5eb375e92010-11-26 07:50:41907 UpdateExtensionPreservesLocation);
[email protected]19118d52010-07-26 22:13:42908 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
909 FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58910
[email protected]894bb502009-05-21 22:39:57911 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33912};
913
[email protected]9adb9692010-10-29 23:14:02914typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
[email protected]ec5b50d2010-10-09 16:35:18915typedef std::set<std::string> ExtensionIdSet;
[email protected]b1748b1d82009-11-30 20:32:56916
[email protected]c6d474f82009-12-16 21:11:06917// Handy struct to pass core extension info around.
918struct ExtensionInfo {
[email protected]f3a1c642011-07-12 19:15:03919 ExtensionInfo(const base::DictionaryValue* manifest,
[email protected]c6d474f82009-12-16 21:11:06920 const std::string& id,
921 const FilePath& path,
[email protected]3bb84992010-08-26 17:23:46922 Extension::Location location);
923 ~ExtensionInfo();
[email protected]c6d474f82009-12-16 21:11:06924
[email protected]f3a1c642011-07-12 19:15:03925 scoped_ptr<base::DictionaryValue> extension_manifest;
[email protected]c6d474f82009-12-16 21:11:06926 std::string extension_id;
927 FilePath extension_path;
928 Extension::Location extension_location;
929
930 private:
931 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
932};
933
[email protected]a9f39a312010-12-23 22:14:27934struct UnloadedExtensionInfo {
[email protected]814a7bf0f2011-08-13 05:30:59935 extension_misc::UnloadedExtensionReason reason;
[email protected]a9f39a312010-12-23 22:14:27936
937 // Was the extension already disabled?
938 bool already_disabled;
939
940 // The extension being unloaded - this should always be non-NULL.
941 const Extension* extension;
942
[email protected]814a7bf0f2011-08-13 05:30:59943 UnloadedExtensionInfo(
944 const Extension* extension,
945 extension_misc::UnloadedExtensionReason reason);
[email protected]a9f39a312010-12-23 22:14:27946};
947
[email protected]902fd7b2011-07-27 18:42:31948// The details sent for EXTENSION_PERMISSIONS_UPDATED notifications.
949struct UpdatedExtensionPermissionsInfo {
950 enum Reason {
951 ADDED, // The permissions were added to the extension.
952 REMOVED, // The permissions were removed from the extension.
953 };
954
955 Reason reason;
956
957 // The extension who's permissions have changed.
958 const Extension* extension;
959
960 // The permissions that have changed. For Reason::ADDED, this would contain
961 // only the permissions that have added, and for Reason::REMOVED, this would
962 // only contain the removed permissions.
963 const ExtensionPermissionSet* permissions;
964
965 UpdatedExtensionPermissionsInfo(
966 const Extension* extension,
967 const ExtensionPermissionSet* permissions,
968 Reason reason);
969};
970
[email protected]5b1a0e22009-05-26 19:00:58971#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_