[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] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 16 | #include "base/file_path.h" |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 17 | #include "base/gtest_prod_util.h" |
[email protected] | 8f270be | 2011-12-21 21:15:22 | [diff] [blame] | 18 | #include "base/hash_tables.h" |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 19 | #include "base/memory/linked_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 20 | #include "base/memory/ref_counted.h" |
| 21 | #include "base/memory/scoped_ptr.h" |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 22 | #include "base/synchronization/lock.h" |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 23 | #include "base/threading/thread_checker.h" |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame] | 24 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 807871f | 2010-09-16 01:04:48 | [diff] [blame] | 25 | #include "chrome/common/extensions/extension_icon_set.h" |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 26 | #include "chrome/common/extensions/permissions/api_permission.h" |
[email protected] | 1d8b79a | 2012-08-16 20:22:54 | [diff] [blame] | 27 | #include "chrome/common/extensions/permissions/api_permission_set.h" |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 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" |
| 30 | #include "extensions/common/url_pattern.h" |
[email protected] | e9f541a | 2012-11-19 21:52:31 | [diff] [blame] | 31 | #include "extensions/common/url_pattern_set.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 32 | #include "googleurl/src/gurl.h" |
[email protected] | f553247 | 2012-02-23 13:00:55 | [diff] [blame] | 33 | #include "ui/base/accelerators/accelerator.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 34 | #include "ui/gfx/size.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 35 | |
[email protected] | 0f34d908 | 2012-10-08 19:16:44 | [diff] [blame] | 36 | class ExtensionAction; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 37 | class ExtensionResource; |
[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 | FORWARD_DECLARE_TEST(TabStripModelTest, Apps); |
| 51 | |
| 52 | namespace extensions { |
[email protected] | 972b02f | 2013-01-28 20:38:14 | [diff] [blame^] | 53 | struct ActionInfo; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 54 | class Manifest; |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 55 | class PermissionSet; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 56 | |
[email protected] | d4a37f1c | 2012-07-09 21:36:13 | [diff] [blame] | 57 | typedef std::set<std::string> OAuth2Scopes; |
| 58 | |
[email protected] | f075553 | 2010-06-22 07:27:25 | [diff] [blame] | 59 | // Represents a Chrome extension. |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 60 | class Extension : public base::RefCountedThreadSafe<Extension> { |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 61 | public: |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 62 | struct InstallWarning; |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 63 | struct ManifestData; |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 64 | |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 65 | typedef std::vector<std::string> ScriptingWhitelist; |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 66 | typedef std::vector<InstallWarning> InstallWarningVector; |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 67 | typedef std::map<const std::string, linked_ptr<ManifestData> > |
| 68 | ManifestDataMap; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 69 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 70 | // What an extension was loaded from. |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 71 | // NOTE: These values are stored as integers in the preferences and used |
| 72 | // in histograms so don't remove or reorder existing items. Just append |
| 73 | // to the end. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 74 | enum Location { |
| 75 | INVALID, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 76 | INTERNAL, // A crx file from the internal Extensions directory. |
| 77 | EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 78 | EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 79 | // registry on Windows). |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 80 | LOAD, // --load-extension. |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 81 | COMPONENT, // An integral component of Chrome itself, which |
| 82 | // happens to be implemented as an extension. We don't |
| 83 | // show these in the management UI. |
[email protected] | 4d2913e3 | 2010-11-30 00:28:55 | [diff] [blame] | 84 | EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via |
| 85 | // prefs), installed from an update URL. |
| 86 | EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via |
| 87 | // admin policies), installed from an update URL. |
[email protected] | 04cb754 | 2010-10-25 10:50:06 | [diff] [blame] | 88 | |
| 89 | NUM_LOCATIONS |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 93 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 94 | ENABLED, |
[email protected] | 79c833b5 | 2011-04-05 18:31:01 | [diff] [blame] | 95 | // An external extension that the user uninstalled. We should not reinstall |
| 96 | // such extensions on startup. |
| 97 | EXTERNAL_EXTENSION_UNINSTALLED, |
[email protected] | 8c484b74 | 2012-11-29 06:05:36 | [diff] [blame] | 98 | // Special state for component extensions, since they are always loaded by |
| 99 | // the component loader, and should never be auto-installed on startup. |
| 100 | ENABLED_COMPONENT, |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 101 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 102 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 103 | |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 104 | // Used to record the reason an extension was disabled. |
[email protected] | eb5e4f9 | 2012-08-15 23:33:28 | [diff] [blame] | 105 | enum DeprecatedDisableReason { |
| 106 | DEPRECATED_DISABLE_UNKNOWN, |
| 107 | DEPRECATED_DISABLE_USER_ACTION, |
| 108 | DEPRECATED_DISABLE_PERMISSIONS_INCREASE, |
| 109 | DEPRECATED_DISABLE_RELOAD, |
| 110 | DEPRECATED_DISABLE_LAST, // Not used. |
| 111 | }; |
| 112 | |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 113 | enum DisableReason { |
[email protected] | eb5e4f9 | 2012-08-15 23:33:28 | [diff] [blame] | 114 | DISABLE_NONE = 0, |
| 115 | DISABLE_USER_ACTION = 1 << 0, |
| 116 | DISABLE_PERMISSIONS_INCREASE = 1 << 1, |
| 117 | DISABLE_RELOAD = 1 << 2, |
[email protected] | 215a7be | 2012-10-22 19:53:42 | [diff] [blame] | 118 | DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3, |
| 119 | DISABLE_SIDELOAD_WIPEOUT = 1 << 4, |
[email protected] | f56c65ea6 | 2012-12-10 22:57:21 | [diff] [blame] | 120 | DISABLE_UNKNOWN_FROM_SYNC = 1 << 5, |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 121 | }; |
| 122 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 123 | enum InstallType { |
[email protected] | ab6f2b2 | 2009-07-28 23:28:37 | [diff] [blame] | 124 | INSTALL_ERROR, |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 125 | DOWNGRADE, |
| 126 | REINSTALL, |
| 127 | UPGRADE, |
| 128 | NEW_INSTALL |
| 129 | }; |
| 130 | |
[email protected] | 7fa19f8 | 2010-12-21 19:40:08 | [diff] [blame] | 131 | // Do not change the order of entries or remove entries in this list |
| 132 | // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions. |
| 133 | enum Type { |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 134 | TYPE_UNKNOWN = 0, |
| 135 | TYPE_EXTENSION, |
| 136 | TYPE_THEME, |
| 137 | TYPE_USER_SCRIPT, |
| 138 | TYPE_HOSTED_APP, |
[email protected] | c4f459d | 2012-09-28 04:40:10 | [diff] [blame] | 139 | // This is marked legacy because platform apps are preferred. For |
| 140 | // backwards compatibility, we can't remove support for packaged apps |
| 141 | TYPE_LEGACY_PACKAGED_APP, |
[email protected] | 7d3ed2f | 2011-11-07 23:33:19 | [diff] [blame] | 142 | TYPE_PLATFORM_APP |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 143 | }; |
| 144 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 145 | enum SyncType { |
| 146 | SYNC_TYPE_NONE = 0, |
| 147 | SYNC_TYPE_EXTENSION, |
| 148 | SYNC_TYPE_APP |
| 149 | }; |
| 150 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 151 | // Declared requirements for the extension. |
| 152 | struct Requirements { |
| 153 | Requirements(); |
| 154 | ~Requirements(); |
| 155 | |
| 156 | bool webgl; |
| 157 | bool css3d; |
| 158 | bool npapi; |
| 159 | }; |
| 160 | |
[email protected] | 9288808 | 2010-10-18 19:24:57 | [diff] [blame] | 161 | // An NPAPI plugin included in the extension. |
| 162 | struct PluginInfo { |
| 163 | FilePath path; // Path to the plugin. |
| 164 | bool is_public; // False if only this extension can load this plugin. |
| 165 | }; |
| 166 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 167 | // An NaCl module included in the extension. |
| 168 | struct NaClModuleInfo { |
[email protected] | 84396dbc | 2011-04-14 06:33:42 | [diff] [blame] | 169 | GURL url; |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 170 | std::string mime_type; |
| 171 | }; |
| 172 | |
[email protected] | a79be1f | 2012-03-23 22:14:00 | [diff] [blame] | 173 | // OAuth2 info included in the extension. |
| 174 | struct OAuth2Info { |
| 175 | OAuth2Info(); |
| 176 | ~OAuth2Info(); |
| 177 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 178 | OAuth2Scopes GetScopesAsSet(); |
[email protected] | b6f3862 | 2012-04-25 03:20:19 | [diff] [blame] | 179 | |
[email protected] | a79be1f | 2012-03-23 22:14:00 | [diff] [blame] | 180 | std::string client_id; |
| 181 | std::vector<std::string> scopes; |
| 182 | }; |
| 183 | |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 184 | struct InstallWarning { |
| 185 | enum Format { |
| 186 | // IMPORTANT: Do not build HTML strings from user or developer-supplied |
| 187 | // input. |
| 188 | FORMAT_TEXT, |
| 189 | FORMAT_HTML, |
| 190 | }; |
| 191 | InstallWarning(Format format, const std::string& message) |
| 192 | : format(format), message(message) { |
| 193 | } |
[email protected] | 18049dc | 2012-06-19 23:12:55 | [diff] [blame] | 194 | bool operator==(const InstallWarning& other) const; |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 195 | Format format; |
| 196 | std::string message; |
| 197 | }; |
| 198 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 199 | // A base class for parsed manifest data that APIs want to store on |
| 200 | // the extension. Related to base::SupportsUserData, but with an immutable |
| 201 | // thread-safe interface to match Extension. |
| 202 | struct ManifestData { |
| 203 | virtual ~ManifestData() {} |
| 204 | }; |
| 205 | |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 206 | enum InitFromValueFlags { |
| 207 | NO_FLAGS = 0, |
| 208 | |
| 209 | // Usually, the id of an extension is generated by the "key" property of |
| 210 | // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 211 | // generated based on the path. |
| 212 | REQUIRE_KEY = 1 << 0, |
| 213 | |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 214 | // Requires the extension to have an up-to-date manifest version. |
| 215 | // Typically, we'll support multiple manifest versions during a version |
[email protected] | 26367b6 | 2012-10-04 23:03:32 | [diff] [blame] | 216 | // transition. This flag signals that we want to require the most modern |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 217 | // manifest version that Chrome understands. |
| 218 | REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1, |
| 219 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 220 | // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension |
| 221 | // to have file access. If it's not present, then permissions and content |
| 222 | // scripts that match file:/// URLs will be filtered out. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 223 | ALLOW_FILE_ACCESS = 1 << 2, |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 224 | |
| 225 | // |FROM_WEBSTORE| indicates that the extension was installed from the |
| 226 | // Chrome Web Store. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 227 | FROM_WEBSTORE = 1 << 3, |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 228 | |
| 229 | // |FROM_BOOKMARK| indicates the extension was created using a mock App |
| 230 | // created from a bookmark. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 231 | FROM_BOOKMARK = 1 << 4, |
[email protected] | 3d41d43 | 2012-04-20 20:47:58 | [diff] [blame] | 232 | |
| 233 | // |FOLLOW_SYMLINKS_ANYWHERE| means that resources can be symlinks to |
| 234 | // anywhere in the filesystem, rather than being restricted to the |
| 235 | // extension directory. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 236 | FOLLOW_SYMLINKS_ANYWHERE = 1 << 5, |
[email protected] | ab55c2b | 2012-06-01 23:55:03 | [diff] [blame] | 237 | |
| 238 | // |ERROR_ON_PRIVATE_KEY| means that private keys inside an |
| 239 | // extension should be errors rather than warnings. |
| 240 | ERROR_ON_PRIVATE_KEY = 1 << 6, |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 241 | |
| 242 | // |WAS_INSTALLED_BY_DEFAULT| installed by default when the profile was |
| 243 | // created. |
| 244 | WAS_INSTALLED_BY_DEFAULT = 1 << 7, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 245 | }; |
| 246 | |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 247 | static scoped_refptr<Extension> Create(const FilePath& path, |
| 248 | Location location, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 249 | const base::DictionaryValue& value, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 250 | int flags, |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 251 | std::string* error); |
| 252 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 253 | // 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] | 254 | // an explicit id. Most consumers should just use the other Create() method. |
| 255 | static scoped_refptr<Extension> Create(const FilePath& path, |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 256 | Location location, |
| 257 | const base::DictionaryValue& value, |
| 258 | int flags, |
| 259 | const std::string& explicit_id, |
| 260 | std::string* error); |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 261 | |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 262 | // Given two install sources, return the one which should take priority |
| 263 | // over the other. If an extension is installed from two sources A and B, |
| 264 | // its install source should be set to GetHigherPriorityLocation(A, B). |
| 265 | static Location GetHigherPriorityLocation(Location loc1, Location loc2); |
| 266 | |
[email protected] | 4c4f819 | 2009-10-17 01:03:26 | [diff] [blame] | 267 | // Max size (both dimensions) for browser and page actions. |
| 268 | static const int kPageActionIconMaxSize; |
| 269 | static const int kBrowserActionIconMaxSize; |
| 270 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 271 | // Valid schemes for web extent URLPatterns. |
| 272 | static const int kValidWebExtentSchemes; |
| 273 | |
[email protected] | f71f7e6 | 2010-12-07 03:45:33 | [diff] [blame] | 274 | // Valid schemes for host permission URLPatterns. |
| 275 | static const int kValidHostPermissionSchemes; |
| 276 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 277 | // The name of the manifest inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 278 | static const FilePath::CharType kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 279 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 280 | // The name of locale folder inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 281 | static const FilePath::CharType kLocaleFolder[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 282 | |
| 283 | // The name of the messages file inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 284 | static const FilePath::CharType kMessagesFilename[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 285 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 286 | #if defined(OS_WIN) |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 287 | static const char kExtensionRegistryPath[]; |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 288 | #endif |
| 289 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 290 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 291 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 292 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 293 | // The mimetype used for extensions. |
| 294 | static const char kMimeType[]; |
| 295 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 296 | // Checks to see if the extension has a valid ID. |
| 297 | static bool IdIsValid(const std::string& id); |
| 298 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 299 | // Generate an ID for an extension in the given path. |
[email protected] | 28d7479b | 2011-03-09 21:33:27 | [diff] [blame] | 300 | // Used while developing extensions, before they have a key. |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 301 | static std::string GenerateIdForPath(const FilePath& file_name); |
| 302 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 303 | // Returns true if the specified file is an extension. |
| 304 | static bool IsExtension(const FilePath& file_name); |
| 305 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 306 | // Whether the |location| is external or not. |
| 307 | static inline bool IsExternalLocation(Location location) { |
| 308 | return location == Extension::EXTERNAL_PREF || |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 309 | location == Extension::EXTERNAL_REGISTRY || |
[email protected] | 04cb754 | 2010-10-25 10:50:06 | [diff] [blame] | 310 | location == Extension::EXTERNAL_PREF_DOWNLOAD || |
| 311 | location == Extension::EXTERNAL_POLICY_DOWNLOAD; |
| 312 | } |
| 313 | |
| 314 | // Whether extensions with |location| are auto-updatable or not. |
| 315 | static inline bool IsAutoUpdateableLocation(Location location) { |
| 316 | // Only internal and external extensions can be autoupdated. |
| 317 | return location == Extension::INTERNAL || |
| 318 | IsExternalLocation(location); |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 319 | } |
| 320 | |
[email protected] | cdfca970 | 2011-08-08 16:07:01 | [diff] [blame] | 321 | // Unpacked extensions start off with file access since they are a developer |
| 322 | // feature. |
| 323 | static inline bool ShouldAlwaysAllowFileAccess(Location location) { |
| 324 | return location == Extension::LOAD; |
| 325 | } |
| 326 | |
[email protected] | fc6b061 | 2012-03-29 13:40:06 | [diff] [blame] | 327 | // Fills the |info| dictionary with basic information about the extension. |
| 328 | // |enabled| is injected for easier testing. |
| 329 | void GetBasicInfo(bool enabled, base::DictionaryValue* info) const; |
| 330 | |
[email protected] | 7fa19f8 | 2010-12-21 19:40:08 | [diff] [blame] | 331 | // See Type definition above. |
| 332 | Type GetType() const; |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 333 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 334 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 335 | // |extension_url| argument should be the url() from an Extension object. The |
| 336 | // |relative_path| can be untrusted user input. The returned URL will either |
| 337 | // be invalid() or a child of |extension_url|. |
| 338 | // NOTE: Static so that it can be used from multiple threads. |
| 339 | static GURL GetResourceURL(const GURL& extension_url, |
| 340 | const std::string& relative_path); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 341 | GURL GetResourceURL(const std::string& relative_path) const { |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 342 | return GetResourceURL(url(), relative_path); |
| 343 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 344 | |
[email protected] | f59a805 | 2012-06-20 22:25:00 | [diff] [blame] | 345 | // Returns true if the resource matches a pattern in the pattern_set. |
| 346 | bool ResourceMatches(const URLPatternSet& pattern_set, |
| 347 | const std::string& resource) const; |
| 348 | |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 349 | // Returns true if the specified page is sandboxed (served in a unique |
| 350 | // origin). |
| 351 | bool IsSandboxedPage(const std::string& relative_path) const; |
| 352 | |
| 353 | // Returns the Content Security Policy that the specified resource should be |
| 354 | // served with. |
| 355 | std::string GetResourceContentSecurityPolicy(const std::string& relative_path) |
| 356 | const; |
| 357 | |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 358 | // Returns an extension resource object. |relative_path| should be UTF8 |
| 359 | // encoded. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 360 | ExtensionResource GetResource(const std::string& relative_path) const; |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 361 | |
| 362 | // As above, but with |relative_path| following the file system's encoding. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 363 | ExtensionResource GetResource(const FilePath& relative_path) const; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 364 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 365 | // |input| is expected to be the text of an rsa public or private key. It |
| 366 | // tolerates the presence or absence of bracking header/footer like this: |
| 367 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 368 | // and may contain newlines. |
| 369 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 370 | |
| 371 | // Does a simple base64 encoding of |input| into |output|. |
| 372 | static bool ProducePEM(const std::string& input, std::string* output); |
| 373 | |
[email protected] | 84ac7f3 | 2009-10-06 06:17:54 | [diff] [blame] | 374 | // Generates an extension ID from arbitrary input. The same input string will |
| 375 | // always generate the same output ID. |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 376 | static bool GenerateId(const std::string& input, |
| 377 | std::string* output) WARN_UNUSED_RESULT; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 378 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 379 | // Expects base64 encoded |input| and formats into |output| including |
| 380 | // the appropriate header & footer. |
[email protected] | e0d0819 | 2011-03-29 19:02:50 | [diff] [blame] | 381 | static bool FormatPEMForFileOutput(const std::string& input, |
| 382 | std::string* output, |
| 383 | bool is_public); |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 384 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 385 | // Given an extension, icon size, and match type, read a valid icon if present |
[email protected] | e3c0bc2 | 2012-02-24 01:34:15 | [diff] [blame] | 386 | // and decode it into result. In the browser process, this will DCHECK if not |
| 387 | // called on the file thread. To easily load extension images on the UI |
| 388 | // thread, see ImageLoadingTracker. |
| 389 | static void DecodeIcon(const Extension* extension, |
[email protected] | faf8719 | 2012-08-17 00:07:59 | [diff] [blame] | 390 | int icon_size, |
[email protected] | e3c0bc2 | 2012-02-24 01:34:15 | [diff] [blame] | 391 | ExtensionIconSet::MatchType match_type, |
| 392 | scoped_ptr<SkBitmap>* result); |
| 393 | |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 394 | // Given an extension and icon size, read it if present and decode it into |
[email protected] | ae2e0f9 | 2010-04-06 20:32:23 | [diff] [blame] | 395 | // result. In the browser process, this will DCHECK if not called on the |
| 396 | // file thread. To easily load extension images on the UI thread, see |
| 397 | // ImageLoadingTracker. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 398 | static void DecodeIcon(const Extension* extension, |
[email protected] | faf8719 | 2012-08-17 00:07:59 | [diff] [blame] | 399 | int icon_size, |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 400 | scoped_ptr<SkBitmap>* result); |
| 401 | |
| 402 | // Given an icon_path and icon size, read it if present and decode it into |
[email protected] | ae2e0f9 | 2010-04-06 20:32:23 | [diff] [blame] | 403 | // result. In the browser process, this will DCHECK if not called on the |
| 404 | // file thread. To easily load extension images on the UI thread, see |
| 405 | // ImageLoadingTracker. |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 406 | static void DecodeIconFromPath(const FilePath& icon_path, |
[email protected] | faf8719 | 2012-08-17 00:07:59 | [diff] [blame] | 407 | int icon_size, |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 408 | scoped_ptr<SkBitmap>* result); |
| 409 | |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 410 | // Returns the default extension/app icon (for extensions or apps that don't |
| 411 | // have one). |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 412 | static const gfx::ImageSkia& GetDefaultIcon(bool is_app); |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 413 | |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 414 | // Returns the base extension url for a given |extension_id|. |
| 415 | static GURL GetBaseURLFromExtensionId(const std::string& extension_id); |
| 416 | |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 417 | // Adds an extension to the scripting whitelist. Used for testing only. |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 418 | static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 419 | static const ScriptingWhitelist* GetScriptingWhitelist(); |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 420 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 421 | // Parses the host and api permissions from the specified permission |key| |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 422 | // from |manifest_|. |
| 423 | bool ParsePermissions(const char* key, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 424 | string16* error, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 425 | APIPermissionSet* api_permissions, |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 426 | URLPatternSet* host_permissions); |
| 427 | |
[email protected] | d624b0b | 2012-12-12 04:05:19 | [diff] [blame] | 428 | // Returns true if this extension has the given permission. Prefer |
| 429 | // IsExtensionWithPermissionOrSuggestInConsole when developers may be using an |
| 430 | // 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] | 431 | bool HasAPIPermission(APIPermission::ID permission) const; |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 432 | bool HasAPIPermission(const std::string& function_name) const; |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 433 | bool HasAPIPermissionForTab(int tab_id, APIPermission::ID permission) const; |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 434 | |
[email protected] | ecb9ad1 | 2012-08-21 13:02:15 | [diff] [blame] | 435 | bool CheckAPIPermissionWithParam(APIPermission::ID permission, |
| 436 | const APIPermission::CheckParam* param) const; |
[email protected] | 1d8b79a | 2012-08-16 20:22:54 | [diff] [blame] | 437 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 438 | const URLPatternSet& GetEffectiveHostPermissions() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 439 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 440 | // Returns true if the extension can silently increase its permission level. |
[email protected] | 0d90431 | 2012-01-25 23:00:16 | [diff] [blame] | 441 | // Users must approve permissions for unpacked and packed extensions in the |
| 442 | // following situations: |
| 443 | // - when installing or upgrading packed extensions |
| 444 | // - when installing unpacked extensions that have NPAPI plugins |
| 445 | // - when either type of extension requests optional permissions |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 446 | bool CanSilentlyIncreasePermissions() const; |
| 447 | |
[email protected] | 584b8e3f | 2010-04-10 00:23:37 | [diff] [blame] | 448 | // Whether the extension has access to the given URL. |
| 449 | bool HasHostPermission(const GURL& url) const; |
| 450 | |
[email protected] | 0df165f | 2010-09-28 16:49:40 | [diff] [blame] | 451 | // Whether the extension has effective access to all hosts. This is true if |
| 452 | // there is a content script that matches all hosts, if there is a host |
| 453 | // permission grants access to all hosts (like <all_urls>) or an api |
| 454 | // permission that effectively grants access to all hosts (e.g. proxy, |
| 455 | // network, etc.) |
| 456 | bool HasEffectiveAccessToAllHosts() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 457 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 458 | // Whether the extension effectively has all permissions (for example, by |
| 459 | // having an NPAPI plugin). |
| 460 | bool HasFullPermissions() const; |
| 461 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 462 | // Returns the full list of permission messages that this extension |
| 463 | // should display at install time. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 464 | PermissionMessages GetPermissionMessages() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 465 | |
| 466 | // Returns the full list of permission messages that this extension |
| 467 | // should display at install time. The messages are returned as strings |
| 468 | // for convenience. |
| 469 | std::vector<string16> GetPermissionMessageStrings() const; |
| 470 | |
[email protected] | b0d1d0b | 2012-11-02 21:19:03 | [diff] [blame] | 471 | // Returns true if the extension does not require permission warnings |
| 472 | // to be displayed at install time. |
| 473 | bool ShouldSkipPermissionWarnings() const; |
| 474 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 475 | // Sets the active |permissions|. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 476 | void SetActivePermissions(const PermissionSet* permissions) const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 477 | |
| 478 | // Gets the extension's active permission set. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 479 | scoped_refptr<const PermissionSet> GetActivePermissions() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 480 | |
[email protected] | 5df6a5d | 2011-01-26 07:39:12 | [diff] [blame] | 481 | // Whether context menu should be shown for page and browser actions. |
| 482 | bool ShowConfigureContextMenus() const; |
| 483 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 484 | // Returns a list of paths (relative to the extension dir) for images that |
| 485 | // the browser might load (like themes and page action icons). |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 486 | std::set<FilePath> GetBrowserImages() const; |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 487 | |
[email protected] | 807871f | 2010-09-16 01:04:48 | [diff] [blame] | 488 | // Get an extension icon as a resource or URL. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 489 | ExtensionResource GetIconResource( |
| 490 | int size, ExtensionIconSet::MatchType match_type) const; |
| 491 | GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 492 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 493 | // Gets the fully resolved absolute launch URL. |
| 494 | GURL GetFullLaunchURL() const; |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 495 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 496 | // Image cache related methods. These are only valid on the UI thread and |
| 497 | // not maintained by this class. See ImageLoadingTracker for usage. The |
| 498 | // |original_size| parameter should be the size of the image at |source| |
| 499 | // before any scaling may have been done to produce the pixels in |image|. |
| 500 | void SetCachedImage(const ExtensionResource& source, |
| 501 | const SkBitmap& image, |
| 502 | const gfx::Size& original_size) const; |
| 503 | bool HasCachedImage(const ExtensionResource& source, |
| 504 | const gfx::Size& max_size) const; |
| 505 | SkBitmap GetCachedImage(const ExtensionResource& source, |
| 506 | const gfx::Size& max_size) const; |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 507 | |
| 508 | // Returns true if this extension can execute script on a page. If a |
| 509 | // UserScript object is passed, permission to run that specific script is |
| 510 | // checked (using its matches list). Otherwise, permission to execute script |
| 511 | // programmatically is checked (using the extension's host permission). |
| 512 | // |
| 513 | // This method is also aware of certain special pages that extensions are |
| 514 | // usually not allowed to run script on. |
[email protected] | 78bdfd66 | 2012-08-23 05:53:18 | [diff] [blame] | 515 | bool CanExecuteScriptOnPage(const GURL& document_url, |
| 516 | const GURL& top_document_url, |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 517 | int tab_id, |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 518 | const UserScript* script, |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 519 | std::string* error) const; |
| 520 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 521 | // Returns true if this extension is a COMPONENT extension, or if it is |
| 522 | // on the whitelist of extensions that can script all pages. |
| 523 | bool CanExecuteScriptEverywhere() const; |
| 524 | |
[email protected] | 5efbfe01 | 2011-02-22 23:07:18 | [diff] [blame] | 525 | // Returns true if this extension is allowed to obtain the contents of a |
| 526 | // page as an image. Since a page may contain sensitive information, this |
| 527 | // is restricted to the extension's host permissions as well as the |
| 528 | // extension page itself. |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 529 | bool CanCaptureVisiblePage(const GURL& page_url, |
| 530 | int tab_id, |
| 531 | std::string* error) const; |
[email protected] | 5efbfe01 | 2011-02-22 23:07:18 | [diff] [blame] | 532 | |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 533 | // Returns true if this extension updates itself using the extension |
| 534 | // gallery. |
| 535 | bool UpdatesFromGallery() const; |
| 536 | |
[email protected] | cca14717 | 2011-02-17 01:29:29 | [diff] [blame] | 537 | // Returns true if this extension or app includes areas within |origin|. |
| 538 | bool OverlapsWithOrigin(const GURL& origin) const; |
| 539 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 540 | // Returns the sync bucket to use for this extension. |
| 541 | SyncType GetSyncType() const; |
| 542 | |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 543 | // Returns true if the extension should be synced. |
| 544 | bool IsSyncable() const; |
| 545 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 546 | // Returns true if the extension requires a valid ordinal for sorting, e.g., |
| 547 | // for displaying in a launcher or new tab page. |
| 548 | bool RequiresSortOrdinal() const; |
| 549 | |
| 550 | // Returns true if the extension should be displayed in the app launcher. |
| 551 | bool ShouldDisplayInAppLauncher() const; |
| 552 | |
| 553 | // Returns true if the extension should be displayed in the browser NTP. |
| 554 | bool ShouldDisplayInNewTabPage() const; |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 555 | |
[email protected] | e0b3de7 | 2012-05-01 01:21:34 | [diff] [blame] | 556 | // Returns true if the extension should be displayed in the extension |
| 557 | // settings page (i.e. chrome://extensions). |
| 558 | bool ShouldDisplayInExtensionSettings() const; |
| 559 | |
[email protected] | 4f88601 | 2012-05-19 03:51:10 | [diff] [blame] | 560 | // Returns true if the extension has a content script declared at |url|. |
| 561 | bool HasContentScriptAtURL(const GURL& url) const; |
| 562 | |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 563 | // Gets the tab-specific host permissions of |tab_id|, or NULL if there |
| 564 | // aren't any. |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 565 | scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) |
| 566 | const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 567 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 568 | // Updates the tab-specific permissions of |tab_id| to include those from |
| 569 | // |permissions|. |
[email protected] | 6144057e | 2012-08-02 19:02:37 | [diff] [blame] | 570 | void UpdateTabSpecificPermissions( |
| 571 | int tab_id, |
| 572 | scoped_refptr<const PermissionSet> permissions) const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 573 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 574 | // Clears the tab-specific permissions of |tab_id|. |
| 575 | void ClearTabSpecificPermissions(int tab_id) const; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 576 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 577 | // Get the manifest data associated with the key, or NULL if there is none. |
| 578 | // Can only be called after InitValue is finished. |
| 579 | ManifestData* GetManifestData(const std::string& key) const; |
| 580 | |
| 581 | // Sets |data| to be associated with the key. Takes ownership of |data|. |
| 582 | // Can only be called before InitValue is finished. Not thread-safe; |
| 583 | // all SetManifestData calls should be on only one thread. |
| 584 | void SetManifestData(const std::string& key, ManifestData* data); |
| 585 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 586 | // Accessors: |
| 587 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 588 | const Requirements& requirements() const { return requirements_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 589 | const FilePath& path() const { return path_; } |
| 590 | const GURL& url() const { return extension_url_; } |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 591 | Location location() const; |
| 592 | const std::string& id() const; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 593 | const Version* version() const { return version_.get(); } |
| 594 | const std::string VersionString() const; |
| 595 | const std::string& name() const { return name_; } |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 596 | const std::string& non_localized_name() const { return non_localized_name_; } |
[email protected] | 200423d | 2012-06-05 01:16:06 | [diff] [blame] | 597 | // Base64-encoded version of the key used to sign this extension. |
| 598 | // In pseudocode, returns |
| 599 | // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
| 600 | const std::string& public_key() const { return public_key_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 601 | const std::string& description() const { return description_; } |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 602 | int manifest_version() const { return manifest_version_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 603 | bool converted_from_user_script() const { |
| 604 | return converted_from_user_script_; |
| 605 | } |
| 606 | const UserScriptList& content_scripts() const { return content_scripts_; } |
[email protected] | 0f34d908 | 2012-10-08 19:16:44 | [diff] [blame] | 607 | const ActionInfo* page_action_info() const { return page_action_info_.get(); } |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 608 | const ActionInfo* system_indicator_info() const { |
| 609 | return system_indicator_info_.get(); |
| 610 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 611 | const std::vector<PluginInfo>& plugins() const { return plugins_; } |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 612 | const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 613 | return nacl_modules_; |
| 614 | } |
[email protected] | a03d4448f | 2012-01-10 23:25:28 | [diff] [blame] | 615 | bool has_background_page() const { |
| 616 | return background_url_.is_valid() || !background_scripts_.empty(); |
| 617 | } |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 618 | bool allow_background_js_access() const { |
| 619 | return allow_background_js_access_; |
| 620 | } |
[email protected] | a03d4448f | 2012-01-10 23:25:28 | [diff] [blame] | 621 | const std::vector<std::string>& background_scripts() const { |
| 622 | return background_scripts_; |
| 623 | } |
[email protected] | d2aa06b | 2012-03-21 20:57:26 | [diff] [blame] | 624 | bool has_persistent_background_page() const { |
[email protected] | dd62fa80 | 2012-04-25 18:37:00 | [diff] [blame] | 625 | return has_background_page() && background_page_is_persistent_; |
[email protected] | d2aa06b | 2012-03-21 20:57:26 | [diff] [blame] | 626 | } |
| 627 | bool has_lazy_background_page() const { |
[email protected] | dd62fa80 | 2012-04-25 18:37:00 | [diff] [blame] | 628 | return has_background_page() && !background_page_is_persistent_; |
[email protected] | d2aa06b | 2012-03-21 20:57:26 | [diff] [blame] | 629 | } |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 630 | const PermissionSet* optional_permission_set() const { |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 631 | return optional_permission_set_.get(); |
| 632 | } |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 633 | const PermissionSet* required_permission_set() const { |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 634 | return required_permission_set_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 635 | } |
[email protected] | 23b3c0a | 2013-01-16 23:36:36 | [diff] [blame] | 636 | // Appends |new_warning[s]| to install_warnings_. |
| 637 | void AddInstallWarning(const InstallWarning& new_warning); |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 638 | void AddInstallWarnings(const InstallWarningVector& new_warnings); |
| 639 | const InstallWarningVector& install_warnings() const { |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 640 | return install_warnings_; |
| 641 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 642 | const ExtensionIconSet& icons() const { return icons_; } |
[email protected] | 953620b | 2011-12-04 00:55:32 | [diff] [blame] | 643 | const extensions::Manifest* manifest() const { |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 644 | return manifest_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 645 | } |
| 646 | const std::string default_locale() const { return default_locale_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 647 | bool incognito_split_mode() const { return incognito_split_mode_; } |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 648 | bool offline_enabled() const { return offline_enabled_; } |
[email protected] | a79be1f | 2012-03-23 22:14:00 | [diff] [blame] | 649 | const OAuth2Info& oauth2_info() const { return oauth2_info_; } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 650 | bool wants_file_access() const { return wants_file_access_; } |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 651 | int creation_flags() const { return creation_flags_; } |
| 652 | bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 653 | bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 654 | bool was_installed_by_default() const { |
| 655 | return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0; |
| 656 | } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 657 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 658 | // App-related. |
[email protected] | 953620b | 2011-12-04 00:55:32 | [diff] [blame] | 659 | bool is_app() const { |
[email protected] | c4f459d | 2012-09-28 04:40:10 | [diff] [blame] | 660 | return is_legacy_packaged_app() || is_hosted_app() || is_platform_app(); |
[email protected] | 2369087 | 2011-12-01 22:02:39 | [diff] [blame] | 661 | } |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 662 | bool is_platform_app() const; |
| 663 | bool is_hosted_app() const; |
[email protected] | c4f459d | 2012-09-28 04:40:10 | [diff] [blame] | 664 | bool is_legacy_packaged_app() const; |
[email protected] | ff05a4b10 | 2012-12-19 00:12:06 | [diff] [blame] | 665 | bool is_extension() const; |
[email protected] | 605fb810 | 2012-05-04 01:36:55 | [diff] [blame] | 666 | bool is_storage_isolated() const { return is_storage_isolated_; } |
[email protected] | cdc7b1f4 | 2012-12-07 19:39:48 | [diff] [blame] | 667 | bool can_be_incognito_enabled() const; |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 668 | void AddWebExtentPattern(const URLPattern& pattern); |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 669 | const URLPatternSet& web_extent() const { return extent_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 670 | const std::string& launch_local_path() const { return launch_local_path_; } |
| 671 | const std::string& launch_web_url() const { return launch_web_url_; } |
| 672 | extension_misc::LaunchContainer launch_container() const { |
| 673 | return launch_container_; |
| 674 | } |
[email protected] | dc37b00 | 2012-04-23 23:02:26 | [diff] [blame] | 675 | int launch_width() const { return launch_width_; } |
| 676 | int launch_height() const { return launch_height_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 677 | |
| 678 | // Theme-related. |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 679 | bool is_theme() const; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 680 | base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 681 | base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); } |
| 682 | base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
| 683 | base::DictionaryValue* GetThemeDisplayProperties() const { |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 684 | return theme_display_properties_.get(); |
| 685 | } |
| 686 | |
[email protected] | 6d55bd6 | 2012-11-21 17:52:03 | [diff] [blame] | 687 | // Content Security Policy! |
| 688 | const std::string& content_security_policy() const { |
| 689 | return content_security_policy_; |
| 690 | } |
| 691 | |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 692 | // Content pack related. |
[email protected] | fbb62083 | 2013-01-25 17:20:35 | [diff] [blame] | 693 | bool is_content_pack() const; |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 694 | ExtensionResource GetContentPackSiteList() const; |
| 695 | |
[email protected] | a03d4448f | 2012-01-10 23:25:28 | [diff] [blame] | 696 | GURL GetBackgroundURL() const; |
| 697 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 698 | private: |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 699 | friend class base::RefCountedThreadSafe<Extension>; |
| 700 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 701 | // We keep a cache of images loaded from extension resources based on their |
| 702 | // path and a string representation of a size that may have been used to |
| 703 | // scale it (or the empty string if the image is at its original size). |
| 704 | typedef std::pair<FilePath, std::string> ImageCacheKey; |
| 705 | typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
| 706 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 707 | class RuntimeData { |
| 708 | public: |
| 709 | RuntimeData(); |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 710 | explicit RuntimeData(const PermissionSet* active); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 711 | ~RuntimeData(); |
| 712 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 713 | void SetActivePermissions(const PermissionSet* active); |
| 714 | scoped_refptr<const PermissionSet> GetActivePermissions() const; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 715 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 716 | scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) |
| 717 | const; |
[email protected] | 6144057e | 2012-08-02 19:02:37 | [diff] [blame] | 718 | void UpdateTabSpecificPermissions( |
| 719 | int tab_id, |
| 720 | scoped_refptr<const PermissionSet> permissions); |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 721 | void ClearTabSpecificPermissions(int tab_id); |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 722 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 723 | private: |
| 724 | friend class base::RefCountedThreadSafe<RuntimeData>; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 725 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 726 | scoped_refptr<const PermissionSet> active_permissions_; |
[email protected] | fc5e65d6b | 2012-06-13 00:22:57 | [diff] [blame] | 727 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 728 | typedef std::map<int, scoped_refptr<const PermissionSet> > |
| 729 | TabPermissionsMap; |
| 730 | TabPermissionsMap tab_specific_permissions_; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 731 | }; |
| 732 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 733 | // Chooses the extension ID for an extension based on a variety of criteria. |
| 734 | // The chosen ID will be set in |manifest|. |
| 735 | static bool InitExtensionID(extensions::Manifest* manifest, |
| 736 | const FilePath& path, |
| 737 | const std::string& explicit_id, |
| 738 | int creation_flags, |
| 739 | string16* error); |
| 740 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 741 | // Normalize the path for use by the extension. On Windows, this will make |
| 742 | // sure the drive letter is uppercase. |
| 743 | static FilePath MaybeNormalizePath(const FilePath& path); |
| 744 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 745 | // Returns true if this extension id is from a trusted provider. |
| 746 | static bool IsTrustedId(const std::string& id); |
| 747 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 748 | Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest); |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 749 | virtual ~Extension(); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 750 | |
| 751 | // Initialize the extension from a parsed manifest. |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 752 | // TODO(aa): Rename to just Init()? There's no Value here anymore. |
| 753 | // TODO(aa): It is really weird the way this class essentially contains a copy |
| 754 | // of the underlying DictionaryValue in its members. We should decide to |
| 755 | // either wrap the DictionaryValue and go with that only, or we should parse |
| 756 | // into strong types and discard the value. But doing both is bad. |
| 757 | bool InitFromValue(int flags, string16* error); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 758 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 759 | // The following are helpers for InitFromValue to load various features of the |
| 760 | // extension from the manifest. |
| 761 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 762 | bool LoadAppIsolation(const APIPermissionSet& api_permissions, |
[email protected] | 605fb810 | 2012-05-04 01:36:55 | [diff] [blame] | 763 | string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 764 | |
| 765 | bool LoadRequiredFeatures(string16* error); |
| 766 | bool LoadName(string16* error); |
| 767 | bool LoadVersion(string16* error); |
| 768 | |
| 769 | bool LoadAppFeatures(string16* error); |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 770 | bool LoadExtent(const char* key, |
| 771 | URLPatternSet* extent, |
| 772 | const char* list_error, |
| 773 | const char* value_error, |
| 774 | string16* error); |
| 775 | bool LoadLaunchContainer(string16* error); |
| 776 | bool LoadLaunchURL(string16* error); |
[email protected] | 10253da | 2012-03-09 04:06:42 | [diff] [blame] | 777 | |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 778 | bool LoadSharedFeatures(const APIPermissionSet& api_permissions, |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 779 | string16* error); |
| 780 | bool LoadDescription(string16* error); |
| 781 | bool LoadManifestVersion(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 782 | bool LoadIcons(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 783 | bool LoadPlugins(string16* error); |
| 784 | bool LoadNaClModules(string16* error); |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 785 | bool LoadSandboxedPages(string16* error); |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 786 | // Must be called after LoadPlugins(). |
| 787 | bool LoadRequirements(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 788 | bool LoadDefaultLocale(string16* error); |
| 789 | bool LoadOfflineEnabled(string16* error); |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 790 | bool LoadBackgroundScripts(string16* error); |
[email protected] | 75603853 | 2012-06-08 05:45:03 | [diff] [blame] | 791 | bool LoadBackgroundScripts(const std::string& key, string16* error); |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 792 | bool LoadBackgroundPage(const APIPermissionSet& api_permissions, |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 793 | string16* error); |
[email protected] | 75603853 | 2012-06-08 05:45:03 | [diff] [blame] | 794 | bool LoadBackgroundPage(const std::string& key, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 795 | const APIPermissionSet& api_permissions, |
[email protected] | 75603853 | 2012-06-08 05:45:03 | [diff] [blame] | 796 | string16* error); |
[email protected] | dd62fa80 | 2012-04-25 18:37:00 | [diff] [blame] | 797 | bool LoadBackgroundPersistent( |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 798 | const APIPermissionSet& api_permissions, |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 799 | string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 800 | bool LoadBackgroundAllowJSAccess( |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 801 | const APIPermissionSet& api_permissions, |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 802 | string16* error); |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 803 | bool LoadExtensionFeatures(APIPermissionSet* api_permissions, |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 804 | string16* error); |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 805 | bool LoadManifestHandlerFeatures(string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 806 | bool LoadContentScripts(string16* error); |
| 807 | bool LoadPageAction(string16* error); |
| 808 | bool LoadBrowserAction(string16* error); |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 809 | bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 810 | bool LoadTextToSpeechVoices(string16* error); |
| 811 | bool LoadIncognitoMode(string16* error); |
| 812 | bool LoadContentSecurityPolicy(string16* error); |
| 813 | |
| 814 | bool LoadThemeFeatures(string16* error); |
| 815 | bool LoadThemeImages(const base::DictionaryValue* theme_value, |
| 816 | string16* error); |
| 817 | bool LoadThemeColors(const base::DictionaryValue* theme_value, |
| 818 | string16* error); |
| 819 | bool LoadThemeTints(const base::DictionaryValue* theme_value, |
| 820 | string16* error); |
| 821 | bool LoadThemeDisplayProperties(const base::DictionaryValue* theme_value, |
| 822 | string16* error); |
| 823 | |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 824 | bool LoadManagedModeFeatures(string16* error); |
| 825 | bool LoadManagedModeSites( |
| 826 | const base::DictionaryValue* content_pack_value, |
| 827 | string16* error); |
| 828 | bool LoadManagedModeConfigurations( |
| 829 | const base::DictionaryValue* content_pack_value, |
| 830 | string16* error); |
| 831 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 832 | // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 833 | // value of NULL means there is no matching image cached (we allow caching an |
| 834 | // empty SkBitmap). |
| 835 | SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
| 836 | const gfx::Size& max_size) const; |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 837 | |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 838 | // Helper method that loads a UserScript object from a |
| 839 | // dictionary in the content_script list of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 840 | bool LoadUserScriptHelper(const base::DictionaryValue* content_script, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 841 | int definition_index, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 842 | string16* error, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 843 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 844 | |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 845 | // Helper method that loads either the include_globs or exclude_globs list |
| 846 | // from an entry in the content_script lists of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 847 | bool LoadGlobsHelper(const base::DictionaryValue* content_script, |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 848 | int content_script_index, |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 849 | const char* globs_property_name, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 850 | string16* error, |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 851 | void(UserScript::*add_method)(const std::string& glob), |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 852 | UserScript* instance); |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 853 | |
[email protected] | a79be1f | 2012-03-23 22:14:00 | [diff] [blame] | 854 | // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. |
| 855 | bool LoadOAuth2Info(string16* error); |
| 856 | |
[email protected] | 2f6698b | 2010-10-14 00:58:21 | [diff] [blame] | 857 | // Returns true if the extension has more than one "UI surface". For example, |
| 858 | // an extension that has a browser action and a page action. |
| 859 | bool HasMultipleUISurfaces() const; |
| 860 | |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 861 | // Updates the launch URL and extents for the extension using the given |
| 862 | // |override_url|. |
| 863 | void OverrideLaunchUrl(const GURL& override_url); |
| 864 | |
[email protected] | ae655e4e | 2012-03-16 21:47:55 | [diff] [blame] | 865 | // Custom checks for the experimental permission that can't be expressed in |
| 866 | // _permission_features.json. |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 867 | bool CanSpecifyExperimentalPermission() const; |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 868 | |
| 869 | // Checks whether the host |pattern| is allowed for this extension, given API |
| 870 | // permissions |permissions|. |
| 871 | bool CanSpecifyHostPermission(const URLPattern& pattern, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 872 | const APIPermissionSet& permissions) const; |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 873 | |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 874 | bool CheckMinimumChromeVersion(string16* error) const; |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 875 | |
[email protected] | e92169e | 2012-05-04 22:49:32 | [diff] [blame] | 876 | // Check that platform app features are valid. Called after InitFromValue. |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 877 | bool CheckPlatformAppFeatures(std::string* utf8_error) const; |
[email protected] | e92169e | 2012-05-04 22:49:32 | [diff] [blame] | 878 | |
[email protected] | f1bab9c9 | 2012-05-11 21:15:10 | [diff] [blame] | 879 | // Check that features don't conflict. Called after InitFromValue. |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 880 | bool CheckConflictingFeatures(std::string* utf8_error) const; |
[email protected] | f1bab9c9 | 2012-05-11 21:15:10 | [diff] [blame] | 881 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 882 | // Cached images for this extension. This should only be touched on the UI |
| 883 | // thread. |
| 884 | mutable ImageCache image_cache_; |
[email protected] | 1e8c93f | 2010-02-08 22:58:31 | [diff] [blame] | 885 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 886 | // The extension's human-readable name. Name is used for display purpose. It |
| 887 | // might be wrapped with unicode bidi control characters so that it is |
| 888 | // displayed correctly in RTL context. |
| 889 | // NOTE: Name is UTF-8 and may contain non-ascii characters. |
| 890 | std::string name_; |
| 891 | |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 892 | // A non-localized version of the extension's name. This is useful for |
| 893 | // debug output. |
| 894 | std::string non_localized_name_; |
| 895 | |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 896 | // The version of this extension's manifest. We increase the manifest |
| 897 | // version when making breaking changes to the extension system. |
| 898 | // Version 1 was the first manifest version (implied by a lack of a |
| 899 | // manifest_version attribute in the extension's manifest). We initialize |
| 900 | // this member variable to 0 to distinguish the "uninitialized" case from |
| 901 | // the case when we know the manifest version actually is 1. |
| 902 | int manifest_version_; |
| 903 | |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 904 | // The requirements declared in the manifest. |
| 905 | Requirements requirements_; |
| 906 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 907 | // The absolute path to the directory the extension is stored in. |
| 908 | FilePath path_; |
| 909 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 910 | // Default locale for fall back. Can be empty if extension is not localized. |
| 911 | std::string default_locale_; |
| 912 | |
| 913 | // If true, a separate process will be used for the extension in incognito |
| 914 | // mode. |
| 915 | bool incognito_split_mode_; |
| 916 | |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 917 | // Whether the extension or app should be enabled when offline. |
| 918 | bool offline_enabled_; |
| 919 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 920 | // Defines the set of URLs in the extension's web content. |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 921 | URLPatternSet extent_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 922 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 923 | // The extension runtime data. |
| 924 | mutable base::Lock runtime_data_lock_; |
| 925 | mutable RuntimeData runtime_data_; |
| 926 | |
| 927 | // The set of permissions the extension can request at runtime. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 928 | scoped_refptr<const PermissionSet> optional_permission_set_; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 929 | |
| 930 | // The extension's required / default set of permissions. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 931 | scoped_refptr<const PermissionSet> required_permission_set_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 932 | |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 933 | // Any warnings that occurred when trying to create/parse the extension. |
[email protected] | 1e0f45a | 2012-06-13 00:31:06 | [diff] [blame] | 934 | InstallWarningVector install_warnings_; |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 935 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 936 | // The icons for the extension. |
| 937 | ExtensionIconSet icons_; |
| 938 | |
| 939 | // The base extension url for the extension. |
| 940 | GURL extension_url_; |
| 941 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 942 | // The extension's version. |
| 943 | scoped_ptr<Version> version_; |
| 944 | |
| 945 | // An optional longer description of the extension. |
| 946 | std::string description_; |
| 947 | |
| 948 | // True if the extension was generated from a user script. (We show slightly |
| 949 | // different UI if so). |
| 950 | bool converted_from_user_script_; |
| 951 | |
| 952 | // Paths to the content scripts the extension contains. |
| 953 | UserScriptList content_scripts_; |
| 954 | |
| 955 | // The extension's page action, if any. |
[email protected] | 0f34d908 | 2012-10-08 19:16:44 | [diff] [blame] | 956 | scoped_ptr<ActionInfo> page_action_info_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 957 | |
[email protected] | ad12b6b | 2012-11-28 23:21:15 | [diff] [blame] | 958 | // The extension's system indicator, if any. |
| 959 | scoped_ptr<ActionInfo> system_indicator_info_; |
| 960 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 961 | // Optional list of NPAPI plugins and associated properties. |
| 962 | std::vector<PluginInfo> plugins_; |
| 963 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 964 | // Optional list of NaCl modules and associated properties. |
| 965 | std::vector<NaClModuleInfo> nacl_modules_; |
| 966 | |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 967 | // Optional list of extension pages that are sandboxed (served from a unique |
| 968 | // origin with a different Content Security Policy). |
[email protected] | f59a805 | 2012-06-20 22:25:00 | [diff] [blame] | 969 | URLPatternSet sandboxed_pages_; |
[email protected] | dbb2416 | 2012-06-06 01:41:22 | [diff] [blame] | 970 | |
| 971 | // Content Security Policy that should be used to enforce the sandbox used |
| 972 | // by sandboxed pages (guaranteed to have the "sandbox" directive without the |
| 973 | // "allow-same-origin" token). |
| 974 | std::string sandboxed_pages_content_security_policy_; |
| 975 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 976 | // Optional URL to a master page of which a single instance should be always |
| 977 | // loaded in the background. |
| 978 | GURL background_url_; |
| 979 | |
[email protected] | a03d4448f | 2012-01-10 23:25:28 | [diff] [blame] | 980 | // Optional list of scripts to use to generate a background page. If this is |
| 981 | // present, background_url_ will be empty and generated by GetBackgroundURL(). |
| 982 | std::vector<std::string> background_scripts_; |
| 983 | |
[email protected] | dd62fa80 | 2012-04-25 18:37:00 | [diff] [blame] | 984 | // True if the background page should stay loaded forever; false if it should |
| 985 | // load on-demand (when it needs to handle an event). Defaults to true. |
| 986 | bool background_page_is_persistent_; |
[email protected] | 9e6720a | 2012-01-24 02:30:56 | [diff] [blame] | 987 | |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 988 | // True if the background page can be scripted by pages of the app or |
| 989 | // extension, in which case all such pages must run in the same process. |
| 990 | // False if such pages are not permitted to script the background page, |
| 991 | // allowing them to run in different processes. |
| 992 | bool allow_background_js_access_; |
| 993 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 994 | // The public key used to sign the contents of the crx package. |
| 995 | std::string public_key_; |
| 996 | |
| 997 | // A map of resource id's to relative file paths. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 998 | scoped_ptr<base::DictionaryValue> theme_images_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 999 | |
| 1000 | // A map of color names to colors. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1001 | scoped_ptr<base::DictionaryValue> theme_colors_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1002 | |
| 1003 | // A map of color names to colors. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1004 | scoped_ptr<base::DictionaryValue> theme_tints_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1005 | |
| 1006 | // A map of display properties. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1007 | scoped_ptr<base::DictionaryValue> theme_display_properties_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1008 | |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 1009 | // A file containing a list of sites for Managed Mode. |
| 1010 | FilePath content_pack_site_list_; |
| 1011 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 1012 | // The manifest from which this extension was created. |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 1013 | scoped_ptr<Manifest> manifest_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1014 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 1015 | // Stored parsed manifest data. |
| 1016 | ManifestDataMap manifest_data_; |
| 1017 | |
| 1018 | // Set to true at the end of InitValue when initialization is finished. |
| 1019 | bool finished_parsing_manifest_; |
| 1020 | |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 1021 | // Ensures that any call to GetManifestData() prior to finishing |
| 1022 | // initialization happens from the same thread (this can happen when certain |
| 1023 | // parts of the initialization process need information from previous parts). |
| 1024 | base::ThreadChecker thread_checker_; |
| 1025 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 1026 | // Whether this extension requests isolated storage. |
| 1027 | bool is_storage_isolated_; |
| 1028 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1029 | // The local path inside the extension to use with the launcher. |
| 1030 | std::string launch_local_path_; |
| 1031 | |
| 1032 | // A web url to use with the launcher. Note that this might be relative or |
| 1033 | // absolute. If relative, it is relative to web_origin. |
| 1034 | std::string launch_web_url_; |
| 1035 | |
[email protected] | 4e59568 | 2011-02-09 17:07:02 | [diff] [blame] | 1036 | // The window type that an app's manifest specifies to launch into. |
| 1037 | // This is not always the window type an app will open into, because |
| 1038 | // users can override the way each app launches. See |
| 1039 | // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref |
| 1040 | // to decide what container an app will launch in. |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 1041 | extension_misc::LaunchContainer launch_container_; |
| 1042 | |
| 1043 | // The default size of the container when launching. Only respected for |
| 1044 | // containers like panels and windows. |
| 1045 | int launch_width_; |
| 1046 | int launch_height_; |
| 1047 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 1048 | // Should this app be shown in the app launcher. |
[email protected] | ed1a204f | 2012-09-22 00:28:44 | [diff] [blame] | 1049 | bool display_in_launcher_; |
| 1050 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 1051 | // Should this app be shown in the browser New Tab Page. |
| 1052 | bool display_in_new_tab_page_; |
| 1053 | |
[email protected] | a79be1f | 2012-03-23 22:14:00 | [diff] [blame] | 1054 | // The OAuth2 client id and scopes, if specified by the extension. |
| 1055 | OAuth2Info oauth2_info_; |
| 1056 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 1057 | // Whether the extension has host permissions or user script patterns that |
| 1058 | // imply access to file:/// scheme URLs (the user may not have actually |
| 1059 | // granted it that access). |
| 1060 | bool wants_file_access_; |
| 1061 | |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 1062 | // The flags that were passed to InitFromValue. |
| 1063 | int creation_flags_; |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 1064 | |
[email protected] | 7f7b9d93 | 2011-04-20 16:13:26 | [diff] [blame] | 1065 | // The Content-Security-Policy for this extension. Extensions can use |
| 1066 | // Content-Security-Policies to mitigate cross-site scripting and other |
| 1067 | // vulnerabilities. |
| 1068 | std::string content_security_policy_; |
| 1069 | |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 1070 | FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 1071 | FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps); |
[email protected] | ae7fe71 | 2009-07-02 20:33:58 | [diff] [blame] | 1072 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 1073 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 1074 | }; |
| 1075 | |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 1076 | typedef std::vector< scoped_refptr<const Extension> > ExtensionList; |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 1077 | typedef std::set<std::string> ExtensionIdSet; |
[email protected] | 82590cb | 2012-09-28 04:14:08 | [diff] [blame] | 1078 | typedef std::vector<std::string> ExtensionIdList; |
[email protected] | b1748b1d8 | 2009-11-30 20:32:56 | [diff] [blame] | 1079 | |
[email protected] | 18049dc | 2012-06-19 23:12:55 | [diff] [blame] | 1080 | // Let gtest print InstallWarnings. |
| 1081 | void PrintTo(const Extension::InstallWarning&, ::std::ostream* os); |
| 1082 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 1083 | // Handy struct to pass core extension info around. |
| 1084 | struct ExtensionInfo { |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1085 | ExtensionInfo(const base::DictionaryValue* manifest, |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 1086 | const std::string& id, |
| 1087 | const FilePath& path, |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 1088 | Extension::Location location); |
| 1089 | ~ExtensionInfo(); |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 1090 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1091 | scoped_ptr<base::DictionaryValue> extension_manifest; |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 1092 | std::string extension_id; |
| 1093 | FilePath extension_path; |
| 1094 | Extension::Location extension_location; |
| 1095 | |
| 1096 | private: |
| 1097 | DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
| 1098 | }; |
| 1099 | |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 1100 | struct UnloadedExtensionInfo { |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 1101 | extension_misc::UnloadedExtensionReason reason; |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 1102 | |
| 1103 | // Was the extension already disabled? |
| 1104 | bool already_disabled; |
| 1105 | |
| 1106 | // The extension being unloaded - this should always be non-NULL. |
| 1107 | const Extension* extension; |
| 1108 | |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 1109 | UnloadedExtensionInfo( |
| 1110 | const Extension* extension, |
| 1111 | extension_misc::UnloadedExtensionReason reason); |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 1112 | }; |
| 1113 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 1114 | // The details sent for EXTENSION_PERMISSIONS_UPDATED notifications. |
| 1115 | struct UpdatedExtensionPermissionsInfo { |
| 1116 | enum Reason { |
[email protected] | f553247 | 2012-02-23 13:00:55 | [diff] [blame] | 1117 | ADDED, // The permissions were added to the extension. |
| 1118 | REMOVED, // The permissions were removed from the extension. |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 1119 | }; |
| 1120 | |
| 1121 | Reason reason; |
| 1122 | |
| 1123 | // The extension who's permissions have changed. |
| 1124 | const Extension* extension; |
| 1125 | |
| 1126 | // The permissions that have changed. For Reason::ADDED, this would contain |
| 1127 | // only the permissions that have added, and for Reason::REMOVED, this would |
| 1128 | // only contain the removed permissions. |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 1129 | const PermissionSet* permissions; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 1130 | |
| 1131 | UpdatedExtensionPermissionsInfo( |
| 1132 | const Extension* extension, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 1133 | const PermissionSet* permissions, |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 1134 | Reason reason); |
| 1135 | }; |
| 1136 | |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 1137 | } // namespace extensions |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 1138 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 1139 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |