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