[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] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 5 | #ifndef EXTENSIONS_COMMON_EXTENSION_H_ |
| 6 | #define EXTENSIONS_COMMON_EXTENSION_H_ |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 7 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 8 | #include <map> |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 9 | #include <set> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 10 | #include <string> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 13 | #include "base/files/file_path.h" |
avi | 2d124c0 | 2015-12-23 06:36:42 | [diff] [blame] | 14 | #include "base/macros.h" |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 15 | #include "base/memory/linked_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 16 | #include "base/memory/ref_counted.h" |
| 17 | #include "base/memory/scoped_ptr.h" |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 18 | #include "base/threading/thread_checker.h" |
[email protected] | 993da5e | 2013-03-23 21:25:16 | [diff] [blame] | 19 | #include "extensions/common/extension_resource.h" |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 20 | #include "extensions/common/install_warning.h" |
[email protected] | d42c1115 | 2013-08-22 19:36:32 | [diff] [blame] | 21 | #include "extensions/common/manifest.h" |
[email protected] | e9f541a | 2012-11-19 21:52:31 | [diff] [blame] | 22 | #include "extensions/common/url_pattern_set.h" |
[email protected] | 5f5ef80 | 2013-07-04 16:11:13 | [diff] [blame] | 23 | #include "url/gurl.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 24 | |
thestig | 52a87b3b | 2014-10-23 22:02:38 | [diff] [blame] | 25 | #if !defined(ENABLE_EXTENSIONS) |
| 26 | #error "Extensions must be enabled" |
| 27 | #endif |
| 28 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 29 | namespace base { |
| 30 | class DictionaryValue; |
[email protected] | 1f04ef4 | 2013-04-22 07:35:50 | [diff] [blame] | 31 | class Version; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 32 | } |
| 33 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 34 | namespace extensions { |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 35 | class PermissionSet; |
[email protected] | d695bb1 | 2014-06-05 16:16:30 | [diff] [blame] | 36 | class PermissionsData; |
| 37 | class PermissionsParser; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 38 | |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 39 | // Uniquely identifies an Extension, using 32 characters from the alphabet |
| 40 | // 'a'-'p'. An empty string represents "no extension". |
| 41 | // |
| 42 | // Note: If this gets used heavily in files that don't otherwise need to include |
| 43 | // extension.h, we should pull it into a dedicated header. |
| 44 | typedef std::string ExtensionId; |
| 45 | |
[email protected] | f075553 | 2010-06-22 07:27:25 | [diff] [blame] | 46 | // Represents a Chrome extension. |
[email protected] | 5cd5634 | 2013-04-03 19:50:47 | [diff] [blame] | 47 | // Once created, an Extension object is immutable, with the exception of its |
| 48 | // RuntimeData. This makes it safe to use on any thread, since access to the |
| 49 | // RuntimeData is protected by a lock. |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 50 | class Extension : public base::RefCountedThreadSafe<Extension> { |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 51 | public: |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 52 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 53 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 54 | ENABLED, |
[email protected] | 79c833b5 | 2011-04-05 18:31:01 | [diff] [blame] | 55 | // An external extension that the user uninstalled. We should not reinstall |
| 56 | // such extensions on startup. |
| 57 | EXTERNAL_EXTENSION_UNINSTALLED, |
[email protected] | 9ae7396 | 2014-08-14 16:53:41 | [diff] [blame] | 58 | // DEPRECATED: Special state for component extensions. |
| 59 | // Maintained as a placeholder since states may be stored to disk. |
| 60 | ENABLED_COMPONENT_DEPRECATED, |
mlerman | 6a37b6a4 | 2014-11-26 22:10:53 | [diff] [blame] | 61 | // Add new states here as this enum is stored in prefs. |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 62 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 63 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 64 | |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 65 | // Reasons an extension may be disabled. These are used in histograms, so do |
| 66 | // not remove/reorder entries - only add at the end just before |
| 67 | // DISABLE_REASON_LAST (and update the shift value for it). Also remember to |
| 68 | // update the enum listing in tools/metrics/histograms.xml. |
treib | 29e1b9b1 | 2015-11-11 08:50:56 | [diff] [blame] | 69 | // Also carefully consider if your reason should sync to other devices, and if |
| 70 | // so, add it to kKnownSyncableDisableReasons in extension_sync_service.cc. |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 71 | enum DisableReason { |
[email protected] | eb5e4f9 | 2012-08-15 23:33:28 | [diff] [blame] | 72 | DISABLE_NONE = 0, |
| 73 | DISABLE_USER_ACTION = 1 << 0, |
| 74 | DISABLE_PERMISSIONS_INCREASE = 1 << 1, |
| 75 | DISABLE_RELOAD = 1 << 2, |
[email protected] | 215a7be | 2012-10-22 19:53:42 | [diff] [blame] | 76 | DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3, |
| 77 | DISABLE_SIDELOAD_WIPEOUT = 1 << 4, |
treib | 3b91e9f | 2015-11-04 11:29:41 | [diff] [blame] | 78 | DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC = 1 << 5, |
[email protected] | 367d077d | 2014-06-23 20:38:17 | [diff] [blame] | 79 | // DISABLE_PERMISSIONS_CONSENT = 1 << 6, // Deprecated. |
| 80 | // DISABLE_KNOWN_DISABLED = 1 << 7, // Deprecated. |
[email protected] | 2d19eb6e | 2014-01-27 17:30:00 | [diff] [blame] | 81 | DISABLE_NOT_VERIFIED = 1 << 8, // Disabled because we could not verify |
| 82 | // the install. |
[email protected] | e1e2da3 | 2014-05-05 13:11:37 | [diff] [blame] | 83 | DISABLE_GREYLIST = 1 << 9, |
| 84 | DISABLE_CORRUPTED = 1 << 10, |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 85 | DISABLE_REMOTE_INSTALL = 1 << 11, |
benwells | 1dd4acd | 2015-12-09 02:20:24 | [diff] [blame] | 86 | // DISABLE_INACTIVE_EPHEMERAL_APP = 1 << 12, // Deprecated. |
| 87 | DISABLE_EXTERNAL_EXTENSION = 1 << 13, // External extensions might be |
| 88 | // disabled for user prompting. |
binjin | 8e3d018 | 2014-12-04 16:44:28 | [diff] [blame] | 89 | DISABLE_UPDATE_REQUIRED_BY_POLICY = 1 << 14, // Doesn't meet minimum |
| 90 | // version requirement. |
| 91 | DISABLE_REASON_LAST = 1 << 15, // This should always be the last value |
[email protected] | 44d62b6 | 2012-04-11 00:06:03 | [diff] [blame] | 92 | }; |
| 93 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 94 | // A base class for parsed manifest data that APIs want to store on |
| 95 | // the extension. Related to base::SupportsUserData, but with an immutable |
| 96 | // thread-safe interface to match Extension. |
| 97 | struct ManifestData { |
| 98 | virtual ~ManifestData() {} |
| 99 | }; |
| 100 | |
[email protected] | f9c5d39 | 2014-05-13 05:34:18 | [diff] [blame] | 101 | // Do not change the order of entries or remove entries in this list |
| 102 | // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions. |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 103 | enum InitFromValueFlags { |
| 104 | NO_FLAGS = 0, |
| 105 | |
| 106 | // Usually, the id of an extension is generated by the "key" property of |
| 107 | // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 108 | // generated based on the path. |
| 109 | REQUIRE_KEY = 1 << 0, |
| 110 | |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 111 | // Requires the extension to have an up-to-date manifest version. |
| 112 | // Typically, we'll support multiple manifest versions during a version |
[email protected] | 26367b6 | 2012-10-04 23:03:32 | [diff] [blame] | 113 | // transition. This flag signals that we want to require the most modern |
[email protected] | 3f53dfe | 2011-11-30 01:18:29 | [diff] [blame] | 114 | // manifest version that Chrome understands. |
| 115 | REQUIRE_MODERN_MANIFEST_VERSION = 1 << 1, |
| 116 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 117 | // |ALLOW_FILE_ACCESS| indicates that the user is allowing this extension |
| 118 | // to have file access. If it's not present, then permissions and content |
| 119 | // scripts that match file:/// URLs will be filtered out. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 120 | ALLOW_FILE_ACCESS = 1 << 2, |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 121 | |
| 122 | // |FROM_WEBSTORE| indicates that the extension was installed from the |
| 123 | // Chrome Web Store. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 124 | FROM_WEBSTORE = 1 << 3, |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 125 | |
[email protected] | 4660146 | 2014-02-04 11:08:50 | [diff] [blame] | 126 | // |FROM_BOOKMARK| indicates the extension is a bookmark app which has been |
| 127 | // generated from a web page. Bookmark apps have no permissions or extent |
| 128 | // and launch the web page they are created from when run. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 129 | FROM_BOOKMARK = 1 << 4, |
[email protected] | 3d41d43 | 2012-04-20 20:47:58 | [diff] [blame] | 130 | |
| 131 | // |FOLLOW_SYMLINKS_ANYWHERE| means that resources can be symlinks to |
| 132 | // anywhere in the filesystem, rather than being restricted to the |
| 133 | // extension directory. |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 134 | FOLLOW_SYMLINKS_ANYWHERE = 1 << 5, |
[email protected] | ab55c2b | 2012-06-01 23:55:03 | [diff] [blame] | 135 | |
| 136 | // |ERROR_ON_PRIVATE_KEY| means that private keys inside an |
| 137 | // extension should be errors rather than warnings. |
| 138 | ERROR_ON_PRIVATE_KEY = 1 << 6, |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 139 | |
| 140 | // |WAS_INSTALLED_BY_DEFAULT| installed by default when the profile was |
| 141 | // created. |
| 142 | WAS_INSTALLED_BY_DEFAULT = 1 << 7, |
[email protected] | aa5a547 | 2013-10-04 03:41:04 | [diff] [blame] | 143 | |
[email protected] | 1b563df | 2013-10-30 16:49:36 | [diff] [blame] | 144 | // Unused - was part of an abandoned experiment. |
[email protected] | aa5a547 | 2013-10-04 03:41:04 | [diff] [blame] | 145 | REQUIRE_PERMISSIONS_CONSENT = 1 << 8, |
[email protected] | ce35418b | 2013-11-25 01:22:33 | [diff] [blame] | 146 | |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 147 | // Unused - this flag has been moved to ExtensionPrefs. |
[email protected] | ce35418b | 2013-11-25 01:22:33 | [diff] [blame] | 148 | IS_EPHEMERAL = 1 << 9, |
[email protected] | acc3c7c2 | 2014-03-19 06:23:39 | [diff] [blame] | 149 | |
| 150 | // |WAS_INSTALLED_BY_OEM| installed by an OEM (e.g on Chrome OS) and should |
| 151 | // be placed in a special OEM folder in the App Launcher. Note: OEM apps are |
| 152 | // also installed by Default (i.e. WAS_INSTALLED_BY_DEFAULT is also true). |
| 153 | WAS_INSTALLED_BY_OEM = 1 << 10, |
[email protected] | f9c5d39 | 2014-05-13 05:34:18 | [diff] [blame] | 154 | |
[email protected] | 6338fa3 | 2014-07-16 21:41:59 | [diff] [blame] | 155 | // |WAS_INSTALLED_BY_CUSTODIAN| means this extension was installed by the |
| 156 | // custodian of a supervised user. |
| 157 | WAS_INSTALLED_BY_CUSTODIAN = 1 << 11, |
| 158 | |
[email protected] | 2b6a580 | 2014-08-16 07:58:08 | [diff] [blame] | 159 | // |MAY_BE_UNTRUSTED| indicates that this extension came from a potentially |
| 160 | // unsafe source (e.g., sideloaded from a local CRX file via the Windows |
| 161 | // registry). Such extensions may be subjected to additional constraints |
| 162 | // before they are fully installed and enabled. |
| 163 | MAY_BE_UNTRUSTED = 1 << 12, |
| 164 | |
[email protected] | f9c5d39 | 2014-05-13 05:34:18 | [diff] [blame] | 165 | // When adding new flags, make sure to update kInitFromValueFlagBits. |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 166 | }; |
| 167 | |
[email protected] | f9c5d39 | 2014-05-13 05:34:18 | [diff] [blame] | 168 | // This is the highest bit index of the flags defined above. |
| 169 | static const int kInitFromValueFlagBits; |
| 170 | |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 171 | static scoped_refptr<Extension> Create(const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 172 | Manifest::Location location, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 173 | const base::DictionaryValue& value, |
[email protected] | 83048a2 | 2011-03-29 00:14:13 | [diff] [blame] | 174 | int flags, |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 175 | std::string* error); |
| 176 | |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 177 | // 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] | 178 | // an explicit id. Most consumers should just use the other Create() method. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 179 | static scoped_refptr<Extension> Create(const base::FilePath& path, |
[email protected] | 2cb5e30 | 2013-05-09 05:00:06 | [diff] [blame] | 180 | Manifest::Location location, |
| 181 | const base::DictionaryValue& value, |
| 182 | int flags, |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 183 | const ExtensionId& explicit_id, |
[email protected] | 2cb5e30 | 2013-05-09 05:00:06 | [diff] [blame] | 184 | std::string* error); |
[email protected] | 87c655e | 2011-07-01 21:42:00 | [diff] [blame] | 185 | |
[email protected] | 8d888c1 | 2010-11-30 00:00:25 | [diff] [blame] | 186 | // Valid schemes for web extent URLPatterns. |
| 187 | static const int kValidWebExtentSchemes; |
| 188 | |
dominickn | 0bdf6c73 | 2015-08-25 06:13:46 | [diff] [blame] | 189 | // Valid schemes for bookmark app installs. |
| 190 | static const int kValidBookmarkAppSchemes; |
| 191 | |
[email protected] | f71f7e6 | 2010-12-07 03:45:33 | [diff] [blame] | 192 | // Valid schemes for host permission URLPatterns. |
| 193 | static const int kValidHostPermissionSchemes; |
| 194 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 195 | // The mimetype used for extensions. |
| 196 | static const char kMimeType[]; |
| 197 | |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 198 | // See Type definition in Manifest. |
| 199 | Manifest::Type GetType() const; |
[email protected] | 9b21765 | 2010-10-08 22:04:23 | [diff] [blame] | 200 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 201 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 202 | // |extension_url| argument should be the url() from an Extension object. The |
| 203 | // |relative_path| can be untrusted user input. The returned URL will either |
| 204 | // be invalid() or a child of |extension_url|. |
| 205 | // NOTE: Static so that it can be used from multiple threads. |
| 206 | static GURL GetResourceURL(const GURL& extension_url, |
| 207 | const std::string& relative_path); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 208 | GURL GetResourceURL(const std::string& relative_path) const { |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 209 | return GetResourceURL(url(), relative_path); |
| 210 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 211 | |
[email protected] | f59a805 | 2012-06-20 22:25:00 | [diff] [blame] | 212 | // Returns true if the resource matches a pattern in the pattern_set. |
| 213 | bool ResourceMatches(const URLPatternSet& pattern_set, |
| 214 | const std::string& resource) const; |
| 215 | |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 216 | // Returns an extension resource object. |relative_path| should be UTF8 |
| 217 | // encoded. |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 218 | ExtensionResource GetResource(const std::string& relative_path) const; |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 219 | |
| 220 | // As above, but with |relative_path| following the file system's encoding. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 221 | ExtensionResource GetResource(const base::FilePath& relative_path) const; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 222 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 223 | // |input| is expected to be the text of an rsa public or private key. It |
| 224 | // tolerates the presence or absence of bracking header/footer like this: |
| 225 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 226 | // and may contain newlines. |
| 227 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 228 | |
| 229 | // Does a simple base64 encoding of |input| into |output|. |
| 230 | static bool ProducePEM(const std::string& input, std::string* output); |
| 231 | |
| 232 | // Expects base64 encoded |input| and formats into |output| including |
| 233 | // the appropriate header & footer. |
[email protected] | e0d0819 | 2011-03-29 19:02:50 | [diff] [blame] | 234 | static bool FormatPEMForFileOutput(const std::string& input, |
| 235 | std::string* output, |
| 236 | bool is_public); |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 237 | |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 238 | // Returns the base extension url for a given |extension_id|. |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 239 | static GURL GetBaseURLFromExtensionId(const ExtensionId& extension_id); |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 240 | |
[email protected] | 5df6a5d | 2011-01-26 07:39:12 | [diff] [blame] | 241 | // Whether context menu should be shown for page and browser actions. |
| 242 | bool ShowConfigureContextMenus() const; |
| 243 | |
[email protected] | cca14717 | 2011-02-17 01:29:29 | [diff] [blame] | 244 | // Returns true if this extension or app includes areas within |origin|. |
| 245 | bool OverlapsWithOrigin(const GURL& origin) const; |
| 246 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 247 | // Returns true if the extension requires a valid ordinal for sorting, e.g., |
| 248 | // for displaying in a launcher or new tab page. |
| 249 | bool RequiresSortOrdinal() const; |
| 250 | |
| 251 | // Returns true if the extension should be displayed in the app launcher. |
| 252 | bool ShouldDisplayInAppLauncher() const; |
| 253 | |
| 254 | // Returns true if the extension should be displayed in the browser NTP. |
| 255 | bool ShouldDisplayInNewTabPage() const; |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 256 | |
[email protected] | e0b3de7 | 2012-05-01 01:21:34 | [diff] [blame] | 257 | // Returns true if the extension should be displayed in the extension |
| 258 | // settings page (i.e. chrome://extensions). |
| 259 | bool ShouldDisplayInExtensionSettings() const; |
| 260 | |
[email protected] | 624e63d0c | 2013-08-16 00:09:50 | [diff] [blame] | 261 | // Returns true if the extension should not be shown anywhere. This is |
| 262 | // mostly the same as the extension being a component extension, but also |
| 263 | // includes non-component apps that are hidden from the app launcher and ntp. |
| 264 | bool ShouldNotBeVisible() const; |
| 265 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 266 | // Get the manifest data associated with the key, or NULL if there is none. |
| 267 | // Can only be called after InitValue is finished. |
| 268 | ManifestData* GetManifestData(const std::string& key) const; |
| 269 | |
| 270 | // Sets |data| to be associated with the key. Takes ownership of |data|. |
| 271 | // Can only be called before InitValue is finished. Not thread-safe; |
| 272 | // all SetManifestData calls should be on only one thread. |
| 273 | void SetManifestData(const std::string& key, ManifestData* data); |
| 274 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 275 | // Accessors: |
| 276 | |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 277 | const base::FilePath& path() const { return path_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 278 | const GURL& url() const { return extension_url_; } |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 279 | Manifest::Location location() const; |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 280 | const ExtensionId& id() const; |
[email protected] | 1f04ef4 | 2013-04-22 07:35:50 | [diff] [blame] | 281 | const base::Version* version() const { return version_.get(); } |
limasdf | c8a1187 | 2016-01-21 05:24:50 | [diff] [blame] | 282 | const std::string& version_name() const { return version_name_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 283 | const std::string VersionString() const; |
elijahtaylor | 89b02d7 | 2014-12-05 00:42:20 | [diff] [blame] | 284 | const std::string GetVersionForDisplay() const; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 285 | const std::string& name() const { return name_; } |
[email protected] | 680eaa67 | 2013-08-27 10:25:08 | [diff] [blame] | 286 | const std::string& short_name() const { return short_name_; } |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 287 | const std::string& non_localized_name() const { return non_localized_name_; } |
[email protected] | 200423d | 2012-06-05 01:16:06 | [diff] [blame] | 288 | // Base64-encoded version of the key used to sign this extension. |
| 289 | // In pseudocode, returns |
| 290 | // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
| 291 | const std::string& public_key() const { return public_key_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 292 | const std::string& description() const { return description_; } |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 293 | int manifest_version() const { return manifest_version_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 294 | bool converted_from_user_script() const { |
| 295 | return converted_from_user_script_; |
| 296 | } |
[email protected] | d695bb1 | 2014-06-05 16:16:30 | [diff] [blame] | 297 | PermissionsParser* permissions_parser() { return permissions_parser_.get(); } |
| 298 | const PermissionsParser* permissions_parser() const { |
| 299 | return permissions_parser_.get(); |
| 300 | } |
| 301 | |
[email protected] | 2cb5e30 | 2013-05-09 05:00:06 | [diff] [blame] | 302 | const PermissionsData* permissions_data() const { |
| 303 | return permissions_data_.get(); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 304 | } |
[email protected] | 2cb5e30 | 2013-05-09 05:00:06 | [diff] [blame] | 305 | |
[email protected] | 23b3c0a | 2013-01-16 23:36:36 | [diff] [blame] | 306 | // Appends |new_warning[s]| to install_warnings_. |
| 307 | void AddInstallWarning(const InstallWarning& new_warning); |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 308 | void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings); |
| 309 | const std::vector<InstallWarning>& install_warnings() const { |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 310 | return install_warnings_; |
| 311 | } |
[email protected] | 953620b | 2011-12-04 00:55:32 | [diff] [blame] | 312 | const extensions::Manifest* manifest() const { |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 313 | return manifest_.get(); |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 314 | } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 315 | bool wants_file_access() const { return wants_file_access_; } |
[email protected] | 334ec0a | 2013-03-24 01:36:16 | [diff] [blame] | 316 | // TODO(rdevlin.cronin): This is needed for ContentScriptsHandler, and should |
| 317 | // be moved out as part of crbug.com/159265. This should not be used anywhere |
| 318 | // else. |
| 319 | void set_wants_file_access(bool wants_file_access) { |
| 320 | wants_file_access_ = wants_file_access; |
| 321 | } |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 322 | int creation_flags() const { return creation_flags_; } |
| 323 | bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } |
[email protected] | e805baf | 2011-07-26 18:23:05 | [diff] [blame] | 324 | bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } |
proberge | 83469713 | 2015-10-21 21:04:49 | [diff] [blame] | 325 | bool may_be_untrusted() const { |
| 326 | return (creation_flags_ & MAY_BE_UNTRUSTED) != 0; |
| 327 | } |
[email protected] | e33bbc2 | 2012-08-27 22:05:46 | [diff] [blame] | 328 | bool was_installed_by_default() const { |
| 329 | return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0; |
| 330 | } |
[email protected] | acc3c7c2 | 2014-03-19 06:23:39 | [diff] [blame] | 331 | bool was_installed_by_oem() const { |
| 332 | return (creation_flags_ & WAS_INSTALLED_BY_OEM) != 0; |
| 333 | } |
[email protected] | 6338fa3 | 2014-07-16 21:41:59 | [diff] [blame] | 334 | bool was_installed_by_custodian() const { |
| 335 | return (creation_flags_ & WAS_INSTALLED_BY_CUSTODIAN) != 0; |
| 336 | } |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 337 | |
[email protected] | b86960e | 2014-07-18 05:35:09 | [diff] [blame] | 338 | // Type-related queries. |
[email protected] | 21c0104 | 2013-03-10 23:41:14 | [diff] [blame] | 339 | bool is_app() const; |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 340 | bool is_platform_app() const; |
| 341 | bool is_hosted_app() const; |
[email protected] | c4f459d | 2012-09-28 04:40:10 | [diff] [blame] | 342 | bool is_legacy_packaged_app() const; |
[email protected] | ff05a4b10 | 2012-12-19 00:12:06 | [diff] [blame] | 343 | bool is_extension() const; |
[email protected] | b86960e | 2014-07-18 05:35:09 | [diff] [blame] | 344 | bool is_shared_module() const; |
| 345 | bool is_theme() const; |
| 346 | |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 347 | void AddWebExtentPattern(const URLPattern& pattern); |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 348 | const URLPatternSet& web_extent() const { return extent_; } |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 349 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 350 | private: |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 351 | friend class base::RefCountedThreadSafe<Extension>; |
| 352 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 353 | // Chooses the extension ID for an extension based on a variety of criteria. |
| 354 | // The chosen ID will be set in |manifest|. |
| 355 | static bool InitExtensionID(extensions::Manifest* manifest, |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 356 | const base::FilePath& path, |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 357 | const ExtensionId& explicit_id, |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 358 | int creation_flags, |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 359 | base::string16* error); |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 360 | |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 361 | Extension(const base::FilePath& path, |
| 362 | scoped_ptr<extensions::Manifest> manifest); |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 363 | virtual ~Extension(); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 364 | |
| 365 | // Initialize the extension from a parsed manifest. |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 366 | // TODO(aa): Rename to just Init()? There's no Value here anymore. |
| 367 | // TODO(aa): It is really weird the way this class essentially contains a copy |
| 368 | // of the underlying DictionaryValue in its members. We should decide to |
| 369 | // either wrap the DictionaryValue and go with that only, or we should parse |
| 370 | // into strong types and discard the value. But doing both is bad. |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 371 | bool InitFromValue(int flags, base::string16* error); |
[email protected] | 66e4eb3 | 2010-10-27 20:37:41 | [diff] [blame] | 372 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 373 | // The following are helpers for InitFromValue to load various features of the |
| 374 | // extension from the manifest. |
| 375 | |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 376 | bool LoadRequiredFeatures(base::string16* error); |
| 377 | bool LoadName(base::string16* error); |
| 378 | bool LoadVersion(base::string16* error); |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 379 | |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 380 | bool LoadAppFeatures(base::string16* error); |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 381 | bool LoadExtent(const char* key, |
| 382 | URLPatternSet* extent, |
| 383 | const char* list_error, |
| 384 | const char* value_error, |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 385 | base::string16* error); |
[email protected] | 10253da | 2012-03-09 04:06:42 | [diff] [blame] | 386 | |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 387 | bool LoadSharedFeatures(base::string16* error); |
| 388 | bool LoadDescription(base::string16* error); |
| 389 | bool LoadManifestVersion(base::string16* error); |
| 390 | bool LoadShortName(base::string16* error); |
[email protected] | 6600800 | 2013-01-08 09:09:13 | [diff] [blame] | 391 | |
[email protected] | 0d163dc | 2013-12-20 23:48:36 | [diff] [blame] | 392 | bool CheckMinimumChromeVersion(base::string16* error) const; |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 393 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 394 | // The extension's human-readable name. Name is used for display purpose. It |
| 395 | // might be wrapped with unicode bidi control characters so that it is |
| 396 | // displayed correctly in RTL context. |
| 397 | // NOTE: Name is UTF-8 and may contain non-ascii characters. |
| 398 | std::string name_; |
| 399 | |
[email protected] | 701d1e8 | 2012-05-14 05:34:19 | [diff] [blame] | 400 | // A non-localized version of the extension's name. This is useful for |
| 401 | // debug output. |
| 402 | std::string non_localized_name_; |
| 403 | |
[email protected] | 680eaa67 | 2013-08-27 10:25:08 | [diff] [blame] | 404 | // A short version of the extension's name. This can be used as an alternative |
| 405 | // to the name where there is insufficient space to display the full name. If |
| 406 | // an extension has not explicitly specified a short name, the value of this |
| 407 | // member variable will be the full name rather than an empty string. |
| 408 | std::string short_name_; |
| 409 | |
[email protected] | a47c8a2 | 2011-11-17 18:40:31 | [diff] [blame] | 410 | // The version of this extension's manifest. We increase the manifest |
| 411 | // version when making breaking changes to the extension system. |
| 412 | // Version 1 was the first manifest version (implied by a lack of a |
| 413 | // manifest_version attribute in the extension's manifest). We initialize |
| 414 | // this member variable to 0 to distinguish the "uninitialized" case from |
| 415 | // the case when we know the manifest version actually is 1. |
| 416 | int manifest_version_; |
| 417 | |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 418 | // The absolute path to the directory the extension is stored in. |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 419 | base::FilePath path_; |
[email protected] | d41e215 | 2012-02-24 04:20:27 | [diff] [blame] | 420 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 421 | // Defines the set of URLs in the extension's web content. |
[email protected] | cced75a | 2011-05-20 08:31:12 | [diff] [blame] | 422 | URLPatternSet extent_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 423 | |
[email protected] | d695bb1 | 2014-06-05 16:16:30 | [diff] [blame] | 424 | // The parser for the manifest's permissions. This is NULL anytime not during |
| 425 | // initialization. |
| 426 | // TODO(rdevlin.cronin): This doesn't really belong here. |
| 427 | scoped_ptr<PermissionsParser> permissions_parser_; |
| 428 | |
| 429 | // The active permissions for the extension. |
[email protected] | 2cb5e30 | 2013-05-09 05:00:06 | [diff] [blame] | 430 | scoped_ptr<PermissionsData> permissions_data_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 431 | |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 432 | // Any warnings that occurred when trying to create/parse the extension. |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 433 | std::vector<InstallWarning> install_warnings_; |
[email protected] | 8629c54 | 2012-04-20 03:40:03 | [diff] [blame] | 434 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 435 | // The base extension url for the extension. |
| 436 | GURL extension_url_; |
| 437 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 438 | // The extension's version. |
[email protected] | 1f04ef4 | 2013-04-22 07:35:50 | [diff] [blame] | 439 | scoped_ptr<base::Version> version_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 440 | |
elijahtaylor | 89b02d7 | 2014-12-05 00:42:20 | [diff] [blame] | 441 | // The extension's user visible version name. |
| 442 | std::string version_name_; |
| 443 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 444 | // An optional longer description of the extension. |
| 445 | std::string description_; |
| 446 | |
| 447 | // True if the extension was generated from a user script. (We show slightly |
| 448 | // different UI if so). |
| 449 | bool converted_from_user_script_; |
| 450 | |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 451 | // The public key used to sign the contents of the crx package. |
| 452 | std::string public_key_; |
| 453 | |
[email protected] | 58f62cf | 2012-03-09 10:45:11 | [diff] [blame] | 454 | // The manifest from which this extension was created. |
[email protected] | e9629d77 | 2012-08-06 19:44:46 | [diff] [blame] | 455 | scoped_ptr<Manifest> manifest_; |
[email protected] | 6f229e8 | 2010-11-02 17:47:26 | [diff] [blame] | 456 | |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 457 | // Stored parsed manifest data. |
treib | 2eab429f | 2016-02-02 15:02:14 | [diff] [blame] | 458 | using ManifestDataMap = std::map<std::string, scoped_ptr<ManifestData>>; |
[email protected] | d356c98 | 2012-12-12 19:32:55 | [diff] [blame] | 459 | ManifestDataMap manifest_data_; |
| 460 | |
| 461 | // Set to true at the end of InitValue when initialization is finished. |
| 462 | bool finished_parsing_manifest_; |
| 463 | |
[email protected] | 7eeab9ec | 2013-01-15 04:08:33 | [diff] [blame] | 464 | // Ensures that any call to GetManifestData() prior to finishing |
| 465 | // initialization happens from the same thread (this can happen when certain |
| 466 | // parts of the initialization process need information from previous parts). |
| 467 | base::ThreadChecker thread_checker_; |
| 468 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 469 | // Should this app be shown in the app launcher. |
[email protected] | ed1a204f | 2012-09-22 00:28:44 | [diff] [blame] | 470 | bool display_in_launcher_; |
| 471 | |
[email protected] | 7e0f92b | 2012-11-09 03:51:04 | [diff] [blame] | 472 | // Should this app be shown in the browser New Tab Page. |
| 473 | bool display_in_new_tab_page_; |
| 474 | |
[email protected] | 3aff9ad | 2011-04-01 20:26:48 | [diff] [blame] | 475 | // Whether the extension has host permissions or user script patterns that |
| 476 | // imply access to file:/// scheme URLs (the user may not have actually |
| 477 | // granted it that access). |
| 478 | bool wants_file_access_; |
| 479 | |
[email protected] | 2af352b | 2011-07-22 08:21:23 | [diff] [blame] | 480 | // The flags that were passed to InitFromValue. |
| 481 | int creation_flags_; |
[email protected] | 620db176 | 2011-07-15 21:57:34 | [diff] [blame] | 482 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 483 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 484 | }; |
| 485 | |
[email protected] | bc151cf9 | 2013-02-12 04:57:26 | [diff] [blame] | 486 | typedef std::vector<scoped_refptr<const Extension> > ExtensionList; |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 487 | typedef std::set<ExtensionId> ExtensionIdSet; |
| 488 | typedef std::vector<ExtensionId> ExtensionIdList; |
[email protected] | b1748b1d8 | 2009-11-30 20:32:56 | [diff] [blame] | 489 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 490 | // Handy struct to pass core extension info around. |
| 491 | struct ExtensionInfo { |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 492 | ExtensionInfo(const base::DictionaryValue* manifest, |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 493 | const ExtensionId& id, |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 494 | const base::FilePath& path, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 495 | Manifest::Location location); |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 496 | ~ExtensionInfo(); |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 497 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 498 | scoped_ptr<base::DictionaryValue> extension_manifest; |
[email protected] | 53d5f0f46 | 2014-03-07 09:15:20 | [diff] [blame] | 499 | ExtensionId extension_id; |
[email protected] | a732916 | 2013-02-07 19:21:48 | [diff] [blame] | 500 | base::FilePath extension_path; |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 501 | Manifest::Location extension_location; |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 502 | |
| 503 | private: |
| 504 | DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
| 505 | }; |
| 506 | |
[email protected] | 41bb80bd | 2013-05-03 10:56:02 | [diff] [blame] | 507 | struct InstalledExtensionInfo { |
| 508 | // The extension being installed - this should always be non-NULL. |
| 509 | const Extension* extension; |
| 510 | |
| 511 | // True if the extension is being updated; false if it is being installed. |
| 512 | bool is_update; |
| 513 | |
[email protected] | 760f743b | 2014-05-28 13:52:02 | [diff] [blame] | 514 | // True if the extension was previously installed ephemerally and is now |
| 515 | // a regular installed extension. |
| 516 | bool from_ephemeral; |
| 517 | |
[email protected] | e7554c3f | 2013-05-29 00:36:56 | [diff] [blame] | 518 | // The name of the extension prior to this update. Will be empty if |
| 519 | // |is_update| is false. |
| 520 | std::string old_name; |
| 521 | |
| 522 | InstalledExtensionInfo(const Extension* extension, |
| 523 | bool is_update, |
[email protected] | 760f743b | 2014-05-28 13:52:02 | [diff] [blame] | 524 | bool from_ephemeral, |
[email protected] | e7554c3f | 2013-05-29 00:36:56 | [diff] [blame] | 525 | const std::string& old_name); |
[email protected] | 41bb80bd | 2013-05-03 10:56:02 | [diff] [blame] | 526 | }; |
| 527 | |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 528 | struct UnloadedExtensionInfo { |
[email protected] | e51232f3 | 2014-04-18 20:05:36 | [diff] [blame] | 529 | // TODO(DHNishi): Move this enum to ExtensionRegistryObserver. |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 530 | enum Reason { |
[email protected] | ebe0777 | 2014-05-22 04:16:06 | [diff] [blame] | 531 | REASON_UNDEFINED, // Undefined state used to initialize variables. |
| 532 | REASON_DISABLE, // Extension is being disabled. |
| 533 | REASON_UPDATE, // Extension is being updated to a newer version. |
| 534 | REASON_UNINSTALL, // Extension is being uninstalled. |
| 535 | REASON_TERMINATE, // Extension has terminated. |
| 536 | REASON_BLACKLIST, // Extension has been blacklisted. |
| 537 | REASON_PROFILE_SHUTDOWN, // Profile is being shut down. |
mlerman | 6a37b6a4 | 2014-11-26 22:10:53 | [diff] [blame] | 538 | REASON_LOCK_ALL, // All extensions for the profile are blocked. |
mfoltz | 96f329c | 2016-01-13 18:16:58 | [diff] [blame] | 539 | REASON_MIGRATED_TO_COMPONENT, // Extension is being migrated to a component |
| 540 | // action. |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | Reason reason; |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 544 | |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 545 | // The extension being unloaded - this should always be non-NULL. |
| 546 | const Extension* extension; |
| 547 | |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 548 | UnloadedExtensionInfo(const Extension* extension, Reason reason); |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 549 | }; |
| 550 | |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 551 | // The details sent for EXTENSION_PERMISSIONS_UPDATED notifications. |
| 552 | struct UpdatedExtensionPermissionsInfo { |
| 553 | enum Reason { |
[email protected] | f553247 | 2012-02-23 13:00:55 | [diff] [blame] | 554 | ADDED, // The permissions were added to the extension. |
| 555 | REMOVED, // The permissions were removed from the extension. |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 556 | }; |
| 557 | |
| 558 | Reason reason; |
| 559 | |
| 560 | // The extension who's permissions have changed. |
| 561 | const Extension* extension; |
| 562 | |
| 563 | // The permissions that have changed. For Reason::ADDED, this would contain |
| 564 | // only the permissions that have added, and for Reason::REMOVED, this would |
| 565 | // only contain the removed permissions. |
rdevlin.cronin | e2d0fd0 | 2015-09-24 22:35:49 | [diff] [blame] | 566 | const PermissionSet& permissions; |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 567 | |
rdevlin.cronin | e2d0fd0 | 2015-09-24 22:35:49 | [diff] [blame] | 568 | UpdatedExtensionPermissionsInfo(const Extension* extension, |
| 569 | const PermissionSet& permissions, |
| 570 | Reason reason); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 571 | }; |
| 572 | |
[email protected] | 488e650 | 2012-09-07 14:17:34 | [diff] [blame] | 573 | } // namespace extensions |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 574 | |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 575 | #endif // EXTENSIONS_COMMON_EXTENSION_H_ |