[email protected] | 225c8f5 | 2010-02-05 22:23:20 | [diff] [blame] | 1 | // Copyright (c) 2010 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] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 16 | #include "base/scoped_ptr.h" |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame^] | 17 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 18 | #include "chrome/common/extensions/extension_extent.h" |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 19 | #include "chrome/common/extensions/user_script.h" |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 20 | #include "chrome/common/extensions/url_pattern.h" |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 21 | #include "gfx/size.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 22 | #include "googleurl/src/gurl.h" |
| 23 | |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 24 | class DictionaryValue; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 25 | class ExtensionAction; |
| 26 | class ExtensionResource; |
[email protected] | 1280270 | 2010-07-09 19:43:09 | [diff] [blame] | 27 | class SkBitmap; |
[email protected] | daf66aa | 2010-08-06 06:24:28 | [diff] [blame] | 28 | class Version; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 29 | |
[email protected] | f075553 | 2010-06-22 07:27:25 | [diff] [blame] | 30 | // Represents a Chrome extension. |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 31 | class Extension { |
| 32 | public: |
[email protected] | b30e0dd | 2010-01-29 23:33:21 | [diff] [blame] | 33 | typedef std::vector<URLPattern> URLPatternList; |
[email protected] | d3cfa48 | 2009-10-17 13:54:57 | [diff] [blame] | 34 | typedef std::map<const std::string, GURL> URLOverrideMap; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 35 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 36 | // What an extension was loaded from. |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 37 | // NOTE: These values are stored as integers in the preferences, so you |
| 38 | // really don't want to change any existing ones. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 39 | enum Location { |
| 40 | INVALID, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 41 | INTERNAL, // A crx file from the internal Extensions directory. |
| 42 | EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 43 | EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 44 | // registry on Windows). |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 45 | LOAD, // --load-extension. |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 46 | COMPONENT, // An integral component of Chrome itself, which |
| 47 | // happens to be implemented as an extension. We don't |
| 48 | // show these in the management UI. |
| 49 | EXTERNAL_PREF_DOWNLOAD // A crx file from an external directory (via |
| 50 | // prefs), installed from an update URL. |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 54 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 55 | ENABLED, |
| 56 | KILLBIT, // Don't install/upgrade (applies to external extensions only). |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 57 | |
| 58 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 59 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 60 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 61 | enum InstallType { |
[email protected] | ab6f2b2 | 2009-07-28 23:28:37 | [diff] [blame] | 62 | INSTALL_ERROR, |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 63 | DOWNGRADE, |
| 64 | REINSTALL, |
| 65 | UPGRADE, |
| 66 | NEW_INSTALL |
| 67 | }; |
| 68 | |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 69 | // NOTE: If you change this list, you should also change kIconSizes in the cc |
| 70 | // file. |
| 71 | enum Icons { |
| 72 | EXTENSION_ICON_LARGE = 128, |
| 73 | EXTENSION_ICON_MEDIUM = 48, |
| 74 | EXTENSION_ICON_SMALL = 32, |
[email protected] | 3938294 | 2010-03-23 15:57:09 | [diff] [blame] | 75 | EXTENSION_ICON_SMALLISH = 24, |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 76 | EXTENSION_ICON_BITTY = 16, |
| 77 | }; |
| 78 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 79 | bool apps_enabled() const { return apps_enabled_; } |
| 80 | void set_apps_enabled(bool val) { apps_enabled_ = val; } |
| 81 | |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 82 | // Icon sizes used by the extension system. |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 83 | static const int kIconSizes[]; |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 84 | |
[email protected] | 4c4f819 | 2009-10-17 01:03:26 | [diff] [blame] | 85 | // Max size (both dimensions) for browser and page actions. |
| 86 | static const int kPageActionIconMaxSize; |
| 87 | static const int kBrowserActionIconMaxSize; |
| 88 | |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 89 | // Each permission is a module that the extension is permitted to use. |
[email protected] | 218990c | 2010-06-26 01:21:07 | [diff] [blame] | 90 | // |
| 91 | // NOTE: If you add a permission, consider also changing: |
| 92 | // - Extension::GetSimplePermissions() |
| 93 | // - Extension::IsPrivilegeIncrease() |
| 94 | // - ExtensionInstallUI::GetV2Warnings() |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 95 | static const char kBackgroundPermission[]; |
| 96 | static const char kBookmarkPermission[]; |
| 97 | static const char kContextMenusPermission[]; |
| 98 | static const char kCookiePermission[]; |
| 99 | static const char kExperimentalPermission[]; |
| 100 | static const char kGeolocationPermission[]; |
| 101 | static const char kHistoryPermission[]; |
| 102 | static const char kIdlePermission[]; |
| 103 | static const char kNotificationPermission[]; |
| 104 | static const char kProxyPermission[]; |
| 105 | static const char kTabPermission[]; |
| 106 | static const char kUnlimitedStoragePermission[]; |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 107 | static const char kWebstorePrivatePermission[]; |
[email protected] | aeb53b3 | 2009-10-29 07:34:45 | [diff] [blame] | 108 | |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 109 | static const char* const kPermissionNames[]; |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 110 | static const size_t kNumPermissions; |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 111 | static const char* const kHostedAppPermissionNames[]; |
[email protected] | b746f37 | 2010-08-29 21:39:32 | [diff] [blame] | 112 | static const size_t kNumHostedAppPermissions; |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 113 | |
[email protected] | 03b612f | 2010-08-13 21:09:21 | [diff] [blame] | 114 | // The old name for the unlimited storage permission, which is deprecated but |
| 115 | // still accepted as meaning the same thing as kUnlimitedStoragePermission. |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 116 | static const char kOldUnlimitedStoragePermission[]; |
[email protected] | 03b612f | 2010-08-13 21:09:21 | [diff] [blame] | 117 | |
[email protected] | 218990c | 2010-06-26 01:21:07 | [diff] [blame] | 118 | // A "simple permission" is one that has a one-to-one mapping with a message |
| 119 | // that is displayed in the install UI. This is in contrast to more complex |
| 120 | // permissions like http access, where the exact message displayed depends on |
| 121 | // several factors. |
| 122 | typedef std::map<std::string, string16> SimplePermissions; |
| 123 | static const SimplePermissions& GetSimplePermissions(); |
| 124 | |
[email protected] | b746f37 | 2010-08-29 21:39:32 | [diff] [blame] | 125 | // Returns true if the string is one of the known hosted app permissions (see |
| 126 | // kHostedAppPermissionNames). |
| 127 | static bool IsHostedAppPermission(const std::string& permission); |
| 128 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 129 | // An NPAPI plugin included in the extension. |
| 130 | struct PluginInfo { |
| 131 | FilePath path; // Path to the plugin. |
| 132 | bool is_public; // False if only this extension can load this plugin. |
| 133 | }; |
| 134 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 135 | // The name of the manifest inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 136 | static const FilePath::CharType kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 137 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 138 | // The name of locale folder inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 139 | static const FilePath::CharType kLocaleFolder[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 140 | |
| 141 | // The name of the messages file inside an extension. |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 142 | static const FilePath::CharType kMessagesFilename[]; |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 143 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 144 | #if defined(OS_WIN) |
[email protected] | 9dcf8f1 | 2010-09-02 20:39:19 | [diff] [blame] | 145 | static const char kExtensionRegistryPath[]; |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 146 | #endif |
| 147 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 148 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 149 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 150 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 151 | // The mimetype used for extensions. |
| 152 | static const char kMimeType[]; |
| 153 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 154 | explicit Extension(const FilePath& path); |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 155 | virtual ~Extension(); |
| 156 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 157 | // Checks to see if the extension has a valid ID. |
| 158 | static bool IdIsValid(const std::string& id); |
| 159 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 160 | // Returns true if the specified file is an extension. |
| 161 | static bool IsExtension(const FilePath& file_name); |
| 162 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 163 | // Whether the |location| is external or not. |
| 164 | static inline bool IsExternalLocation(Location location) { |
| 165 | return location == Extension::EXTERNAL_PREF || |
[email protected] | 8ef78fd | 2010-08-19 17:14:32 | [diff] [blame] | 166 | location == Extension::EXTERNAL_REGISTRY || |
| 167 | location == Extension::EXTERNAL_PREF_DOWNLOAD; |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 168 | } |
| 169 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 170 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 171 | // |extension_url| argument should be the url() from an Extension object. The |
| 172 | // |relative_path| can be untrusted user input. The returned URL will either |
| 173 | // be invalid() or a child of |extension_url|. |
| 174 | // NOTE: Static so that it can be used from multiple threads. |
| 175 | static GURL GetResourceURL(const GURL& extension_url, |
| 176 | const std::string& relative_path); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 177 | GURL GetResourceURL(const std::string& relative_path) const { |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 178 | return GetResourceURL(url(), relative_path); |
| 179 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 180 | |
[email protected] | 99efb7b1 | 2009-12-18 02:39:16 | [diff] [blame] | 181 | // Returns an extension resource object. |relative_path| should be UTF8 |
| 182 | // encoded. |
| 183 | ExtensionResource GetResource(const std::string& relative_path); |
| 184 | |
| 185 | // As above, but with |relative_path| following the file system's encoding. |
| 186 | ExtensionResource GetResource(const FilePath& relative_path); |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 187 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 188 | // |input| is expected to be the text of an rsa public or private key. It |
| 189 | // tolerates the presence or absence of bracking header/footer like this: |
| 190 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 191 | // and may contain newlines. |
| 192 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 193 | |
| 194 | // Does a simple base64 encoding of |input| into |output|. |
| 195 | static bool ProducePEM(const std::string& input, std::string* output); |
| 196 | |
[email protected] | 84ac7f3 | 2009-10-06 06:17:54 | [diff] [blame] | 197 | // Generates an extension ID from arbitrary input. The same input string will |
| 198 | // always generate the same output ID. |
| 199 | static bool GenerateId(const std::string& input, std::string* output); |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 200 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 201 | // Expects base64 encoded |input| and formats into |output| including |
| 202 | // the appropriate header & footer. |
| 203 | static bool FormatPEMForFileOutput(const std::string input, |
| 204 | std::string* output, bool is_public); |
| 205 | |
[email protected] | 2a40953 | 2009-08-28 19:39:44 | [diff] [blame] | 206 | // Determine whether |new_extension| has increased privileges compared to |
| 207 | // |old_extension|. |
| 208 | static bool IsPrivilegeIncrease(Extension* old_extension, |
| 209 | Extension* new_extension); |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 210 | |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 211 | // 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] | 212 | // result. In the browser process, this will DCHECK if not called on the |
| 213 | // file thread. To easily load extension images on the UI thread, see |
| 214 | // ImageLoadingTracker. |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 215 | static void DecodeIcon(Extension* extension, |
| 216 | Icons icon_size, |
| 217 | scoped_ptr<SkBitmap>* result); |
| 218 | |
| 219 | // 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] | 220 | // result. In the browser process, this will DCHECK if not called on the |
| 221 | // file thread. To easily load extension images on the UI thread, see |
| 222 | // ImageLoadingTracker. |
[email protected] | c690a981 | 2009-12-17 05:55:32 | [diff] [blame] | 223 | static void DecodeIconFromPath(const FilePath& icon_path, |
| 224 | Icons icon_size, |
| 225 | scoped_ptr<SkBitmap>* result); |
| 226 | |
[email protected] | a807bbe | 2010-04-14 10:51:19 | [diff] [blame] | 227 | // Returns the base extension url for a given |extension_id|. |
| 228 | static GURL GetBaseURLFromExtensionId(const std::string& extension_id); |
| 229 | |
[email protected] | 596c6aa | 2010-05-25 15:56:26 | [diff] [blame] | 230 | // Returns whether the browser has apps enabled (either as the default or if |
[email protected] | ce3eb7b6 | 2010-09-14 13:57:44 | [diff] [blame] | 231 | // it was explicitly turned on via a command line switch). |
[email protected] | 596c6aa | 2010-05-25 15:56:26 | [diff] [blame] | 232 | static bool AppsAreEnabled(); |
| 233 | |
[email protected] | a0cf04a | 2010-06-23 03:29:55 | [diff] [blame] | 234 | // Returns the url prefix for the extension/apps gallery. Can be set via the |
[email protected] | ce3eb7b6 | 2010-09-14 13:57:44 | [diff] [blame] | 235 | // --apps-gallery-url switch. The URL returned will not contain a trailing |
| 236 | // slash. |
[email protected] | a0cf04a | 2010-06-23 03:29:55 | [diff] [blame] | 237 | static std::string ChromeStoreURL(); |
| 238 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 239 | // Initialize the extension from a parsed manifest. |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 240 | // Usually, the id of an extension is generated by the "key" property of |
| 241 | // its manifest, but if |require_key| is |false|, a temporary ID will be |
| 242 | // generated based on the path. |
| 243 | bool InitFromValue(const DictionaryValue& value, bool require_key, |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 244 | std::string* error); |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 245 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 246 | const FilePath& path() const { return path_; } |
[email protected] | af1277b | 2009-07-28 00:47:53 | [diff] [blame] | 247 | void set_path(const FilePath& path) { path_ = path; } |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 248 | const GURL& url() const { return extension_url_; } |
[email protected] | 225c8f5 | 2010-02-05 22:23:20 | [diff] [blame] | 249 | Location location() const { return location_; } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 250 | void set_location(Location location) { location_ = location; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 251 | const std::string& id() const { return id_; } |
| 252 | const Version* version() const { return version_.get(); } |
| 253 | // String representation of the version number. |
| 254 | const std::string VersionString() const; |
| 255 | const std::string& name() const { return name_; } |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 256 | const std::string& public_key() const { return public_key_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 257 | const std::string& description() const { return description_; } |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 258 | bool converted_from_user_script() const { |
| 259 | return converted_from_user_script_; |
| 260 | } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 261 | const UserScriptList& content_scripts() const { return content_scripts_; } |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 262 | ExtensionAction* page_action() const { return page_action_.get(); } |
| 263 | ExtensionAction* browser_action() const { return browser_action_.get(); } |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 264 | const std::vector<PluginInfo>& plugins() const { return plugins_; } |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 265 | const GURL& background_url() const { return background_url_; } |
[email protected] | 43919ac9 | 2009-10-16 18:34:28 | [diff] [blame] | 266 | const GURL& options_url() const { return options_url_; } |
[email protected] | c082105 | 2010-08-06 11:44:57 | [diff] [blame] | 267 | const GURL& devtools_url() const { return devtools_url_; } |
[email protected] | 6d7a604 | 2010-08-12 20:12:42 | [diff] [blame] | 268 | const std::vector<GURL>& toolstrips() const { return toolstrips_; } |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 269 | const std::vector<std::string>& api_permissions() const { |
| 270 | return api_permissions_; |
| 271 | } |
[email protected] | b30e0dd | 2010-01-29 23:33:21 | [diff] [blame] | 272 | const URLPatternList& host_permissions() const { |
[email protected] | c7ad50f | 2009-09-11 06:28:15 | [diff] [blame] | 273 | return host_permissions_; |
| 274 | } |
| 275 | |
[email protected] | aeb53b3 | 2009-10-29 07:34:45 | [diff] [blame] | 276 | // Returns true if the extension has the specified API permission. |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 277 | static bool HasApiPermission(const std::vector<std::string>& api_permissions, |
[email protected] | 246c05f | 2010-09-10 09:12:11 | [diff] [blame] | 278 | const std::string& function_name); |
[email protected] | 583d45c1 | 2010-08-31 02:48:12 | [diff] [blame] | 279 | |
[email protected] | 246c05f | 2010-09-10 09:12:11 | [diff] [blame] | 280 | bool HasApiPermission(const std::string& function_name) const { |
| 281 | return HasApiPermission(this->api_permissions(), function_name); |
[email protected] | aeb53b3 | 2009-10-29 07:34:45 | [diff] [blame] | 282 | } |
| 283 | |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 284 | // Returns the set of hosts that the extension effectively has access to. This |
| 285 | // is used in the permissions UI and is a combination of the hosts accessible |
| 286 | // through content scripts and the hosts accessible through XHR. |
[email protected] | 8b3b54b | 2010-08-05 18:28:48 | [diff] [blame] | 287 | const ExtensionExtent GetEffectiveHostPermissions() const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 288 | |
[email protected] | fbd17cf | 2010-04-28 23:52:56 | [diff] [blame] | 289 | // Whether or not the extension is allowed permission for a URL pattern from |
| 290 | // the manifest. http, https, and chrome://favicon/ is allowed for all |
| 291 | // extensions, while component extensions are allowed access to |
| 292 | // chrome://resources. |
| 293 | bool CanAccessURL(const URLPattern pattern) const; |
| 294 | |
[email protected] | 584b8e3f | 2010-04-10 00:23:37 | [diff] [blame] | 295 | // Whether the extension has access to the given URL. |
| 296 | bool HasHostPermission(const GURL& url) const; |
| 297 | |
[email protected] | 215160af | 2010-04-03 06:02:34 | [diff] [blame] | 298 | // Returns true if the extension effectively has access to the user's browsing |
| 299 | // history. There are several permissions that we group together into this |
| 300 | // bucket. For example: tabs, bookmarks, and history. |
| 301 | bool HasEffectiveBrowsingHistoryPermission() const; |
| 302 | |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 303 | // Whether the extension has access to all hosts. This is true if there is |
| 304 | // a content script that matches all hosts, or if there is a host permission |
| 305 | // for all hosts. |
| 306 | bool HasAccessToAllHosts() const; |
| 307 | |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 308 | const GURL& update_url() const { return update_url_; } |
[email protected] | 0cb5f50 | 2009-10-21 21:35:47 | [diff] [blame] | 309 | const std::map<int, std::string>& icons() const { return icons_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 310 | |
[email protected] | bfa90a3a | 2010-04-28 15:43:23 | [diff] [blame] | 311 | // Returns the Google Gallery URL for this extension, if one exists. For |
| 312 | // third-party extensions, this returns a blank GURL. |
| 313 | GURL GalleryUrl() const; |
| 314 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 315 | // Theme-related. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 316 | DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 317 | DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } |
| 318 | DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 319 | DictionaryValue* GetThemeDisplayProperties() const { |
| 320 | return theme_display_properties_.get(); |
| 321 | } |
[email protected] | 3ba0fd3 | 2010-06-19 05:39:10 | [diff] [blame] | 322 | bool is_theme() const { return is_theme_; } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 323 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 324 | // Returns a list of paths (relative to the extension dir) for images that |
| 325 | // the browser might load (like themes and page action icons). |
| 326 | std::set<FilePath> GetBrowserImages(); |
| 327 | |
[email protected] | 86693068 | 2009-08-18 22:53:47 | [diff] [blame] | 328 | // Returns an absolute path to the given icon inside of the extension. Returns |
| 329 | // an empty FilePath if the extension does not have that icon. |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 330 | ExtensionResource GetIconResource(Icons icon); |
[email protected] | 86693068 | 2009-08-18 22:53:47 | [diff] [blame] | 331 | |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 332 | // Looks for an extension icon of dimension |icon|. If not found, checks if |
| 333 | // the next larger size exists (until one is found or the end is reached). If |
| 334 | // an icon is found, the path is returned in |resource| and the dimension |
| 335 | // found is returned to the caller (as function return value). |
| 336 | // NOTE: |resource| is not guaranteed to be non-empty. |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 337 | Icons GetIconResourceAllowLargerSize(ExtensionResource* resource, Icons icon); |
| 338 | |
[email protected] | 969894ab | 2010-08-29 00:35:01 | [diff] [blame] | 339 | GURL GetIconURL(Icons icon); |
| 340 | GURL GetIconURLAllowLargerSize(Icons icon); |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 341 | |
[email protected] | b6ab96d | 2009-08-20 18:58:19 | [diff] [blame] | 342 | const DictionaryValue* manifest_value() const { |
| 343 | return manifest_value_.get(); |
| 344 | } |
| 345 | |
[email protected] | 9428edc | 2009-11-18 18:02:47 | [diff] [blame] | 346 | const std::string default_locale() const { return default_locale_; } |
| 347 | |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 348 | // Chrome URL overrides (see ExtensionOverrideUI). |
[email protected] | d3cfa48 | 2009-10-17 13:54:57 | [diff] [blame] | 349 | const URLOverrideMap& GetChromeURLOverrides() const { |
| 350 | return chrome_url_overrides_; |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 351 | } |
| 352 | |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 353 | const std::string omnibox_keyword() const { return omnibox_keyword_; } |
| 354 | |
[email protected] | 3ba0fd3 | 2010-06-19 05:39:10 | [diff] [blame] | 355 | bool is_app() const { return is_app_; } |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 356 | ExtensionExtent& web_extent() { return web_extent_; } |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 357 | const std::string& launch_local_path() const { return launch_local_path_; } |
| 358 | const std::string& launch_web_url() const { return launch_web_url_; } |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 359 | void set_launch_web_url(const std::string& launch_web_url) { |
| 360 | launch_web_url_ = launch_web_url; |
| 361 | } |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame^] | 362 | extension_misc::LaunchContainer launch_container() const { |
| 363 | return launch_container_; |
| 364 | } |
[email protected] | 605cfad | 2010-06-22 20:49:35 | [diff] [blame] | 365 | int launch_width() const { return launch_width_; } |
| 366 | int launch_height() const { return launch_height_; } |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 367 | bool incognito_split_mode() const { return incognito_split_mode_; } |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 368 | |
| 369 | // Gets the fully resolved absolute launch URL. |
| 370 | GURL GetFullLaunchURL() const; |
[email protected] | ceefd3d | 2010-03-12 09:10:29 | [diff] [blame] | 371 | |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 372 | // Runtime data: |
| 373 | // Put dynamic data about the state of a running extension below. |
| 374 | |
| 375 | // Whether the background page, if any, is ready. We don't load other |
| 376 | // components until then. If there is no background page, we consider it to |
| 377 | // be ready. |
| 378 | bool GetBackgroundPageReady(); |
| 379 | void SetBackgroundPageReady(); |
| 380 | |
[email protected] | 1e8c93f | 2010-02-08 22:58:31 | [diff] [blame] | 381 | // Getter and setter for the flag that specifies whether the extension is |
| 382 | // being upgraded. |
| 383 | bool being_upgraded() const { return being_upgraded_; } |
| 384 | void set_being_upgraded(bool value) { being_upgraded_ = value; } |
| 385 | |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 386 | // Image cache related methods. These are only valid on the UI thread and |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 387 | // not maintained by this class. See ImageLoadingTracker for usage. The |
| 388 | // |original_size| parameter should be the size of the image at |source| |
| 389 | // before any scaling may have been done to produce the pixels in |image|. |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 390 | void SetCachedImage(const ExtensionResource& source, |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 391 | const SkBitmap& image, |
| 392 | const gfx::Size& original_size); |
| 393 | bool HasCachedImage(const ExtensionResource& source, |
| 394 | const gfx::Size& max_size); |
| 395 | SkBitmap GetCachedImage(const ExtensionResource& source, |
| 396 | const gfx::Size& max_size); |
[email protected] | 10256cf8 | 2010-09-14 23:50:45 | [diff] [blame] | 397 | bool is_hosted_app() const { return is_app() && !web_extent_.is_empty(); } |
| 398 | bool is_packaged_app() const { return is_app() && web_extent_.is_empty(); } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 399 | private: |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 400 | // We keep a cache of images loaded from extension resources based on their |
| 401 | // path and a string representation of a size that may have been used to |
| 402 | // scale it (or the empty string if the image is at its original size). |
| 403 | typedef std::pair<FilePath, std::string> ImageCacheKey; |
| 404 | typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
| 405 | |
| 406 | // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 407 | // value of NULL means there is no matching image cached (we allow caching an |
| 408 | // empty SkBitmap). |
| 409 | SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
| 410 | const gfx::Size& max_size); |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 411 | |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 412 | // Helper method that loads a UserScript object from a |
| 413 | // dictionary in the content_script list of the manifest. |
| 414 | bool LoadUserScriptHelper(const DictionaryValue* content_script, |
| 415 | int definition_index, |
| 416 | std::string* error, |
| 417 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 418 | |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 419 | // Helper method that loads either the include_globs or exclude_globs list |
| 420 | // from an entry in the content_script lists of the manifest. |
| 421 | bool LoadGlobsHelper(const DictionaryValue* content_script, |
| 422 | int content_script_index, |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 423 | const char* globs_property_name, |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 424 | std::string* error, |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 425 | void(UserScript::*add_method)(const std::string& glob), |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 426 | UserScript *instance); |
| 427 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 428 | // Helpers to load various chunks of the manifest. |
[email protected] | 3ba0fd3 | 2010-06-19 05:39:10 | [diff] [blame] | 429 | bool LoadIsApp(const DictionaryValue* manifest, std::string* error); |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 430 | bool LoadExtent(const DictionaryValue* manifest, const char* key, |
[email protected] | 4fdbc149 | 2010-07-01 01:20:59 | [diff] [blame] | 431 | ExtensionExtent* extent, const char* list_error, |
| 432 | const char* value_error, std::string* error); |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 433 | bool LoadLaunchContainer(const DictionaryValue* manifest, std::string* error); |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 434 | bool LoadLaunchURL(const DictionaryValue* manifest, std::string* error); |
[email protected] | cbf4d191 | 2010-08-12 18:24:57 | [diff] [blame] | 435 | bool EnsureNotHybridApp(const DictionaryValue* manifest, std::string* error); |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 436 | |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 437 | // Helper method to load an ExtensionAction from the page_action or |
[email protected] | 92c6f9b9 | 2009-10-24 04:35:08 | [diff] [blame] | 438 | // browser_action entries in the manifest. |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 439 | ExtensionAction* LoadExtensionActionHelper( |
[email protected] | 92c6f9b9 | 2009-10-24 04:35:08 | [diff] [blame] | 440 | const DictionaryValue* extension_action, std::string* error); |
| 441 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 442 | // Figures out if a source contains keys not associated with themes - we |
| 443 | // don't want to allow scripts and such to be bundled with themes. |
| 444 | bool ContainsNonThemeKeys(const DictionaryValue& source); |
| 445 | |
[email protected] | 1952c7d | 2010-03-04 23:48:34 | [diff] [blame] | 446 | // Returns true if the string is one of the known api permissions (see |
| 447 | // kPermissionNames). |
| 448 | bool IsAPIPermission(const std::string& permission); |
| 449 | |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 450 | // Utility functions to get the icon relative path used to create an |
| 451 | // ExtensionResource or URL. |
| 452 | std::string GetIconPath(Icons icon); |
| 453 | Icons GetIconPathAllowLargerSize(std::string* path, Icons icon); |
| 454 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 455 | // The absolute path to the directory the extension is stored in. |
| 456 | FilePath path_; |
| 457 | |
| 458 | // The base extension url for the extension. |
| 459 | GURL extension_url_; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 460 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 461 | // The location the extension was loaded from. |
| 462 | Location location_; |
| 463 | |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 464 | // A human-readable ID for the extension. The convention is to use something |
| 465 | // like 'com.example.myextension', but this is not currently enforced. An |
| 466 | // extension's ID is used in things like directory structures and URLs, and |
| 467 | // is expected to not change across versions. In the case of conflicts, |
| 468 | // updates will only be allowed if the extension can be validated using the |
| 469 | // previous version's update key. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 470 | std::string id_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 471 | |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 472 | // The extension's version. |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 473 | scoped_ptr<Version> version_; |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 474 | |
[email protected] | 49a7c77 | 2010-05-21 18:32:35 | [diff] [blame] | 475 | // The extension's human-readable name. Name is used for display purpose. It |
| 476 | // might be wrapped with unicode bidi control characters so that it is |
| 477 | // displayed correctly in RTL context. |
| 478 | // NOTE: Name is UTF-8 and may contain non-ascii characters. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 479 | std::string name_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 480 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 481 | // An optional longer description of the extension. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 482 | std::string description_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 483 | |
[email protected] | 6657afa6 | 2009-11-04 02:15:20 | [diff] [blame] | 484 | // True if the extension was generated from a user script. (We show slightly |
| 485 | // different UI if so). |
| 486 | bool converted_from_user_script_; |
| 487 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 488 | // Paths to the content scripts the extension contains. |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 489 | UserScriptList content_scripts_; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 490 | |
[email protected] | 37e960e | 2009-10-13 23:17:50 | [diff] [blame] | 491 | // The extension's page action, if any. |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 492 | scoped_ptr<ExtensionAction> page_action_; |
[email protected] | 671e6c1ce | 2009-09-26 03:18:46 | [diff] [blame] | 493 | |
| 494 | // The extension's browser action, if any. |
[email protected] | 5d246db2 | 2009-10-27 06:17:57 | [diff] [blame] | 495 | scoped_ptr<ExtensionAction> browser_action_; |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 496 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 497 | // Optional list of NPAPI plugins and associated properties. |
| 498 | std::vector<PluginInfo> plugins_; |
[email protected] | 367230c5 | 2009-02-21 01:44:30 | [diff] [blame] | 499 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 500 | // Optional URL to a master page of which a single instance should be always |
| 501 | // loaded in the background. |
| 502 | GURL background_url_; |
| 503 | |
[email protected] | 43919ac9 | 2009-10-16 18:34:28 | [diff] [blame] | 504 | // Optional URL to a page for setting options/preferences. |
| 505 | GURL options_url_; |
| 506 | |
[email protected] | c082105 | 2010-08-06 11:44:57 | [diff] [blame] | 507 | // Optional URL to a devtools extension page. |
| 508 | GURL devtools_url_; |
| 509 | |
[email protected] | bbc94554 | 2009-07-26 00:11:42 | [diff] [blame] | 510 | // Optional list of toolstrips_ and associated properties. |
[email protected] | 6d7a604 | 2010-08-12 20:12:42 | [diff] [blame] | 511 | std::vector<GURL> toolstrips_; |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 512 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 513 | // The public key ('key' in the manifest) used to sign the contents of the |
| 514 | // crx package ('signature' in the manifest) |
| 515 | std::string public_key_; |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 516 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 517 | // A map of resource id's to relative file paths. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 518 | scoped_ptr<DictionaryValue> theme_images_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 519 | |
| 520 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 521 | scoped_ptr<DictionaryValue> theme_colors_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 522 | |
| 523 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 524 | scoped_ptr<DictionaryValue> theme_tints_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 525 | |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 526 | // A map of display properties. |
| 527 | scoped_ptr<DictionaryValue> theme_display_properties_; |
| 528 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 529 | // Whether the extension is a theme - if it is, certain things are disabled. |
| 530 | bool is_theme_; |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 531 | |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 532 | // The set of module-level APIs this extension can use. |
| 533 | std::vector<std::string> api_permissions_; |
| 534 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 535 | // The sites this extension has permission to talk to (using XHR, etc). |
[email protected] | b30e0dd | 2010-01-29 23:33:21 | [diff] [blame] | 536 | URLPatternList host_permissions_; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 537 | |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 538 | // The paths to the icons the extension contains mapped by their width. |
| 539 | std::map<int, std::string> icons_; |
| 540 | |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 541 | // URL for fetching an update manifest |
| 542 | GURL update_url_; |
[email protected] | d6336a9 | 2009-08-13 17:25:12 | [diff] [blame] | 543 | |
[email protected] | b6ab96d | 2009-08-20 18:58:19 | [diff] [blame] | 544 | // A copy of the manifest that this extension was created from. |
| 545 | scoped_ptr<DictionaryValue> manifest_value_; |
| 546 | |
[email protected] | 9428edc | 2009-11-18 18:02:47 | [diff] [blame] | 547 | // Default locale for fall back. Can be empty if extension is not localized. |
| 548 | std::string default_locale_; |
| 549 | |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 550 | // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 551 | // which override the handling of those URLs. |
[email protected] | d3cfa48 | 2009-10-17 13:54:57 | [diff] [blame] | 552 | URLOverrideMap chrome_url_overrides_; |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 553 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 554 | // Whether apps-related features can be parsed during InitFromValue(). |
| 555 | // Defaults to the value from --enable-extension-apps. |
| 556 | bool apps_enabled_; |
[email protected] | 581b0ad | 2010-01-12 21:54:38 | [diff] [blame] | 557 | |
[email protected] | 3ba0fd3 | 2010-06-19 05:39:10 | [diff] [blame] | 558 | // Whether this extension uses app features. |
| 559 | bool is_app_; |
[email protected] | 3b35564 | 2010-02-05 16:01:49 | [diff] [blame] | 560 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 561 | // Defines the set of URLs in the extension's web content. |
| 562 | ExtensionExtent web_extent_; |
[email protected] | 3b35564 | 2010-02-05 16:01:49 | [diff] [blame] | 563 | |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 564 | // The local path inside the extension to use with the launcher. |
| 565 | std::string launch_local_path_; |
| 566 | |
| 567 | // A web url to use with the launcher. Note that this might be relative or |
| 568 | // absolute. If relative, it is relative to web_origin_. |
| 569 | std::string launch_web_url_; |
| 570 | |
| 571 | // The type of container to launch into. |
[email protected] | d83a560 | 2010-09-16 00:22:48 | [diff] [blame^] | 572 | extension_misc::LaunchContainer launch_container_; |
[email protected] | 867a73e1 | 2010-03-19 20:45:46 | [diff] [blame] | 573 | |
[email protected] | 605cfad | 2010-06-22 20:49:35 | [diff] [blame] | 574 | // The default size of the container when launching. Only respected for |
| 575 | // containers like panels and windows. |
| 576 | int launch_width_; |
| 577 | int launch_height_; |
| 578 | |
[email protected] | 052c9270 | 2010-06-25 07:25:52 | [diff] [blame] | 579 | // Cached images for this extension. |
[email protected] | d9ad80f | 2010-03-30 20:40:18 | [diff] [blame] | 580 | ImageCache image_cache_; |
[email protected] | ceefd3d | 2010-03-12 09:10:29 | [diff] [blame] | 581 | |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 582 | // The omnibox keyword for this extension, or empty if there is none. |
| 583 | std::string omnibox_keyword_; |
| 584 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 585 | // If true, a separate process will be used for the extension in incognito |
| 586 | // mode. |
| 587 | bool incognito_split_mode_; |
| 588 | |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 589 | // Runtime data: |
| 590 | |
| 591 | // True if the background page is ready. |
| 592 | bool background_page_ready_; |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 593 | |
[email protected] | 1e8c93f | 2010-02-08 22:58:31 | [diff] [blame] | 594 | // True while the extension is being upgraded. |
| 595 | bool being_upgraded_; |
| 596 | |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 597 | FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); |
| 598 | FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps); |
[email protected] | ae7fe71 | 2009-07-02 20:33:58 | [diff] [blame] | 599 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 600 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 601 | }; |
| 602 | |
[email protected] | b1748b1d8 | 2009-11-30 20:32:56 | [diff] [blame] | 603 | typedef std::vector<Extension*> ExtensionList; |
| 604 | |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 605 | // Handy struct to pass core extension info around. |
| 606 | struct ExtensionInfo { |
| 607 | ExtensionInfo(const DictionaryValue* manifest, |
| 608 | const std::string& id, |
| 609 | const FilePath& path, |
[email protected] | 3bb8499 | 2010-08-26 17:23:46 | [diff] [blame] | 610 | Extension::Location location); |
| 611 | ~ExtensionInfo(); |
[email protected] | c6d474f8 | 2009-12-16 21:11:06 | [diff] [blame] | 612 | |
| 613 | scoped_ptr<DictionaryValue> extension_manifest; |
| 614 | std::string extension_id; |
| 615 | FilePath extension_path; |
| 616 | Extension::Location extension_location; |
| 617 | |
| 618 | private: |
| 619 | DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
| 620 | }; |
| 621 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 622 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |