blob: 4cb0fbe8f6cf7493d0768c3c708baa298d7dbd48 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]7713d632008-12-02 07:52:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5b1a0e22009-05-26 19:00:585#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_
6#define CHROME_COMMON_EXTENSIONS_EXTENSION_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]7713d632008-12-02 07:52:338
[email protected]300cc58db2009-08-19 20:45:149#include <map>
[email protected]facd7a7652009-06-05 23:15:0210#include <set>
[email protected]7713d632008-12-02 07:52:3311#include <string>
12#include <vector>
13
[email protected]6014d672008-12-05 00:38:2514#include "base/file_path.h"
[email protected]19118d52010-07-26 22:13:4215#include "base/gtest_prod_util.h"
[email protected]b6b805e92011-04-16 09:24:1416#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1517#include "base/memory/ref_counted.h"
18#include "base/memory/scoped_ptr.h"
[email protected]902fd7b2011-07-27 18:42:3119#include "base/synchronization/lock.h"
[email protected]d83a5602010-09-16 00:22:4820#include "chrome/common/extensions/extension_constants.h"
[email protected]807871f2010-09-16 01:04:4821#include "chrome/common/extensions/extension_icon_set.h"
[email protected]0d3e4a22011-06-23 19:02:5222#include "chrome/common/extensions/extension_permission_set.h"
[email protected]42b6f0f82009-09-18 21:07:3923#include "chrome/common/extensions/user_script.h"
[email protected]7197f4992009-03-23 05:05:4924#include "chrome/common/extensions/url_pattern.h"
[email protected]cced75a2011-05-20 08:31:1225#include "chrome/common/extensions/url_pattern_set.h"
[email protected]eab9b452009-01-23 20:48:5926#include "googleurl/src/gurl.h"
[email protected]08397d52011-02-05 01:53:3827#include "ui/gfx/size.h"
[email protected]be5f007862011-09-23 00:35:1328#include "webkit/glue/web_intent_service_data.h"
[email protected]eab9b452009-01-23 20:48:5929
[email protected]942690b132010-05-11 06:42:1430class ExtensionAction;
31class ExtensionResource;
[email protected]e2dffe02011-01-20 20:30:0632class ExtensionSidebarDefaults;
[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]f0755532010-06-22 07:27:2542// Represents a Chrome extension.
[email protected]66e4eb32010-10-27 20:37:4143class Extension : public base::RefCountedThreadSafe<Extension> {
[email protected]7713d632008-12-02 07:52:3344 public:
[email protected]d3cfa482009-10-17 13:54:5745 typedef std::map<const std::string, GURL> URLOverrideMap;
[email protected]10fb1992010-10-08 09:00:1746 typedef std::vector<std::string> ScriptingWhitelist;
[email protected]b6b805e92011-04-16 09:24:1447 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
[email protected]b24d8312009-08-27 06:47:4648
[email protected]631cf822009-05-15 07:01:2549 // What an extension was loaded from.
[email protected]9b217652010-10-08 22:04:2350 // NOTE: These values are stored as integers in the preferences and used
51 // in histograms so don't remove or reorder existing items. Just append
52 // to the end.
[email protected]631cf822009-05-15 07:01:2553 enum Location {
54 INVALID,
[email protected]25b34332009-06-05 21:53:1955 INTERNAL, // A crx file from the internal Extensions directory.
56 EXTERNAL_PREF, // A crx file from an external directory (via prefs).
57 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the
58 // registry on Windows).
[email protected]1952c7d2010-03-04 23:48:3459 LOAD, // --load-extension.
[email protected]8ef78fd2010-08-19 17:14:3260 COMPONENT, // An integral component of Chrome itself, which
61 // happens to be implemented as an extension. We don't
62 // show these in the management UI.
[email protected]4d2913e32010-11-30 00:28:5563 EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via
64 // prefs), installed from an update URL.
65 EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via
66 // admin policies), installed from an update URL.
[email protected]04cb7542010-10-25 10:50:0667
68 NUM_LOCATIONS
[email protected]25b34332009-06-05 21:53:1969 };
70
71 enum State {
[email protected]0c6da502009-08-14 22:32:3972 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1973 ENABLED,
[email protected]79c833b52011-04-05 18:31:0174 // An external extension that the user uninstalled. We should not reinstall
75 // such extensions on startup.
76 EXTERNAL_EXTENSION_UNINSTALLED,
[email protected]0c6da502009-08-14 22:32:3977 NUM_STATES
[email protected]631cf822009-05-15 07:01:2578 };
[email protected]7713d632008-12-02 07:52:3379
[email protected]fbcc40302009-06-12 20:45:4580 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:3781 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:4582 DOWNGRADE,
83 REINSTALL,
84 UPGRADE,
85 NEW_INSTALL
86 };
87
[email protected]d2817012009-08-04 06:46:2188 // NOTE: If you change this list, you should also change kIconSizes in the cc
89 // file.
90 enum Icons {
91 EXTENSION_ICON_LARGE = 128,
92 EXTENSION_ICON_MEDIUM = 48,
93 EXTENSION_ICON_SMALL = 32,
[email protected]39382942010-03-23 15:57:0994 EXTENSION_ICON_SMALLISH = 24,
[email protected]d2817012009-08-04 06:46:2195 EXTENSION_ICON_BITTY = 16,
96 };
97
[email protected]7fa19f82010-12-21 19:40:0898 // Do not change the order of entries or remove entries in this list
99 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions.
100 enum Type {
[email protected]9b217652010-10-08 22:04:23101 TYPE_UNKNOWN = 0,
102 TYPE_EXTENSION,
103 TYPE_THEME,
104 TYPE_USER_SCRIPT,
105 TYPE_HOSTED_APP,
[email protected]7d3ed2f2011-11-07 23:33:19106 TYPE_PACKAGED_APP,
107 TYPE_PLATFORM_APP
[email protected]9b217652010-10-08 22:04:23108 };
109
[email protected]3bdba0d2011-08-23 07:17:30110 enum SyncType {
111 SYNC_TYPE_NONE = 0,
112 SYNC_TYPE_EXTENSION,
113 SYNC_TYPE_APP
114 };
115
[email protected]92888082010-10-18 19:24:57116 // An NPAPI plugin included in the extension.
117 struct PluginInfo {
118 FilePath path; // Path to the plugin.
119 bool is_public; // False if only this extension can load this plugin.
120 };
121
[email protected]65378f52011-04-08 02:31:23122 // An NaCl module included in the extension.
123 struct NaClModuleInfo {
[email protected]84396dbc2011-04-14 06:33:42124 GURL url;
[email protected]65378f52011-04-08 02:31:23125 std::string mime_type;
126 };
127
[email protected]b0820372011-06-03 07:05:27128 enum InputComponentType {
[email protected]d45f7512011-06-21 21:18:27129 INPUT_COMPONENT_TYPE_NONE = -1,
130 INPUT_COMPONENT_TYPE_IME,
[email protected]b0820372011-06-03 07:05:27131 INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD,
132 INPUT_COMPONENT_TYPE_COUNT
133 };
134
135 struct InputComponentInfo {
136 // Define out of line constructor/destructor to please Clang.
137 InputComponentInfo();
138 ~InputComponentInfo();
139
140 std::string name;
141 InputComponentType type;
142 std::string id;
143 std::string description;
144 std::string language;
145 std::set<std::string> layouts;
146 std::string shortcut_keycode;
147 bool shortcut_alt;
148 bool shortcut_ctrl;
149 bool shortcut_shift;
150 };
151
[email protected]a4a38c12010-12-23 16:43:56152 struct TtsVoice {
[email protected]77a3ecac2011-07-07 05:56:33153 // Define out of line constructor/destructor to please Clang.
154 TtsVoice();
155 ~TtsVoice();
156
[email protected]a4a38c12010-12-23 16:43:56157 std::string voice_name;
[email protected]c63f2b72011-07-07 05:25:00158 std::string lang;
[email protected]a4a38c12010-12-23 16:43:56159 std::string gender;
[email protected]c63f2b72011-07-07 05:25:00160 std::set<std::string> event_types;
[email protected]a4a38c12010-12-23 16:43:56161 };
162
[email protected]83048a22011-03-29 00:14:13163 enum InitFromValueFlags {
164 NO_FLAGS = 0,
165
166 // Usually, the id of an extension is generated by the "key" property of
167 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
168 // generated based on the path.
169 REQUIRE_KEY = 1 << 0,
170
[email protected]3f53dfe2011-11-30 01:18:29171 // Requires the extension to have an up-to-date manifest version.
172 // Typically, we'll support multiple manifest versions during a version
173 // transition. This flag signals that we want to require the most modern
174 // manifest version that Chrome understands.
175 REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1,
176
[email protected]83048a22011-03-29 00:14:13177 // |STRICT_ERROR_CHECKS| enables extra error checking, such as
178 // checks that URL patterns do not contain ports. This error
179 // checking may find an error that a previous version of
180 // Chrome did not flag. To avoid errors in installed extensions
181 // when Chrome is upgraded, strict error checking is only enabled
182 // when loading extensions as a developer would (such as loading
183 // an unpacked extension), or when loading an extension that is
184 // tied to a specific version of Chrome (such as a component
185 // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when
186 // Extension::ShouldDoStrictErrorChecking(location) returns true.
[email protected]3f53dfe2011-11-30 01:18:29187 STRICT_ERROR_CHECKS = 1 << 2,
[email protected]3aff9ad2011-04-01 20:26:48188
189 // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension
190 // to have file access. If it's not present, then permissions and content
191 // scripts that match file:/// URLs will be filtered out.
[email protected]3f53dfe2011-11-30 01:18:29192 ALLOW_FILE_ACCESS = 1 << 3,
[email protected]620db1762011-07-15 21:57:34193
194 // |FROM_WEBSTORE| indicates that the extension was installed from the
195 // Chrome Web Store.
[email protected]3f53dfe2011-11-30 01:18:29196 FROM_WEBSTORE = 1 << 4,
[email protected]e805baf2011-07-26 18:23:05197
198 // |FROM_BOOKMARK| indicates the extension was created using a mock App
199 // created from a bookmark.
[email protected]3f53dfe2011-11-30 01:18:29200 FROM_BOOKMARK = 1 << 5,
[email protected]83048a22011-03-29 00:14:13201 };
202
[email protected]66e4eb32010-10-27 20:37:41203 static scoped_refptr<Extension> Create(const FilePath& path,
204 Location location,
[email protected]f3a1c642011-07-12 19:15:03205 const base::DictionaryValue& value,
[email protected]83048a22011-03-29 00:14:13206 int flags,
[email protected]66e4eb32010-10-27 20:37:41207 std::string* error);
208
[email protected]87c655e2011-07-01 21:42:00209 // In a few special circumstances, we want to create an Extension and give it
210 // an explicit id. Most consumers should just use the plain Create() method.
[email protected]f3a1c642011-07-12 19:15:03211 static scoped_refptr<Extension> CreateWithId(
212 const FilePath& path,
213 Location location,
214 const base::DictionaryValue& value,
215 int flags,
216 const std::string& explicit_id,
217 std::string* error);
[email protected]87c655e2011-07-01 21:42:00218
[email protected]145a317b2011-04-12 16:03:46219 // Given two install sources, return the one which should take priority
220 // over the other. If an extension is installed from two sources A and B,
221 // its install source should be set to GetHigherPriorityLocation(A, B).
222 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
223
[email protected]c3e3def742009-07-17 07:51:06224 // Icon sizes used by the extension system.
[email protected]d2817012009-08-04 06:46:21225 static const int kIconSizes[];
[email protected]c3e3def742009-07-17 07:51:06226
[email protected]4c4f8192009-10-17 01:03:26227 // Max size (both dimensions) for browser and page actions.
228 static const int kPageActionIconMaxSize;
229 static const int kBrowserActionIconMaxSize;
[email protected]e2dffe02011-01-20 20:30:06230 static const int kSidebarIconMaxSize;
[email protected]4c4f8192009-10-17 01:03:26231
[email protected]8d888c12010-11-30 00:00:25232 // Valid schemes for web extent URLPatterns.
233 static const int kValidWebExtentSchemes;
234
[email protected]f71f7e62010-12-07 03:45:33235 // Valid schemes for host permission URLPatterns.
236 static const int kValidHostPermissionSchemes;
237
[email protected]6014d672008-12-05 00:38:25238 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16239 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25240
[email protected]300cc58db2009-08-19 20:45:14241 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16242 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14243
244 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16245 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14246
[email protected]25b34332009-06-05 21:53:19247#if defined(OS_WIN)
[email protected]9dcf8f12010-09-02 20:39:19248 static const char kExtensionRegistryPath[];
[email protected]25b34332009-06-05 21:53:19249#endif
250
[email protected]37eeb5a2009-02-26 23:36:17251 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48252 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17253
[email protected]e435d6b72009-07-25 03:15:58254 // The mimetype used for extensions.
255 static const char kMimeType[];
256
[email protected]25b34332009-06-05 21:53:19257 // Checks to see if the extension has a valid ID.
258 static bool IdIsValid(const std::string& id);
259
[email protected]4ead6f72010-10-13 19:54:18260 // Generate an ID for an extension in the given path.
[email protected]28d7479b2011-03-09 21:33:27261 // Used while developing extensions, before they have a key.
[email protected]4ead6f72010-10-13 19:54:18262 static std::string GenerateIdForPath(const FilePath& file_name);
263
[email protected]e435d6b72009-07-25 03:15:58264 // Returns true if the specified file is an extension.
265 static bool IsExtension(const FilePath& file_name);
266
[email protected]25b34332009-06-05 21:53:19267 // Whether the |location| is external or not.
268 static inline bool IsExternalLocation(Location location) {
269 return location == Extension::EXTERNAL_PREF ||
[email protected]8ef78fd2010-08-19 17:14:32270 location == Extension::EXTERNAL_REGISTRY ||
[email protected]04cb7542010-10-25 10:50:06271 location == Extension::EXTERNAL_PREF_DOWNLOAD ||
272 location == Extension::EXTERNAL_POLICY_DOWNLOAD;
273 }
274
275 // Whether extensions with |location| are auto-updatable or not.
276 static inline bool IsAutoUpdateableLocation(Location location) {
277 // Only internal and external extensions can be autoupdated.
278 return location == Extension::INTERNAL ||
279 IsExternalLocation(location);
[email protected]25b34332009-06-05 21:53:19280 }
281
[email protected]95da88c42011-03-31 10:07:33282 // Whether extensions with |location| can be uninstalled or not. Policy
283 // controlled extensions are silently auto-installed and updated, and cannot
284 // be disabled by the user. The same applies for internal components.
285 static inline bool UserMayDisable(Location location) {
286 return location != Extension::EXTERNAL_POLICY_DOWNLOAD &&
287 location != Extension::COMPONENT;
288 }
289
[email protected]542258c2011-03-04 21:25:31290 // Whether extensions with |location| should be loaded with strict
291 // error checking. Strict error checks may flag errors older versions
292 // of chrome did not detect. To avoid breaking installed extensions,
293 // strict checks are disabled unless the location indicates that the
294 // developer is loading the extension, or the extension is a component
295 // of chrome.
296 static inline bool ShouldDoStrictErrorChecking(Location location) {
297 return location == Extension::LOAD ||
298 location == Extension::COMPONENT;
299 }
300
[email protected]cdfca9702011-08-08 16:07:01301 // Unpacked extensions start off with file access since they are a developer
302 // feature.
303 static inline bool ShouldAlwaysAllowFileAccess(Location location) {
304 return location == Extension::LOAD;
305 }
306
[email protected]7fa19f82010-12-21 19:40:08307 // See Type definition above.
308 Type GetType() const;
[email protected]9b217652010-10-08 22:04:23309
[email protected]07c00d992009-03-04 20:27:04310 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59311 // |extension_url| argument should be the url() from an Extension object. The
312 // |relative_path| can be untrusted user input. The returned URL will either
313 // be invalid() or a child of |extension_url|.
314 // NOTE: Static so that it can be used from multiple threads.
315 static GURL GetResourceURL(const GURL& extension_url,
316 const std::string& relative_path);
[email protected]cffd7892010-08-26 17:43:28317 GURL GetResourceURL(const std::string& relative_path) const {
[email protected]3cfbd0e2009-03-18 21:26:24318 return GetResourceURL(url(), relative_path);
319 }
[email protected]eab9b452009-01-23 20:48:59320
[email protected]99efb7b12009-12-18 02:39:16321 // Returns an extension resource object. |relative_path| should be UTF8
322 // encoded.
[email protected]9adb9692010-10-29 23:14:02323 ExtensionResource GetResource(const std::string& relative_path) const;
[email protected]99efb7b12009-12-18 02:39:16324
325 // As above, but with |relative_path| following the file system's encoding.
[email protected]9adb9692010-10-29 23:14:02326 ExtensionResource GetResource(const FilePath& relative_path) const;
[email protected]eab9b452009-01-23 20:48:59327
[email protected]a17f9462009-06-09 02:56:41328 // |input| is expected to be the text of an rsa public or private key. It
329 // tolerates the presence or absence of bracking header/footer like this:
330 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
331 // and may contain newlines.
332 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
333
334 // Does a simple base64 encoding of |input| into |output|.
335 static bool ProducePEM(const std::string& input, std::string* output);
336
[email protected]84ac7f32009-10-06 06:17:54337 // Generates an extension ID from arbitrary input. The same input string will
338 // always generate the same output ID.
[email protected]af9db5f2011-10-05 05:13:15339 static bool GenerateId(const std::string& input,
340 std::string* output) WARN_UNUSED_RESULT;
[email protected]fbcc40302009-06-12 20:45:45341
[email protected]a17f9462009-06-09 02:56:41342 // Expects base64 encoded |input| and formats into |output| including
343 // the appropriate header & footer.
[email protected]e0d08192011-03-29 19:02:50344 static bool FormatPEMForFileOutput(const std::string& input,
345 std::string* output,
346 bool is_public);
[email protected]a17f9462009-06-09 02:56:41347
[email protected]c690a9812009-12-17 05:55:32348 // Given an extension and icon size, read it if present and decode it into
[email protected]ae2e0f92010-04-06 20:32:23349 // result. In the browser process, this will DCHECK if not called on the
350 // file thread. To easily load extension images on the UI thread, see
351 // ImageLoadingTracker.
[email protected]9adb9692010-10-29 23:14:02352 static void DecodeIcon(const Extension* extension,
[email protected]c690a9812009-12-17 05:55:32353 Icons icon_size,
354 scoped_ptr<SkBitmap>* result);
355
356 // Given an icon_path 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]c690a9812009-12-17 05:55:32360 static void DecodeIconFromPath(const FilePath& icon_path,
361 Icons icon_size,
362 scoped_ptr<SkBitmap>* result);
363
[email protected]5349ac6d2011-04-05 22:20:17364 // Returns the default extension/app icon (for extensions or apps that don't
365 // have one).
366 static const SkBitmap& GetDefaultIcon(bool is_app);
367
[email protected]a807bbe2010-04-14 10:51:19368 // Returns the base extension url for a given |extension_id|.
369 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
370
[email protected]be7e5cb2010-10-04 12:53:17371 // Adds an extension to the scripting whitelist. Used for testing only.
[email protected]10fb1992010-10-08 09:00:17372 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
[email protected]2a521c52011-01-26 18:45:21373 static const ScriptingWhitelist* GetScriptingWhitelist();
[email protected]be7e5cb2010-10-04 12:53:17374
[email protected]902fd7b2011-07-27 18:42:31375 // Parses the host and api permissions from the specified permission |key|
376 // in the manifest |source|.
377 bool ParsePermissions(const base::DictionaryValue* source,
378 const char* key,
379 int flags,
380 std::string* error,
381 ExtensionAPIPermissionSet* api_permissions,
382 URLPatternSet* host_permissions);
383
[email protected]0d3e4a22011-06-23 19:02:52384 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const;
385 bool HasAPIPermission(const std::string& function_name) const;
[email protected]583d45c12010-08-31 02:48:12386
[email protected]0d3e4a22011-06-23 19:02:52387 const URLPatternSet& GetEffectiveHostPermissions() const;
[email protected]b24d8312009-08-27 06:47:46388
[email protected]902fd7b2011-07-27 18:42:31389 // Returns true if the extension can silently increase its permission level.
390 // Extensions that can silently increase permissions are installed through
391 // mechanisms that are implicitly trusted.
392 bool CanSilentlyIncreasePermissions() const;
393
[email protected]fbd17cf2010-04-28 23:52:56394
[email protected]584b8e3f2010-04-10 00:23:37395 // Whether the extension has access to the given URL.
396 bool HasHostPermission(const GURL& url) const;
397
[email protected]0df165f2010-09-28 16:49:40398 // Whether the extension has effective access to all hosts. This is true if
399 // there is a content script that matches all hosts, if there is a host
400 // permission grants access to all hosts (like <all_urls>) or an api
401 // permission that effectively grants access to all hosts (e.g. proxy,
402 // network, etc.)
403 bool HasEffectiveAccessToAllHosts() const;
[email protected]b24d8312009-08-27 06:47:46404
[email protected]8d888c12010-11-30 00:00:25405 // Whether the extension effectively has all permissions (for example, by
406 // having an NPAPI plugin).
407 bool HasFullPermissions() const;
408
[email protected]902fd7b2011-07-27 18:42:31409 // Returns the full list of permission messages that this extension
410 // should display at install time.
411 ExtensionPermissionMessages GetPermissionMessages() const;
412
413 // Returns the full list of permission messages that this extension
414 // should display at install time. The messages are returned as strings
415 // for convenience.
416 std::vector<string16> GetPermissionMessageStrings() const;
417
418 // Sets the active |permissions|.
419 void SetActivePermissions(const ExtensionPermissionSet* permissions) const;
420
421 // Gets the extension's active permission set.
422 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
423
[email protected]5df6a5d2011-01-26 07:39:12424 // Whether context menu should be shown for page and browser actions.
425 bool ShowConfigureContextMenus() const;
426
[email protected]b6cf240f2011-10-15 22:09:53427 // Whether network requests should be delayed on browser startup until the
428 // extension's background page has loaded, even if the extension doesn't
429 // explicitly request a delay.
430 bool ImplicitlyDelaysNetworkStartup() const;
431
[email protected]37cd64d2010-10-25 18:17:58432 // Returns the Homepage URL for this extension. If homepage_url was not
433 // specified in the manifest, this returns the Google Gallery URL. For
[email protected]bfa90a3a2010-04-28 15:43:23434 // third-party extensions, this returns a blank GURL.
[email protected]37cd64d2010-10-25 18:17:58435 GURL GetHomepageURL() const;
[email protected]bfa90a3a2010-04-28 15:43:23436
[email protected]facd7a7652009-06-05 23:15:02437 // Returns a list of paths (relative to the extension dir) for images that
438 // the browser might load (like themes and page action icons).
[email protected]9adb9692010-10-29 23:14:02439 std::set<FilePath> GetBrowserImages() const;
[email protected]facd7a7652009-06-05 23:15:02440
[email protected]807871f2010-09-16 01:04:48441 // Get an extension icon as a resource or URL.
[email protected]9adb9692010-10-29 23:14:02442 ExtensionResource GetIconResource(
443 int size, ExtensionIconSet::MatchType match_type) const;
444 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
[email protected]f34e79632010-03-17 02:34:08445
[email protected]867a73e12010-03-19 20:45:46446 // Gets the fully resolved absolute launch URL.
447 GURL GetFullLaunchURL() const;
[email protected]2a521c52011-01-26 18:45:21448
[email protected]6f229e82010-11-02 17:47:26449 // Image cache related methods. These are only valid on the UI thread and
450 // not maintained by this class. See ImageLoadingTracker for usage. The
451 // |original_size| parameter should be the size of the image at |source|
452 // before any scaling may have been done to produce the pixels in |image|.
453 void SetCachedImage(const ExtensionResource& source,
454 const SkBitmap& image,
455 const gfx::Size& original_size) const;
456 bool HasCachedImage(const ExtensionResource& source,
457 const gfx::Size& max_size) const;
458 SkBitmap GetCachedImage(const ExtensionResource& source,
459 const gfx::Size& max_size) const;
[email protected]2a521c52011-01-26 18:45:21460
461 // Returns true if this extension can execute script on a page. If a
462 // UserScript object is passed, permission to run that specific script is
463 // checked (using its matches list). Otherwise, permission to execute script
464 // programmatically is checked (using the extension's host permission).
465 //
466 // This method is also aware of certain special pages that extensions are
467 // usually not allowed to run script on.
468 bool CanExecuteScriptOnPage(const GURL& page_url,
[email protected]3aff9ad2011-04-01 20:26:48469 const UserScript* script,
[email protected]2a521c52011-01-26 18:45:21470 std::string* error) const;
471
[email protected]6f229e82010-11-02 17:47:26472 // Returns true if this extension is a COMPONENT extension, or if it is
473 // on the whitelist of extensions that can script all pages.
474 bool CanExecuteScriptEverywhere() const;
475
[email protected]5efbfe012011-02-22 23:07:18476 // Returns true if this extension is allowed to obtain the contents of a
477 // page as an image. Since a page may contain sensitive information, this
478 // is restricted to the extension's host permissions as well as the
479 // extension page itself.
480 bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const;
481
[email protected]a65882c2010-11-12 15:15:09482 // Returns true if this extension updates itself using the extension
483 // gallery.
484 bool UpdatesFromGallery() const;
485
[email protected]cca147172011-02-17 01:29:29486 // Returns true if this extension or app includes areas within |origin|.
487 bool OverlapsWithOrigin(const GURL& origin) const;
488
[email protected]3bdba0d2011-08-23 07:17:30489 // Returns the sync bucket to use for this extension.
490 SyncType GetSyncType() const;
491
[email protected]6f229e82010-11-02 17:47:26492 // Accessors:
493
494 const FilePath& path() const { return path_; }
495 const GURL& url() const { return extension_url_; }
496 Location location() const { return location_; }
497 const std::string& id() const { return id_; }
498 const Version* version() const { return version_.get(); }
499 const std::string VersionString() const;
500 const std::string& name() const { return name_; }
501 const std::string& public_key() const { return public_key_; }
502 const std::string& description() const { return description_; }
[email protected]a47c8a22011-11-17 18:40:31503 int manifest_version() const { return manifest_version_; }
[email protected]6f229e82010-11-02 17:47:26504 bool converted_from_user_script() const {
505 return converted_from_user_script_;
506 }
507 const UserScriptList& content_scripts() const { return content_scripts_; }
508 ExtensionAction* page_action() const { return page_action_.get(); }
509 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]e2dffe02011-01-20 20:30:06510 ExtensionSidebarDefaults* sidebar_defaults() const {
511 return sidebar_defaults_.get();
512 }
[email protected]b6b805e92011-04-16 09:24:14513 const FileBrowserHandlerList* file_browser_handlers() const {
514 return file_browser_handlers_.get();
515 }
[email protected]6f229e82010-11-02 17:47:26516 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]65378f52011-04-08 02:31:23517 const std::vector<NaClModuleInfo>& nacl_modules() const {
518 return nacl_modules_;
519 }
[email protected]b0820372011-06-03 07:05:27520 const std::vector<InputComponentInfo>& input_components() const {
521 return input_components_;
522 }
[email protected]6f229e82010-11-02 17:47:26523 const GURL& background_url() const { return background_url_; }
524 const GURL& options_url() const { return options_url_; }
525 const GURL& devtools_url() const { return devtools_url_; }
[email protected]902fd7b2011-07-27 18:42:31526 const ExtensionPermissionSet* optional_permission_set() const {
527 return optional_permission_set_.get();
528 }
529 const ExtensionPermissionSet* required_permission_set() const {
530 return required_permission_set_.get();
[email protected]6f229e82010-11-02 17:47:26531 }
[email protected]6f229e82010-11-02 17:47:26532 const GURL& update_url() const { return update_url_; }
533 const ExtensionIconSet& icons() const { return icons_; }
[email protected]f3a1c642011-07-12 19:15:03534 const base::DictionaryValue* manifest_value() const {
[email protected]6f229e82010-11-02 17:47:26535 return manifest_value_.get();
536 }
537 const std::string default_locale() const { return default_locale_; }
538 const URLOverrideMap& GetChromeURLOverrides() const {
539 return chrome_url_overrides_;
540 }
541 const std::string omnibox_keyword() const { return omnibox_keyword_; }
542 bool incognito_split_mode() const { return incognito_split_mode_; }
[email protected]1abdf4f2011-08-16 21:11:55543 bool offline_enabled() const { return offline_enabled_; }
[email protected]a4a38c12010-12-23 16:43:56544 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
[email protected]56624422011-11-01 22:11:27545 const std::vector<webkit_glue::WebIntentServiceData>&
546 intents_services() const {
547 return intents_services_;
548 }
[email protected]6f229e82010-11-02 17:47:26549
[email protected]3aff9ad2011-04-01 20:26:48550 bool wants_file_access() const { return wants_file_access_; }
[email protected]2af352b2011-07-22 08:21:23551 int creation_flags() const { return creation_flags_; }
552 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
[email protected]e805baf2011-07-26 18:23:05553 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; }
[email protected]3aff9ad2011-04-01 20:26:48554
[email protected]7f7b9d932011-04-20 16:13:26555 const std::string& content_security_policy() const {
556 return content_security_policy_;
557 }
558
[email protected]6f229e82010-11-02 17:47:26559 // App-related.
560 bool is_app() const { return is_app_; }
[email protected]7d3ed2f2011-11-07 23:33:19561 bool is_platform_app() const { return is_platform_app_; }
[email protected]6f229e82010-11-02 17:47:26562 bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); }
563 bool is_packaged_app() const { return is_app() && web_extent().is_empty(); }
[email protected]d9696672011-03-15 22:45:09564 bool is_storage_isolated() const { return is_app() && is_storage_isolated_; }
[email protected]cced75a2011-05-20 08:31:12565 const URLPatternSet& web_extent() const { return extent_; }
[email protected]6f229e82010-11-02 17:47:26566 const std::string& launch_local_path() const { return launch_local_path_; }
567 const std::string& launch_web_url() const { return launch_web_url_; }
568 extension_misc::LaunchContainer launch_container() const {
569 return launch_container_;
570 }
571 int launch_width() const { return launch_width_; }
572 int launch_height() const { return launch_height_; }
573
574 // Theme-related.
575 bool is_theme() const { return is_theme_; }
[email protected]f3a1c642011-07-12 19:15:03576 base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
577 base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); }
578 base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
579 base::DictionaryValue* GetThemeDisplayProperties() const {
[email protected]6f229e82010-11-02 17:47:26580 return theme_display_properties_.get();
581 }
582
[email protected]4a8d3272009-03-10 19:15:08583 private:
[email protected]66e4eb32010-10-27 20:37:41584 friend class base::RefCountedThreadSafe<Extension>;
585
[email protected]d7e9a862010-11-03 21:57:49586 // We keep a cache of images loaded from extension resources based on their
587 // path and a string representation of a size that may have been used to
588 // scale it (or the empty string if the image is at its original size).
589 typedef std::pair<FilePath, std::string> ImageCacheKey;
590 typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
591
[email protected]902fd7b2011-07-27 18:42:31592 class RuntimeData {
593 public:
594 RuntimeData();
595 explicit RuntimeData(const ExtensionPermissionSet* active);
596 ~RuntimeData();
597
598 void SetActivePermissions(const ExtensionPermissionSet* active);
599 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
600
601 private:
602 friend class base::RefCountedThreadSafe<RuntimeData>;
603 scoped_refptr<const ExtensionPermissionSet> active_permissions_;
604 };
605
[email protected]4ead6f72010-10-13 19:54:18606 // Normalize the path for use by the extension. On Windows, this will make
607 // sure the drive letter is uppercase.
608 static FilePath MaybeNormalizePath(const FilePath& path);
609
[email protected]87c655e2011-07-01 21:42:00610 // Returns true if this extension id is from a trusted provider.
611 static bool IsTrustedId(const std::string& id);
612
[email protected]66e4eb32010-10-27 20:37:41613 Extension(const FilePath& path, Location location);
614 ~Extension();
615
616 // Initialize the extension from a parsed manifest.
[email protected]f3a1c642011-07-12 19:15:03617 bool InitFromValue(const base::DictionaryValue& value, int flags,
[email protected]83048a22011-03-29 00:14:13618 std::string* error);
[email protected]66e4eb32010-10-27 20:37:41619
[email protected]052c92702010-06-25 07:25:52620 // Helper function for implementing HasCachedImage/GetCachedImage. A return
621 // value of NULL means there is no matching image cached (we allow caching an
622 // empty SkBitmap).
623 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
[email protected]9adb9692010-10-29 23:14:02624 const gfx::Size& max_size) const;
[email protected]d9ad80f2010-03-30 20:40:18625
[email protected]3cfbd0e2009-03-18 21:26:24626 // Helper method that loads a UserScript object from a
627 // dictionary in the content_script list of the manifest.
[email protected]f3a1c642011-07-12 19:15:03628 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
[email protected]3cfbd0e2009-03-18 21:26:24629 int definition_index,
[email protected]3aff9ad2011-04-01 20:26:48630 int flags,
[email protected]3cfbd0e2009-03-18 21:26:24631 std::string* error,
632 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34633
[email protected]6657afa62009-11-04 02:15:20634 // Helper method that loads either the include_globs or exclude_globs list
635 // from an entry in the content_script lists of the manifest.
[email protected]f3a1c642011-07-12 19:15:03636 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
[email protected]6657afa62009-11-04 02:15:20637 int content_script_index,
[email protected]e2194742010-08-12 05:54:34638 const char* globs_property_name,
[email protected]6657afa62009-11-04 02:15:20639 std::string* error,
[email protected]11f4857282009-11-13 19:56:17640 void(UserScript::*add_method)(const std::string& glob),
[email protected]6657afa62009-11-04 02:15:20641 UserScript *instance);
642
[email protected]867a73e12010-03-19 20:45:46643 // Helpers to load various chunks of the manifest.
[email protected]f3a1c642011-07-12 19:15:03644 bool LoadIsApp(const base::DictionaryValue* manifest, std::string* error);
645 bool LoadExtent(const base::DictionaryValue* manifest,
[email protected]542258c2011-03-04 21:25:31646 const char* key,
[email protected]cced75a2011-05-20 08:31:12647 URLPatternSet* extent,
[email protected]542258c2011-03-04 21:25:31648 const char* list_error,
649 const char* value_error,
650 URLPattern::ParseOption parse_strictness,
651 std::string* error);
[email protected]f3a1c642011-07-12 19:15:03652 bool LoadLaunchContainer(const base::DictionaryValue* manifest,
653 std::string* error);
654 bool LoadLaunchURL(const base::DictionaryValue* manifest,
655 std::string* error);
656 bool LoadAppIsolation(const base::DictionaryValue* manifest,
657 std::string* error);
[email protected]56624422011-11-01 22:11:27658 bool LoadWebIntentServices(const base::DictionaryValue& manifest,
659 std::string* error);
[email protected]f3a1c642011-07-12 19:15:03660 bool EnsureNotHybridApp(const base::DictionaryValue* manifest,
661 std::string* error);
[email protected]867a73e12010-03-19 20:45:46662
[email protected]5d246db22009-10-27 06:17:57663 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08664 // browser_action entries in the manifest.
[email protected]5d246db22009-10-27 06:17:57665 ExtensionAction* LoadExtensionActionHelper(
[email protected]f3a1c642011-07-12 19:15:03666 const base::DictionaryValue* extension_action, std::string* error);
[email protected]92c6f9b92009-10-24 04:35:08667
[email protected]b6b805e92011-04-16 09:24:14668 // Helper method to load an FileBrowserHandlerList from the manifest.
669 FileBrowserHandlerList* LoadFileBrowserHandlers(
[email protected]f3a1c642011-07-12 19:15:03670 const base::ListValue* extension_actions, std::string* error);
[email protected]b6b805e92011-04-16 09:24:14671 // Helper method to load an FileBrowserHandler from manifest.
672 FileBrowserHandler* LoadFileBrowserHandler(
[email protected]f3a1c642011-07-12 19:15:03673 const base::DictionaryValue* file_browser_handlers, std::string* error);
[email protected]b6b805e92011-04-16 09:24:14674
[email protected]e2dffe02011-01-20 20:30:06675 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
676 // entry.
677 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
[email protected]f3a1c642011-07-12 19:15:03678 const base::DictionaryValue* sidebar, std::string* error);
[email protected]e2dffe02011-01-20 20:30:06679
[email protected]2f6698b2010-10-14 00:58:21680 // Returns true if the extension has more than one "UI surface". For example,
681 // an extension that has a browser action and a page action.
682 bool HasMultipleUISurfaces() const;
683
[email protected]e2eb43112009-05-29 21:19:54684 // Figures out if a source contains keys not associated with themes - we
685 // don't want to allow scripts and such to be bundled with themes.
[email protected]f3a1c642011-07-12 19:15:03686 bool ContainsNonThemeKeys(const base::DictionaryValue& source) const;
[email protected]e2eb43112009-05-29 21:19:54687
[email protected]be9d9c82011-07-13 04:17:31688 // Updates the launch URL and extents for the extension using the given
689 // |override_url|.
690 void OverrideLaunchUrl(const GURL& override_url);
691
[email protected]5eddc3e2011-10-26 04:33:31692 // Returns true if this extension can specify |api|.
693 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api,
694 std::string* error) const;
695 bool CanSpecifyComponentOnlyPermission() const;
696 bool CanSpecifyExperimentalPermission() const;
697 bool CanSpecifyPermissionForHostedApp(
698 const ExtensionAPIPermission* api) const;
699
700 // Checks whether the host |pattern| is allowed for this extension, given API
701 // permissions |permissions|.
702 bool CanSpecifyHostPermission(const URLPattern& pattern,
703 const ExtensionAPIPermissionSet& permissions) const;
704
[email protected]d7e9a862010-11-03 21:57:49705 // Cached images for this extension. This should only be touched on the UI
706 // thread.
707 mutable ImageCache image_cache_;
[email protected]1e8c93f2010-02-08 22:58:31708
[email protected]6f229e82010-11-02 17:47:26709 // A persistent, globally unique ID. An extension's ID is used in things
710 // like directory structures and URLs, and is expected to not change across
711 // versions. It is generated as a SHA-256 hash of the extension's public
712 // key, or as a hash of the path in the case of unpacked extensions.
713 std::string id_;
714
715 // The extension's human-readable name. Name is used for display purpose. It
716 // might be wrapped with unicode bidi control characters so that it is
717 // displayed correctly in RTL context.
718 // NOTE: Name is UTF-8 and may contain non-ascii characters.
719 std::string name_;
720
721 // The absolute path to the directory the extension is stored in.
722 FilePath path_;
723
[email protected]a47c8a22011-11-17 18:40:31724 // The version of this extension's manifest. We increase the manifest
725 // version when making breaking changes to the extension system.
726 // Version 1 was the first manifest version (implied by a lack of a
727 // manifest_version attribute in the extension's manifest). We initialize
728 // this member variable to 0 to distinguish the "uninitialized" case from
729 // the case when we know the manifest version actually is 1.
730 int manifest_version_;
731
[email protected]6f229e82010-11-02 17:47:26732 // Default locale for fall back. Can be empty if extension is not localized.
733 std::string default_locale_;
734
735 // If true, a separate process will be used for the extension in incognito
736 // mode.
737 bool incognito_split_mode_;
738
[email protected]1abdf4f2011-08-16 21:11:55739 // Whether the extension or app should be enabled when offline.
740 bool offline_enabled_;
741
[email protected]6f229e82010-11-02 17:47:26742 // Defines the set of URLs in the extension's web content.
[email protected]cced75a2011-05-20 08:31:12743 URLPatternSet extent_;
[email protected]6f229e82010-11-02 17:47:26744
[email protected]902fd7b2011-07-27 18:42:31745 // The extension runtime data.
746 mutable base::Lock runtime_data_lock_;
747 mutable RuntimeData runtime_data_;
748
749 // The set of permissions the extension can request at runtime.
750 scoped_refptr<const ExtensionPermissionSet> optional_permission_set_;
751
752 // The extension's required / default set of permissions.
753 scoped_refptr<const ExtensionPermissionSet> required_permission_set_;
[email protected]6f229e82010-11-02 17:47:26754
755 // The icons for the extension.
756 ExtensionIconSet icons_;
757
758 // The base extension url for the extension.
759 GURL extension_url_;
760
761 // The location the extension was loaded from.
762 Location location_;
763
764 // The extension's version.
765 scoped_ptr<Version> version_;
766
767 // An optional longer description of the extension.
768 std::string description_;
769
770 // True if the extension was generated from a user script. (We show slightly
771 // different UI if so).
772 bool converted_from_user_script_;
773
774 // Paths to the content scripts the extension contains.
775 UserScriptList content_scripts_;
776
777 // The extension's page action, if any.
778 scoped_ptr<ExtensionAction> page_action_;
779
780 // The extension's browser action, if any.
781 scoped_ptr<ExtensionAction> browser_action_;
782
[email protected]b6b805e92011-04-16 09:24:14783 // The extension's file browser actions, if any.
784 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
785
[email protected]e2dffe02011-01-20 20:30:06786 // The extension's sidebar, if any.
787 scoped_ptr<ExtensionSidebarDefaults> sidebar_defaults_;
788
[email protected]6f229e82010-11-02 17:47:26789 // Optional list of NPAPI plugins and associated properties.
790 std::vector<PluginInfo> plugins_;
791
[email protected]65378f52011-04-08 02:31:23792 // Optional list of NaCl modules and associated properties.
793 std::vector<NaClModuleInfo> nacl_modules_;
794
[email protected]b0820372011-06-03 07:05:27795 // Optional list of input components and associated properties.
796 std::vector<InputComponentInfo> input_components_;
797
[email protected]6f229e82010-11-02 17:47:26798 // Optional URL to a master page of which a single instance should be always
799 // loaded in the background.
800 GURL background_url_;
801
802 // Optional URL to a page for setting options/preferences.
803 GURL options_url_;
804
805 // Optional URL to a devtools extension page.
806 GURL devtools_url_;
807
[email protected]6f229e82010-11-02 17:47:26808 // The public key used to sign the contents of the crx package.
809 std::string public_key_;
810
811 // A map of resource id's to relative file paths.
[email protected]f3a1c642011-07-12 19:15:03812 scoped_ptr<base::DictionaryValue> theme_images_;
[email protected]6f229e82010-11-02 17:47:26813
814 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03815 scoped_ptr<base::DictionaryValue> theme_colors_;
[email protected]6f229e82010-11-02 17:47:26816
817 // A map of color names to colors.
[email protected]f3a1c642011-07-12 19:15:03818 scoped_ptr<base::DictionaryValue> theme_tints_;
[email protected]6f229e82010-11-02 17:47:26819
820 // A map of display properties.
[email protected]f3a1c642011-07-12 19:15:03821 scoped_ptr<base::DictionaryValue> theme_display_properties_;
[email protected]6f229e82010-11-02 17:47:26822
823 // Whether the extension is a theme.
824 bool is_theme_;
825
[email protected]6f229e82010-11-02 17:47:26826 // The homepage for this extension. Useful if it is not hosted by Google and
827 // therefore does not have a Gallery URL.
828 GURL homepage_url_;
829
830 // URL for fetching an update manifest
831 GURL update_url_;
832
833 // A copy of the manifest that this extension was created from.
[email protected]f3a1c642011-07-12 19:15:03834 scoped_ptr<base::DictionaryValue> manifest_value_;
[email protected]6f229e82010-11-02 17:47:26835
836 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
837 // which override the handling of those URLs. (see ExtensionOverrideUI).
838 URLOverrideMap chrome_url_overrides_;
839
840 // Whether this extension uses app features.
841 bool is_app_;
842
[email protected]7d3ed2f2011-11-07 23:33:19843 // Whether this app uses platform features.
844 bool is_platform_app_;
845
[email protected]d9696672011-03-15 22:45:09846 // Whether this extension requests isolated storage.
847 bool is_storage_isolated_;
848
[email protected]6f229e82010-11-02 17:47:26849 // The local path inside the extension to use with the launcher.
850 std::string launch_local_path_;
851
852 // A web url to use with the launcher. Note that this might be relative or
853 // absolute. If relative, it is relative to web_origin.
854 std::string launch_web_url_;
855
[email protected]4e595682011-02-09 17:07:02856 // The window type that an app's manifest specifies to launch into.
857 // This is not always the window type an app will open into, because
858 // users can override the way each app launches. See
859 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
860 // to decide what container an app will launch in.
[email protected]6f229e82010-11-02 17:47:26861 extension_misc::LaunchContainer launch_container_;
862
863 // The default size of the container when launching. Only respected for
864 // containers like panels and windows.
865 int launch_width_;
866 int launch_height_;
867
868 // The Omnibox keyword for this extension, or empty if there is none.
869 std::string omnibox_keyword_;
870
[email protected]a4a38c12010-12-23 16:43:56871 // List of text-to-speech voices that this extension provides, if any.
872 std::vector<TtsVoice> tts_voices_;
873
[email protected]56624422011-11-01 22:11:27874 // List of intent services that this extension provides, if any.
875 std::vector<webkit_glue::WebIntentServiceData> intents_services_;
[email protected]be5f007862011-09-23 00:35:13876
[email protected]3aff9ad2011-04-01 20:26:48877 // Whether the extension has host permissions or user script patterns that
878 // imply access to file:/// scheme URLs (the user may not have actually
879 // granted it that access).
880 bool wants_file_access_;
881
[email protected]2af352b2011-07-22 08:21:23882 // The flags that were passed to InitFromValue.
883 int creation_flags_;
[email protected]620db1762011-07-15 21:57:34884
[email protected]7f7b9d932011-04-20 16:13:26885 // The Content-Security-Policy for this extension. Extensions can use
886 // Content-Security-Policies to mitigate cross-site scripting and other
887 // vulnerabilities.
888 std::string content_security_policy_;
889
[email protected]eaa7dd182010-12-14 11:09:00890 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
[email protected]5eb375e92010-11-26 07:50:41891 UpdateExtensionPreservesLocation);
[email protected]19118d52010-07-26 22:13:42892 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
893 FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58894
[email protected]894bb502009-05-21 22:39:57895 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33896};
897
[email protected]9adb9692010-10-29 23:14:02898typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
[email protected]ec5b50d2010-10-09 16:35:18899typedef std::set<std::string> ExtensionIdSet;
[email protected]b1748b1d82009-11-30 20:32:56900
[email protected]c6d474f82009-12-16 21:11:06901// Handy struct to pass core extension info around.
902struct ExtensionInfo {
[email protected]f3a1c642011-07-12 19:15:03903 ExtensionInfo(const base::DictionaryValue* manifest,
[email protected]c6d474f82009-12-16 21:11:06904 const std::string& id,
905 const FilePath& path,
[email protected]3bb84992010-08-26 17:23:46906 Extension::Location location);
907 ~ExtensionInfo();
[email protected]c6d474f82009-12-16 21:11:06908
[email protected]f3a1c642011-07-12 19:15:03909 scoped_ptr<base::DictionaryValue> extension_manifest;
[email protected]c6d474f82009-12-16 21:11:06910 std::string extension_id;
911 FilePath extension_path;
912 Extension::Location extension_location;
913
914 private:
915 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
916};
917
[email protected]a9f39a312010-12-23 22:14:27918struct UnloadedExtensionInfo {
[email protected]814a7bf0f2011-08-13 05:30:59919 extension_misc::UnloadedExtensionReason reason;
[email protected]a9f39a312010-12-23 22:14:27920
921 // Was the extension already disabled?
922 bool already_disabled;
923
924 // The extension being unloaded - this should always be non-NULL.
925 const Extension* extension;
926
[email protected]814a7bf0f2011-08-13 05:30:59927 UnloadedExtensionInfo(
928 const Extension* extension,
929 extension_misc::UnloadedExtensionReason reason);
[email protected]a9f39a312010-12-23 22:14:27930};
931
[email protected]902fd7b2011-07-27 18:42:31932// The details sent for EXTENSION_PERMISSIONS_UPDATED notifications.
933struct UpdatedExtensionPermissionsInfo {
934 enum Reason {
935 ADDED, // The permissions were added to the extension.
936 REMOVED, // The permissions were removed from the extension.
937 };
938
939 Reason reason;
940
941 // The extension who's permissions have changed.
942 const Extension* extension;
943
944 // The permissions that have changed. For Reason::ADDED, this would contain
945 // only the permissions that have added, and for Reason::REMOVED, this would
946 // only contain the removed permissions.
947 const ExtensionPermissionSet* permissions;
948
949 UpdatedExtensionPermissionsInfo(
950 const Extension* extension,
951 const ExtensionPermissionSet* permissions,
952 Reason reason);
953};
954
[email protected]5b1a0e22009-05-26 19:00:58955#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_