[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 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] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 8 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 9 | #include <map> |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 10 | #include <set> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 14 | #include "base/file_path.h" |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 15 | #include "base/gtest_prod_util.h" |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 16 | #include "base/memory/linked_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 17 | #include "base/memory/ref_counted.h" |
| 18 | #include "base/memory/scoped_ptr.h" |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 19 | #include "base/synchronization/lock.h" |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame] | 20 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 807871f | 2010-09-16 01:04:48 | [diff] [blame] | 21 | #include "chrome/common/extensions/extension_icon_set.h" |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 22 | #include "chrome/common/extensions/extension_permission_set.h" |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 23 | #include "chrome/common/extensions/user_script.h" |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 24 | #include "chrome/common/extensions/url_pattern.h" |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 25 | #include "chrome/common/extensions/url_pattern_set.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 26 | #include "googleurl/src/gurl.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 27 | #include "ui/gfx/size.h" |
[email protected] | be5f00786 | 2011-09-23 00:35:13 | [diff] [blame] | 28 | #include "webkit/glue/web_intent_service_data.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 29 | |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 30 | class ExtensionAction; |
| 31 | class ExtensionResource; |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 32 | class ExtensionSidebarDefaults; |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 33 | class FileBrowserHandler; |
[email protected] | 1280270 | 2010-07-09 19:43:09 | [diff] [blame] | 34 | class SkBitmap; |
[email protected] | daf66aa | 2010-08-06 06:24:28 | [diff] [blame] | 35 | class Version; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 36 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 37 | namespace base { |
| 38 | class DictionaryValue; |
| 39 | class ListValue; |
| 40 | } |
| 41 | |
[email protected] | f075553 | 2010-06-22 07:27:25 | [diff] [blame] | 42 | // Represents a Chrome extension. |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 43 | class Extension : public base::RefCountedThreadSafe<Extension> { |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 44 | public: |
[email protected] | d3cfa48 | 2009-10-17 13:54:57 | [diff] [blame] | 45 | typedef std::map<const std::string, GURL> URLOverrideMap; |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 46 | typedef std::vector<std::string> ScriptingWhitelist; |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 47 | typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 48 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 49 | // What an extension was loaded from. |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 50 | // NOTE: These values are stored as integers in the preferences and used |
| 51 | // in histograms so don't remove or reorder existing items. Just append |
| 52 | // to the end. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 53 | enum Location { |
| 54 | INVALID, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 55 | INTERNAL, // A crx file from the internal Extensions directory. |
| 56 | EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 57 | EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 58 | // registry on Windows). |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 59 | LOAD, // --load-extension. |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 60 | COMPONENT, // An integral component of Chrome itself, which |
| 61 | // happens to be implemented as an extension. We don't |
| 62 | // show these in the management UI. |
[email protected] | 4d2913e3 | 2010-11-30 00:28:55 | [diff] [blame] | 63 | EXTERNAL_PREF_DOWNLOAD, // A crx file from an external directory (via |
| 64 | // prefs), installed from an update URL. |
| 65 | EXTERNAL_POLICY_DOWNLOAD, // A crx file from an external directory (via |
| 66 | // admin policies), installed from an update URL. |
[email protected] | 04cb754 | 2010-10-25 10:50:06 | [diff] [blame] | 67 | |
| 68 | NUM_LOCATIONS |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 72 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 73 | ENABLED, |
[email protected] | 79c833b5 | 2011-04-05 18:31:01 | [diff] [blame] | 74 | // An external extension that the user uninstalled. We should not reinstall |
| 75 | // such extensions on startup. |
| 76 | EXTERNAL_EXTENSION_UNINSTALLED, |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 77 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 78 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 79 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 80 | enum InstallType { |
[email protected] | ab6f2b2 | 2009-07-28 23:28:37 | [diff] [blame] | 81 | INSTALL_ERROR, |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 82 | DOWNGRADE, |
| 83 | REINSTALL, |
| 84 | UPGRADE, |
| 85 | NEW_INSTALL |
| 86 | }; |
| 87 | |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 88 | // NOTE: If you change this list, you should also change kIconSizes in the cc |
| 89 | // file. |
| 90 | enum Icons { |
| 91 | EXTENSION_ICON_LARGE = 128, |
| 92 | EXTENSION_ICON_MEDIUM = 48, |
| 93 | EXTENSION_ICON_SMALL = 32, |
[email protected] | 3938294 | 2010-03-23 15:57:09 | [diff] [blame] | 94 | EXTENSION_ICON_SMALLISH = 24, |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 95 | EXTENSION_ICON_BITTY = 16, |
| 96 | }; |
| 97 | |
[email protected] | 7fa19f8 | 2010-12-21 19:40:08 | [diff] [blame] | 98 | // Do not change the order of entries or remove entries in this list |
| 99 | // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions. |
| 100 | enum Type { |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 101 | TYPE_UNKNOWN = 0, |
| 102 | TYPE_EXTENSION, |
| 103 | TYPE_THEME, |
| 104 | TYPE_USER_SCRIPT, |
| 105 | TYPE_HOSTED_APP, |
[email protected] | 7d3ed2f | 2011-11-07 23:33:19 | [diff] [blame] | 106 | TYPE_PACKAGED_APP, |
| 107 | TYPE_PLATFORM_APP |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 108 | }; |
| 109 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 110 | enum SyncType { |
| 111 | SYNC_TYPE_NONE = 0, |
| 112 | SYNC_TYPE_EXTENSION, |
| 113 | SYNC_TYPE_APP |
| 114 | }; |
| 115 | |
[email protected] | 9288808 | 2010-10-18 19:24:57 | [diff] [blame] | 116 | // An NPAPI plugin included in the extension. |
| 117 | struct PluginInfo { |
| 118 | FilePath path; // Path to the plugin. |
| 119 | bool is_public; // False if only this extension can load this plugin. |
| 120 | }; |
| 121 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 122 | // An NaCl module included in the extension. |
| 123 | struct NaClModuleInfo { |
[email protected] | 84396dbc | 2011-04-14 06:33:42 | [diff] [blame] | 124 | GURL url; |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 125 | std::string mime_type; |
| 126 | }; |
| 127 | |
[email protected] | b082037 | 2011-06-03 07:05:27 | [diff] [blame] | 128 | enum InputComponentType { |
[email protected] | d45f751 | 2011-06-21 21:18:27 | [diff] [blame] | 129 | INPUT_COMPONENT_TYPE_NONE = -1, |
| 130 | INPUT_COMPONENT_TYPE_IME, |
[email protected] | b082037 | 2011-06-03 07:05:27 | [diff] [blame] | 131 | INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD, |
| 132 | INPUT_COMPONENT_TYPE_COUNT |
| 133 | }; |
| 134 | |
| 135 | struct InputComponentInfo { |
| 136 | // Define out of line constructor/destructor to please Clang. |
| 137 | InputComponentInfo(); |
| 138 | ~InputComponentInfo(); |
| 139 | |
| 140 | std::string name; |
| 141 | InputComponentType type; |
| 142 | std::string id; |
| 143 | std::string description; |
| 144 | std::string language; |
| 145 | std::set<std::string> layouts; |
| 146 | std::string shortcut_keycode; |
| 147 | bool shortcut_alt; |
| 148 | bool shortcut_ctrl; |
| 149 | bool shortcut_shift; |
| 150 | }; |
| 151 | |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 152 | struct TtsVoice { |
[email protected] | 77a3ecac | 2011-07-07 05:56:33 | [diff] [blame] | 153 | // Define out of line constructor/destructor to please Clang. |
| 154 | TtsVoice(); |
| 155 | ~TtsVoice(); |
| 156 | |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 157 | std::string voice_name; |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 158 | std::string lang; |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 159 | std::string gender; |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 160 | std::set<std::string> event_types; |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 161 | }; |
| 162 | |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 163 | enum InitFromValueFlags { |
| 164 | NO_FLAGS = 0, |
| 165 | |
| 166 | // Usually, the id of an extension is generated by the "key" property of |
| 167 | // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 168 | // generated based on the path. |
| 169 | REQUIRE_KEY = 1 << 0, |
| 170 | |
| 171 | // |STRICT_ERROR_CHECKS| enables extra error checking, such as |
| 172 | // checks that URL patterns do not contain ports. This error |
| 173 | // checking may find an error that a previous version of |
| 174 | // Chrome did not flag. To avoid errors in installed extensions |
| 175 | // when Chrome is upgraded, strict error checking is only enabled |
| 176 | // when loading extensions as a developer would (such as loading |
| 177 | // an unpacked extension), or when loading an extension that is |
| 178 | // tied to a specific version of Chrome (such as a component |
| 179 | // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when |
| 180 | // Extension::ShouldDoStrictErrorChecking(location) returns true. |
| 181 | STRICT_ERROR_CHECKS = 1 << 1, |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 182 | |
| 183 | // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension |
| 184 | // to have file access. If it's not present, then permissions and content |
| 185 | // scripts that match file:/// URLs will be filtered out. |
| 186 | ALLOW_FILE_ACCESS = 1 << 2, |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 187 | |
| 188 | // |FROM_WEBSTORE| indicates that the extension was installed from the |
| 189 | // Chrome Web Store. |
| 190 | FROM_WEBSTORE = 1 << 3, |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 191 | |
| 192 | // |FROM_BOOKMARK| indicates the extension was created using a mock App |
| 193 | // created from a bookmark. |
| 194 | FROM_BOOKMARK = 1 << 4, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 195 | }; |
| 196 | |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 197 | static scoped_refptr<Extension> Create(const FilePath& path, |
| 198 | Location location, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 199 | const base::DictionaryValue& value, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 200 | int flags, |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 201 | std::string* error); |
| 202 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 203 | // In a few special circumstances, we want to create an Extension and give it |
| 204 | // an explicit id. Most consumers should just use the plain Create() method. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 205 | static scoped_refptr<Extension> CreateWithId( |
| 206 | const FilePath& path, |
| 207 | Location location, |
| 208 | const base::DictionaryValue& value, |
| 209 | int flags, |
| 210 | const std::string& explicit_id, |
| 211 | std::string* error); |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 212 | |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 213 | // Given two install sources, return the one which should take priority |
| 214 | // over the other. If an extension is installed from two sources A and B, |
| 215 | // its install source should be set to GetHigherPriorityLocation(A, B). |
| 216 | static Location GetHigherPriorityLocation(Location loc1, Location loc2); |
| 217 | |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 218 | // Icon sizes used by the extension system. |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 219 | static const int kIconSizes[]; |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 220 | |
[email protected] | 4c4f819 | 2009-10-17 01:03:26 | [diff] [blame] | 221 | // Max size (both dimensions) for browser and page actions. |
| 222 | static const int kPageActionIconMaxSize; |
| 223 | static const int kBrowserActionIconMaxSize; |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 224 | static const int kSidebarIconMaxSize; |
[email protected] | 4c4f819 | 2009-10-17 01:03:26 | [diff] [blame] | 225 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 226 | // Valid schemes for web extent URLPatterns. |
| 227 | static const int kValidWebExtentSchemes; |
| 228 | |
[email protected] | f71f7e6 | 2010-12-07 03:45:33 | [diff] [blame] | 229 | // Valid schemes for host permission URLPatterns. |
| 230 | static const int kValidHostPermissionSchemes; |
| 231 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 232 | // The name of the manifest inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 233 | static const FilePath::CharType kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 234 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 235 | // The name of locale folder inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 236 | static const FilePath::CharType kLocaleFolder[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 237 | |
| 238 | // The name of the messages file inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 239 | static const FilePath::CharType kMessagesFilename[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 240 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 241 | #if defined(OS_WIN) |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 242 | static const char kExtensionRegistryPath[]; |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 243 | #endif |
| 244 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 245 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 246 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 247 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 248 | // The mimetype used for extensions. |
| 249 | static const char kMimeType[]; |
| 250 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 251 | // Checks to see if the extension has a valid ID. |
| 252 | static bool IdIsValid(const std::string& id); |
| 253 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 254 | // Generate an ID for an extension in the given path. |
[email protected] | 28d7479b | 2011-03-09 21:33:27 | [diff] [blame] | 255 | // Used while developing extensions, before they have a key. |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 256 | static std::string GenerateIdForPath(const FilePath& file_name); |
| 257 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 258 | // Returns true if the specified file is an extension. |
| 259 | static bool IsExtension(const FilePath& file_name); |
| 260 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 261 | // Whether the |location| is external or not. |
| 262 | static inline bool IsExternalLocation(Location location) { |
| 263 | return location == Extension::EXTERNAL_PREF || |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 264 | location == Extension::EXTERNAL_REGISTRY || |
[email protected] | 04cb754 | 2010-10-25 10:50:06 | [diff] [blame] | 265 | location == Extension::EXTERNAL_PREF_DOWNLOAD || |
| 266 | location == Extension::EXTERNAL_POLICY_DOWNLOAD; |
| 267 | } |
| 268 | |
| 269 | // Whether extensions with |location| are auto-updatable or not. |
| 270 | static inline bool IsAutoUpdateableLocation(Location location) { |
| 271 | // Only internal and external extensions can be autoupdated. |
| 272 | return location == Extension::INTERNAL || |
| 273 | IsExternalLocation(location); |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 274 | } |
| 275 | |
[email protected] | 95da88c4 | 2011-03-31 10:07:33 | [diff] [blame] | 276 | // Whether extensions with |location| can be uninstalled or not. Policy |
| 277 | // controlled extensions are silently auto-installed and updated, and cannot |
| 278 | // be disabled by the user. The same applies for internal components. |
| 279 | static inline bool UserMayDisable(Location location) { |
| 280 | return location != Extension::EXTERNAL_POLICY_DOWNLOAD && |
| 281 | location != Extension::COMPONENT; |
| 282 | } |
| 283 | |
[email protected] | 542258c | 2011-03-04 21:25:31 | [diff] [blame] | 284 | // Whether extensions with |location| should be loaded with strict |
| 285 | // error checking. Strict error checks may flag errors older versions |
| 286 | // of chrome did not detect. To avoid breaking installed extensions, |
| 287 | // strict checks are disabled unless the location indicates that the |
| 288 | // developer is loading the extension, or the extension is a component |
| 289 | // of chrome. |
| 290 | static inline bool ShouldDoStrictErrorChecking(Location location) { |
| 291 | return location == Extension::LOAD || |
| 292 | location == Extension::COMPONENT; |
| 293 | } |
| 294 | |
[email protected] | cdfca970 | 2011-08-08 16:07:01 | [diff] [blame] | 295 | // Unpacked extensions start off with file access since they are a developer |
| 296 | // feature. |
| 297 | static inline bool ShouldAlwaysAllowFileAccess(Location location) { |
| 298 | return location == Extension::LOAD; |
| 299 | } |
| 300 | |
[email protected] | 7fa19f8 | 2010-12-21 19:40:08 | [diff] [blame] | 301 | // See Type definition above. |
| 302 | Type GetType() const; |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 303 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 304 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 305 | // |extension_url| argument should be the url() from an Extension object. The |
| 306 | // |relative_path| can be untrusted user input. The returned URL will either |
| 307 | // be invalid() or a child of |extension_url|. |
| 308 | // NOTE: Static so that it can be used from multiple threads. |
| 309 | static GURL GetResourceURL(const GURL& extension_url, |
| 310 | const std::string& relative_path); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 311 | GURL GetResourceURL(const std::string& relative_path) const { |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 312 | return GetResourceURL(url(), relative_path); |
| 313 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 314 | |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 315 | // Returns an extension resource object. |relative_path| should be UTF8 |
| 316 | // encoded. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 317 | ExtensionResource GetResource(const std::string& relative_path) const; |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 318 | |
| 319 | // As above, but with |relative_path| following the file system's encoding. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 320 | ExtensionResource GetResource(const FilePath& relative_path) const; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 321 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 322 | // |input| is expected to be the text of an rsa public or private key. It |
| 323 | // tolerates the presence or absence of bracking header/footer like this: |
| 324 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 325 | // and may contain newlines. |
| 326 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 327 | |
| 328 | // Does a simple base64 encoding of |input| into |output|. |
| 329 | static bool ProducePEM(const std::string& input, std::string* output); |
| 330 | |
[email protected] | 84ac7f3 | 2009-10-06 06:17:54 | [diff] [blame] | 331 | // Generates an extension ID from arbitrary input. The same input string will |
| 332 | // always generate the same output ID. |
[email protected] | af9db5f | 2011-10-05 05:13:15 | [diff] [blame] | 333 | static bool GenerateId(const std::string& input, |
| 334 | std::string* output) WARN_UNUSED_RESULT; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 335 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 336 | // Expects base64 encoded |input| and formats into |output| including |
| 337 | // the appropriate header & footer. |
[email protected] | e0d0819 | 2011-03-29 19:02:50 | [diff] [blame] | 338 | static bool FormatPEMForFileOutput(const std::string& input, |
| 339 | std::string* output, |
| 340 | bool is_public); |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 341 | |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 342 | // 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] | 343 | // result. In the browser process, this will DCHECK if not called on the |
| 344 | // file thread. To easily load extension images on the UI thread, see |
| 345 | // ImageLoadingTracker. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 346 | static void DecodeIcon(const Extension* extension, |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 347 | Icons icon_size, |
| 348 | scoped_ptr<SkBitmap>* result); |
| 349 | |
| 350 | // 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] | 351 | // result. In the browser process, this will DCHECK if not called on the |
| 352 | // file thread. To easily load extension images on the UI thread, see |
| 353 | // ImageLoadingTracker. |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 354 | static void DecodeIconFromPath(const FilePath& icon_path, |
| 355 | Icons icon_size, |
| 356 | scoped_ptr<SkBitmap>* result); |
| 357 | |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 358 | // Returns the default extension/app icon (for extensions or apps that don't |
| 359 | // have one). |
| 360 | static const SkBitmap& GetDefaultIcon(bool is_app); |
| 361 | |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 362 | // Returns the base extension url for a given |extension_id|. |
| 363 | static GURL GetBaseURLFromExtensionId(const std::string& extension_id); |
| 364 | |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 365 | // Adds an extension to the scripting whitelist. Used for testing only. |
[email protected] | 10fb199 | 2010-10-08 09:00:17 | [diff] [blame] | 366 | static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 367 | static const ScriptingWhitelist* GetScriptingWhitelist(); |
[email protected] | be7e5cb | 2010-10-04 12:53:17 | [diff] [blame] | 368 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 369 | // Parses the host and api permissions from the specified permission |key| |
| 370 | // in the manifest |source|. |
| 371 | bool ParsePermissions(const base::DictionaryValue* source, |
| 372 | const char* key, |
| 373 | int flags, |
| 374 | std::string* error, |
| 375 | ExtensionAPIPermissionSet* api_permissions, |
| 376 | URLPatternSet* host_permissions); |
| 377 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 378 | bool HasAPIPermission(ExtensionAPIPermission::ID permission) const; |
| 379 | bool HasAPIPermission(const std::string& function_name) const; |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 380 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 381 | const URLPatternSet& GetEffectiveHostPermissions() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 382 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 383 | // Returns true if the extension can silently increase its permission level. |
| 384 | // Extensions that can silently increase permissions are installed through |
| 385 | // mechanisms that are implicitly trusted. |
| 386 | bool CanSilentlyIncreasePermissions() const; |
| 387 | |
[email protected] | fbd17cf | 2010-04-28 23:52:56 | [diff] [blame] | 388 | |
[email protected] | 584b8e3f | 2010-04-10 00:23:37 | [diff] [blame] | 389 | // Whether the extension has access to the given URL. |
| 390 | bool HasHostPermission(const GURL& url) const; |
| 391 | |
[email protected] | 0df165f | 2010-09-28 16:49:40 | [diff] [blame] | 392 | // Whether the extension has effective access to all hosts. This is true if |
| 393 | // there is a content script that matches all hosts, if there is a host |
| 394 | // permission grants access to all hosts (like <all_urls>) or an api |
| 395 | // permission that effectively grants access to all hosts (e.g. proxy, |
| 396 | // network, etc.) |
| 397 | bool HasEffectiveAccessToAllHosts() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 398 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 399 | // Whether the extension effectively has all permissions (for example, by |
| 400 | // having an NPAPI plugin). |
| 401 | bool HasFullPermissions() const; |
| 402 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 403 | // Returns the full list of permission messages that this extension |
| 404 | // should display at install time. |
| 405 | ExtensionPermissionMessages GetPermissionMessages() const; |
| 406 | |
| 407 | // Returns the full list of permission messages that this extension |
| 408 | // should display at install time. The messages are returned as strings |
| 409 | // for convenience. |
| 410 | std::vector<string16> GetPermissionMessageStrings() const; |
| 411 | |
| 412 | // Sets the active |permissions|. |
| 413 | void SetActivePermissions(const ExtensionPermissionSet* permissions) const; |
| 414 | |
| 415 | // Gets the extension's active permission set. |
| 416 | scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; |
| 417 | |
[email protected] | 5df6a5d | 2011-01-26 07:39:12 | [diff] [blame] | 418 | // Whether context menu should be shown for page and browser actions. |
| 419 | bool ShowConfigureContextMenus() const; |
| 420 | |
[email protected] | b6cf240f | 2011-10-15 22:09:53 | [diff] [blame] | 421 | // Whether network requests should be delayed on browser startup until the |
| 422 | // extension's background page has loaded, even if the extension doesn't |
| 423 | // explicitly request a delay. |
| 424 | bool ImplicitlyDelaysNetworkStartup() const; |
| 425 | |
[email protected] | 37cd64d | 2010-10-25 18:17:58 | [diff] [blame] | 426 | // Returns the Homepage URL for this extension. If homepage_url was not |
| 427 | // specified in the manifest, this returns the Google Gallery URL. For |
[email protected] | bfa90a3a | 2010-04-28 15:43:23 | [diff] [blame] | 428 | // third-party extensions, this returns a blank GURL. |
[email protected] | 37cd64d | 2010-10-25 18:17:58 | [diff] [blame] | 429 | GURL GetHomepageURL() const; |
[email protected] | bfa90a3a | 2010-04-28 15:43:23 | [diff] [blame] | 430 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 431 | // Returns a list of paths (relative to the extension dir) for images that |
| 432 | // the browser might load (like themes and page action icons). |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 433 | std::set<FilePath> GetBrowserImages() const; |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 434 | |
[email protected] | 807871f | 2010-09-16 01:04:48 | [diff] [blame] | 435 | // Get an extension icon as a resource or URL. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 436 | ExtensionResource GetIconResource( |
| 437 | int size, ExtensionIconSet::MatchType match_type) const; |
| 438 | GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 439 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 440 | // Gets the fully resolved absolute launch URL. |
| 441 | GURL GetFullLaunchURL() const; |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 442 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 443 | // Image cache related methods. These are only valid on the UI thread and |
| 444 | // not maintained by this class. See ImageLoadingTracker for usage. The |
| 445 | // |original_size| parameter should be the size of the image at |source| |
| 446 | // before any scaling may have been done to produce the pixels in |image|. |
| 447 | void SetCachedImage(const ExtensionResource& source, |
| 448 | const SkBitmap& image, |
| 449 | const gfx::Size& original_size) const; |
| 450 | bool HasCachedImage(const ExtensionResource& source, |
| 451 | const gfx::Size& max_size) const; |
| 452 | SkBitmap GetCachedImage(const ExtensionResource& source, |
| 453 | const gfx::Size& max_size) const; |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 454 | |
| 455 | // Returns true if this extension can execute script on a page. If a |
| 456 | // UserScript object is passed, permission to run that specific script is |
| 457 | // checked (using its matches list). Otherwise, permission to execute script |
| 458 | // programmatically is checked (using the extension's host permission). |
| 459 | // |
| 460 | // This method is also aware of certain special pages that extensions are |
| 461 | // usually not allowed to run script on. |
| 462 | bool CanExecuteScriptOnPage(const GURL& page_url, |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 463 | const UserScript* script, |
[email protected] | 2a521c5 | 2011-01-26 18:45:21 | [diff] [blame] | 464 | std::string* error) const; |
| 465 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 466 | // Returns true if this extension is a COMPONENT extension, or if it is |
| 467 | // on the whitelist of extensions that can script all pages. |
| 468 | bool CanExecuteScriptEverywhere() const; |
| 469 | |
[email protected] | 5efbfe01 | 2011-02-22 23:07:18 | [diff] [blame] | 470 | // Returns true if this extension is allowed to obtain the contents of a |
| 471 | // page as an image. Since a page may contain sensitive information, this |
| 472 | // is restricted to the extension's host permissions as well as the |
| 473 | // extension page itself. |
| 474 | bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const; |
| 475 | |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 476 | // Returns true if this extension updates itself using the extension |
| 477 | // gallery. |
| 478 | bool UpdatesFromGallery() const; |
| 479 | |
[email protected] | cca14717 | 2011-02-17 01:29:29 | [diff] [blame] | 480 | // Returns true if this extension or app includes areas within |origin|. |
| 481 | bool OverlapsWithOrigin(const GURL& origin) const; |
| 482 | |
[email protected] | 3bdba0d | 2011-08-23 07:17:30 | [diff] [blame] | 483 | // Returns the sync bucket to use for this extension. |
| 484 | SyncType GetSyncType() const; |
| 485 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 486 | // Accessors: |
| 487 | |
| 488 | const FilePath& path() const { return path_; } |
| 489 | const GURL& url() const { return extension_url_; } |
| 490 | Location location() const { return location_; } |
| 491 | const std::string& id() const { return id_; } |
| 492 | const Version* version() const { return version_.get(); } |
| 493 | const std::string VersionString() const; |
| 494 | const std::string& name() const { return name_; } |
| 495 | const std::string& public_key() const { return public_key_; } |
| 496 | const std::string& description() const { return description_; } |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame^] | 497 | int manifest_version() const { return manifest_version_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 498 | bool converted_from_user_script() const { |
| 499 | return converted_from_user_script_; |
| 500 | } |
| 501 | const UserScriptList& content_scripts() const { return content_scripts_; } |
| 502 | ExtensionAction* page_action() const { return page_action_.get(); } |
| 503 | ExtensionAction* browser_action() const { return browser_action_.get(); } |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 504 | ExtensionSidebarDefaults* sidebar_defaults() const { |
| 505 | return sidebar_defaults_.get(); |
| 506 | } |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 507 | const FileBrowserHandlerList* file_browser_handlers() const { |
| 508 | return file_browser_handlers_.get(); |
| 509 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 510 | const std::vector<PluginInfo>& plugins() const { return plugins_; } |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 511 | const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 512 | return nacl_modules_; |
| 513 | } |
[email protected] | b082037 | 2011-06-03 07:05:27 | [diff] [blame] | 514 | const std::vector<InputComponentInfo>& input_components() const { |
| 515 | return input_components_; |
| 516 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 517 | const GURL& background_url() const { return background_url_; } |
| 518 | const GURL& options_url() const { return options_url_; } |
| 519 | const GURL& devtools_url() const { return devtools_url_; } |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 520 | const ExtensionPermissionSet* optional_permission_set() const { |
| 521 | return optional_permission_set_.get(); |
| 522 | } |
| 523 | const ExtensionPermissionSet* required_permission_set() const { |
| 524 | return required_permission_set_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 525 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 526 | const GURL& update_url() const { return update_url_; } |
| 527 | const ExtensionIconSet& icons() const { return icons_; } |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 528 | const base::DictionaryValue* manifest_value() const { |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 529 | return manifest_value_.get(); |
| 530 | } |
| 531 | const std::string default_locale() const { return default_locale_; } |
| 532 | const URLOverrideMap& GetChromeURLOverrides() const { |
| 533 | return chrome_url_overrides_; |
| 534 | } |
| 535 | const std::string omnibox_keyword() const { return omnibox_keyword_; } |
| 536 | bool incognito_split_mode() const { return incognito_split_mode_; } |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 537 | bool offline_enabled() const { return offline_enabled_; } |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 538 | const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; } |
[email protected] | 5662442 | 2011-11-01 22:11:27 | [diff] [blame] | 539 | const std::vector<webkit_glue::WebIntentServiceData>& |
| 540 | intents_services() const { |
| 541 | return intents_services_; |
| 542 | } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 543 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 544 | bool wants_file_access() const { return wants_file_access_; } |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 545 | int creation_flags() const { return creation_flags_; } |
| 546 | bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 547 | bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 548 | |
[email protected] | 7f7b9d93 | 2011-04-20 16:13:26 | [diff] [blame] | 549 | const std::string& content_security_policy() const { |
| 550 | return content_security_policy_; |
| 551 | } |
| 552 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 553 | // App-related. |
| 554 | bool is_app() const { return is_app_; } |
[email protected] | 7d3ed2f | 2011-11-07 23:33:19 | [diff] [blame] | 555 | bool is_platform_app() const { return is_platform_app_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 556 | bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); } |
| 557 | bool is_packaged_app() const { return is_app() && web_extent().is_empty(); } |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 558 | bool is_storage_isolated() const { return is_app() && is_storage_isolated_; } |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 559 | const URLPatternSet& web_extent() const { return extent_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 560 | const std::string& launch_local_path() const { return launch_local_path_; } |
| 561 | const std::string& launch_web_url() const { return launch_web_url_; } |
| 562 | extension_misc::LaunchContainer launch_container() const { |
| 563 | return launch_container_; |
| 564 | } |
| 565 | int launch_width() const { return launch_width_; } |
| 566 | int launch_height() const { return launch_height_; } |
| 567 | |
| 568 | // Theme-related. |
| 569 | bool is_theme() const { return is_theme_; } |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 570 | base::DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 571 | base::DictionaryValue* GetThemeColors() const {return theme_colors_.get(); } |
| 572 | base::DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
| 573 | base::DictionaryValue* GetThemeDisplayProperties() const { |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 574 | return theme_display_properties_.get(); |
| 575 | } |
| 576 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 577 | private: |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 578 | friend class base::RefCountedThreadSafe<Extension>; |
| 579 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 580 | // We keep a cache of images loaded from extension resources based on their |
| 581 | // path and a string representation of a size that may have been used to |
| 582 | // scale it (or the empty string if the image is at its original size). |
| 583 | typedef std::pair<FilePath, std::string> ImageCacheKey; |
| 584 | typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
| 585 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 586 | class RuntimeData { |
| 587 | public: |
| 588 | RuntimeData(); |
| 589 | explicit RuntimeData(const ExtensionPermissionSet* active); |
| 590 | ~RuntimeData(); |
| 591 | |
| 592 | void SetActivePermissions(const ExtensionPermissionSet* active); |
| 593 | scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; |
| 594 | |
| 595 | private: |
| 596 | friend class base::RefCountedThreadSafe<RuntimeData>; |
| 597 | scoped_refptr<const ExtensionPermissionSet> active_permissions_; |
| 598 | }; |
| 599 | |
[email protected] | 4ead6f7 | 2010-10-13 19:54:18 | [diff] [blame] | 600 | // Normalize the path for use by the extension. On Windows, this will make |
| 601 | // sure the drive letter is uppercase. |
| 602 | static FilePath MaybeNormalizePath(const FilePath& path); |
| 603 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 604 | // Returns true if this extension id is from a trusted provider. |
| 605 | static bool IsTrustedId(const std::string& id); |
| 606 | |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 607 | Extension(const FilePath& path, Location location); |
| 608 | ~Extension(); |
| 609 | |
| 610 | // Initialize the extension from a parsed manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 611 | bool InitFromValue(const base::DictionaryValue& value, int flags, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 612 | std::string* error); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 613 | |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 614 | // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 615 | // value of NULL means there is no matching image cached (we allow caching an |
| 616 | // empty SkBitmap). |
| 617 | SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 618 | const gfx::Size& max_size) const; |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 619 | |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 620 | // Helper method that loads a UserScript object from a |
| 621 | // dictionary in the content_script list of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 622 | bool LoadUserScriptHelper(const base::DictionaryValue* content_script, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 623 | int definition_index, |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 624 | int flags, |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 625 | std::string* error, |
| 626 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 627 | |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 628 | // Helper method that loads either the include_globs or exclude_globs list |
| 629 | // from an entry in the content_script lists of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 630 | bool LoadGlobsHelper(const base::DictionaryValue* content_script, |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 631 | int content_script_index, |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 632 | const char* globs_property_name, |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 633 | std::string* error, |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 634 | void(UserScript::*add_method)(const std::string& glob), |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 635 | UserScript *instance); |
| 636 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 637 | // Helpers to load various chunks of the manifest. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 638 | bool LoadIsApp(const base::DictionaryValue* manifest, std::string* error); |
| 639 | bool LoadExtent(const base::DictionaryValue* manifest, |
[email protected] | 542258c | 2011-03-04 21:25:31 | [diff] [blame] | 640 | const char* key, |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 641 | URLPatternSet* extent, |
[email protected] | 542258c | 2011-03-04 21:25:31 | [diff] [blame] | 642 | const char* list_error, |
| 643 | const char* value_error, |
| 644 | URLPattern::ParseOption parse_strictness, |
| 645 | std::string* error); |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 646 | bool LoadLaunchContainer(const base::DictionaryValue* manifest, |
| 647 | std::string* error); |
| 648 | bool LoadLaunchURL(const base::DictionaryValue* manifest, |
| 649 | std::string* error); |
| 650 | bool LoadAppIsolation(const base::DictionaryValue* manifest, |
| 651 | std::string* error); |
[email protected] | 5662442 | 2011-11-01 22:11:27 | [diff] [blame] | 652 | bool LoadWebIntentServices(const base::DictionaryValue& manifest, |
| 653 | std::string* error); |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 654 | bool EnsureNotHybridApp(const base::DictionaryValue* manifest, |
| 655 | std::string* error); |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 656 | |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 657 | // Helper method to load an ExtensionAction from the page_action or |
[email protected] | 92c6f9b9 | 2009-10-24 04:35:08 | [diff] [blame] | 658 | // browser_action entries in the manifest. |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 659 | ExtensionAction* LoadExtensionActionHelper( |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 660 | const base::DictionaryValue* extension_action, std::string* error); |
[email protected] | 92c6f9b9 | 2009-10-24 04:35:08 | [diff] [blame] | 661 | |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 662 | // Helper method to load an FileBrowserHandlerList from the manifest. |
| 663 | FileBrowserHandlerList* LoadFileBrowserHandlers( |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 664 | const base::ListValue* extension_actions, std::string* error); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 665 | // Helper method to load an FileBrowserHandler from manifest. |
| 666 | FileBrowserHandler* LoadFileBrowserHandler( |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 667 | const base::DictionaryValue* file_browser_handlers, std::string* error); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 668 | |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 669 | // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest |
| 670 | // entry. |
| 671 | ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 672 | const base::DictionaryValue* sidebar, std::string* error); |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 673 | |
[email protected] | 2f6698b | 2010-10-14 00:58:21 | [diff] [blame] | 674 | // Returns true if the extension has more than one "UI surface". For example, |
| 675 | // an extension that has a browser action and a page action. |
| 676 | bool HasMultipleUISurfaces() const; |
| 677 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 678 | // Figures out if a source contains keys not associated with themes - we |
| 679 | // don't want to allow scripts and such to be bundled with themes. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 680 | bool ContainsNonThemeKeys(const base::DictionaryValue& source) const; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 681 | |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 682 | // Updates the launch URL and extents for the extension using the given |
| 683 | // |override_url|. |
| 684 | void OverrideLaunchUrl(const GURL& override_url); |
| 685 | |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 686 | // Returns true if this extension can specify |api|. |
| 687 | bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api, |
| 688 | std::string* error) const; |
| 689 | bool CanSpecifyComponentOnlyPermission() const; |
| 690 | bool CanSpecifyExperimentalPermission() const; |
| 691 | bool CanSpecifyPermissionForHostedApp( |
| 692 | const ExtensionAPIPermission* api) const; |
| 693 | |
| 694 | // Checks whether the host |pattern| is allowed for this extension, given API |
| 695 | // permissions |permissions|. |
| 696 | bool CanSpecifyHostPermission(const URLPattern& pattern, |
| 697 | const ExtensionAPIPermissionSet& permissions) const; |
| 698 | |
[email protected] | d7e9a86 | 2010-11-03 21:57:49 | [diff] [blame] | 699 | // Cached images for this extension. This should only be touched on the UI |
| 700 | // thread. |
| 701 | mutable ImageCache image_cache_; |
[email protected] | 1e8c93f | 2010-02-08 22:58:31 | [diff] [blame] | 702 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 703 | // A persistent, globally unique ID. An extension's ID is used in things |
| 704 | // like directory structures and URLs, and is expected to not change across |
| 705 | // versions. It is generated as a SHA-256 hash of the extension's public |
| 706 | // key, or as a hash of the path in the case of unpacked extensions. |
| 707 | std::string id_; |
| 708 | |
| 709 | // The extension's human-readable name. Name is used for display purpose. It |
| 710 | // might be wrapped with unicode bidi control characters so that it is |
| 711 | // displayed correctly in RTL context. |
| 712 | // NOTE: Name is UTF-8 and may contain non-ascii characters. |
| 713 | std::string name_; |
| 714 | |
| 715 | // The absolute path to the directory the extension is stored in. |
| 716 | FilePath path_; |
| 717 | |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame^] | 718 | // The version of this extension's manifest. We increase the manifest |
| 719 | // version when making breaking changes to the extension system. |
| 720 | // Version 1 was the first manifest version (implied by a lack of a |
| 721 | // manifest_version attribute in the extension's manifest). We initialize |
| 722 | // this member variable to 0 to distinguish the "uninitialized" case from |
| 723 | // the case when we know the manifest version actually is 1. |
| 724 | int manifest_version_; |
| 725 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 726 | // Default locale for fall back. Can be empty if extension is not localized. |
| 727 | std::string default_locale_; |
| 728 | |
| 729 | // If true, a separate process will be used for the extension in incognito |
| 730 | // mode. |
| 731 | bool incognito_split_mode_; |
| 732 | |
[email protected] | 1abdf4f | 2011-08-16 21:11:55 | [diff] [blame] | 733 | // Whether the extension or app should be enabled when offline. |
| 734 | bool offline_enabled_; |
| 735 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 736 | // Defines the set of URLs in the extension's web content. |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 737 | URLPatternSet extent_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 738 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 739 | // The extension runtime data. |
| 740 | mutable base::Lock runtime_data_lock_; |
| 741 | mutable RuntimeData runtime_data_; |
| 742 | |
| 743 | // The set of permissions the extension can request at runtime. |
| 744 | scoped_refptr<const ExtensionPermissionSet> optional_permission_set_; |
| 745 | |
| 746 | // The extension's required / default set of permissions. |
| 747 | scoped_refptr<const ExtensionPermissionSet> required_permission_set_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 748 | |
| 749 | // The icons for the extension. |
| 750 | ExtensionIconSet icons_; |
| 751 | |
| 752 | // The base extension url for the extension. |
| 753 | GURL extension_url_; |
| 754 | |
| 755 | // The location the extension was loaded from. |
| 756 | Location location_; |
| 757 | |
| 758 | // The extension's version. |
| 759 | scoped_ptr<Version> version_; |
| 760 | |
| 761 | // An optional longer description of the extension. |
| 762 | std::string description_; |
| 763 | |
| 764 | // True if the extension was generated from a user script. (We show slightly |
| 765 | // different UI if so). |
| 766 | bool converted_from_user_script_; |
| 767 | |
| 768 | // Paths to the content scripts the extension contains. |
| 769 | UserScriptList content_scripts_; |
| 770 | |
| 771 | // The extension's page action, if any. |
| 772 | scoped_ptr<ExtensionAction> page_action_; |
| 773 | |
| 774 | // The extension's browser action, if any. |
| 775 | scoped_ptr<ExtensionAction> browser_action_; |
| 776 | |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 777 | // The extension's file browser actions, if any. |
| 778 | scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; |
| 779 | |
[email protected] | e2dffe0 | 2011-01-20 20:30:06 | [diff] [blame] | 780 | // The extension's sidebar, if any. |
| 781 | scoped_ptr<ExtensionSidebarDefaults> sidebar_defaults_; |
| 782 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 783 | // Optional list of NPAPI plugins and associated properties. |
| 784 | std::vector<PluginInfo> plugins_; |
| 785 | |
[email protected] | 65378f5 | 2011-04-08 02:31:23 | [diff] [blame] | 786 | // Optional list of NaCl modules and associated properties. |
| 787 | std::vector<NaClModuleInfo> nacl_modules_; |
| 788 | |
[email protected] | b082037 | 2011-06-03 07:05:27 | [diff] [blame] | 789 | // Optional list of input components and associated properties. |
| 790 | std::vector<InputComponentInfo> input_components_; |
| 791 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 792 | // Optional URL to a master page of which a single instance should be always |
| 793 | // loaded in the background. |
| 794 | GURL background_url_; |
| 795 | |
| 796 | // Optional URL to a page for setting options/preferences. |
| 797 | GURL options_url_; |
| 798 | |
| 799 | // Optional URL to a devtools extension page. |
| 800 | GURL devtools_url_; |
| 801 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 802 | // The public key used to sign the contents of the crx package. |
| 803 | std::string public_key_; |
| 804 | |
| 805 | // A map of resource id's to relative file paths. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 806 | scoped_ptr<base::DictionaryValue> theme_images_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 807 | |
| 808 | // A map of color names to colors. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 809 | scoped_ptr<base::DictionaryValue> theme_colors_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 810 | |
| 811 | // A map of color names to colors. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 812 | scoped_ptr<base::DictionaryValue> theme_tints_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 813 | |
| 814 | // A map of display properties. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 815 | scoped_ptr<base::DictionaryValue> theme_display_properties_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 816 | |
| 817 | // Whether the extension is a theme. |
| 818 | bool is_theme_; |
| 819 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 820 | // The homepage for this extension. Useful if it is not hosted by Google and |
| 821 | // therefore does not have a Gallery URL. |
| 822 | GURL homepage_url_; |
| 823 | |
| 824 | // URL for fetching an update manifest |
| 825 | GURL update_url_; |
| 826 | |
| 827 | // A copy of the manifest that this extension was created from. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 828 | scoped_ptr<base::DictionaryValue> manifest_value_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 829 | |
| 830 | // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 831 | // which override the handling of those URLs. (see ExtensionOverrideUI). |
| 832 | URLOverrideMap chrome_url_overrides_; |
| 833 | |
| 834 | // Whether this extension uses app features. |
| 835 | bool is_app_; |
| 836 | |
[email protected] | 7d3ed2f | 2011-11-07 23:33:19 | [diff] [blame] | 837 | // Whether this app uses platform features. |
| 838 | bool is_platform_app_; |
| 839 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 840 | // Whether this extension requests isolated storage. |
| 841 | bool is_storage_isolated_; |
| 842 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 843 | // The local path inside the extension to use with the launcher. |
| 844 | std::string launch_local_path_; |
| 845 | |
| 846 | // A web url to use with the launcher. Note that this might be relative or |
| 847 | // absolute. If relative, it is relative to web_origin. |
| 848 | std::string launch_web_url_; |
| 849 | |
[email protected] | 4e59568 | 2011-02-09 17:07:02 | [diff] [blame] | 850 | // The window type that an app's manifest specifies to launch into. |
| 851 | // This is not always the window type an app will open into, because |
| 852 | // users can override the way each app launches. See |
| 853 | // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref |
| 854 | // to decide what container an app will launch in. |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 855 | extension_misc::LaunchContainer launch_container_; |
| 856 | |
| 857 | // The default size of the container when launching. Only respected for |
| 858 | // containers like panels and windows. |
| 859 | int launch_width_; |
| 860 | int launch_height_; |
| 861 | |
| 862 | // The Omnibox keyword for this extension, or empty if there is none. |
| 863 | std::string omnibox_keyword_; |
| 864 | |
[email protected] | a4a38c1 | 2010-12-23 16:43:56 | [diff] [blame] | 865 | // List of text-to-speech voices that this extension provides, if any. |
| 866 | std::vector<TtsVoice> tts_voices_; |
| 867 | |
[email protected] | 5662442 | 2011-11-01 22:11:27 | [diff] [blame] | 868 | // List of intent services that this extension provides, if any. |
| 869 | std::vector<webkit_glue::WebIntentServiceData> intents_services_; |
[email protected] | be5f00786 | 2011-09-23 00:35:13 | [diff] [blame] | 870 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 871 | // Whether the extension has host permissions or user script patterns that |
| 872 | // imply access to file:/// scheme URLs (the user may not have actually |
| 873 | // granted it that access). |
| 874 | bool wants_file_access_; |
| 875 | |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 876 | // The flags that were passed to InitFromValue. |
| 877 | int creation_flags_; |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 878 | |
[email protected] | 7f7b9d93 | 2011-04-20 16:13:26 | [diff] [blame] | 879 | // The Content-Security-Policy for this extension. Extensions can use |
| 880 | // Content-Security-Policies to mitigate cross-site scripting and other |
| 881 | // vulnerabilities. |
| 882 | std::string content_security_policy_; |
| 883 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 884 | FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
[email protected] | 5eb375e9 | 2010-11-26 07:50:41 | [diff] [blame] | 885 | UpdateExtensionPreservesLocation); |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 886 | FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); |
| 887 | FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps); |
[email protected] | ae7fe71 | 2009-07-02 20:33:58 | [diff] [blame] | 888 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 889 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 890 | }; |
| 891 | |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 892 | typedef std::vector< scoped_refptr<const Extension> > ExtensionList; |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 893 | typedef std::set<std::string> ExtensionIdSet; |
[email protected] | b1748b1d8 | 2009-11-30 20:32:56 | [diff] [blame] | 894 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 895 | // Handy struct to pass core extension info around. |
| 896 | struct ExtensionInfo { |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 897 | ExtensionInfo(const base::DictionaryValue* manifest, |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 898 | const std::string& id, |
| 899 | const FilePath& path, |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 900 | Extension::Location location); |
| 901 | ~ExtensionInfo(); |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 902 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 903 | scoped_ptr<base::DictionaryValue> extension_manifest; |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 904 | std::string extension_id; |
| 905 | FilePath extension_path; |
| 906 | Extension::Location extension_location; |
| 907 | |
| 908 | private: |
| 909 | DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
| 910 | }; |
| 911 | |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 912 | struct UnloadedExtensionInfo { |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 913 | extension_misc::UnloadedExtensionReason reason; |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 914 | |
| 915 | // Was the extension already disabled? |
| 916 | bool already_disabled; |
| 917 | |
| 918 | // The extension being unloaded - this should always be non-NULL. |
| 919 | const Extension* extension; |
| 920 | |
[email protected] | 814a7bf0f | 2011-08-13 05:30:59 | [diff] [blame] | 921 | UnloadedExtensionInfo( |
| 922 | const Extension* extension, |
| 923 | extension_misc::UnloadedExtensionReason reason); |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 924 | }; |
| 925 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 926 | // The details sent for EXTENSION_PERMISSIONS_UPDATED notifications. |
| 927 | struct UpdatedExtensionPermissionsInfo { |
| 928 | enum Reason { |
| 929 | ADDED, // The permissions were added to the extension. |
| 930 | REMOVED, // The permissions were removed from the extension. |
| 931 | }; |
| 932 | |
| 933 | Reason reason; |
| 934 | |
| 935 | // The extension who's permissions have changed. |
| 936 | const Extension* extension; |
| 937 | |
| 938 | // The permissions that have changed. For Reason::ADDED, this would contain |
| 939 | // only the permissions that have added, and for Reason::REMOVED, this would |
| 940 | // only contain the removed permissions. |
| 941 | const ExtensionPermissionSet* permissions; |
| 942 | |
| 943 | UpdatedExtensionPermissionsInfo( |
| 944 | const Extension* extension, |
| 945 | const ExtensionPermissionSet* permissions, |
| 946 | Reason reason); |
| 947 | }; |
| 948 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 949 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |