[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 5 | #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 6 | #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 7 | |
[email protected] | 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> |
| 11 | #include <vector> |
| 12 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 13 | #include "base/file_path.h" |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 14 | #include "base/scoped_ptr.h" |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 15 | #include "base/values.h" |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 16 | #include "base/version.h" |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 17 | #include "chrome/browser/extensions/user_script_master.h" |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 18 | #include "chrome/common/extensions/extension_action.h" |
[email protected] | 75e126b93 | 2009-09-28 19:38:49 | [diff] [blame] | 19 | #include "chrome/common/extensions/extension_message_bundle.h" |
[email protected] | ecabe6ee | 2009-10-07 22:49:10 | [diff] [blame] | 20 | #include "chrome/common/extensions/extension_resource.h" |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 21 | #include "chrome/common/extensions/user_script.h" |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 22 | #include "chrome/common/extensions/url_pattern.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 23 | #include "googleurl/src/gurl.h" |
| 24 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 25 | // Represents a Chrome extension. |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 26 | class Extension { |
| 27 | public: |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 28 | typedef std::vector<URLPattern> HostPermissions; |
| 29 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 30 | // What an extension was loaded from. |
| 31 | enum Location { |
| 32 | INVALID, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 33 | INTERNAL, // A crx file from the internal Extensions directory. |
| 34 | EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 35 | EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 36 | // registry on Windows). |
| 37 | LOAD // --load-extension. |
| 38 | }; |
| 39 | |
| 40 | enum State { |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 41 | DISABLED = 0, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 42 | ENABLED, |
| 43 | KILLBIT, // Don't install/upgrade (applies to external extensions only). |
[email protected] | 0c6da50 | 2009-08-14 22:32:39 | [diff] [blame] | 44 | |
| 45 | NUM_STATES |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 46 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 47 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 48 | enum InstallType { |
[email protected] | ab6f2b2 | 2009-07-28 23:28:37 | [diff] [blame] | 49 | INSTALL_ERROR, |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 50 | DOWNGRADE, |
| 51 | REINSTALL, |
| 52 | UPGRADE, |
| 53 | NEW_INSTALL |
| 54 | }; |
| 55 | |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 56 | // NOTE: If you change this list, you should also change kIconSizes in the cc |
| 57 | // file. |
| 58 | enum Icons { |
| 59 | EXTENSION_ICON_LARGE = 128, |
| 60 | EXTENSION_ICON_MEDIUM = 48, |
| 61 | EXTENSION_ICON_SMALL = 32, |
| 62 | EXTENSION_ICON_BITTY = 16, |
| 63 | }; |
| 64 | |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 65 | // Icon sizes used by the extension system. |
[email protected] | d281701 | 2009-08-04 06:46:21 | [diff] [blame] | 66 | static const int kIconSizes[]; |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 67 | |
[email protected] | 4c4f819 | 2009-10-17 01:03:26 | [diff] [blame^] | 68 | // Max size (both dimensions) for browser and page actions. |
| 69 | static const int kPageActionIconMaxSize; |
| 70 | static const int kBrowserActionIconMaxSize; |
| 71 | |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 72 | // Each permission is a module that the extension is permitted to use. |
| 73 | static const char* kPermissionNames[]; |
| 74 | static const size_t kNumPermissions; |
| 75 | |
[email protected] | d6336a9 | 2009-08-13 17:25:12 | [diff] [blame] | 76 | struct PrivacyBlacklistInfo { |
| 77 | FilePath path; // Path to the plain-text blacklist. |
| 78 | }; |
| 79 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 80 | // An NPAPI plugin included in the extension. |
| 81 | struct PluginInfo { |
| 82 | FilePath path; // Path to the plugin. |
| 83 | bool is_public; // False if only this extension can load this plugin. |
| 84 | }; |
| 85 | |
[email protected] | bbc94554 | 2009-07-26 00:11:42 | [diff] [blame] | 86 | // A toolstrip and its associated mole. |
| 87 | struct ToolstripInfo { |
| 88 | ToolstripInfo() : mole_height(0) {} |
| 89 | |
| 90 | GURL toolstrip; |
| 91 | GURL mole; |
| 92 | int mole_height; |
| 93 | }; |
| 94 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 95 | // The name of the manifest inside an extension. |
[email protected] | 0e29223 | 2009-01-22 15:23:34 | [diff] [blame] | 96 | static const char kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 97 | |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 98 | // The name of locale folder inside an extension. |
| 99 | static const char kLocaleFolder[]; |
| 100 | |
| 101 | // The name of the messages file inside an extension. |
| 102 | static const char kMessagesFilename[]; |
| 103 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 104 | #if defined(OS_WIN) |
| 105 | static const char* kExtensionRegistryPath; |
| 106 | #endif |
| 107 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 108 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 109 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 110 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 111 | // The mimetype used for extensions. |
| 112 | static const char kMimeType[]; |
| 113 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 114 | explicit Extension(const FilePath& path); |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 115 | virtual ~Extension(); |
| 116 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 117 | // Checks to see if the extension has a valid ID. |
| 118 | static bool IdIsValid(const std::string& id); |
| 119 | |
[email protected] | e435d6b7 | 2009-07-25 03:15:58 | [diff] [blame] | 120 | // Returns true if the specified file is an extension. |
| 121 | static bool IsExtension(const FilePath& file_name); |
| 122 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 123 | // Whether the |location| is external or not. |
| 124 | static inline bool IsExternalLocation(Location location) { |
| 125 | return location == Extension::EXTERNAL_PREF || |
| 126 | location == Extension::EXTERNAL_REGISTRY; |
| 127 | } |
| 128 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 129 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 130 | // |extension_url| argument should be the url() from an Extension object. The |
| 131 | // |relative_path| can be untrusted user input. The returned URL will either |
| 132 | // be invalid() or a child of |extension_url|. |
| 133 | // NOTE: Static so that it can be used from multiple threads. |
| 134 | static GURL GetResourceURL(const GURL& extension_url, |
| 135 | const std::string& relative_path); |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 136 | GURL GetResourceURL(const std::string& relative_path) { |
| 137 | return GetResourceURL(url(), relative_path); |
| 138 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 139 | |
[email protected] | ecabe6ee | 2009-10-07 22:49:10 | [diff] [blame] | 140 | // Returns an extension resource object. The |extension_path| argument should |
| 141 | // be the path() from an Extension object. |
| 142 | // The |relative_path| can be untrusted user input. |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 143 | // NOTE: Static so that it can be used from multiple threads. |
[email protected] | ecabe6ee | 2009-10-07 22:49:10 | [diff] [blame] | 144 | static ExtensionResource GetResource(const FilePath& extension_path, |
| 145 | const std::string& relative_path); |
| 146 | ExtensionResource GetResource(const std::string& relative_path) { |
| 147 | return GetResource(path(), relative_path); |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 148 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 149 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 150 | // |input| is expected to be the text of an rsa public or private key. It |
| 151 | // tolerates the presence or absence of bracking header/footer like this: |
| 152 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 153 | // and may contain newlines. |
| 154 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 155 | |
| 156 | // Does a simple base64 encoding of |input| into |output|. |
| 157 | static bool ProducePEM(const std::string& input, std::string* output); |
| 158 | |
[email protected] | 84ac7f3 | 2009-10-06 06:17:54 | [diff] [blame] | 159 | // Generates an extension ID from arbitrary input. The same input string will |
| 160 | // always generate the same output ID. |
| 161 | static bool GenerateId(const std::string& input, std::string* output); |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 162 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 163 | // Expects base64 encoded |input| and formats into |output| including |
| 164 | // the appropriate header & footer. |
| 165 | static bool FormatPEMForFileOutput(const std::string input, |
| 166 | std::string* output, bool is_public); |
| 167 | |
[email protected] | 2a40953 | 2009-08-28 19:39:44 | [diff] [blame] | 168 | // Determine whether |new_extension| has increased privileges compared to |
| 169 | // |old_extension|. |
| 170 | static bool IsPrivilegeIncrease(Extension* old_extension, |
| 171 | Extension* new_extension); |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 172 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 173 | // Initialize the extension from a parsed manifest. |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 174 | // If |require_id| is true, will return an error if the "id" key is missing |
| 175 | // from the value. |
| 176 | bool InitFromValue(const DictionaryValue& value, bool require_id, |
| 177 | std::string* error); |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 178 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 179 | const FilePath& path() const { return path_; } |
[email protected] | af1277b | 2009-07-28 00:47:53 | [diff] [blame] | 180 | void set_path(const FilePath& path) { path_ = path; } |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 181 | const GURL& url() const { return extension_url_; } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 182 | const Location location() const { return location_; } |
| 183 | void set_location(Location location) { location_ = location; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 184 | const std::string& id() const { return id_; } |
| 185 | const Version* version() const { return version_.get(); } |
| 186 | // String representation of the version number. |
| 187 | const std::string VersionString() const; |
| 188 | const std::string& name() const { return name_; } |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 189 | const std::string& public_key() const { return public_key_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 190 | const std::string& description() const { return description_; } |
| 191 | const UserScriptList& content_scripts() const { return content_scripts_; } |
[email protected] | 37e960e | 2009-10-13 23:17:50 | [diff] [blame] | 192 | ExtensionAction* page_action() const { return page_action_.get(); } |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 193 | ExtensionAction* browser_action() const { return browser_action_.get(); } |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 194 | ExtensionActionState* browser_action_state() { |
| 195 | return browser_action_state_.get(); |
| 196 | } |
[email protected] | d6336a9 | 2009-08-13 17:25:12 | [diff] [blame] | 197 | const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { |
| 198 | return privacy_blacklists_; |
| 199 | } |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 200 | const std::vector<PluginInfo>& plugins() const { return plugins_; } |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 201 | const GURL& background_url() const { return background_url_; } |
[email protected] | 43919ac9 | 2009-10-16 18:34:28 | [diff] [blame] | 202 | const GURL& options_url() const { return options_url_; } |
[email protected] | bbc94554 | 2009-07-26 00:11:42 | [diff] [blame] | 203 | const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 204 | const std::vector<std::string>& api_permissions() const { |
| 205 | return api_permissions_; |
| 206 | } |
[email protected] | c7ad50f | 2009-09-11 06:28:15 | [diff] [blame] | 207 | const HostPermissions& host_permissions() const { |
| 208 | return host_permissions_; |
| 209 | } |
| 210 | |
| 211 | // Returns true if the extension has permission to access the host for the |
| 212 | // specified URL. |
| 213 | bool CanAccessHost(const GURL& url) const; |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 214 | |
| 215 | // Returns the set of hosts that the extension effectively has access to. This |
| 216 | // is used in the permissions UI and is a combination of the hosts accessible |
| 217 | // through content scripts and the hosts accessible through XHR. |
| 218 | const std::set<std::string> GetEffectiveHostPermissions() const; |
| 219 | |
| 220 | // Whether the extension has access to all hosts. This is true if there is |
| 221 | // a content script that matches all hosts, or if there is a host permission |
| 222 | // for all hosts. |
| 223 | bool HasAccessToAllHosts() const; |
| 224 | |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 225 | const GURL& update_url() const { return update_url_; } |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 226 | const std::map<int, std::string>& icons() { return icons_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 227 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 228 | // Returns the origin of this extension. This function takes a |registry_path| |
| 229 | // so that the registry location can be overwritten during testing. |
| 230 | Location ExternalExtensionInstallType(std::string registry_path); |
| 231 | |
| 232 | // Theme-related. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 233 | DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 234 | DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } |
| 235 | DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 236 | DictionaryValue* GetThemeDisplayProperties() const { |
| 237 | return theme_display_properties_.get(); |
| 238 | } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 239 | bool IsTheme() { return is_theme_; } |
| 240 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 241 | // Returns a list of paths (relative to the extension dir) for images that |
| 242 | // the browser might load (like themes and page action icons). |
| 243 | std::set<FilePath> GetBrowserImages(); |
| 244 | |
[email protected] | 86693068 | 2009-08-18 22:53:47 | [diff] [blame] | 245 | // Returns an absolute path to the given icon inside of the extension. Returns |
| 246 | // an empty FilePath if the extension does not have that icon. |
[email protected] | ecabe6ee | 2009-10-07 22:49:10 | [diff] [blame] | 247 | ExtensionResource GetIconPath(Icons icon); |
[email protected] | 86693068 | 2009-08-18 22:53:47 | [diff] [blame] | 248 | |
[email protected] | b6ab96d | 2009-08-20 18:58:19 | [diff] [blame] | 249 | const DictionaryValue* manifest_value() const { |
| 250 | return manifest_value_.get(); |
| 251 | } |
| 252 | |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 253 | // Getter/setter for l10n message bundle. |
| 254 | const ExtensionMessageBundle* message_bundle() const { |
| 255 | return message_bundle_.get(); |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 256 | } |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 257 | void set_message_bundle(ExtensionMessageBundle* message_bundle) { |
| 258 | message_bundle_.reset(message_bundle); |
[email protected] | 300cc58db | 2009-08-19 20:45:14 | [diff] [blame] | 259 | } |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 260 | |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 261 | // Chrome URL overrides (see ExtensionOverrideUI). |
| 262 | DictionaryValue* GetChromeURLOverrides() const { |
| 263 | return chrome_url_overrides_.get(); |
| 264 | } |
| 265 | |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 266 | // Runtime data: |
| 267 | // Put dynamic data about the state of a running extension below. |
| 268 | |
| 269 | // Whether the background page, if any, is ready. We don't load other |
| 270 | // components until then. If there is no background page, we consider it to |
| 271 | // be ready. |
| 272 | bool GetBackgroundPageReady(); |
| 273 | void SetBackgroundPageReady(); |
| 274 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 275 | private: |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 276 | // Helper method that loads a UserScript object from a |
| 277 | // dictionary in the content_script list of the manifest. |
| 278 | bool LoadUserScriptHelper(const DictionaryValue* content_script, |
| 279 | int definition_index, |
| 280 | std::string* error, |
| 281 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 282 | |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 283 | // Helper method that loads a ExtensionAction object from a |
[email protected] | 671e6c1ce | 2009-09-26 03:18:46 | [diff] [blame] | 284 | // dictionary in the page_action or browser_action section of the manifest. |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 285 | ExtensionAction* LoadExtensionActionHelper( |
[email protected] | 671e6c1ce | 2009-09-26 03:18:46 | [diff] [blame] | 286 | const DictionaryValue* contextual_action, |
[email protected] | 671e6c1ce | 2009-09-26 03:18:46 | [diff] [blame] | 287 | std::string* error, |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 288 | ExtensionAction::ExtensionActionType action_type); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 289 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 290 | // Figures out if a source contains keys not associated with themes - we |
| 291 | // don't want to allow scripts and such to be bundled with themes. |
| 292 | bool ContainsNonThemeKeys(const DictionaryValue& source); |
| 293 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 294 | // The absolute path to the directory the extension is stored in. |
| 295 | FilePath path_; |
| 296 | |
| 297 | // The base extension url for the extension. |
| 298 | GURL extension_url_; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 299 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 300 | // The location the extension was loaded from. |
| 301 | Location location_; |
| 302 | |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 303 | // A human-readable ID for the extension. The convention is to use something |
| 304 | // like 'com.example.myextension', but this is not currently enforced. An |
| 305 | // extension's ID is used in things like directory structures and URLs, and |
| 306 | // is expected to not change across versions. In the case of conflicts, |
| 307 | // updates will only be allowed if the extension can be validated using the |
| 308 | // previous version's update key. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 309 | std::string id_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 310 | |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 311 | // The extension's version. |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 312 | scoped_ptr<Version> version_; |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 313 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 314 | // The extension's human-readable name. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 315 | std::string name_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 316 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 317 | // An optional longer description of the extension. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 318 | std::string description_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 319 | |
| 320 | // Paths to the content scripts the extension contains. |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 321 | UserScriptList content_scripts_; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 322 | |
[email protected] | 37e960e | 2009-10-13 23:17:50 | [diff] [blame] | 323 | // The extension's page action, if any. |
| 324 | scoped_ptr<ExtensionAction> page_action_; |
[email protected] | 671e6c1ce | 2009-09-26 03:18:46 | [diff] [blame] | 325 | |
| 326 | // The extension's browser action, if any. |
[email protected] | ba69a7d | 2009-09-28 21:09:56 | [diff] [blame] | 327 | scoped_ptr<ExtensionAction> browser_action_; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 328 | |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 329 | // The state of the browser action. Valid iff browser_action_ is non-NULL. |
| 330 | scoped_ptr<ExtensionActionState> browser_action_state_; |
| 331 | |
[email protected] | d6336a9 | 2009-08-13 17:25:12 | [diff] [blame] | 332 | // Optional list of privacy blacklistrom. |
| 333 | std::vector<PrivacyBlacklistInfo> privacy_blacklists_; |
| 334 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 335 | // Optional list of NPAPI plugins and associated properties. |
| 336 | std::vector<PluginInfo> plugins_; |
[email protected] | 367230c5 | 2009-02-21 01:44:30 | [diff] [blame] | 337 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 338 | // Optional URL to a master page of which a single instance should be always |
| 339 | // loaded in the background. |
| 340 | GURL background_url_; |
| 341 | |
[email protected] | 43919ac9 | 2009-10-16 18:34:28 | [diff] [blame] | 342 | // Optional URL to a page for setting options/preferences. |
| 343 | GURL options_url_; |
| 344 | |
[email protected] | bbc94554 | 2009-07-26 00:11:42 | [diff] [blame] | 345 | // Optional list of toolstrips_ and associated properties. |
| 346 | std::vector<ToolstripInfo> toolstrips_; |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 347 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 348 | // The public key ('key' in the manifest) used to sign the contents of the |
| 349 | // crx package ('signature' in the manifest) |
| 350 | std::string public_key_; |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 351 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 352 | // A map of resource id's to relative file paths. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 353 | scoped_ptr<DictionaryValue> theme_images_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 354 | |
| 355 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 356 | scoped_ptr<DictionaryValue> theme_colors_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 357 | |
| 358 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 359 | scoped_ptr<DictionaryValue> theme_tints_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 360 | |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 361 | // A map of display properties. |
| 362 | scoped_ptr<DictionaryValue> theme_display_properties_; |
| 363 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 364 | // Whether the extension is a theme - if it is, certain things are disabled. |
| 365 | bool is_theme_; |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 366 | |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 367 | // The set of module-level APIs this extension can use. |
| 368 | std::vector<std::string> api_permissions_; |
| 369 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 370 | // The sites this extension has permission to talk to (using XHR, etc). |
[email protected] | b24d831 | 2009-08-27 06:47:46 | [diff] [blame] | 371 | HostPermissions host_permissions_; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 372 | |
[email protected] | c3e3def74 | 2009-07-17 07:51:06 | [diff] [blame] | 373 | // The paths to the icons the extension contains mapped by their width. |
| 374 | std::map<int, std::string> icons_; |
| 375 | |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 376 | // URL for fetching an update manifest |
| 377 | GURL update_url_; |
[email protected] | d6336a9 | 2009-08-13 17:25:12 | [diff] [blame] | 378 | |
[email protected] | b6ab96d | 2009-08-20 18:58:19 | [diff] [blame] | 379 | // A copy of the manifest that this extension was created from. |
| 380 | scoped_ptr<DictionaryValue> manifest_value_; |
| 381 | |
[email protected] | 42b6f0f8 | 2009-09-18 21:07:39 | [diff] [blame] | 382 | // Handles the l10n messages replacement and parsing. |
| 383 | scoped_ptr<ExtensionMessageBundle> message_bundle_; |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 384 | |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 385 | // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 386 | // which override the handling of those URLs. |
| 387 | scoped_ptr<DictionaryValue> chrome_url_overrides_; |
| 388 | |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 389 | // Runtime data: |
| 390 | |
| 391 | // True if the background page is ready. |
| 392 | bool background_page_ready_; |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 393 | |
[email protected] | ae7fe71 | 2009-07-02 20:33:58 | [diff] [blame] | 394 | FRIEND_TEST(ExtensionTest, LoadPageActionHelper); |
| 395 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 396 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 397 | }; |
| 398 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 399 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |