blob: da65d7d1fbba0057d2939fb5bc4720fd54573d6f [file] [log] [blame]
[email protected]7eeab9ec2013-01-15 04:08:331// Copyright (c) 2013 The Chromium Authors. All rights reserved.
[email protected]7713d632008-12-02 07:52:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5b1a0e22009-05-26 19:00:585#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_
6#define CHROME_COMMON_EXTENSIONS_EXTENSION_H_
[email protected]7713d632008-12-02 07:52:337
[email protected]8629c542012-04-20 03:40:038#include <algorithm>
[email protected]18049dc2012-06-19 23:12:559#include <iosfwd>
[email protected]300cc58db2009-08-19 20:45:1410#include <map>
[email protected]facd7a7652009-06-05 23:15:0211#include <set>
[email protected]7713d632008-12-02 07:52:3312#include <string>
[email protected]58f62cf2012-03-09 10:45:1113#include <utility>
[email protected]7713d632008-12-02 07:52:3314#include <vector>
15
[email protected]57999812013-02-24 05:40:5216#include "base/files/file_path.h"
[email protected]8f270be2011-12-21 21:15:2217#include "base/hash_tables.h"
[email protected]b6b805e92011-04-16 09:24:1418#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1519#include "base/memory/ref_counted.h"
20#include "base/memory/scoped_ptr.h"
[email protected]902fd7b2011-07-27 18:42:3121#include "base/synchronization/lock.h"
[email protected]7eeab9ec2013-01-15 04:08:3322#include "base/threading/thread_checker.h"
[email protected]d83a5602010-09-16 00:22:4823#include "chrome/common/extensions/extension_constants.h"
[email protected]807871f2010-09-16 01:04:4824#include "chrome/common/extensions/extension_icon_set.h"
[email protected]702d8b42013-02-27 20:55:5025#include "chrome/common/extensions/extension_resource.h"
[email protected]1d5e58b2013-01-31 08:41:4026#include "chrome/common/extensions/manifest.h"
[email protected]bebe1d02012-08-02 20:17:0927#include "chrome/common/extensions/permissions/api_permission.h"
28#include "chrome/common/extensions/permissions/permission_message.h"
[email protected]885c0e92012-11-13 20:27:4229#include "chrome/common/extensions/user_script.h"
[email protected]1d5e58b2013-01-31 08:41:4030#include "extensions/common/install_warning.h"
[email protected]885c0e92012-11-13 20:27:4231#include "extensions/common/url_pattern.h"
[email protected]e9f541a2012-11-19 21:52:3132#include "extensions/common/url_pattern_set.h"
[email protected]eab9b452009-01-23 20:48:5933#include "googleurl/src/gurl.h"
[email protected]f5532472012-02-23 13:00:5534#include "ui/base/accelerators/accelerator.h"
[email protected]08397d52011-02-05 01:53:3835#include "ui/gfx/size.h"
[email protected]eab9b452009-01-23 20:48:5936
[email protected]0f34d9082012-10-08 19:16:4437class ExtensionAction;
[email protected]12802702010-07-09 19:43:0938class SkBitmap;
[email protected]daf66aa2010-08-06 06:24:2839class Version;
[email protected]942690b132010-05-11 06:42:1440
[email protected]f3a1c642011-07-12 19:15:0341namespace base {
42class DictionaryValue;
43class ListValue;
44}
45
[email protected]0f34d9082012-10-08 19:16:4446namespace gfx {
47class ImageSkia;
48}
49
[email protected]1c321ee2012-05-21 03:02:3450namespace extensions {
[email protected]972b02f2013-01-28 20:38:1451struct ActionInfo;
[email protected]465594632013-02-15 19:50:2852class APIPermissionSet;
[email protected]bebe1d02012-08-02 20:17:0953class PermissionSet;
[email protected]1c321ee2012-05-21 03:02:3454
[email protected]f0755532010-06-22 07:27:2555// Represents a Chrome extension.
[email protected]512b8772013-02-23 01:20:2456// Once created, an Extension object is immutable, with the exception of its
57// RuntimeData. This makes it safe to use on any thread, since access to the
58// RuntimeData is protected by a lock.
[email protected]66e4eb32010-10-27 20:37:4159class Extension : public base::RefCountedThreadSafe<Extension> {
[email protected]7713d632008-12-02 07:52:3360 public:
[email protected]d356c982012-12-12 19:32:5561 struct ManifestData;
[email protected]1e0f45a2012-06-13 00:31:0662
[email protected]10fb1992010-10-08 09:00:1763 typedef std::vector<std::string> ScriptingWhitelist;
[email protected]d356c982012-12-12 19:32:5564 typedef std::map<const std::string, linked_ptr<ManifestData> >
65 ManifestDataMap;
[email protected]b24d8312009-08-27 06:47:4666
[email protected]25b34332009-06-05 21:53:1967 enum State {
[email protected]0c6da502009-08-14 22:32:3968 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1969 ENABLED,
[email protected]79c833b52011-04-05 18:31:0170 // An external extension that the user uninstalled. We should not reinstall
71 // such extensions on startup.
72 EXTERNAL_EXTENSION_UNINSTALLED,
[email protected]8c484b742012-11-29 06:05:3673 // Special state for component extensions, since they are always loaded by
74 // the component loader, and should never be auto-installed on startup.
75 ENABLED_COMPONENT,
[email protected]0c6da502009-08-14 22:32:3976 NUM_STATES
[email protected]631cf822009-05-15 07:01:2577 };
[email protected]7713d632008-12-02 07:52:3378
[email protected]44d62b62012-04-11 00:06:0379 // Used to record the reason an extension was disabled.
[email protected]eb5e4f92012-08-15 23:33:2880 enum DeprecatedDisableReason {
81 DEPRECATED_DISABLE_UNKNOWN,
82 DEPRECATED_DISABLE_USER_ACTION,
83 DEPRECATED_DISABLE_PERMISSIONS_INCREASE,
84 DEPRECATED_DISABLE_RELOAD,
85 DEPRECATED_DISABLE_LAST, // Not used.
86 };
87
[email protected]44d62b62012-04-11 00:06:0388 enum DisableReason {
[email protected]eb5e4f92012-08-15 23:33:2889 DISABLE_NONE = 0,
90 DISABLE_USER_ACTION = 1 << 0,
91 DISABLE_PERMISSIONS_INCREASE = 1 << 1,
92 DISABLE_RELOAD = 1 << 2,
[email protected]215a7be2012-10-22 19:53:4293 DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3,
94 DISABLE_SIDELOAD_WIPEOUT = 1 << 4,
[email protected]f56c65ea62012-12-10 22:57:2195 DISABLE_UNKNOWN_FROM_SYNC = 1 << 5,
[email protected]44d62b62012-04-11 00:06:0396 };
97
[email protected]fbcc40302009-06-12 20:45:4598 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:3799 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:45100 DOWNGRADE,
101 REINSTALL,
102 UPGRADE,
103 NEW_INSTALL
104 };
105
[email protected]3bdba0d2011-08-23 07:17:30106 enum SyncType {
107 SYNC_TYPE_NONE = 0,
108 SYNC_TYPE_EXTENSION,
109 SYNC_TYPE_APP
110 };
111
[email protected]98270432012-09-11 20:51:24112 // Declared requirements for the extension.
113 struct Requirements {
114 Requirements();
115 ~Requirements();
116
117 bool webgl;
118 bool css3d;
119 bool npapi;
120 };
121
[email protected]92888082010-10-18 19:24:57122 // An NPAPI plugin included in the extension.
123 struct PluginInfo {
[email protected]a7329162013-02-07 19:21:48124 base::FilePath path; // Path to the plugin.
[email protected]92888082010-10-18 19:24:57125 bool is_public; // False if only this extension can load this plugin.
126 };
127
[email protected]65378f52011-04-08 02:31:23128 // An NaCl module included in the extension.
129 struct NaClModuleInfo {
[email protected]84396dbc2011-04-14 06:33:42130 GURL url;
[email protected]65378f52011-04-08 02:31:23131 std::string mime_type;
132 };
133
[email protected]d356c982012-12-12 19:32:55134 // A base class for parsed manifest data that APIs want to store on
135 // the extension. Related to base::SupportsUserData, but with an immutable
136 // thread-safe interface to match Extension.
137 struct ManifestData {
138 virtual ~ManifestData() {}
139 };
140
[email protected]83048a22011-03-29 00:14:13141 enum InitFromValueFlags {
142 NO_FLAGS = 0,
143
144 // Usually, the id of an extension is generated by the "key" property of
145 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
146 // generated based on the path.
147 REQUIRE_KEY = 1 << 0,
148
[email protected]3f53dfe2011-11-30 01:18:29149 // Requires the extension to have an up-to-date manifest version.
150 // Typically, we'll support multiple manifest versions during a version
[email protected]26367b62012-10-04 23:03:32151 // transition. This flag signals that we want to require the most modern
[email protected]3f53dfe2011-11-30 01:18:29152 // manifest version that Chrome understands.
153 REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1,
154
[email protected]3aff9ad2011-04-01 20:26:48155 // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension
156 // to have file access. If it's not present, then permissions and content
157 // scripts that match file:/// URLs will be filtered out.
[email protected]ed3b9b12012-05-31 18:37:51158 ALLOW_FILE_ACCESS = 1 << 2,
[email protected]620db1762011-07-15 21:57:34159
160 // |FROM_WEBSTORE| indicates that the extension was installed from the
161 // Chrome Web Store.
[email protected]ed3b9b12012-05-31 18:37:51162 FROM_WEBSTORE = 1 << 3,
[email protected]e805baf2011-07-26 18:23:05163
164 // |FROM_BOOKMARK| indicates the extension was created using a mock App
165 // created from a bookmark.
[email protected]ed3b9b12012-05-31 18:37:51166 FROM_BOOKMARK = 1 << 4,
[email protected]3d41d432012-04-20 20:47:58167
168 // |FOLLOW_SYMLINKS_ANYWHERE| means that resources can be symlinks to
169 // anywhere in the filesystem, rather than being restricted to the
170 // extension directory.
[email protected]ed3b9b12012-05-31 18:37:51171 FOLLOW_SYMLINKS_ANYWHERE = 1 << 5,
[email protected]ab55c2b2012-06-01 23:55:03172
173 // |ERROR_ON_PRIVATE_KEY| means that private keys inside an
174 // extension should be errors rather than warnings.
175 ERROR_ON_PRIVATE_KEY = 1 << 6,
[email protected]e33bbc22012-08-27 22:05:46176
177 // |WAS_INSTALLED_BY_DEFAULT| installed by default when the profile was
178 // created.
179 WAS_INSTALLED_BY_DEFAULT = 1 << 7,
[email protected]83048a22011-03-29 00:14:13180 };
181
[email protected]a7329162013-02-07 19:21:48182 static scoped_refptr<Extension> Create(const base::FilePath& path,
[email protected]1d5e58b2013-01-31 08:41:40183 Manifest::Location location,
[email protected]f3a1c642011-07-12 19:15:03184 const base::DictionaryValue& value,
[email protected]83048a22011-03-29 00:14:13185 int flags,
[email protected]66e4eb32010-10-27 20:37:41186 std::string* error);
187
[email protected]87c655e2011-07-01 21:42:00188 // In a few special circumstances, we want to create an Extension and give it
[email protected]f5bf1842012-02-15 02:52:26189 // an explicit id. Most consumers should just use the other Create() method.
[email protected]a7329162013-02-07 19:21:48190 static scoped_refptr<Extension> Create(const base::FilePath& path,
[email protected]1d5e58b2013-01-31 08:41:40191 Manifest::Location location,
[email protected]58f62cf2012-03-09 10:45:11192 const base::DictionaryValue& value,
193 int flags,
194 const std::string& explicit_id,
195 std::string* error);
[email protected]87c655e2011-07-01 21:42:00196
[email protected]8d888c12010-11-30 00:00:25197 // Valid schemes for web extent URLPatterns.
198 static const int kValidWebExtentSchemes;
199
[email protected]f71f7e62010-12-07 03:45:33200 // Valid schemes for host permission URLPatterns.
201 static const int kValidHostPermissionSchemes;
202
[email protected]6014d672008-12-05 00:38:25203 // The name of the manifest inside an extension.
[email protected]a7329162013-02-07 19:21:48204 static const base::FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25205
[email protected]300cc58db2009-08-19 20:45:14206 // The name of locale folder inside an extension.
[email protected]a7329162013-02-07 19:21:48207 static const base::FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14208
209 // The name of the messages file inside an extension.
[email protected]a7329162013-02-07 19:21:48210 static const base::FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14211
[email protected]25b34332009-06-05 21:53:19212#if defined(OS_WIN)
[email protected]9dcf8f12010-09-02 20:39:19213 static const char kExtensionRegistryPath[];
[email protected]25b34332009-06-05 21:53:19214#endif
215
[email protected]37eeb5a2009-02-26 23:36:17216 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48217 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17218
[email protected]e435d6b72009-07-25 03:15:58219 // The mimetype used for extensions.
220 static const char kMimeType[];
221
[email protected]25b34332009-06-05 21:53:19222 // Checks to see if the extension has a valid ID.
223 static bool IdIsValid(const std::string& id);
224
[email protected]4ead6f72010-10-13 19:54:18225 // Generate an ID for an extension in the given path.
[email protected]28d7479b2011-03-09 21:33:27226 // Used while developing extensions, before they have a key.
[email protected]a7329162013-02-07 19:21:48227 static std::string GenerateIdForPath(const base::FilePath& file_name);
[email protected]4ead6f72010-10-13 19:54:18228
[email protected]e435d6b72009-07-25 03:15:58229 // Returns true if the specified file is an extension.
[email protected]a7329162013-02-07 19:21:48230 static bool IsExtension(const base::FilePath& file_name);
[email protected]e435d6b72009-07-25 03:15:58231
[email protected]fc6b0612012-03-29 13:40:06232 // Fills the |info| dictionary with basic information about the extension.
233 // |enabled| is injected for easier testing.
234 void GetBasicInfo(bool enabled, base::DictionaryValue* info) const;
235
[email protected]1d5e58b2013-01-31 08:41:40236 // See Type definition in Manifest.
237 Manifest::Type GetType() const;
[email protected]9b217652010-10-08 22:04:23238
[email protected]07c00d992009-03-04 20:27:04239 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59240 // |extension_url| argument should be the url() from an Extension object. The
241 // |relative_path| can be untrusted user input. The returned URL will either
242 // be invalid() or a child of |extension_url|.
243 // NOTE: Static so that it can be used from multiple threads.
244 static GURL GetResourceURL(const GURL& extension_url,
245 const std::string& relative_path);
[email protected]cffd7892010-08-26 17:43:28246 GURL GetResourceURL(const std::string& relative_path) const {
[email protected]3cfbd0e2009-03-18 21:26:24247 return GetResourceURL(url(), relative_path);
248 }
[email protected]eab9b452009-01-23 20:48:59249
[email protected]f59a8052012-06-20 22:25:00250 // Returns true if the resource matches a pattern in the pattern_set.
251 bool ResourceMatches(const URLPatternSet& pattern_set,
252 const std::string& resource) const;
253
[email protected]dbb24162012-06-06 01:41:22254 // Returns true if the specified page is sandboxed (served in a unique
255 // origin).
256 bool IsSandboxedPage(const std::string& relative_path) const;
257
258 // Returns the Content Security Policy that the specified resource should be
259 // served with.
260 std::string GetResourceContentSecurityPolicy(const std::string& relative_path)
261 const;
262
[email protected]99efb7b12009-12-18 02:39:16263 // Returns an extension resource object. |relative_path| should be UTF8
264 // encoded.
[email protected]9adb9692010-10-29 23:14:02265 ExtensionResource GetResource(const std::string& relative_path) const;
[email protected]99efb7b12009-12-18 02:39:16266
267 // As above, but with |relative_path| following the file system's encoding.
[email protected]a7329162013-02-07 19:21:48268 ExtensionResource GetResource(const base::FilePath& relative_path) const;
[email protected]eab9b452009-01-23 20:48:59269
[email protected]a17f9462009-06-09 02:56:41270 // |input| is expected to be the text of an rsa public or private key. It
271 // tolerates the presence or absence of bracking header/footer like this:
272 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
273 // and may contain newlines.
274 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
275
276 // Does a simple base64 encoding of |input| into |output|.
277 static bool ProducePEM(const std::string& input, std::string* output);
278
[email protected]84ac7f32009-10-06 06:17:54279 // Generates an extension ID from arbitrary input. The same input string will
280 // always generate the same output ID.
[email protected]af9db5f2011-10-05 05:13:15281 static bool GenerateId(const std::string& input,
282 std::string* output) WARN_UNUSED_RESULT;
[email protected]fbcc40302009-06-12 20:45:45283
[email protected]a17f9462009-06-09 02:56:41284 // Expects base64 encoded |input| and formats into |output| including
285 // the appropriate header & footer.
[email protected]e0d08192011-03-29 19:02:50286 static bool FormatPEMForFileOutput(const std::string& input,
287 std::string* output,
288 bool is_public);
[email protected]a17f9462009-06-09 02:56:41289
[email protected]a807bbe2010-04-14 10:51:19290 // Returns the base extension url for a given |extension_id|.
291 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
292
[email protected]be7e5cb2010-10-04 12:53:17293 // Adds an extension to the scripting whitelist. Used for testing only.
[email protected]10fb1992010-10-08 09:00:17294 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
[email protected]2a521c52011-01-26 18:45:21295 static const ScriptingWhitelist* GetScriptingWhitelist();
[email protected]be7e5cb2010-10-04 12:53:17296
[email protected]902fd7b2011-07-27 18:42:31297 // Parses the host and api permissions from the specified permission |key|
[email protected]d41e2152012-02-24 04:20:27298 // from |manifest_|.
299 bool ParsePermissions(const char* key,
[email protected]fc670822011-12-17 09:33:49300 string16* error,
[email protected]c2e66e12012-06-27 06:27:06301 APIPermissionSet* api_permissions,
[email protected]902fd7b2011-07-27 18:42:31302 URLPatternSet* host_permissions);
303
[email protected]d624b0b2012-12-12 04:05:19304 // Returns true if this extension has the given permission. Prefer
305 // IsExtensionWithPermissionOrSuggestInConsole when developers may be using an
306 // api that requires a permission they didn't know about, e.g. open web apis.
[email protected]c2e66e12012-06-27 06:27:06307 bool HasAPIPermission(APIPermission::ID permission) const;
[email protected]0d3e4a22011-06-23 19:02:52308 bool HasAPIPermission(const std::string& function_name) const;
[email protected]3d0e2262012-08-02 15:32:16309 bool HasAPIPermissionForTab(int tab_id, APIPermission::ID permission) const;
[email protected]583d45c12010-08-31 02:48:12310
[email protected]ecb9ad12012-08-21 13:02:15311 bool CheckAPIPermissionWithParam(APIPermission::ID permission,
312 const APIPermission::CheckParam* param) const;
[email protected]1d8b79a2012-08-16 20:22:54313
[email protected]0d3e4a22011-06-23 19:02:52314 const URLPatternSet& GetEffectiveHostPermissions() const;
[email protected]b24d8312009-08-27 06:47:46315
[email protected]902fd7b2011-07-27 18:42:31316 // Returns true if the extension can silently increase its permission level.
[email protected]0d904312012-01-25 23:00:16317 // Users must approve permissions for unpacked and packed extensions in the
318 // following situations:
319 // - when installing or upgrading packed extensions
320 // - when installing unpacked extensions that have NPAPI plugins
321 // - when either type of extension requests optional permissions
[email protected]902fd7b2011-07-27 18:42:31322 bool CanSilentlyIncreasePermissions() const;
323
[email protected]584b8e3f2010-04-10 00:23:37324 // Whether the extension has access to the given URL.
325 bool HasHostPermission(const GURL& url) const;
326
[email protected]0df165f2010-09-28 16:49:40327 // Whether the extension has effective access to all hosts. This is true if
328 // there is a content script that matches all hosts, if there is a host
329 // permission grants access to all hosts (like <all_urls>) or an api
330 // permission that effectively grants access to all hosts (e.g. proxy,
331 // network, etc.)
332 bool HasEffectiveAccessToAllHosts() const;
[email protected]b24d8312009-08-27 06:47:46333
[email protected]8d888c12010-11-30 00:00:25334 // Whether the extension effectively has all permissions (for example, by
335 // having an NPAPI plugin).
336 bool HasFullPermissions() const;
337
[email protected]902fd7b2011-07-27 18:42:31338 // Returns the full list of permission messages that this extension
339 // should display at install time.
[email protected]c2e66e12012-06-27 06:27:06340 PermissionMessages GetPermissionMessages() const;
[email protected]902fd7b2011-07-27 18:42:31341
342 // Returns the full list of permission messages that this extension
343 // should display at install time. The messages are returned as strings
344 // for convenience.
345 std::vector<string16> GetPermissionMessageStrings() const;
346
[email protected]b0d1d0b2012-11-02 21:19:03347 // Returns true if the extension does not require permission warnings
348 // to be displayed at install time.
349 bool ShouldSkipPermissionWarnings() const;
350
[email protected]902fd7b2011-07-27 18:42:31351 // Sets the active |permissions|.
[email protected]c2e66e12012-06-27 06:27:06352 void SetActivePermissions(const PermissionSet* permissions) const;
[email protected]902fd7b2011-07-27 18:42:31353
354 // Gets the extension's active permission set.
[email protected]c2e66e12012-06-27 06:27:06355 scoped_refptr<const PermissionSet> GetActivePermissions() const;
[email protected]902fd7b2011-07-27 18:42:31356
[email protected]5df6a5d2011-01-26 07:39:12357 // Whether context menu should be shown for page and browser actions.
358 bool ShowConfigureContextMenus() const;
359
[email protected]facd7a7652009-06-05 23:15:02360 // Returns a list of paths (relative to the extension dir) for images that
361 // the browser might load (like themes and page action icons).
[email protected]a7329162013-02-07 19:21:48362 std::set<base::FilePath> GetBrowserImages() const;
[email protected]facd7a7652009-06-05 23:15:02363
[email protected]867a73e12010-03-19 20:45:46364 // Gets the fully resolved absolute launch URL.
365 GURL GetFullLaunchURL() const;
[email protected]2a521c52011-01-26 18:45:21366
[email protected]2a521c52011-01-26 18:45:21367 // Returns true if this extension can execute script on a page. If a
368 // UserScript object is passed, permission to run that specific script is
369 // checked (using its matches list). Otherwise, permission to execute script
370 // programmatically is checked (using the extension's host permission).
371 //
372 // This method is also aware of certain special pages that extensions are
373 // usually not allowed to run script on.
[email protected]78bdfd662012-08-23 05:53:18374 bool CanExecuteScriptOnPage(const GURL& document_url,
375 const GURL& top_document_url,
[email protected]fc5e65d6b2012-06-13 00:22:57376 int tab_id,
[email protected]3aff9ad2011-04-01 20:26:48377 const UserScript* script,
[email protected]2a521c52011-01-26 18:45:21378 std::string* error) const;
379
[email protected]6f229e82010-11-02 17:47:26380 // Returns true if this extension is a COMPONENT extension, or if it is
381 // on the whitelist of extensions that can script all pages.
382 bool CanExecuteScriptEverywhere() const;
383
[email protected]5efbfe012011-02-22 23:07:18384 // Returns true if this extension is allowed to obtain the contents of a
385 // page as an image. Since a page may contain sensitive information, this
386 // is restricted to the extension's host permissions as well as the
387 // extension page itself.
[email protected]fc5e65d6b2012-06-13 00:22:57388 bool CanCaptureVisiblePage(const GURL& page_url,
389 int tab_id,
390 std::string* error) const;
[email protected]5efbfe012011-02-22 23:07:18391
[email protected]a65882c2010-11-12 15:15:09392 // Returns true if this extension updates itself using the extension
393 // gallery.
394 bool UpdatesFromGallery() const;
395
[email protected]cca147172011-02-17 01:29:29396 // Returns true if this extension or app includes areas within |origin|.
397 bool OverlapsWithOrigin(const GURL& origin) const;
398
[email protected]3bdba0d2011-08-23 07:17:30399 // Returns the sync bucket to use for this extension.
400 SyncType GetSyncType() const;
401
[email protected]b873cd92012-02-09 21:51:48402 // Returns true if the extension should be synced.
403 bool IsSyncable() const;
404
[email protected]7e0f92b2012-11-09 03:51:04405 // Returns true if the extension requires a valid ordinal for sorting, e.g.,
406 // for displaying in a launcher or new tab page.
407 bool RequiresSortOrdinal() const;
408
409 // Returns true if the extension should be displayed in the app launcher.
410 bool ShouldDisplayInAppLauncher() const;
411
412 // Returns true if the extension should be displayed in the browser NTP.
413 bool ShouldDisplayInNewTabPage() const;
[email protected]b873cd92012-02-09 21:51:48414
[email protected]e0b3de72012-05-01 01:21:34415 // Returns true if the extension should be displayed in the extension
416 // settings page (i.e. chrome://extensions).
417 bool ShouldDisplayInExtensionSettings() const;
418
[email protected]4f886012012-05-19 03:51:10419 // Returns true if the extension has a content script declared at |url|.
420 bool HasContentScriptAtURL(const GURL& url) const;
421
[email protected]fc5e65d6b2012-06-13 00:22:57422 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
423 // aren't any.
[email protected]3d0e2262012-08-02 15:32:16424 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
425 const;
[email protected]fc5e65d6b2012-06-13 00:22:57426
[email protected]3d0e2262012-08-02 15:32:16427 // Updates the tab-specific permissions of |tab_id| to include those from
428 // |permissions|.
[email protected]6144057e2012-08-02 19:02:37429 void UpdateTabSpecificPermissions(
430 int tab_id,
431 scoped_refptr<const PermissionSet> permissions) const;
[email protected]fc5e65d6b2012-06-13 00:22:57432
[email protected]3d0e2262012-08-02 15:32:16433 // Clears the tab-specific permissions of |tab_id|.
434 void ClearTabSpecificPermissions(int tab_id) const;
[email protected]fc5e65d6b2012-06-13 00:22:57435
[email protected]d356c982012-12-12 19:32:55436 // Get the manifest data associated with the key, or NULL if there is none.
437 // Can only be called after InitValue is finished.
438 ManifestData* GetManifestData(const std::string& key) const;
439
440 // Sets |data| to be associated with the key. Takes ownership of |data|.
441 // Can only be called before InitValue is finished. Not thread-safe;
442 // all SetManifestData calls should be on only one thread.
443 void SetManifestData(const std::string& key, ManifestData* data);
444
[email protected]6f229e82010-11-02 17:47:26445 // Accessors:
446
[email protected]98270432012-09-11 20:51:24447 const Requirements& requirements() const { return requirements_; }
[email protected]a7329162013-02-07 19:21:48448 const base::FilePath& path() const { return path_; }
[email protected]6f229e82010-11-02 17:47:26449 const GURL& url() const { return extension_url_; }
[email protected]1d5e58b2013-01-31 08:41:40450 Manifest::Location location() const;
[email protected]d41e2152012-02-24 04:20:27451 const std::string& id() const;
[email protected]6f229e82010-11-02 17:47:26452 const Version* version() const { return version_.get(); }
453 const std::string VersionString() const;
454 const std::string& name() const { return name_; }
[email protected]701d1e82012-05-14 05:34:19455 const std::string& non_localized_name() const { return non_localized_name_; }
[email protected]200423d2012-06-05 01:16:06456 // Base64-encoded version of the key used to sign this extension.
457 // In pseudocode, returns
458 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()).
459 const std::string& public_key() const { return public_key_; }
[email protected]6f229e82010-11-02 17:47:26460 const std::string& description() const { return description_; }
[email protected]a47c8a22011-11-17 18:40:31461 int manifest_version() const { return manifest_version_; }
[email protected]6f229e82010-11-02 17:47:26462 bool converted_from_user_script() const {
463 return converted_from_user_script_;
464 }
465 const UserScriptList& content_scripts() const { return content_scripts_; }
[email protected]ad12b6b2012-11-28 23:21:15466 const ActionInfo* system_indicator_info() const {
467 return system_indicator_info_.get();
468 }
[email protected]6f229e82010-11-02 17:47:26469 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]65378f52011-04-08 02:31:23470 const std::vector<NaClModuleInfo>& nacl_modules() const {
471 return nacl_modules_;
472 }
[email protected]c2e66e12012-06-27 06:27:06473 const PermissionSet* optional_permission_set() const {
[email protected]902fd7b2011-07-27 18:42:31474 return optional_permission_set_.get();
475 }
[email protected]c2e66e12012-06-27 06:27:06476 const PermissionSet* required_permission_set() const {
[email protected]902fd7b2011-07-27 18:42:31477 return required_permission_set_.get();
[email protected]6f229e82010-11-02 17:47:26478 }
[email protected]465594632013-02-15 19:50:28479 // Returns the temporary APIPermissionSet used in initialization.
480 // (NULL after initialization is completed.)
481 APIPermissionSet* initial_api_permissions() {
482 return initial_api_permissions_.get();
483 }
[email protected]9367eabc2013-03-01 01:29:29484 const APIPermissionSet* initial_api_permissions() const {
485 return initial_api_permissions_.get();
486 }
[email protected]23b3c0a2013-01-16 23:36:36487 // Appends |new_warning[s]| to install_warnings_.
488 void AddInstallWarning(const InstallWarning& new_warning);
[email protected]1d5e58b2013-01-31 08:41:40489 void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings);
490 const std::vector<InstallWarning>& install_warnings() const {
[email protected]8629c542012-04-20 03:40:03491 return install_warnings_;
492 }
[email protected]953620b2011-12-04 00:55:32493 const extensions::Manifest* manifest() const {
[email protected]e9629d772012-08-06 19:44:46494 return manifest_.get();
[email protected]6f229e82010-11-02 17:47:26495 }
[email protected]6f229e82010-11-02 17:47:26496 bool incognito_split_mode() const { return incognito_split_mode_; }
[email protected]1abdf4f2011-08-16 21:11:55497 bool offline_enabled() const { return offline_enabled_; }
[email protected]3aff9ad2011-04-01 20:26:48498 bool wants_file_access() const { return wants_file_access_; }
[email protected]2af352b2011-07-22 08:21:23499 int creation_flags() const { return creation_flags_; }
500 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
[email protected]e805baf2011-07-26 18:23:05501 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; }
[email protected]e33bbc22012-08-27 22:05:46502 bool was_installed_by_default() const {
503 return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0;
504 }
[email protected]3aff9ad2011-04-01 20:26:48505
[email protected]6f229e82010-11-02 17:47:26506 // App-related.
[email protected]953620b2011-12-04 00:55:32507 bool is_app() const {
[email protected]c4f459d2012-09-28 04:40:10508 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app();
[email protected]23690872011-12-01 22:02:39509 }
[email protected]d41e2152012-02-24 04:20:27510 bool is_platform_app() const;
511 bool is_hosted_app() const;
[email protected]c4f459d2012-09-28 04:40:10512 bool is_legacy_packaged_app() const;
[email protected]ff05a4b102012-12-19 00:12:06513 bool is_extension() const;
[email protected]605fb8102012-05-04 01:36:55514 bool is_storage_isolated() const { return is_storage_isolated_; }
[email protected]cdc7b1f42012-12-07 19:39:48515 bool can_be_incognito_enabled() const;
[email protected]636ee43282013-01-12 15:58:00516 void AddWebExtentPattern(const URLPattern& pattern);
[email protected]cced75a2011-05-20 08:31:12517 const URLPatternSet& web_extent() const { return extent_; }
[email protected]6f229e82010-11-02 17:47:26518 const std::string& launch_local_path() const { return launch_local_path_; }
519 const std::string& launch_web_url() const { return launch_web_url_; }
520 extension_misc::LaunchContainer launch_container() const {
521 return launch_container_;
522 }
[email protected]dc37b002012-04-23 23:02:26523 int launch_width() const { return launch_width_; }
524 int launch_height() const { return launch_height_; }
[email protected]6f229e82010-11-02 17:47:26525
526 // Theme-related.
[email protected]d41e2152012-02-24 04:20:27527 bool is_theme() const;
[email protected]6f229e82010-11-02 17:47:26528
[email protected]66008002013-01-08 09:09:13529 // Content pack related.
[email protected]fbb620832013-01-25 17:20:35530 bool is_content_pack() const;
[email protected]66008002013-01-08 09:09:13531 ExtensionResource GetContentPackSiteList() const;
532
[email protected]4a8d3272009-03-10 19:15:08533 private:
[email protected]66e4eb32010-10-27 20:37:41534 friend class base::RefCountedThreadSafe<Extension>;
535
[email protected]902fd7b2011-07-27 18:42:31536 class RuntimeData {
537 public:
538 RuntimeData();
[email protected]c2e66e12012-06-27 06:27:06539 explicit RuntimeData(const PermissionSet* active);
[email protected]902fd7b2011-07-27 18:42:31540 ~RuntimeData();
541
[email protected]c2e66e12012-06-27 06:27:06542 void SetActivePermissions(const PermissionSet* active);
543 scoped_refptr<const PermissionSet> GetActivePermissions() const;
[email protected]902fd7b2011-07-27 18:42:31544
[email protected]3d0e2262012-08-02 15:32:16545 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
546 const;
[email protected]6144057e2012-08-02 19:02:37547 void UpdateTabSpecificPermissions(
548 int tab_id,
549 scoped_refptr<const PermissionSet> permissions);
[email protected]3d0e2262012-08-02 15:32:16550 void ClearTabSpecificPermissions(int tab_id);
[email protected]fc5e65d6b2012-06-13 00:22:57551
[email protected]902fd7b2011-07-27 18:42:31552 private:
553 friend class base::RefCountedThreadSafe<RuntimeData>;
[email protected]fc5e65d6b2012-06-13 00:22:57554
[email protected]c2e66e12012-06-27 06:27:06555 scoped_refptr<const PermissionSet> active_permissions_;
[email protected]fc5e65d6b2012-06-13 00:22:57556
[email protected]3d0e2262012-08-02 15:32:16557 typedef std::map<int, scoped_refptr<const PermissionSet> >
558 TabPermissionsMap;
559 TabPermissionsMap tab_specific_permissions_;
[email protected]902fd7b2011-07-27 18:42:31560 };
561
[email protected]d41e2152012-02-24 04:20:27562 // Chooses the extension ID for an extension based on a variety of criteria.
563 // The chosen ID will be set in |manifest|.
564 static bool InitExtensionID(extensions::Manifest* manifest,
[email protected]a7329162013-02-07 19:21:48565 const base::FilePath& path,
[email protected]d41e2152012-02-24 04:20:27566 const std::string& explicit_id,
567 int creation_flags,
568 string16* error);
569
[email protected]4ead6f72010-10-13 19:54:18570 // Normalize the path for use by the extension. On Windows, this will make
571 // sure the drive letter is uppercase.
[email protected]a7329162013-02-07 19:21:48572 static base::FilePath MaybeNormalizePath(const base::FilePath& path);
[email protected]4ead6f72010-10-13 19:54:18573
[email protected]87c655e2011-07-01 21:42:00574 // Returns true if this extension id is from a trusted provider.
575 static bool IsTrustedId(const std::string& id);
576
[email protected]a7329162013-02-07 19:21:48577 Extension(const base::FilePath& path,
578 scoped_ptr<extensions::Manifest> manifest);
[email protected]d356c982012-12-12 19:32:55579 virtual ~Extension();
[email protected]66e4eb32010-10-27 20:37:41580
581 // Initialize the extension from a parsed manifest.
[email protected]d41e2152012-02-24 04:20:27582 // TODO(aa): Rename to just Init()? There's no Value here anymore.
583 // TODO(aa): It is really weird the way this class essentially contains a copy
584 // of the underlying DictionaryValue in its members. We should decide to
585 // either wrap the DictionaryValue and go with that only, or we should parse
586 // into strong types and discard the value. But doing both is bad.
587 bool InitFromValue(int flags, string16* error);
[email protected]66e4eb32010-10-27 20:37:41588
[email protected]58f62cf2012-03-09 10:45:11589 // The following are helpers for InitFromValue to load various features of the
590 // extension from the manifest.
591
[email protected]465594632013-02-15 19:50:28592 bool LoadAppIsolation(string16* error);
[email protected]58f62cf2012-03-09 10:45:11593
594 bool LoadRequiredFeatures(string16* error);
595 bool LoadName(string16* error);
596 bool LoadVersion(string16* error);
597
598 bool LoadAppFeatures(string16* error);
[email protected]d41e2152012-02-24 04:20:27599 bool LoadExtent(const char* key,
600 URLPatternSet* extent,
601 const char* list_error,
602 const char* value_error,
603 string16* error);
604 bool LoadLaunchContainer(string16* error);
605 bool LoadLaunchURL(string16* error);
[email protected]10253da2012-03-09 04:06:42606
[email protected]465594632013-02-15 19:50:28607 bool LoadSharedFeatures(string16* error);
[email protected]58f62cf2012-03-09 10:45:11608 bool LoadDescription(string16* error);
609 bool LoadManifestVersion(string16* error);
[email protected]58f62cf2012-03-09 10:45:11610 bool LoadPlugins(string16* error);
611 bool LoadNaClModules(string16* error);
[email protected]dbb24162012-06-06 01:41:22612 bool LoadSandboxedPages(string16* error);
[email protected]98270432012-09-11 20:51:24613 // Must be called after LoadPlugins().
614 bool LoadRequirements(string16* error);
[email protected]58f62cf2012-03-09 10:45:11615 bool LoadOfflineEnabled(string16* error);
[email protected]465594632013-02-15 19:50:28616 bool LoadExtensionFeatures(string16* error);
[email protected]58f62cf2012-03-09 10:45:11617 bool LoadContentScripts(string16* error);
[email protected]58f62cf2012-03-09 10:45:11618 bool LoadBrowserAction(string16* error);
[email protected]465594632013-02-15 19:50:28619 bool LoadSystemIndicator(string16* error);
[email protected]58f62cf2012-03-09 10:45:11620 bool LoadTextToSpeechVoices(string16* error);
621 bool LoadIncognitoMode(string16* error);
[email protected]66008002013-01-08 09:09:13622 bool LoadManagedModeFeatures(string16* error);
623 bool LoadManagedModeSites(
624 const base::DictionaryValue* content_pack_value,
625 string16* error);
626 bool LoadManagedModeConfigurations(
627 const base::DictionaryValue* content_pack_value,
628 string16* error);
629
[email protected]3cfbd0e2009-03-18 21:26:24630 // Helper method that loads a UserScript object from a
631 // dictionary in the content_script list of the manifest.
[email protected]f3a1c642011-07-12 19:15:03632 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
[email protected]3cfbd0e2009-03-18 21:26:24633 int definition_index,
[email protected]fc670822011-12-17 09:33:49634 string16* error,
[email protected]3cfbd0e2009-03-18 21:26:24635 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34636
[email protected]6657afa62009-11-04 02:15:20637 // Helper method that loads either the include_globs or exclude_globs list
638 // from an entry in the content_script lists of the manifest.
[email protected]f3a1c642011-07-12 19:15:03639 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
[email protected]6657afa62009-11-04 02:15:20640 int content_script_index,
[email protected]e2194742010-08-12 05:54:34641 const char* globs_property_name,
[email protected]fc670822011-12-17 09:33:49642 string16* error,
[email protected]11f4857282009-11-13 19:56:17643 void(UserScript::*add_method)(const std::string& glob),
[email protected]488e6502012-09-07 14:17:34644 UserScript* instance);
[email protected]6657afa62009-11-04 02:15:20645
[email protected]2f6698b2010-10-14 00:58:21646 // Returns true if the extension has more than one "UI surface". For example,
647 // an extension that has a browser action and a page action.
648 bool HasMultipleUISurfaces() const;
649
[email protected]be9d9c82011-07-13 04:17:31650 // Updates the launch URL and extents for the extension using the given
651 // |override_url|.
652 void OverrideLaunchUrl(const GURL& override_url);
653
[email protected]ae655e4e2012-03-16 21:47:55654 // Custom checks for the experimental permission that can't be expressed in
655 // _permission_features.json.
[email protected]5eddc3e2011-10-26 04:33:31656 bool CanSpecifyExperimentalPermission() const;
[email protected]5eddc3e2011-10-26 04:33:31657
658 // Checks whether the host |pattern| is allowed for this extension, given API
659 // permissions |permissions|.
660 bool CanSpecifyHostPermission(const URLPattern& pattern,
[email protected]465594632013-02-15 19:50:28661 const APIPermissionSet& permissions) const;
[email protected]5eddc3e2011-10-26 04:33:31662
[email protected]488e6502012-09-07 14:17:34663 bool CheckMinimumChromeVersion(string16* error) const;
[email protected]488e6502012-09-07 14:17:34664
[email protected]e92169e2012-05-04 22:49:32665 // Check that platform app features are valid. Called after InitFromValue.
[email protected]9a494872013-03-02 03:05:45666 bool CheckPlatformAppFeatures(string16* error) const;
[email protected]e92169e2012-05-04 22:49:32667
[email protected]f1bab9c92012-05-11 21:15:10668 // Check that features don't conflict. Called after InitFromValue.
[email protected]9a494872013-03-02 03:05:45669 bool CheckConflictingFeatures(string16* error) const;
[email protected]f1bab9c92012-05-11 21:15:10670
[email protected]6f229e82010-11-02 17:47:26671 // The extension's human-readable name. Name is used for display purpose. It
672 // might be wrapped with unicode bidi control characters so that it is
673 // displayed correctly in RTL context.
674 // NOTE: Name is UTF-8 and may contain non-ascii characters.
675 std::string name_;
676
[email protected]701d1e82012-05-14 05:34:19677 // A non-localized version of the extension's name. This is useful for
678 // debug output.
679 std::string non_localized_name_;
680
[email protected]a47c8a22011-11-17 18:40:31681 // The version of this extension's manifest. We increase the manifest
682 // version when making breaking changes to the extension system.
683 // Version 1 was the first manifest version (implied by a lack of a
684 // manifest_version attribute in the extension's manifest). We initialize
685 // this member variable to 0 to distinguish the "uninitialized" case from
686 // the case when we know the manifest version actually is 1.
687 int manifest_version_;
688
[email protected]98270432012-09-11 20:51:24689 // The requirements declared in the manifest.
690 Requirements requirements_;
691
[email protected]d41e2152012-02-24 04:20:27692 // The absolute path to the directory the extension is stored in.
[email protected]a7329162013-02-07 19:21:48693 base::FilePath path_;
[email protected]d41e2152012-02-24 04:20:27694
[email protected]6f229e82010-11-02 17:47:26695 // If true, a separate process will be used for the extension in incognito
696 // mode.
697 bool incognito_split_mode_;
698
[email protected]1abdf4f2011-08-16 21:11:55699 // Whether the extension or app should be enabled when offline.
700 bool offline_enabled_;
701
[email protected]6f229e82010-11-02 17:47:26702 // Defines the set of URLs in the extension's web content.
[email protected]cced75a2011-05-20 08:31:12703 URLPatternSet extent_;
[email protected]6f229e82010-11-02 17:47:26704
[email protected]902fd7b2011-07-27 18:42:31705 // The extension runtime data.
706 mutable base::Lock runtime_data_lock_;
707 mutable RuntimeData runtime_data_;
708
[email protected]465594632013-02-15 19:50:28709 // The API permission set; used during extension initialization.
710 // Cleared after permissions are finalized by SetActivePermissions.
711 scoped_ptr<APIPermissionSet> initial_api_permissions_;
712
[email protected]902fd7b2011-07-27 18:42:31713 // The set of permissions the extension can request at runtime.
[email protected]c2e66e12012-06-27 06:27:06714 scoped_refptr<const PermissionSet> optional_permission_set_;
[email protected]902fd7b2011-07-27 18:42:31715
716 // The extension's required / default set of permissions.
[email protected]c2e66e12012-06-27 06:27:06717 scoped_refptr<const PermissionSet> required_permission_set_;
[email protected]6f229e82010-11-02 17:47:26718
[email protected]8629c542012-04-20 03:40:03719 // Any warnings that occurred when trying to create/parse the extension.
[email protected]1d5e58b2013-01-31 08:41:40720 std::vector<InstallWarning> install_warnings_;
[email protected]8629c542012-04-20 03:40:03721
[email protected]6f229e82010-11-02 17:47:26722 // The base extension url for the extension.
723 GURL extension_url_;
724
[email protected]6f229e82010-11-02 17:47:26725 // The extension's version.
726 scoped_ptr<Version> version_;
727
728 // An optional longer description of the extension.
729 std::string description_;
730
731 // True if the extension was generated from a user script. (We show slightly
732 // different UI if so).
733 bool converted_from_user_script_;
734
735 // Paths to the content scripts the extension contains.
736 UserScriptList content_scripts_;
737
[email protected]ad12b6b2012-11-28 23:21:15738 // The extension's system indicator, if any.
739 scoped_ptr<ActionInfo> system_indicator_info_;
740
[email protected]6f229e82010-11-02 17:47:26741 // Optional list of NPAPI plugins and associated properties.
742 std::vector<PluginInfo> plugins_;
743
[email protected]65378f52011-04-08 02:31:23744 // Optional list of NaCl modules and associated properties.
745 std::vector<NaClModuleInfo> nacl_modules_;
746
[email protected]dbb24162012-06-06 01:41:22747 // Optional list of extension pages that are sandboxed (served from a unique
748 // origin with a different Content Security Policy).
[email protected]f59a8052012-06-20 22:25:00749 URLPatternSet sandboxed_pages_;
[email protected]dbb24162012-06-06 01:41:22750
751 // Content Security Policy that should be used to enforce the sandbox used
752 // by sandboxed pages (guaranteed to have the "sandbox" directive without the
753 // "allow-same-origin" token).
754 std::string sandboxed_pages_content_security_policy_;
755
[email protected]6f229e82010-11-02 17:47:26756 // The public key used to sign the contents of the crx package.
757 std::string public_key_;
758
[email protected]66008002013-01-08 09:09:13759 // A file containing a list of sites for Managed Mode.
[email protected]a7329162013-02-07 19:21:48760 base::FilePath content_pack_site_list_;
[email protected]66008002013-01-08 09:09:13761
[email protected]58f62cf2012-03-09 10:45:11762 // The manifest from which this extension was created.
[email protected]e9629d772012-08-06 19:44:46763 scoped_ptr<Manifest> manifest_;
[email protected]6f229e82010-11-02 17:47:26764
[email protected]d356c982012-12-12 19:32:55765 // Stored parsed manifest data.
766 ManifestDataMap manifest_data_;
767
768 // Set to true at the end of InitValue when initialization is finished.
769 bool finished_parsing_manifest_;
770
[email protected]7eeab9ec2013-01-15 04:08:33771 // Ensures that any call to GetManifestData() prior to finishing
772 // initialization happens from the same thread (this can happen when certain
773 // parts of the initialization process need information from previous parts).
774 base::ThreadChecker thread_checker_;
775
[email protected]d9696672011-03-15 22:45:09776 // Whether this extension requests isolated storage.
777 bool is_storage_isolated_;
778
[email protected]6f229e82010-11-02 17:47:26779 // The local path inside the extension to use with the launcher.
780 std::string launch_local_path_;
781
782 // A web url to use with the launcher. Note that this might be relative or
783 // absolute. If relative, it is relative to web_origin.
784 std::string launch_web_url_;
785
[email protected]4e595682011-02-09 17:07:02786 // The window type that an app's manifest specifies to launch into.
787 // This is not always the window type an app will open into, because
788 // users can override the way each app launches. See
789 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
790 // to decide what container an app will launch in.
[email protected]6f229e82010-11-02 17:47:26791 extension_misc::LaunchContainer launch_container_;
792
793 // The default size of the container when launching. Only respected for
794 // containers like panels and windows.
795 int launch_width_;
796 int launch_height_;
797
[email protected]7e0f92b2012-11-09 03:51:04798 // Should this app be shown in the app launcher.
[email protected]ed1a204f2012-09-22 00:28:44799 bool display_in_launcher_;
800
[email protected]7e0f92b2012-11-09 03:51:04801 // Should this app be shown in the browser New Tab Page.
802 bool display_in_new_tab_page_;
803
[email protected]3aff9ad2011-04-01 20:26:48804 // Whether the extension has host permissions or user script patterns that
805 // imply access to file:/// scheme URLs (the user may not have actually
806 // granted it that access).
807 bool wants_file_access_;
808
[email protected]2af352b2011-07-22 08:21:23809 // The flags that were passed to InitFromValue.
810 int creation_flags_;
[email protected]620db1762011-07-15 21:57:34811
[email protected]894bb502009-05-21 22:39:57812 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33813};
814
[email protected]bc151cf92013-02-12 04:57:26815typedef std::vector<scoped_refptr<const Extension> > ExtensionList;
[email protected]ec5b50d2010-10-09 16:35:18816typedef std::set<std::string> ExtensionIdSet;
[email protected]82590cb2012-09-28 04:14:08817typedef std::vector<std::string> ExtensionIdList;
[email protected]b1748b1d82009-11-30 20:32:56818
[email protected]c6d474f82009-12-16 21:11:06819// Handy struct to pass core extension info around.
820struct ExtensionInfo {
[email protected]f3a1c642011-07-12 19:15:03821 ExtensionInfo(const base::DictionaryValue* manifest,
[email protected]c6d474f82009-12-16 21:11:06822 const std::string& id,
[email protected]a7329162013-02-07 19:21:48823 const base::FilePath& path,
[email protected]1d5e58b2013-01-31 08:41:40824 Manifest::Location location);
[email protected]3bb84992010-08-26 17:23:46825 ~ExtensionInfo();
[email protected]c6d474f82009-12-16 21:11:06826
[email protected]f3a1c642011-07-12 19:15:03827 scoped_ptr<base::DictionaryValue> extension_manifest;
[email protected]c6d474f82009-12-16 21:11:06828 std::string extension_id;
[email protected]a7329162013-02-07 19:21:48829 base::FilePath extension_path;
[email protected]1d5e58b2013-01-31 08:41:40830 Manifest::Location extension_location;
[email protected]c6d474f82009-12-16 21:11:06831
832 private:
833 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
834};
835
[email protected]a9f39a312010-12-23 22:14:27836struct UnloadedExtensionInfo {
[email protected]814a7bf0f2011-08-13 05:30:59837 extension_misc::UnloadedExtensionReason reason;
[email protected]a9f39a312010-12-23 22:14:27838
839 // Was the extension already disabled?
840 bool already_disabled;
841
842 // The extension being unloaded - this should always be non-NULL.
843 const Extension* extension;
844
[email protected]814a7bf0f2011-08-13 05:30:59845 UnloadedExtensionInfo(
846 const Extension* extension,
847 extension_misc::UnloadedExtensionReason reason);
[email protected]a9f39a312010-12-23 22:14:27848};
849
[email protected]902fd7b2011-07-27 18:42:31850// The details sent for EXTENSION_PERMISSIONS_UPDATED notifications.
851struct UpdatedExtensionPermissionsInfo {
852 enum Reason {
[email protected]f5532472012-02-23 13:00:55853 ADDED, // The permissions were added to the extension.
854 REMOVED, // The permissions were removed from the extension.
[email protected]902fd7b2011-07-27 18:42:31855 };
856
857 Reason reason;
858
859 // The extension who's permissions have changed.
860 const Extension* extension;
861
862 // The permissions that have changed. For Reason::ADDED, this would contain
863 // only the permissions that have added, and for Reason::REMOVED, this would
864 // only contain the removed permissions.
[email protected]c2e66e12012-06-27 06:27:06865 const PermissionSet* permissions;
[email protected]902fd7b2011-07-27 18:42:31866
867 UpdatedExtensionPermissionsInfo(
868 const Extension* extension,
[email protected]c2e66e12012-06-27 06:27:06869 const PermissionSet* permissions,
[email protected]902fd7b2011-07-27 18:42:31870 Reason reason);
871};
872
[email protected]488e6502012-09-07 14:17:34873} // namespace extensions
[email protected]1c321ee2012-05-21 03:02:34874
[email protected]5b1a0e22009-05-26 19:00:58875#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_