[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] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 8 | #include <set> |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 12 | #include "base/file_path.h" |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 13 | #include "base/scoped_ptr.h" |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 14 | #include "base/values.h" |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 15 | #include "base/version.h" |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 16 | #include "chrome/common/extensions/user_script.h" |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 17 | #include "chrome/browser/extensions/user_script_master.h" |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 18 | #include "chrome/common/extensions/url_pattern.h" |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 19 | #include "chrome/common/page_action.h" |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 20 | #include "googleurl/src/gurl.h" |
| 21 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 22 | // Represents a Chrome extension. |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 23 | class Extension { |
| 24 | public: |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 25 | // What an extension was loaded from. |
| 26 | enum Location { |
| 27 | INVALID, |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 28 | INTERNAL, // A crx file from the internal Extensions directory. |
| 29 | EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 30 | EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 31 | // registry on Windows). |
| 32 | LOAD // --load-extension. |
| 33 | }; |
| 34 | |
| 35 | enum State { |
| 36 | DISABLED, |
| 37 | ENABLED, |
| 38 | KILLBIT, // Don't install/upgrade (applies to external extensions only). |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 39 | }; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 40 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 41 | enum InstallType { |
| 42 | DOWNGRADE, |
| 43 | REINSTALL, |
| 44 | UPGRADE, |
| 45 | NEW_INSTALL |
| 46 | }; |
| 47 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 48 | // An NPAPI plugin included in the extension. |
| 49 | struct PluginInfo { |
| 50 | FilePath path; // Path to the plugin. |
| 51 | bool is_public; // False if only this extension can load this plugin. |
| 52 | }; |
| 53 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 54 | // The name of the manifest inside an extension. |
[email protected] | 0e29223 | 2009-01-22 15:23:34 | [diff] [blame] | 55 | static const char kManifestFilename[]; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 56 | |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 57 | // Keys used in JSON representation of extensions. |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 58 | static const wchar_t* kBackgroundKey; |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 59 | static const wchar_t* kContentScriptsKey; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 60 | static const wchar_t* kCssKey; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 61 | static const wchar_t* kDescriptionKey; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 62 | static const wchar_t* kIconPathKey; |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 63 | static const wchar_t* kJsKey; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 64 | static const wchar_t* kMatchesKey; |
[email protected] | 1712232 | 2009-01-22 20:03:30 | [diff] [blame] | 65 | static const wchar_t* kNameKey; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 66 | static const wchar_t* kPageActionIdKey; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 67 | static const wchar_t* kPageActionsKey; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 68 | static const wchar_t* kPermissionsKey; |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 69 | static const wchar_t* kPluginsKey; |
| 70 | static const wchar_t* kPluginsPathKey; |
| 71 | static const wchar_t* kPluginsPublicKey; |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 72 | static const wchar_t* kPublicKeyKey; |
| 73 | static const wchar_t* kSignatureKey; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 74 | static const wchar_t* kRunAtKey; |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 75 | static const wchar_t* kThemeKey; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 76 | static const wchar_t* kThemeImagesKey; |
| 77 | static const wchar_t* kThemeColorsKey; |
| 78 | static const wchar_t* kThemeTintsKey; |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 79 | static const wchar_t* kThemeDisplayPropertiesKey; |
[email protected] | d5cef1b | 2009-03-21 05:36:49 | [diff] [blame] | 80 | static const wchar_t* kToolstripsKey; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 81 | static const wchar_t* kTypeKey; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 82 | static const wchar_t* kVersionKey; |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 83 | static const wchar_t* kUpdateURLKey; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 84 | |
[email protected] | 0afe827 | 2009-02-14 04:15:16 | [diff] [blame] | 85 | // Some values expected in manifests. |
| 86 | static const char* kRunAtDocumentStartValue; |
| 87 | static const char* kRunAtDocumentEndValue; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 88 | static const char* kPageActionTypeTab; |
| 89 | static const char* kPageActionTypePermanent; |
[email protected] | 0afe827 | 2009-02-14 04:15:16 | [diff] [blame] | 90 | |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 91 | // Error messages returned from InitFromValue(). |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 92 | static const char* kInvalidContentScriptError; |
| 93 | static const char* kInvalidContentScriptsListError; |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 94 | static const char* kInvalidCssError; |
| 95 | static const char* kInvalidCssListError; |
[email protected] | 1712232 | 2009-01-22 20:03:30 | [diff] [blame] | 96 | static const char* kInvalidDescriptionError; |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 97 | static const char* kInvalidJsError; |
| 98 | static const char* kInvalidJsListError; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 99 | static const char* kInvalidKeyError; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 100 | static const char* kInvalidManifestError; |
| 101 | static const char* kInvalidMatchCountError; |
| 102 | static const char* kInvalidMatchError; |
| 103 | static const char* kInvalidMatchesError; |
| 104 | static const char* kInvalidNameError; |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 105 | static const char* kInvalidPluginsError; |
| 106 | static const char* kInvalidPluginsPathError; |
| 107 | static const char* kInvalidPluginsPublicError; |
| 108 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 109 | static const char* kInvalidBackgroundError; |
[email protected] | 0afe827 | 2009-02-14 04:15:16 | [diff] [blame] | 110 | static const char* kInvalidRunAtError; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 111 | static const char* kInvalidSignatureError; |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 112 | static const char* kInvalidToolstripError; |
[email protected] | d5cef1b | 2009-03-21 05:36:49 | [diff] [blame] | 113 | static const char* kInvalidToolstripsError; |
[email protected] | 1712232 | 2009-01-22 20:03:30 | [diff] [blame] | 114 | static const char* kInvalidVersionError; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 115 | static const char* kInvalidPageActionError; |
| 116 | static const char* kInvalidPageActionsListError; |
| 117 | static const char* kInvalidPageActionIconPathError; |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 118 | static const char* kInvalidPageActionIdError; |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 119 | static const char* kInvalidPageActionTypeValueError; |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 120 | static const char* kInvalidPermissionsError; |
| 121 | static const char* kInvalidPermissionCountWarning; |
| 122 | static const char* kInvalidPermissionError; |
| 123 | static const char* kInvalidPermissionSchemeError; |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 124 | static const char* kInvalidZipHashError; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 125 | static const char* kInvalidThemeError; |
| 126 | static const char* kInvalidThemeImagesMissingError; |
| 127 | static const char* kInvalidThemeImagesError; |
| 128 | static const char* kInvalidThemeColorsError; |
| 129 | static const char* kInvalidThemeTintsError; |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 130 | static const char* kThemesCannotContainExtensionsError; |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 131 | static const char* kMissingFileError; |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 132 | static const char* kInvalidUpdateURLError; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 133 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 134 | #if defined(OS_WIN) |
| 135 | static const char* kExtensionRegistryPath; |
| 136 | #endif |
| 137 | |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 138 | // The number of bytes in a legal id. |
[email protected] | fe0e782 | 2009-02-26 23:51:48 | [diff] [blame] | 139 | static const size_t kIdSize; |
[email protected] | 37eeb5a | 2009-02-26 23:36:17 | [diff] [blame] | 140 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 141 | Extension() : location_(INVALID), is_theme_(false) {} |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 142 | explicit Extension(const FilePath& path); |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 143 | virtual ~Extension(); |
| 144 | |
[email protected] | f1ce6e6 | 2009-06-29 20:31:29 | [diff] [blame^] | 145 | // Returns true if the specified file is an extension. |
| 146 | static bool IsExtension(const FilePath& file_name); |
| 147 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 148 | // Resets the id counter. This is only useful for unit tests. |
| 149 | static void ResetGeneratedIdCounter() { |
| 150 | id_counter_ = 0; |
| 151 | } |
| 152 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 153 | // Checks to see if the extension has a valid ID. |
| 154 | static bool IdIsValid(const std::string& id); |
| 155 | |
| 156 | // Whether the |location| is external or not. |
| 157 | static inline bool IsExternalLocation(Location location) { |
| 158 | return location == Extension::EXTERNAL_PREF || |
| 159 | location == Extension::EXTERNAL_REGISTRY; |
| 160 | } |
| 161 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 162 | // Returns an absolute url to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 163 | // |extension_url| argument should be the url() from an Extension object. The |
| 164 | // |relative_path| can be untrusted user input. The returned URL will either |
| 165 | // be invalid() or a child of |extension_url|. |
| 166 | // NOTE: Static so that it can be used from multiple threads. |
| 167 | static GURL GetResourceURL(const GURL& extension_url, |
| 168 | const std::string& relative_path); |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 169 | GURL GetResourceURL(const std::string& relative_path) { |
| 170 | return GetResourceURL(url(), relative_path); |
| 171 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 172 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 173 | // Returns an absolute path to a resource inside of an extension. The |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 174 | // |extension_path| argument should be the path() from an Extension object. |
| 175 | // The |relative_path| can be untrusted user input. The returned path will |
| 176 | // either be empty or a child of extension_path. |
| 177 | // NOTE: Static so that it can be used from multiple threads. |
| 178 | static FilePath GetResourcePath(const FilePath& extension_path, |
| 179 | const std::string& relative_path); |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 180 | FilePath GetResourcePath(const std::string& relative_path) { |
| 181 | return GetResourcePath(path(), relative_path); |
| 182 | } |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 183 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 184 | // |input| is expected to be the text of an rsa public or private key. It |
| 185 | // tolerates the presence or absence of bracking header/footer like this: |
| 186 | // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY----- |
| 187 | // and may contain newlines. |
| 188 | static bool ParsePEMKeyBytes(const std::string& input, std::string* output); |
| 189 | |
| 190 | // Does a simple base64 encoding of |input| into |output|. |
| 191 | static bool ProducePEM(const std::string& input, std::string* output); |
| 192 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 193 | // Note: The result is coverted to lower-case because the browser enforces |
| 194 | // hosts to be lower-case in omni-bar. |
| 195 | static bool GenerateIdFromPublicKey(const std::string& input, |
| 196 | std::string* output); |
| 197 | |
[email protected] | a17f946 | 2009-06-09 02:56:41 | [diff] [blame] | 198 | // Expects base64 encoded |input| and formats into |output| including |
| 199 | // the appropriate header & footer. |
| 200 | static bool FormatPEMForFileOutput(const std::string input, |
| 201 | std::string* output, bool is_public); |
| 202 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 203 | // Initialize the extension from a parsed manifest. |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 204 | // If |require_id| is true, will return an error if the "id" key is missing |
| 205 | // from the value. |
| 206 | bool InitFromValue(const DictionaryValue& value, bool require_id, |
| 207 | std::string* error); |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 208 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 209 | const FilePath& path() const { return path_; } |
[email protected] | 5bfb1eb0a | 2009-04-08 18:33:30 | [diff] [blame] | 210 | const GURL& url() const { return extension_url_; } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 211 | const Location location() const { return location_; } |
| 212 | void set_location(Location location) { location_ = location; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 213 | const std::string& id() const { return id_; } |
| 214 | const Version* version() const { return version_.get(); } |
| 215 | // String representation of the version number. |
| 216 | const std::string VersionString() const; |
| 217 | const std::string& name() const { return name_; } |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 218 | const std::string& public_key() const { return public_key_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 219 | const std::string& description() const { return description_; } |
| 220 | const UserScriptList& content_scripts() const { return content_scripts_; } |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 221 | const PageActionMap& page_actions() const { return page_actions_; } |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 222 | const std::vector<PluginInfo>& plugins() const { return plugins_; } |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 223 | const GURL& background_url() const { return background_url_; } |
[email protected] | d5cef1b | 2009-03-21 05:36:49 | [diff] [blame] | 224 | const std::vector<std::string>& toolstrips() const { return toolstrips_; } |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 225 | const std::vector<URLPattern>& permissions() const { return permissions_; } |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 226 | const GURL& update_url() const { return update_url_; } |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 227 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 228 | // Retrieves a page action by |id|. |
| 229 | const PageAction* GetPageAction(std::string id) const; |
| 230 | |
[email protected] | 25b3433 | 2009-06-05 21:53:19 | [diff] [blame] | 231 | // Returns the origin of this extension. This function takes a |registry_path| |
| 232 | // so that the registry location can be overwritten during testing. |
| 233 | Location ExternalExtensionInstallType(std::string registry_path); |
| 234 | |
| 235 | // Theme-related. |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 236 | DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 237 | DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } |
| 238 | DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 239 | DictionaryValue* GetThemeDisplayProperties() const { |
| 240 | return theme_display_properties_.get(); |
| 241 | } |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 242 | bool IsTheme() { return is_theme_; } |
| 243 | |
[email protected] | facd7a765 | 2009-06-05 23:15:02 | [diff] [blame] | 244 | // Returns a list of paths (relative to the extension dir) for images that |
| 245 | // the browser might load (like themes and page action icons). |
| 246 | std::set<FilePath> GetBrowserImages(); |
| 247 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 248 | private: |
[email protected] | b55530c | 2009-06-17 19:07:03 | [diff] [blame] | 249 | // Counter used to assign ids to extensions that are loaded using |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 250 | // --load-extension. |
| 251 | static int id_counter_; |
| 252 | |
| 253 | // Returns the next counter id. Intentionally post-incrementing so that first |
| 254 | // value is 0. |
| 255 | static int NextGeneratedId() { return id_counter_++; } |
| 256 | |
[email protected] | 3cfbd0e | 2009-03-18 21:26:24 | [diff] [blame] | 257 | // Helper method that loads a UserScript object from a |
| 258 | // dictionary in the content_script list of the manifest. |
| 259 | bool LoadUserScriptHelper(const DictionaryValue* content_script, |
| 260 | int definition_index, |
| 261 | std::string* error, |
| 262 | UserScript* result); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 263 | |
| 264 | // Helper method that loads a PageAction object from a |
| 265 | // dictionary in the page_action list of the manifest. |
[email protected] | ce5c450 | 2009-05-06 16:46:11 | [diff] [blame] | 266 | PageAction* LoadPageActionHelper(const DictionaryValue* page_action, |
| 267 | int definition_index, |
| 268 | std::string* error); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 269 | |
[email protected] | e2eb4311 | 2009-05-29 21:19:54 | [diff] [blame] | 270 | // Figures out if a source contains keys not associated with themes - we |
| 271 | // don't want to allow scripts and such to be bundled with themes. |
| 272 | bool ContainsNonThemeKeys(const DictionaryValue& source); |
| 273 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 274 | // The absolute path to the directory the extension is stored in. |
| 275 | FilePath path_; |
| 276 | |
| 277 | // The base extension url for the extension. |
| 278 | GURL extension_url_; |
[email protected] | eab9b45 | 2009-01-23 20:48:59 | [diff] [blame] | 279 | |
[email protected] | 631cf82 | 2009-05-15 07:01:25 | [diff] [blame] | 280 | // The location the extension was loaded from. |
| 281 | Location location_; |
| 282 | |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 283 | // A human-readable ID for the extension. The convention is to use something |
| 284 | // like 'com.example.myextension', but this is not currently enforced. An |
| 285 | // extension's ID is used in things like directory structures and URLs, and |
| 286 | // is expected to not change across versions. In the case of conflicts, |
| 287 | // updates will only be allowed if the extension can be validated using the |
| 288 | // previous version's update key. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 289 | std::string id_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 290 | |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 291 | // The extension's version. |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 292 | scoped_ptr<Version> version_; |
[email protected] | 64a02b80 | 2009-01-12 19:36:42 | [diff] [blame] | 293 | |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 294 | // The extension's human-readable name. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 295 | std::string name_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 296 | |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 297 | // An optional longer description of the extension. |
[email protected] | e1cec06c | 2008-12-18 01:22:23 | [diff] [blame] | 298 | std::string description_; |
[email protected] | 8289126 | 2008-12-24 00:21:26 | [diff] [blame] | 299 | |
| 300 | // Paths to the content scripts the extension contains. |
[email protected] | 34aa8dc | 2009-02-19 07:03:05 | [diff] [blame] | 301 | UserScriptList content_scripts_; |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 302 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 303 | // A list of page actions. |
| 304 | PageActionMap page_actions_; |
| 305 | |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 306 | // Optional list of NPAPI plugins and associated properties. |
| 307 | std::vector<PluginInfo> plugins_; |
[email protected] | 367230c5 | 2009-02-21 01:44:30 | [diff] [blame] | 308 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 309 | // Optional URL to a master page of which a single instance should be always |
| 310 | // loaded in the background. |
| 311 | GURL background_url_; |
| 312 | |
[email protected] | d5cef1b | 2009-03-21 05:36:49 | [diff] [blame] | 313 | // Paths to HTML files to be displayed in the toolbar. |
| 314 | std::vector<std::string> toolstrips_; |
[email protected] | 4a8d327 | 2009-03-10 19:15:08 | [diff] [blame] | 315 | |
[email protected] | fbcc4030 | 2009-06-12 20:45:45 | [diff] [blame] | 316 | // The public key ('key' in the manifest) used to sign the contents of the |
| 317 | // crx package ('signature' in the manifest) |
| 318 | std::string public_key_; |
[email protected] | cc65591 | 2009-01-29 23:19:19 | [diff] [blame] | 319 | |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 320 | // A map of resource id's to relative file paths. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 321 | scoped_ptr<DictionaryValue> theme_images_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 322 | |
| 323 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 324 | scoped_ptr<DictionaryValue> theme_colors_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 325 | |
| 326 | // A map of color names to colors. |
[email protected] | bbb436f | 2009-05-09 16:51:07 | [diff] [blame] | 327 | scoped_ptr<DictionaryValue> theme_tints_; |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 328 | |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 329 | // A map of display properties. |
| 330 | scoped_ptr<DictionaryValue> theme_display_properties_; |
| 331 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 332 | // Whether the extension is a theme - if it is, certain things are disabled. |
| 333 | bool is_theme_; |
[email protected] | 07c00d99 | 2009-03-04 20:27:04 | [diff] [blame] | 334 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 335 | // The sites this extension has permission to talk to (using XHR, etc). |
[email protected] | 7197f499 | 2009-03-23 05:05:49 | [diff] [blame] | 336 | std::vector<URLPattern> permissions_; |
| 337 | |
[email protected] | b29682ba2 | 2009-06-18 19:53:56 | [diff] [blame] | 338 | // URL for fetching an update manifest |
| 339 | GURL update_url_; |
| 340 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 341 | DISALLOW_COPY_AND_ASSIGN(Extension); |
[email protected] | 7713d63 | 2008-12-02 07:52:33 | [diff] [blame] | 342 | }; |
| 343 | |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 344 | #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |