[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 5 | #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 6 | #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 7 | |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 8 | #include <algorithm> |
[email protected] | 18049dc | 2012-06-19 23:12:55 | [diff] [blame] | 9 | #include <iosfwd> |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 10 | #include <map> |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 11 | #include <set> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 12 | #include <string> |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 13 | #include <utility> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 16 | #include "base/files/file_path.h" |
[email protected] | 8f270be | 2011-12-21 21:15:22 | [diff] [blame] | 17 | #include "base/hash_tables.h" |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 18 | #include "base/memory/linked_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 19 | #include "base/memory/ref_counted.h" |
| 20 | #include "base/memory/scoped_ptr.h" |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 21 | #include "base/synchronization/lock.h" |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 22 | #include "base/threading/thread_checker.h" |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame] | 23 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 807871f | 2010-09-16 01:04:48 | [diff] [blame] | 24 | #include "chrome/common/extensions/extension_icon_set.h" |
[email protected] | 702d8b4 | 2013-02-27 20:55:50 | [diff] [blame] | 25 | #include "chrome/common/extensions/extension_resource.h" |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 26 | #include "chrome/common/extensions/manifest.h" |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 27 | #include "chrome/common/extensions/permissions/api_permission.h" |
| 28 | #include "chrome/common/extensions/permissions/permission_message.h" |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 29 | #include "chrome/common/extensions/user_script.h" |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 30 | #include "extensions/common/install_warning.h" |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 31 | #include "extensions/common/url_pattern.h" |
[email protected] | e9f541a | 2012-11-19 21:52:31 | [diff] [blame] | 32 | #include "extensions/common/url_pattern_set.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 33 | #include "googleurl/src/gurl.h" |
[email protected] | f553247 | 2012-02-23 13:00:55 | [diff] [blame] | 34 | #include "ui/base/accelerators/accelerator.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 35 | #include "ui/gfx/size.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 36 | |
[email protected] | 0f34d908 | 2012-10-08 19:16:44 | [diff] [blame] | 37 | class ExtensionAction; |
[email protected] | 1280270 | 2010-07-09 19:43:09 | [diff] [blame] | 38 | class SkBitmap; |
[email protected] | daf66aa | 2010-08-06 06:24:28 | [diff] [blame] | 39 | class Version; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 40 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 41 | namespace base { |
| 42 | class DictionaryValue; |
| 43 | class ListValue; |
| 44 | } |
| 45 | |
[email protected] | 0f34d908 | 2012-10-08 19:16:44 | [diff] [blame] | 46 | namespace gfx { |
| 47 | class ImageSkia; |
| 48 | } |
| 49 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 50 | namespace extensions { |
[email protected] | 972b02f | 2013-01-28 20:38:14 | [diff] [blame] | 51 | struct ActionInfo; |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 52 | class APIPermissionSet; |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 53 | class PermissionSet; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 54 | |
[email protected] | f075553 | 2010-06-22 07:27:25 | [diff] [blame] | 55 | // Represents a Chrome extension. |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 56 | class Extension : public base::RefCountedThreadSafe<Extension> { |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 57 | public: |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 58 | struct ManifestData; |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 59 | |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 60 | typedef std::vector<std::string> ScriptingWhitelist; |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 61 | typedef std::map<const std::string, linked_ptr<ManifestData> > |
| 62 | ManifestDataMap; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 63 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 64 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 65 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 66 | ENABLED, |
[email protected] | 79c833b5 | 2011-04-05 18:31:01 | [diff] [blame] | 67 | // An external extension that the user uninstalled. We should not reinstall |
| 68 | // such extensions on startup. |
| 69 | EXTERNAL_EXTENSION_UNINSTALLED, |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 70 | // Special state for component extensions, since they are always loaded by |
| 71 | // the component loader, and should never be auto-installed on startup. |
| 72 | ENABLED_COMPONENT, |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 73 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 74 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 75 | |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 76 | // Used to record the reason an extension was disabled. |
[email protected] | eb5e4f9 | 2012-08-15 23:33:28 | [diff] [blame] | 77 | enum DeprecatedDisableReason { |
| 78 | DEPRECATED_DISABLE_UNKNOWN, |
| 79 | DEPRECATED_DISABLE_USER_ACTION, |
| 80 | DEPRECATED_DISABLE_PERMISSIONS_INCREASE, |
| 81 | DEPRECATED_DISABLE_RELOAD, |
| 82 | DEPRECATED_DISABLE_LAST, // Not used. |
| 83 | }; |
| 84 | |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 85 | enum DisableReason { |
[email protected] | eb5e4f9 | 2012-08-15 23:33:28 | [diff] [blame] | 86 | DISABLE_NONE = 0, |
| 87 | DISABLE_USER_ACTION = 1 << 0, |
| 88 | DISABLE_PERMISSIONS_INCREASE = 1 << 1, |
| 89 | DISABLE_RELOAD = 1 << 2, |
[email protected] | 215a7be | 2012-10-22 19:53:42 | [diff] [blame] | 90 | DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3, |
| 91 | DISABLE_SIDELOAD_WIPEOUT = 1 << 4, |
[email protected] | f56c65ea6 | 2012-12-10 22:57:21 | [diff] [blame] | 92 | DISABLE_UNKNOWN_FROM_SYNC = 1 << 5, |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 93 | }; |
| 94 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 95 | enum InstallType { |
[email protected] | ab6f2b2 | 2009-07-28 23:28:37 | [diff] [blame] | 96 | INSTALL_ERROR, |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 97 | DOWNGRADE, |
| 98 | REINSTALL, |
| 99 | UPGRADE, |
| 100 | NEW_INSTALL |
| 101 | }; |
| 102 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 103 | enum SyncType { |
| 104 | SYNC_TYPE_NONE = 0, |
| 105 | SYNC_TYPE_EXTENSION, |
| 106 | SYNC_TYPE_APP |
| 107 | }; |
| 108 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 109 | // Declared requirements for the extension. |
| 110 | struct Requirements { |
| 111 | Requirements(); |
| 112 | ~Requirements(); |
| 113 | |
| 114 | bool webgl; |
| 115 | bool css3d; |
| 116 | bool npapi; |
| 117 | }; |
| 118 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 119 | // An NaCl module included in the extension. |
| 120 | struct NaClModuleInfo { |
[email protected] | 84396dbc | 2011-04-14 06:33:42 | [diff] [blame] | 121 | GURL url; |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 122 | std::string mime_type; |
| 123 | }; |
| 124 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 125 | // A base class for parsed manifest data that APIs want to store on |
| 126 | // the extension. Related to base::SupportsUserData, but with an immutable |
| 127 | // thread-safe interface to match Extension. |
| 128 | struct ManifestData { |
| 129 | virtual ~ManifestData() {} |
| 130 | }; |
| 131 | |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 132 | enum InitFromValueFlags { |
| 133 | NO_FLAGS = 0, |
| 134 | |
| 135 | // Usually, the id of an extension is generated by the "key" property of |
| 136 | // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 137 | // generated based on the path. |
| 138 | REQUIRE_KEY = 1 << 0, |
| 139 | |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 140 | // Requires the extension to have an up-to-date manifest version. |
| 141 | // Typically, we'll support multiple manifest versions during a version |
[email protected] | 26367b6 | 2012-10-04 23:03:32 | [diff] [blame] | 142 | // transition. This flag signals that we want to require the most modern |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 143 | // manifest version that Chrome understands. |
| 144 | REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1, |
| 145 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 146 | // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension |
| 147 | // to have file access. If it's not present, then permissions and content |
| 148 | // scripts that match file:/// URLs will be filtered out. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 149 | ALLOW_FILE_ACCESS = 1 << 2, |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 150 | |
| 151 | // |FROM_WEBSTORE| indicates that the extension was installed from the |
| 152 | // Chrome Web Store. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 153 | FROM_WEBSTORE = 1 << 3, |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 154 | |
| 155 | // |FROM_BOOKMARK| indicates the extension was created using a mock App |
| 156 | // created from a bookmark. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 157 | FROM_BOOKMARK = 1 << 4, |
[email protected] | 3d41d43 | 2012-04-20 20:47:58 | [diff] [blame] | 158 | |
| 159 | // |FOLLOW_SYMLINKS_ANYWHERE| means that resources can be symlinks to |
| 160 | // anywhere in the filesystem, rather than being restricted to the |
| 161 | // extension directory. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 162 | FOLLOW_SYMLINKS_ANYWHERE = 1 << 5, |
[email protected] | ab55c2b | 2012-06-01 23:55:03 | [diff] [blame] | 163 | |
| 164 | // |ERROR_ON_PRIVATE_KEY| means that private keys inside an |
| 165 | // extension should be errors rather than warnings. |
| 166 | ERROR_ON_PRIVATE_KEY = 1 << 6, |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 167 | |
| 168 | // |WAS_INSTALLED_BY_DEFAULT| installed by default when the profile was |
| 169 | // created. |
| 170 | WAS_INSTALLED_BY_DEFAULT = 1 << 7, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 171 | }; |
| 172 | |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 173 | static scoped_refptr<Extension> Create(const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 174 | Manifest::Location location, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 175 | const base::DictionaryValue& value, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 176 | int flags, |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 177 | std::string* error); |
| 178 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 179 | // In a few special circumstances, we want to create an Extension and give it |
[email protected] | f5bf184 | 2012-02-15 02:52:26 | [diff] [blame] | 180 | // an explicit id. Most consumers should just use the other Create() method. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 181 | static scoped_refptr<Extension> Create(const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 182 | Manifest::Location location, |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 183 | const base::DictionaryValue& value, |
| 184 | int flags, |
| 185 | const std::string& explicit_id, |
| 186 | std::string* error); |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 187 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 188 | // Valid schemes for web extent URLPatterns. |
| 189 | static const int kValidWebExtentSchemes; |
| 190 | |
[email protected] | f71f7e6 | 2010-12-07 03:45:33 | [diff] [blame] | 191 | // Valid schemes for host permission URLPatterns. |
| 192 | static const int kValidHostPermissionSchemes; |
| 193 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 194 | // The name of the manifest inside an extension. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 195 | static const base::FilePath::CharType kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 196 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 197 | // The name of locale folder inside an extension. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 198 | static const base::FilePath::CharType kLocaleFolder[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 199 | |
| 200 | // The name of the messages file inside an extension. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 201 | static const base::FilePath::CharType kMessagesFilename[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 202 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 203 | #if defined(OS_WIN) |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 204 | static const char kExtensionRegistryPath[]; |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 205 | #endif |
| 206 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 207 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 208 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 209 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 210 | // The mimetype used for extensions. |
| 211 | static const char kMimeType[]; |
| 212 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 213 | // Checks to see if the extension has a valid ID. |
| 214 | static bool IdIsValid(const std::string& id); |
| 215 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 216 | // Generate an ID for an extension in the given path. |
[email protected] | 28d7479b | 2011-03-09 21:33:27 | [diff] [blame] | 217 | // Used while developing extensions, before they have a key. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 218 | static std::string GenerateIdForPath(const base::FilePath& file_name); |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 219 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 220 | // Returns true if the specified file is an extension. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 221 | static bool IsExtension(const base::FilePath& file_name); |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 222 | |
[email protected] | fc6b061 | 2012-03-29 13:40:06 | [diff] [blame] | 223 | // Fills the |info| dictionary with basic information about the extension. |
| 224 | // |enabled| is injected for easier testing. |
| 225 | void GetBasicInfo(bool enabled, base::DictionaryValue* info) const; |
| 226 | |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 227 | // See Type definition in Manifest. |
| 228 | Manifest::Type GetType() const; |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 229 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 230 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 231 | // |extension_url| argument should be the url() from an Extension object. The |
| 232 | // |relative_path| can be untrusted user input. The returned URL will either |
| 233 | // be invalid() or a child of |extension_url|. |
| 234 | // NOTE: Static so that it can be used from multiple threads. |
| 235 | static GURL GetResourceURL(const GURL& extension_url, |
| 236 | const std::string& relative_path); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 237 | GURL GetResourceURL(const std::string& relative_path) const { |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 238 | return GetResourceURL(url(), relative_path); |
| 239 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 240 | |
[email protected] | f59a805 | 2012-06-20 22:25:00 | [diff] [blame] | 241 | // Returns true if the resource matches a pattern in the pattern_set. |
| 242 | bool ResourceMatches(const URLPatternSet& pattern_set, |
| 243 | const std::string& resource) const; |
| 244 | |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 245 | // Returns true if the specified page is sandboxed (served in a unique |
| 246 | // origin). |
| 247 | bool IsSandboxedPage(const std::string& relative_path) const; |
| 248 | |
| 249 | // Returns the Content Security Policy that the specified resource should be |
| 250 | // served with. |
| 251 | std::string GetResourceContentSecurityPolicy(const std::string& relative_path) |
| 252 | const; |
| 253 | |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 254 | // Returns an extension resource object. |relative_path| should be UTF8 |
| 255 | // encoded. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 256 | ExtensionResource GetResource(const std::string& relative_path) const; |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 257 | |
| 258 | // As above, but with |relative_path| following the file system's encoding. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 259 | ExtensionResource GetResource(const base::FilePath& relative_path) const; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 260 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 261 | // |input| is expected to be the text of an rsa public or private key. It |
| 262 | // tolerates the presence or absence of bracking header/footer like this: |
| 263 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 264 | // and may contain newlines. |
| 265 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 266 | |
| 267 | // Does a simple base64 encoding of |input| into |output|. |
| 268 | static bool ProducePEM(const std::string& input, std::string* output); |
| 269 | |
[email protected] | 84ac7f3 | 2009-10-06 06:17:54 | [diff] [blame] | 270 | // Generates an extension ID from arbitrary input. The same input string will |
| 271 | // always generate the same output ID. |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 272 | static bool GenerateId(const std::string& input, |
| 273 | std::string* output) WARN_UNUSED_RESULT; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 274 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 275 | // Expects base64 encoded |input| and formats into |output| including |
| 276 | // the appropriate header & footer. |
[email protected] | e0d0819 | 2011-03-29 19:02:50 | [diff] [blame] | 277 | static bool FormatPEMForFileOutput(const std::string& input, |
| 278 | std::string* output, |
| 279 | bool is_public); |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 280 | |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 281 | // Returns the base extension url for a given |extension_id|. |
| 282 | static GURL GetBaseURLFromExtensionId(const std::string& extension_id); |
| 283 | |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 284 | // Adds an extension to the scripting whitelist. Used for testing only. |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 285 | static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 286 | static const ScriptingWhitelist* GetScriptingWhitelist(); |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 287 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 288 | // Parses the host and api permissions from the specified permission |key| |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 289 | // from |manifest_|. |
| 290 | bool ParsePermissions(const char* key, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 291 | string16* error, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 292 | APIPermissionSet* api_permissions, |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 293 | URLPatternSet* host_permissions); |
| 294 | |
[email protected] | d624b0b | 2012-12-12 04:05:19 | [diff] [blame] | 295 | // Returns true if this extension has the given permission. Prefer |
| 296 | // IsExtensionWithPermissionOrSuggestInConsole when developers may be using an |
| 297 | // api that requires a permission they didn't know about, e.g. open web apis. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 298 | bool HasAPIPermission(APIPermission::ID permission) const; |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 299 | bool HasAPIPermission(const std::string& function_name) const; |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 300 | bool HasAPIPermissionForTab(int tab_id, APIPermission::ID permission) const; |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 301 | |
[email protected] | ecb9ad1 | 2012-08-21 13:02:15 | [diff] [blame] | 302 | bool CheckAPIPermissionWithParam(APIPermission::ID permission, |
| 303 | const APIPermission::CheckParam* param) const; |
[email protected] | 1d8b79a | 2012-08-16 20:22:54 | [diff] [blame] | 304 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 305 | const URLPatternSet& GetEffectiveHostPermissions() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 306 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 307 | // Returns true if the extension can silently increase its permission level. |
[email protected] | 0d90431 | 2012-01-25 23:00:16 | [diff] [blame] | 308 | // Users must approve permissions for unpacked and packed extensions in the |
| 309 | // following situations: |
| 310 | // - when installing or upgrading packed extensions |
| 311 | // - when installing unpacked extensions that have NPAPI plugins |
| 312 | // - when either type of extension requests optional permissions |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 313 | bool CanSilentlyIncreasePermissions() const; |
| 314 | |
[email protected] | 584b8e3f | 2010-04-10 00:23:37 | [diff] [blame] | 315 | // Whether the extension has access to the given URL. |
| 316 | bool HasHostPermission(const GURL& url) const; |
| 317 | |
[email protected] | 0df165f | 2010-09-28 16:49:40 | [diff] [blame] | 318 | // Whether the extension has effective access to all hosts. This is true if |
| 319 | // there is a content script that matches all hosts, if there is a host |
| 320 | // permission grants access to all hosts (like <all_urls>) or an api |
| 321 | // permission that effectively grants access to all hosts (e.g. proxy, |
| 322 | // network, etc.) |
| 323 | bool HasEffectiveAccessToAllHosts() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 324 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 325 | // Whether the extension effectively has all permissions (for example, by |
| 326 | // having an NPAPI plugin). |
| 327 | bool HasFullPermissions() const; |
| 328 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 329 | // Returns the full list of permission messages that this extension |
| 330 | // should display at install time. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 331 | PermissionMessages GetPermissionMessages() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 332 | |
| 333 | // Returns the full list of permission messages that this extension |
| 334 | // should display at install time. The messages are returned as strings |
| 335 | // for convenience. |
| 336 | std::vector<string16> GetPermissionMessageStrings() const; |
| 337 | |
[email protected] | b0d1d0b | 2012-11-02 21:19:03 | [diff] [blame] | 338 | // Returns true if the extension does not require permission warnings |
| 339 | // to be displayed at install time. |
| 340 | bool ShouldSkipPermissionWarnings() const; |
| 341 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 342 | // Sets the active |permissions|. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 343 | void SetActivePermissions(const PermissionSet* permissions) const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 344 | |
| 345 | // Gets the extension's active permission set. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 346 | scoped_refptr<const PermissionSet> GetActivePermissions() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 347 | |
[email protected] | 5df6a5d | 2011-01-26 07:39:12 | [diff] [blame] | 348 | // Whether context menu should be shown for page and browser actions. |
| 349 | bool ShowConfigureContextMenus() const; |
| 350 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 351 | // Returns a list of paths (relative to the extension dir) for images that |
| 352 | // the browser might load (like themes and page action icons). |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 353 | std::set<base::FilePath> GetBrowserImages() const; |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 354 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 355 | // Gets the fully resolved absolute launch URL. |
| 356 | GURL GetFullLaunchURL() const; |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 357 | |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 358 | // Returns true if this extension can execute script on a page. If a |
| 359 | // UserScript object is passed, permission to run that specific script is |
| 360 | // checked (using its matches list). Otherwise, permission to execute script |
| 361 | // programmatically is checked (using the extension's host permission). |
| 362 | // |
| 363 | // This method is also aware of certain special pages that extensions are |
| 364 | // usually not allowed to run script on. |
[email protected] | 78bdfd66 | 2012-08-23 05:53:18 | [diff] [blame] | 365 | bool CanExecuteScriptOnPage(const GURL& document_url, |
| 366 | const GURL& top_document_url, |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 367 | int tab_id, |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 368 | const UserScript* script, |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 369 | std::string* error) const; |
| 370 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 371 | // Returns true if this extension is a COMPONENT extension, or if it is |
| 372 | // on the whitelist of extensions that can script all pages. |
| 373 | bool CanExecuteScriptEverywhere() const; |
| 374 | |
[email protected] | 5efbfe01 | 2011-02-22 23:07:18 | [diff] [blame] | 375 | // Returns true if this extension is allowed to obtain the contents of a |
| 376 | // page as an image. Since a page may contain sensitive information, this |
| 377 | // is restricted to the extension's host permissions as well as the |
| 378 | // extension page itself. |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 379 | bool CanCaptureVisiblePage(const GURL& page_url, |
| 380 | int tab_id, |
| 381 | std::string* error) const; |
[email protected] | 5efbfe01 | 2011-02-22 23:07:18 | [diff] [blame] | 382 | |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 383 | // Returns true if this extension updates itself using the extension |
| 384 | // gallery. |
| 385 | bool UpdatesFromGallery() const; |
| 386 | |
[email protected] | cca14717 | 2011-02-17 01:29:29 | [diff] [blame] | 387 | // Returns true if this extension or app includes areas within |origin|. |
| 388 | bool OverlapsWithOrigin(const GURL& origin) const; |
| 389 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 390 | // Returns the sync bucket to use for this extension. |
| 391 | SyncType GetSyncType() const; |
| 392 | |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 393 | // Returns true if the extension should be synced. |
| 394 | bool IsSyncable() const; |
| 395 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 396 | // Returns true if the extension requires a valid ordinal for sorting, e.g., |
| 397 | // for displaying in a launcher or new tab page. |
| 398 | bool RequiresSortOrdinal() const; |
| 399 | |
| 400 | // Returns true if the extension should be displayed in the app launcher. |
| 401 | bool ShouldDisplayInAppLauncher() const; |
| 402 | |
| 403 | // Returns true if the extension should be displayed in the browser NTP. |
| 404 | bool ShouldDisplayInNewTabPage() const; |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 405 | |
[email protected] | e0b3de7 | 2012-05-01 01:21:34 | [diff] [blame] | 406 | // Returns true if the extension should be displayed in the extension |
| 407 | // settings page (i.e. chrome://extensions). |
| 408 | bool ShouldDisplayInExtensionSettings() const; |
| 409 | |
[email protected] | 4f88601 | 2012-05-19 03:51:10 | [diff] [blame] | 410 | // Returns true if the extension has a content script declared at |url|. |
| 411 | bool HasContentScriptAtURL(const GURL& url) const; |
| 412 | |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 413 | // Gets the tab-specific host permissions of |tab_id|, or NULL if there |
| 414 | // aren't any. |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 415 | scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) |
| 416 | const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 417 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 418 | // Updates the tab-specific permissions of |tab_id| to include those from |
| 419 | // |permissions|. |
[email protected] | 6144057e | 2012-08-02 19:02:37 | [diff] [blame] | 420 | void UpdateTabSpecificPermissions( |
| 421 | int tab_id, |
| 422 | scoped_refptr<const PermissionSet> permissions) const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 423 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 424 | // Clears the tab-specific permissions of |tab_id|. |
| 425 | void ClearTabSpecificPermissions(int tab_id) const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 426 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 427 | // Get the manifest data associated with the key, or NULL if there is none. |
| 428 | // Can only be called after InitValue is finished. |
| 429 | ManifestData* GetManifestData(const std::string& key) const; |
| 430 | |
| 431 | // Sets |data| to be associated with the key. Takes ownership of |data|. |
| 432 | // Can only be called before InitValue is finished. Not thread-safe; |
| 433 | // all SetManifestData calls should be on only one thread. |
| 434 | void SetManifestData(const std::string& key, ManifestData* data); |
| 435 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 436 | // Accessors: |
| 437 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 438 | const Requirements& requirements() const { return requirements_; } |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 439 | const base::FilePath& path() const { return path_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 440 | const GURL& url() const { return extension_url_; } |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 441 | Manifest::Location location() const; |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 442 | const std::string& id() const; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 443 | const Version* version() const { return version_.get(); } |
| 444 | const std::string VersionString() const; |
| 445 | const std::string& name() const { return name_; } |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 446 | const std::string& non_localized_name() const { return non_localized_name_; } |
[email protected] | 200423d | 2012-06-05 01:16:06 | [diff] [blame] | 447 | // Base64-encoded version of the key used to sign this extension. |
| 448 | // In pseudocode, returns |
| 449 | // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
| 450 | const std::string& public_key() const { return public_key_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 451 | const std::string& description() const { return description_; } |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 452 | int manifest_version() const { return manifest_version_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 453 | bool converted_from_user_script() const { |
| 454 | return converted_from_user_script_; |
| 455 | } |
| 456 | const UserScriptList& content_scripts() const { return content_scripts_; } |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 457 | const ActionInfo* system_indicator_info() const { |
| 458 | return system_indicator_info_.get(); |
| 459 | } |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 460 | const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 461 | return nacl_modules_; |
| 462 | } |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 463 | const PermissionSet* optional_permission_set() const { |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 464 | return optional_permission_set_.get(); |
| 465 | } |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 466 | const PermissionSet* required_permission_set() const { |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 467 | return required_permission_set_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 468 | } |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 469 | // Returns the temporary APIPermissionSet used in initialization. |
| 470 | // (NULL after initialization is completed.) |
| 471 | APIPermissionSet* initial_api_permissions() { |
| 472 | return initial_api_permissions_.get(); |
| 473 | } |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 474 | const APIPermissionSet* initial_api_permissions() const { |
| 475 | return initial_api_permissions_.get(); |
| 476 | } |
[email protected] | 23b3c0a | 2013-01-16 23:36:36 | [diff] [blame] | 477 | // Appends |new_warning[s]| to install_warnings_. |
| 478 | void AddInstallWarning(const InstallWarning& new_warning); |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 479 | void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings); |
| 480 | const std::vector<InstallWarning>& install_warnings() const { |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 481 | return install_warnings_; |
| 482 | } |
[email protected] | 953620b | 2011-12-04 00:55:32 | [diff] [blame] | 483 | const extensions::Manifest* manifest() const { |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 484 | return manifest_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 485 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 486 | bool incognito_split_mode() const { return incognito_split_mode_; } |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 487 | bool offline_enabled() const { return offline_enabled_; } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 488 | bool wants_file_access() const { return wants_file_access_; } |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 489 | int creation_flags() const { return creation_flags_; } |
| 490 | bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 491 | bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 492 | bool was_installed_by_default() const { |
| 493 | return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0; |
| 494 | } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 495 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 496 | // App-related. |
[email protected] | 21c0104 | 2013-03-10 23:41:14 | [diff] [blame^] | 497 | bool is_app() const; |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 498 | bool is_platform_app() const; |
| 499 | bool is_hosted_app() const; |
[email protected] | c4f459d | 2012-09-28 04:40:10 | [diff] [blame] | 500 | bool is_legacy_packaged_app() const; |
[email protected] | ff05a4b10 | 2012-12-19 00:12:06 | [diff] [blame] | 501 | bool is_extension() const; |
[email protected] | 605fb810 | 2012-05-04 01:36:55 | [diff] [blame] | 502 | bool is_storage_isolated() const { return is_storage_isolated_; } |
[email protected] | cdc7b1f4 | 2012-12-07 19:39:48 | [diff] [blame] | 503 | bool can_be_incognito_enabled() const; |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 504 | void AddWebExtentPattern(const URLPattern& pattern); |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 505 | const URLPatternSet& web_extent() const { return extent_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 506 | const std::string& launch_local_path() const { return launch_local_path_; } |
| 507 | const std::string& launch_web_url() const { return launch_web_url_; } |
| 508 | extension_misc::LaunchContainer launch_container() const { |
| 509 | return launch_container_; |
| 510 | } |
[email protected] | dc37b00 | 2012-04-23 23:02:26 | [diff] [blame] | 511 | int launch_width() const { return launch_width_; } |
| 512 | int launch_height() const { return launch_height_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 513 | |
| 514 | // Theme-related. |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 515 | bool is_theme() const; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 516 | |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 517 | // Content pack related. |
[email protected] | fbb62083 | 2013-01-25 17:20:35 | [diff] [blame] | 518 | bool is_content_pack() const; |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 519 | ExtensionResource GetContentPackSiteList() const; |
| 520 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 521 | private: |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 522 | friend class base::RefCountedThreadSafe<Extension>; |
| 523 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 524 | class RuntimeData { |
| 525 | public: |
| 526 | RuntimeData(); |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 527 | explicit RuntimeData(const PermissionSet* active); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 528 | ~RuntimeData(); |
| 529 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 530 | void SetActivePermissions(const PermissionSet* active); |
| 531 | scoped_refptr<const PermissionSet> GetActivePermissions() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 532 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 533 | scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) |
| 534 | const; |
[email protected] | 6144057e | 2012-08-02 19:02:37 | [diff] [blame] | 535 | void UpdateTabSpecificPermissions( |
| 536 | int tab_id, |
| 537 | scoped_refptr<const PermissionSet> permissions); |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 538 | void ClearTabSpecificPermissions(int tab_id); |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 539 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 540 | private: |
| 541 | friend class base::RefCountedThreadSafe<RuntimeData>; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 542 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 543 | scoped_refptr<const PermissionSet> active_permissions_; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 544 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 545 | typedef std::map<int, scoped_refptr<const PermissionSet> > |
| 546 | TabPermissionsMap; |
| 547 | TabPermissionsMap tab_specific_permissions_; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 548 | }; |
| 549 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 550 | // Chooses the extension ID for an extension based on a variety of criteria. |
| 551 | // The chosen ID will be set in |manifest|. |
| 552 | static bool InitExtensionID(extensions::Manifest* manifest, |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 553 | const base::FilePath& path, |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 554 | const std::string& explicit_id, |
| 555 | int creation_flags, |
| 556 | string16* error); |
| 557 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 558 | // Normalize the path for use by the extension. On Windows, this will make |
| 559 | // sure the drive letter is uppercase. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 560 | static base::FilePath MaybeNormalizePath(const base::FilePath& path); |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 561 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 562 | // Returns true if this extension id is from a trusted provider. |
| 563 | static bool IsTrustedId(const std::string& id); |
| 564 | |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 565 | Extension(const base::FilePath& path, |
| 566 | scoped_ptr<extensions::Manifest> manifest); |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 567 | virtual ~Extension(); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 568 | |
| 569 | // Initialize the extension from a parsed manifest. |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 570 | // TODO(aa): Rename to just Init()? There's no Value here anymore. |
| 571 | // TODO(aa): It is really weird the way this class essentially contains a copy |
| 572 | // of the underlying DictionaryValue in its members. We should decide to |
| 573 | // either wrap the DictionaryValue and go with that only, or we should parse |
| 574 | // into strong types and discard the value. But doing both is bad. |
| 575 | bool InitFromValue(int flags, string16* error); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 576 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 577 | // The following are helpers for InitFromValue to load various features of the |
| 578 | // extension from the manifest. |
| 579 | |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 580 | bool LoadAppIsolation(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 581 | |
| 582 | bool LoadRequiredFeatures(string16* error); |
| 583 | bool LoadName(string16* error); |
| 584 | bool LoadVersion(string16* error); |
| 585 | |
| 586 | bool LoadAppFeatures(string16* error); |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 587 | bool LoadExtent(const char* key, |
| 588 | URLPatternSet* extent, |
| 589 | const char* list_error, |
| 590 | const char* value_error, |
| 591 | string16* error); |
| 592 | bool LoadLaunchContainer(string16* error); |
| 593 | bool LoadLaunchURL(string16* error); |
[email protected] | 10253da | 2012-03-09 04:06:42 | [diff] [blame] | 594 | |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 595 | bool LoadSharedFeatures(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 596 | bool LoadDescription(string16* error); |
| 597 | bool LoadManifestVersion(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 598 | bool LoadNaClModules(string16* error); |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 599 | bool LoadSandboxedPages(string16* error); |
[email protected] | 098fa7a | 2013-03-08 22:11:17 | [diff] [blame] | 600 | // Must be called after the "plugins" key has been parsed. |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 601 | bool LoadRequirements(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 602 | bool LoadOfflineEnabled(string16* error); |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 603 | bool LoadExtensionFeatures(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 604 | bool LoadContentScripts(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 605 | bool LoadBrowserAction(string16* error); |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 606 | bool LoadSystemIndicator(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 607 | bool LoadTextToSpeechVoices(string16* error); |
| 608 | bool LoadIncognitoMode(string16* error); |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 609 | bool LoadManagedModeFeatures(string16* error); |
| 610 | bool LoadManagedModeSites( |
| 611 | const base::DictionaryValue* content_pack_value, |
| 612 | string16* error); |
| 613 | bool LoadManagedModeConfigurations( |
| 614 | const base::DictionaryValue* content_pack_value, |
| 615 | string16* error); |
| 616 | |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 617 | // Helper method that loads a UserScript object from a |
| 618 | // dictionary in the content_script list of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 619 | bool LoadUserScriptHelper(const base::DictionaryValue* content_script, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 620 | int definition_index, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 621 | string16* error, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 622 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 623 | |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 624 | // Helper method that loads either the include_globs or exclude_globs list |
| 625 | // from an entry in the content_script lists of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 626 | bool LoadGlobsHelper(const base::DictionaryValue* content_script, |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 627 | int content_script_index, |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 628 | const char* globs_property_name, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 629 | string16* error, |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 630 | void(UserScript::*add_method)(const std::string& glob), |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 631 | UserScript* instance); |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 632 | |
[email protected] | 2f6698b | 2010-10-14 00:58:21 | [diff] [blame] | 633 | // Returns true if the extension has more than one "UI surface". For example, |
| 634 | // an extension that has a browser action and a page action. |
| 635 | bool HasMultipleUISurfaces() const; |
| 636 | |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 637 | // Updates the launch URL and extents for the extension using the given |
| 638 | // |override_url|. |
| 639 | void OverrideLaunchUrl(const GURL& override_url); |
| 640 | |
[email protected] | ae655e4e | 2012-03-16 21:47:55 | [diff] [blame] | 641 | // Custom checks for the experimental permission that can't be expressed in |
| 642 | // _permission_features.json. |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 643 | bool CanSpecifyExperimentalPermission() const; |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 644 | |
| 645 | // Checks whether the host |pattern| is allowed for this extension, given API |
| 646 | // permissions |permissions|. |
| 647 | bool CanSpecifyHostPermission(const URLPattern& pattern, |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 648 | const APIPermissionSet& permissions) const; |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 649 | |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 650 | bool CheckMinimumChromeVersion(string16* error) const; |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 651 | |
[email protected] | e92169e | 2012-05-04 22:49:32 | [diff] [blame] | 652 | // Check that platform app features are valid. Called after InitFromValue. |
[email protected] | 9a49487 | 2013-03-02 03:05:45 | [diff] [blame] | 653 | bool CheckPlatformAppFeatures(string16* error) const; |
[email protected] | e92169e | 2012-05-04 22:49:32 | [diff] [blame] | 654 | |
[email protected] | f1bab9c9 | 2012-05-11 21:15:10 | [diff] [blame] | 655 | // Check that features don't conflict. Called after InitFromValue. |
[email protected] | 9a49487 | 2013-03-02 03:05:45 | [diff] [blame] | 656 | bool CheckConflictingFeatures(string16* error) const; |
[email protected] | f1bab9c9 | 2012-05-11 21:15:10 | [diff] [blame] | 657 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 658 | // The extension's human-readable name. Name is used for display purpose. It |
| 659 | // might be wrapped with unicode bidi control characters so that it is |
| 660 | // displayed correctly in RTL context. |
| 661 | // NOTE: Name is UTF-8 and may contain non-ascii characters. |
| 662 | std::string name_; |
| 663 | |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 664 | // A non-localized version of the extension's name. This is useful for |
| 665 | // debug output. |
| 666 | std::string non_localized_name_; |
| 667 | |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 668 | // The version of this extension's manifest. We increase the manifest |
| 669 | // version when making breaking changes to the extension system. |
| 670 | // Version 1 was the first manifest version (implied by a lack of a |
| 671 | // manifest_version attribute in the extension's manifest). We initialize |
| 672 | // this member variable to 0 to distinguish the "uninitialized" case from |
| 673 | // the case when we know the manifest version actually is 1. |
| 674 | int manifest_version_; |
| 675 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 676 | // The requirements declared in the manifest. |
| 677 | Requirements requirements_; |
| 678 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 679 | // The absolute path to the directory the extension is stored in. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 680 | base::FilePath path_; |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 681 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 682 | // If true, a separate process will be used for the extension in incognito |
| 683 | // mode. |
| 684 | bool incognito_split_mode_; |
| 685 | |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 686 | // Whether the extension or app should be enabled when offline. |
| 687 | bool offline_enabled_; |
| 688 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 689 | // Defines the set of URLs in the extension's web content. |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 690 | URLPatternSet extent_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 691 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 692 | // The extension runtime data. |
| 693 | mutable base::Lock runtime_data_lock_; |
| 694 | mutable RuntimeData runtime_data_; |
| 695 | |
[email protected] | 46559463 | 2013-02-15 19:50:28 | [diff] [blame] | 696 | // The API permission set; used during extension initialization. |
| 697 | // Cleared after permissions are finalized by SetActivePermissions. |
| 698 | scoped_ptr<APIPermissionSet> initial_api_permissions_; |
| 699 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 700 | // The set of permissions the extension can request at runtime. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 701 | scoped_refptr<const PermissionSet> optional_permission_set_; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 702 | |
| 703 | // The extension's required / default set of permissions. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 704 | scoped_refptr<const PermissionSet> required_permission_set_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 705 | |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 706 | // Any warnings that occurred when trying to create/parse the extension. |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 707 | std::vector<InstallWarning> install_warnings_; |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 708 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 709 | // The base extension url for the extension. |
| 710 | GURL extension_url_; |
| 711 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 712 | // The extension's version. |
| 713 | scoped_ptr<Version> version_; |
| 714 | |
| 715 | // An optional longer description of the extension. |
| 716 | std::string description_; |
| 717 | |
| 718 | // True if the extension was generated from a user script. (We show slightly |
| 719 | // different UI if so). |
| 720 | bool converted_from_user_script_; |
| 721 | |
| 722 | // Paths to the content scripts the extension contains. |
| 723 | UserScriptList content_scripts_; |
| 724 | |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 725 | // The extension's system indicator, if any. |
| 726 | scoped_ptr<ActionInfo> system_indicator_info_; |
| 727 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 728 | // Optional list of NaCl modules and associated properties. |
| 729 | std::vector<NaClModuleInfo> nacl_modules_; |
| 730 | |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 731 | // Optional list of extension pages that are sandboxed (served from a unique |
| 732 | // origin with a different Content Security Policy). |
[email protected] | f59a805 | 2012-06-20 22:25:00 | [diff] [blame] | 733 | URLPatternSet sandboxed_pages_; |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 734 | |
| 735 | // Content Security Policy that should be used to enforce the sandbox used |
| 736 | // by sandboxed pages (guaranteed to have the "sandbox" directive without the |
| 737 | // "allow-same-origin" token). |
| 738 | std::string sandboxed_pages_content_security_policy_; |
| 739 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 740 | // The public key used to sign the contents of the crx package. |
| 741 | std::string public_key_; |
| 742 | |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 743 | // A file containing a list of sites for Managed Mode. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 744 | base::FilePath content_pack_site_list_; |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 745 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 746 | // The manifest from which this extension was created. |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 747 | scoped_ptr<Manifest> manifest_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 748 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 749 | // Stored parsed manifest data. |
| 750 | ManifestDataMap manifest_data_; |
| 751 | |
| 752 | // Set to true at the end of InitValue when initialization is finished. |
| 753 | bool finished_parsing_manifest_; |
| 754 | |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 755 | // Ensures that any call to GetManifestData() prior to finishing |
| 756 | // initialization happens from the same thread (this can happen when certain |
| 757 | // parts of the initialization process need information from previous parts). |
| 758 | base::ThreadChecker thread_checker_; |
| 759 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 760 | // Whether this extension requests isolated storage. |
| 761 | bool is_storage_isolated_; |
| 762 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 763 | // The local path inside the extension to use with the launcher. |
| 764 | std::string launch_local_path_; |
| 765 | |
| 766 | // A web url to use with the launcher. Note that this might be relative or |
| 767 | // absolute. If relative, it is relative to web_origin. |
| 768 | std::string launch_web_url_; |
| 769 | |
[email protected] | 4e59568 | 2011-02-09 17:07:02 | [diff] [blame] | 770 | // The window type that an app's manifest specifies to launch into. |
| 771 | // This is not always the window type an app will open into, because |
| 772 | // users can override the way each app launches. See |
| 773 | // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref |
| 774 | // to decide what container an app will launch in. |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 775 | extension_misc::LaunchContainer launch_container_; |
| 776 | |
| 777 | // The default size of the container when launching. Only respected for |
| 778 | // containers like panels and windows. |
| 779 | int launch_width_; |
| 780 | int launch_height_; |
| 781 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 782 | // Should this app be shown in the app launcher. |
[email protected] | ed1a204f | 2012-09-22 00:28:44 | [diff] [blame] | 783 | bool display_in_launcher_; |
| 784 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 785 | // Should this app be shown in the browser New Tab Page. |
| 786 | bool display_in_new_tab_page_; |
| 787 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 788 | // Whether the extension has host permissions or user script patterns that |
| 789 | // imply access to file:/// scheme URLs (the user may not have actually |
| 790 | // granted it that access). |
| 791 | bool wants_file_access_; |
| 792 | |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 793 | // The flags that were passed to InitFromValue. |
| 794 | int creation_flags_; |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 795 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 796 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 797 | }; |
| 798 | |
[email protected] | bc151cf9 | 2013-02-12 04:57:26 | [diff] [blame] | 799 | typedef std::vector<scoped_refptr<const Extension> > ExtensionList; |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 800 | typedef std::set<std::string> ExtensionIdSet; |
[email protected] | 82590cb | 2012-09-28 04:14:08 | [diff] [blame] | 801 | typedef std::vector<std::string> ExtensionIdList; |
[email protected] | b1748b1d8 | 2009-11-30 20:32:56 | [diff] [blame] | 802 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 803 | // Handy struct to pass core extension info around. |
| 804 | struct ExtensionInfo { |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 805 | ExtensionInfo(const base::DictionaryValue* manifest, |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 806 | const std::string& id, |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 807 | const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 808 | Manifest::Location location); |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 809 | ~ExtensionInfo(); |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 810 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 811 | scoped_ptr<base::DictionaryValue> extension_manifest; |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 812 | std::string extension_id; |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 813 | base::FilePath extension_path; |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 814 | Manifest::Location extension_location; |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 815 | |
| 816 | private: |
| 817 | DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
| 818 | }; |
| 819 | |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 820 | struct UnloadedExtensionInfo { |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 821 | extension_misc::UnloadedExtensionReason reason; |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 822 | |
| 823 | // Was the extension already disabled? |
| 824 | bool already_disabled; |
| 825 | |
| 826 | // The extension being unloaded - this should always be non-NULL. |
| 827 | const Extension* extension; |
| 828 | |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 829 | UnloadedExtensionInfo( |
| 830 | const Extension* extension, |
| 831 | extension_misc::UnloadedExtensionReason reason); |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 832 | }; |
| 833 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 834 | // The details sent for EXTENSION_PERMISSIONS_UPDATED notifications. |
| 835 | struct UpdatedExtensionPermissionsInfo { |
| 836 | enum Reason { |
[email protected] | f553247 | 2012-02-23 13:00:55 | [diff] [blame] | 837 | ADDED, // The permissions were added to the extension. |
| 838 | REMOVED, // The permissions were removed from the extension. |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 839 | }; |
| 840 | |
| 841 | Reason reason; |
| 842 | |
| 843 | // The extension who's permissions have changed. |
| 844 | const Extension* extension; |
| 845 | |
| 846 | // The permissions that have changed. For Reason::ADDED, this would contain |
| 847 | // only the permissions that have added, and for Reason::REMOVED, this would |
| 848 | // only contain the removed permissions. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 849 | const PermissionSet* permissions; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 850 | |
| 851 | UpdatedExtensionPermissionsInfo( |
| 852 | const Extension* extension, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 853 | const PermissionSet* permissions, |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 854 | Reason reason); |
| 855 | }; |
| 856 | |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 857 | } // namespace extensions |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 858 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 859 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |