blob: 087736928e8eb122cceb26177fccf25e3f8a0816 [file] [log] [blame]
[email protected]225c8f52010-02-05 22:23:201// Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]7713d632008-12-02 07:52:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5b1a0e22009-05-26 19:00:585#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_
6#define CHROME_COMMON_EXTENSIONS_EXTENSION_H_
[email protected]7713d632008-12-02 07:52:337
[email protected]300cc58db2009-08-19 20:45:148#include <map>
[email protected]facd7a7652009-06-05 23:15:029#include <set>
[email protected]7713d632008-12-02 07:52:3310#include <string>
11#include <vector>
12
[email protected]6014d672008-12-05 00:38:2513#include "base/file_path.h"
[email protected]cc655912009-01-29 23:19:1914#include "base/scoped_ptr.h"
[email protected]7713d632008-12-02 07:52:3315#include "base/values.h"
[email protected]cc655912009-01-29 23:19:1916#include "base/version.h"
[email protected]ba69a7d2009-09-28 21:09:5617#include "chrome/common/extensions/extension_action.h"
[email protected]ecabe6ee2009-10-07 22:49:1018#include "chrome/common/extensions/extension_resource.h"
[email protected]42b6f0f82009-09-18 21:07:3919#include "chrome/common/extensions/user_script.h"
[email protected]7197f4992009-03-23 05:05:4920#include "chrome/common/extensions/url_pattern.h"
[email protected]eab9b452009-01-23 20:48:5921#include "googleurl/src/gurl.h"
[email protected]8cb5d5b2010-02-09 11:36:1622#include "testing/gtest/include/gtest/gtest_prod.h"
[email protected]eab9b452009-01-23 20:48:5923
[email protected]c533bb22009-06-03 19:06:1124// Represents a Chrome extension.
[email protected]7713d632008-12-02 07:52:3325class Extension {
26 public:
[email protected]b30e0dd2010-01-29 23:33:2127 typedef std::vector<URLPattern> URLPatternList;
[email protected]d3cfa482009-10-17 13:54:5728 typedef std::map<const std::string, GURL> URLOverrideMap;
[email protected]b24d8312009-08-27 06:47:4629
[email protected]631cf822009-05-15 07:01:2530 // What an extension was loaded from.
[email protected]1952c7d2010-03-04 23:48:3431 // NOTE: These values are stored as integers in the preferences, so you
32 // really don't want to change any existing ones.
[email protected]631cf822009-05-15 07:01:2533 enum Location {
34 INVALID,
[email protected]25b34332009-06-05 21:53:1935 INTERNAL, // A crx file from the internal Extensions directory.
36 EXTERNAL_PREF, // A crx file from an external directory (via prefs).
37 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the
38 // registry on Windows).
[email protected]1952c7d2010-03-04 23:48:3439 LOAD, // --load-extension.
40 COMPONENT // An integral component of Chrome itself, which happens
41 // to be implemented as an extension. We don't show
42 // these in the management UI.
[email protected]25b34332009-06-05 21:53:1943 };
44
45 enum State {
[email protected]0c6da502009-08-14 22:32:3946 DISABLED = 0,
[email protected]25b34332009-06-05 21:53:1947 ENABLED,
48 KILLBIT, // Don't install/upgrade (applies to external extensions only).
[email protected]0c6da502009-08-14 22:32:3949
50 NUM_STATES
[email protected]631cf822009-05-15 07:01:2551 };
[email protected]7713d632008-12-02 07:52:3352
[email protected]fbcc40302009-06-12 20:45:4553 enum InstallType {
[email protected]ab6f2b22009-07-28 23:28:3754 INSTALL_ERROR,
[email protected]fbcc40302009-06-12 20:45:4555 DOWNGRADE,
56 REINSTALL,
57 UPGRADE,
58 NEW_INSTALL
59 };
60
[email protected]d2817012009-08-04 06:46:2161 // NOTE: If you change this list, you should also change kIconSizes in the cc
62 // file.
63 enum Icons {
64 EXTENSION_ICON_LARGE = 128,
65 EXTENSION_ICON_MEDIUM = 48,
66 EXTENSION_ICON_SMALL = 32,
67 EXTENSION_ICON_BITTY = 16,
68 };
69
[email protected]28375ae2010-02-05 04:45:5070 enum AppLaunchWindowType {
71 APP,
72 PANEL
73 };
74
[email protected]c3e3def742009-07-17 07:51:0675 // Icon sizes used by the extension system.
[email protected]d2817012009-08-04 06:46:2176 static const int kIconSizes[];
[email protected]c3e3def742009-07-17 07:51:0677
[email protected]4c4f8192009-10-17 01:03:2678 // Max size (both dimensions) for browser and page actions.
79 static const int kPageActionIconMaxSize;
80 static const int kBrowserActionIconMaxSize;
81
[email protected]35506352009-08-07 18:58:1982 // Each permission is a module that the extension is permitted to use.
[email protected]aeb53b32009-10-29 07:34:4583 static const char* kTabPermission;
84 static const char* kBookmarkPermission;
[email protected]0faf2aa82009-11-24 22:10:4985 static const char* kNotificationPermission;
[email protected]ea99c3a2010-01-07 00:40:1986 static const char* kExperimentalPermission;
[email protected]24b538a2010-02-27 01:22:4487 static const char* kUnlimitedStoragePermission;
[email protected]aeb53b32009-10-29 07:34:4588
[email protected]35506352009-08-07 18:58:1989 static const char* kPermissionNames[];
90 static const size_t kNumPermissions;
91
[email protected]c533bb22009-06-03 19:06:1192 // An NPAPI plugin included in the extension.
93 struct PluginInfo {
94 FilePath path; // Path to the plugin.
95 bool is_public; // False if only this extension can load this plugin.
96 };
97
[email protected]bbc945542009-07-26 00:11:4298 // A toolstrip and its associated mole.
99 struct ToolstripInfo {
100 ToolstripInfo() : mole_height(0) {}
101
102 GURL toolstrip;
103 GURL mole;
104 int mole_height;
105 };
106
[email protected]6014d672008-12-05 00:38:25107 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16108 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25109
[email protected]300cc58db2009-08-19 20:45:14110 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16111 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14112
113 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16114 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14115
[email protected]25b34332009-06-05 21:53:19116#if defined(OS_WIN)
117 static const char* kExtensionRegistryPath;
118#endif
119
[email protected]37eeb5a2009-02-26 23:36:17120 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48121 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17122
[email protected]e435d6b72009-07-25 03:15:58123 // The mimetype used for extensions.
124 static const char kMimeType[];
125
[email protected]631cf822009-05-15 07:01:25126 explicit Extension(const FilePath& path);
[email protected]631cf822009-05-15 07:01:25127 virtual ~Extension();
128
[email protected]25b34332009-06-05 21:53:19129 // Checks to see if the extension has a valid ID.
130 static bool IdIsValid(const std::string& id);
131
[email protected]e435d6b72009-07-25 03:15:58132 // Returns true if the specified file is an extension.
133 static bool IsExtension(const FilePath& file_name);
134
[email protected]25b34332009-06-05 21:53:19135 // Whether the |location| is external or not.
136 static inline bool IsExternalLocation(Location location) {
137 return location == Extension::EXTERNAL_PREF ||
138 location == Extension::EXTERNAL_REGISTRY;
139 }
140
[email protected]07c00d992009-03-04 20:27:04141 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59142 // |extension_url| argument should be the url() from an Extension object. The
143 // |relative_path| can be untrusted user input. The returned URL will either
144 // be invalid() or a child of |extension_url|.
145 // NOTE: Static so that it can be used from multiple threads.
146 static GURL GetResourceURL(const GURL& extension_url,
147 const std::string& relative_path);
[email protected]3cfbd0e2009-03-18 21:26:24148 GURL GetResourceURL(const std::string& relative_path) {
149 return GetResourceURL(url(), relative_path);
150 }
[email protected]eab9b452009-01-23 20:48:59151
[email protected]99efb7b12009-12-18 02:39:16152 // Returns an extension resource object. |relative_path| should be UTF8
153 // encoded.
154 ExtensionResource GetResource(const std::string& relative_path);
155
156 // As above, but with |relative_path| following the file system's encoding.
157 ExtensionResource GetResource(const FilePath& relative_path);
[email protected]eab9b452009-01-23 20:48:59158
[email protected]a17f9462009-06-09 02:56:41159 // |input| is expected to be the text of an rsa public or private key. It
160 // tolerates the presence or absence of bracking header/footer like this:
161 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
162 // and may contain newlines.
163 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
164
165 // Does a simple base64 encoding of |input| into |output|.
166 static bool ProducePEM(const std::string& input, std::string* output);
167
[email protected]84ac7f32009-10-06 06:17:54168 // Generates an extension ID from arbitrary input. The same input string will
169 // always generate the same output ID.
170 static bool GenerateId(const std::string& input, std::string* output);
[email protected]fbcc40302009-06-12 20:45:45171
[email protected]a17f9462009-06-09 02:56:41172 // Expects base64 encoded |input| and formats into |output| including
173 // the appropriate header & footer.
174 static bool FormatPEMForFileOutput(const std::string input,
175 std::string* output, bool is_public);
176
[email protected]2a409532009-08-28 19:39:44177 // Determine whether |new_extension| has increased privileges compared to
178 // |old_extension|.
179 static bool IsPrivilegeIncrease(Extension* old_extension,
180 Extension* new_extension);
[email protected]b24d8312009-08-27 06:47:46181
[email protected]c690a9812009-12-17 05:55:32182 // Given an extension and icon size, read it if present and decode it into
183 // result.
184 static void DecodeIcon(Extension* extension,
185 Icons icon_size,
186 scoped_ptr<SkBitmap>* result);
187
188 // Given an icon_path and icon size, read it if present and decode it into
189 // result.
190 static void DecodeIconFromPath(const FilePath& icon_path,
191 Icons icon_size,
192 scoped_ptr<SkBitmap>* result);
193
[email protected]4a8d3272009-03-10 19:15:08194 // Initialize the extension from a parsed manifest.
[email protected]1952c7d2010-03-04 23:48:34195 // Usually, the id of an extension is generated by the "key" property of
196 // its manifest, but if |require_key| is |false|, a temporary ID will be
197 // generated based on the path.
198 bool InitFromValue(const DictionaryValue& value, bool require_key,
[email protected]5bfb1eb0a2009-04-08 18:33:30199 std::string* error);
[email protected]4a8d3272009-03-10 19:15:08200
[email protected]82891262008-12-24 00:21:26201 const FilePath& path() const { return path_; }
[email protected]af1277b2009-07-28 00:47:53202 void set_path(const FilePath& path) { path_ = path; }
[email protected]5bfb1eb0a2009-04-08 18:33:30203 const GURL& url() const { return extension_url_; }
[email protected]225c8f52010-02-05 22:23:20204 Location location() const { return location_; }
[email protected]631cf822009-05-15 07:01:25205 void set_location(Location location) { location_ = location; }
[email protected]4a8d3272009-03-10 19:15:08206 const std::string& id() const { return id_; }
207 const Version* version() const { return version_.get(); }
208 // String representation of the version number.
209 const std::string VersionString() const;
210 const std::string& name() const { return name_; }
[email protected]fbcc40302009-06-12 20:45:45211 const std::string& public_key() const { return public_key_; }
[email protected]4a8d3272009-03-10 19:15:08212 const std::string& description() const { return description_; }
[email protected]6657afa62009-11-04 02:15:20213 bool converted_from_user_script() const {
214 return converted_from_user_script_;
215 }
[email protected]4a8d3272009-03-10 19:15:08216 const UserScriptList& content_scripts() const { return content_scripts_; }
[email protected]5d246db22009-10-27 06:17:57217 ExtensionAction* page_action() const { return page_action_.get(); }
218 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]c533bb22009-06-03 19:06:11219 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]c64631652009-04-29 22:24:31220 const GURL& background_url() const { return background_url_; }
[email protected]43919ac92009-10-16 18:34:28221 const GURL& options_url() const { return options_url_; }
[email protected]bbc945542009-07-26 00:11:42222 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; }
[email protected]35506352009-08-07 18:58:19223 const std::vector<std::string>& api_permissions() const {
224 return api_permissions_;
225 }
[email protected]b30e0dd2010-01-29 23:33:21226 const URLPatternList& host_permissions() const {
[email protected]c7ad50f2009-09-11 06:28:15227 return host_permissions_;
228 }
229
[email protected]e9303b942010-02-20 08:21:19230 // Returns true if the extension has permission to execute script on a
231 // particular host.
232 // TODO(aa): Also use this in the renderer, for normal content script
233 // injection. Currently, that has its own copy of this code.
234 bool CanExecuteScriptOnHost(const GURL& url, std::string* error) const;
[email protected]b24d8312009-08-27 06:47:46235
[email protected]aeb53b32009-10-29 07:34:45236 // Returns true if the extension has the specified API permission.
237 bool HasApiPermission(const std::string& permission) const {
238 return std::find(api_permissions_.begin(), api_permissions_.end(),
239 permission) != api_permissions_.end();
240 }
241
[email protected]b24d8312009-08-27 06:47:46242 // Returns the set of hosts that the extension effectively has access to. This
243 // is used in the permissions UI and is a combination of the hosts accessible
244 // through content scripts and the hosts accessible through XHR.
245 const std::set<std::string> GetEffectiveHostPermissions() const;
246
247 // Whether the extension has access to all hosts. This is true if there is
248 // a content script that matches all hosts, or if there is a host permission
249 // for all hosts.
250 bool HasAccessToAllHosts() const;
251
[email protected]b29682ba22009-06-18 19:53:56252 const GURL& update_url() const { return update_url_; }
[email protected]0cb5f502009-10-21 21:35:47253 const std::map<int, std::string>& icons() const { return icons_; }
[email protected]4a8d3272009-03-10 19:15:08254
[email protected]25b34332009-06-05 21:53:19255 // Theme-related.
[email protected]631cf822009-05-15 07:01:25256 DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
257 DictionaryValue* GetThemeColors() const { return theme_colors_.get(); }
258 DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
[email protected]7895ea22009-06-02 20:53:50259 DictionaryValue* GetThemeDisplayProperties() const {
260 return theme_display_properties_.get();
261 }
[email protected]66da08b2009-10-19 22:27:00262 bool IsTheme() const { return is_theme_; }
[email protected]631cf822009-05-15 07:01:25263
[email protected]facd7a7652009-06-05 23:15:02264 // Returns a list of paths (relative to the extension dir) for images that
265 // the browser might load (like themes and page action icons).
266 std::set<FilePath> GetBrowserImages();
267
[email protected]866930682009-08-18 22:53:47268 // Returns an absolute path to the given icon inside of the extension. Returns
269 // an empty FilePath if the extension does not have that icon.
[email protected]ecabe6ee2009-10-07 22:49:10270 ExtensionResource GetIconPath(Icons icon);
[email protected]866930682009-08-18 22:53:47271
[email protected]b6ab96d2009-08-20 18:58:19272 const DictionaryValue* manifest_value() const {
273 return manifest_value_.get();
274 }
275
[email protected]9428edc2009-11-18 18:02:47276 const std::string default_locale() const { return default_locale_; }
277
[email protected]86c008e82009-08-28 20:26:05278 // Chrome URL overrides (see ExtensionOverrideUI).
[email protected]d3cfa482009-10-17 13:54:57279 const URLOverrideMap& GetChromeURLOverrides() const {
280 return chrome_url_overrides_;
[email protected]86c008e82009-08-28 20:26:05281 }
282
[email protected]ceefd3d2010-03-12 09:10:29283 // App stuff.
284 const URLPatternList& app_extent() const { return app_extent_; }
285 const GURL& app_launch_url() const { return app_launch_url_; }
286 bool IsApp() const { return !app_launch_url_.is_empty(); }
287 AppLaunchWindowType app_launch_window_type() {
288 return app_launch_window_type_;
289 }
290 const GURL& app_origin() const { return app_origin_; }
291
[email protected]e95ad332009-08-03 19:44:25292 // Runtime data:
293 // Put dynamic data about the state of a running extension below.
294
295 // Whether the background page, if any, is ready. We don't load other
296 // components until then. If there is no background page, we consider it to
297 // be ready.
298 bool GetBackgroundPageReady();
299 void SetBackgroundPageReady();
300
[email protected]1e8c93f2010-02-08 22:58:31301 // Getter and setter for the flag that specifies whether the extension is
302 // being upgraded.
303 bool being_upgraded() const { return being_upgraded_; }
304 void set_being_upgraded(bool value) { being_upgraded_ = value; }
305
[email protected]4a8d3272009-03-10 19:15:08306 private:
[email protected]3cfbd0e2009-03-18 21:26:24307 // Helper method that loads a UserScript object from a
308 // dictionary in the content_script list of the manifest.
309 bool LoadUserScriptHelper(const DictionaryValue* content_script,
310 int definition_index,
311 std::string* error,
312 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34313
[email protected]6657afa62009-11-04 02:15:20314 // Helper method that loads either the include_globs or exclude_globs list
315 // from an entry in the content_script lists of the manifest.
316 bool LoadGlobsHelper(const DictionaryValue* content_script,
317 int content_script_index,
318 const wchar_t* globs_property_name,
319 std::string* error,
[email protected]11f4857282009-11-13 19:56:17320 void(UserScript::*add_method)(const std::string& glob),
[email protected]6657afa62009-11-04 02:15:20321 UserScript *instance);
322
[email protected]5d246db22009-10-27 06:17:57323 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08324 // browser_action entries in the manifest.
[email protected]5d246db22009-10-27 06:17:57325 ExtensionAction* LoadExtensionActionHelper(
[email protected]92c6f9b92009-10-24 04:35:08326 const DictionaryValue* extension_action, std::string* error);
327
[email protected]e2eb43112009-05-29 21:19:54328 // Figures out if a source contains keys not associated with themes - we
329 // don't want to allow scripts and such to be bundled with themes.
330 bool ContainsNonThemeKeys(const DictionaryValue& source);
331
[email protected]581b0ad2010-01-12 21:54:38332 // Apps don't have access to all extension features. This enforces those
333 // restrictions.
334 bool ContainsNonAppKeys(const DictionaryValue& source);
335
336 // Helper method to verify the app section of the manifest.
337 bool LoadAppHelper(const DictionaryValue* app, std::string* error);
338
[email protected]1952c7d2010-03-04 23:48:34339 // Returns true if the string is one of the known api permissions (see
340 // kPermissionNames).
341 bool IsAPIPermission(const std::string& permission);
342
[email protected]4a8d3272009-03-10 19:15:08343 // The absolute path to the directory the extension is stored in.
344 FilePath path_;
345
346 // The base extension url for the extension.
347 GURL extension_url_;
[email protected]eab9b452009-01-23 20:48:59348
[email protected]631cf822009-05-15 07:01:25349 // The location the extension was loaded from.
350 Location location_;
351
[email protected]7713d632008-12-02 07:52:33352 // A human-readable ID for the extension. The convention is to use something
353 // like 'com.example.myextension', but this is not currently enforced. An
354 // extension's ID is used in things like directory structures and URLs, and
355 // is expected to not change across versions. In the case of conflicts,
356 // updates will only be allowed if the extension can be validated using the
357 // previous version's update key.
[email protected]e1cec06c2008-12-18 01:22:23358 std::string id_;
[email protected]82891262008-12-24 00:21:26359
[email protected]64a02b802009-01-12 19:36:42360 // The extension's version.
[email protected]cc655912009-01-29 23:19:19361 scoped_ptr<Version> version_;
[email protected]64a02b802009-01-12 19:36:42362
[email protected]82891262008-12-24 00:21:26363 // The extension's human-readable name.
[email protected]e1cec06c2008-12-18 01:22:23364 std::string name_;
[email protected]82891262008-12-24 00:21:26365
[email protected]4a8d3272009-03-10 19:15:08366 // An optional longer description of the extension.
[email protected]e1cec06c2008-12-18 01:22:23367 std::string description_;
[email protected]82891262008-12-24 00:21:26368
[email protected]6657afa62009-11-04 02:15:20369 // True if the extension was generated from a user script. (We show slightly
370 // different UI if so).
371 bool converted_from_user_script_;
372
[email protected]82891262008-12-24 00:21:26373 // Paths to the content scripts the extension contains.
[email protected]34aa8dc2009-02-19 07:03:05374 UserScriptList content_scripts_;
[email protected]7713d632008-12-02 07:52:33375
[email protected]37e960e2009-10-13 23:17:50376 // The extension's page action, if any.
[email protected]5d246db22009-10-27 06:17:57377 scoped_ptr<ExtensionAction> page_action_;
[email protected]671e6c1ce2009-09-26 03:18:46378
379 // The extension's browser action, if any.
[email protected]5d246db22009-10-27 06:17:57380 scoped_ptr<ExtensionAction> browser_action_;
[email protected]ec9ac0df2009-10-01 18:06:47381
[email protected]c533bb22009-06-03 19:06:11382 // Optional list of NPAPI plugins and associated properties.
383 std::vector<PluginInfo> plugins_;
[email protected]367230c52009-02-21 01:44:30384
[email protected]c64631652009-04-29 22:24:31385 // Optional URL to a master page of which a single instance should be always
386 // loaded in the background.
387 GURL background_url_;
388
[email protected]43919ac92009-10-16 18:34:28389 // Optional URL to a page for setting options/preferences.
390 GURL options_url_;
391
[email protected]bbc945542009-07-26 00:11:42392 // Optional list of toolstrips_ and associated properties.
393 std::vector<ToolstripInfo> toolstrips_;
[email protected]4a8d3272009-03-10 19:15:08394
[email protected]fbcc40302009-06-12 20:45:45395 // The public key ('key' in the manifest) used to sign the contents of the
396 // crx package ('signature' in the manifest)
397 std::string public_key_;
[email protected]cc655912009-01-29 23:19:19398
[email protected]07c00d992009-03-04 20:27:04399 // A map of resource id's to relative file paths.
[email protected]bbb436f2009-05-09 16:51:07400 scoped_ptr<DictionaryValue> theme_images_;
[email protected]4a190632009-05-09 01:07:42401
402 // A map of color names to colors.
[email protected]bbb436f2009-05-09 16:51:07403 scoped_ptr<DictionaryValue> theme_colors_;
[email protected]4a190632009-05-09 01:07:42404
405 // A map of color names to colors.
[email protected]bbb436f2009-05-09 16:51:07406 scoped_ptr<DictionaryValue> theme_tints_;
[email protected]4a190632009-05-09 01:07:42407
[email protected]7895ea22009-06-02 20:53:50408 // A map of display properties.
409 scoped_ptr<DictionaryValue> theme_display_properties_;
410
[email protected]4a190632009-05-09 01:07:42411 // Whether the extension is a theme - if it is, certain things are disabled.
412 bool is_theme_;
[email protected]07c00d992009-03-04 20:27:04413
[email protected]35506352009-08-07 18:58:19414 // The set of module-level APIs this extension can use.
415 std::vector<std::string> api_permissions_;
416
[email protected]c64631652009-04-29 22:24:31417 // The sites this extension has permission to talk to (using XHR, etc).
[email protected]b30e0dd2010-01-29 23:33:21418 URLPatternList host_permissions_;
[email protected]7197f4992009-03-23 05:05:49419
[email protected]c3e3def742009-07-17 07:51:06420 // The paths to the icons the extension contains mapped by their width.
421 std::map<int, std::string> icons_;
422
[email protected]b29682ba22009-06-18 19:53:56423 // URL for fetching an update manifest
424 GURL update_url_;
[email protected]d6336a92009-08-13 17:25:12425
[email protected]b6ab96d2009-08-20 18:58:19426 // A copy of the manifest that this extension was created from.
427 scoped_ptr<DictionaryValue> manifest_value_;
428
[email protected]9428edc2009-11-18 18:02:47429 // Default locale for fall back. Can be empty if extension is not localized.
430 std::string default_locale_;
431
[email protected]86c008e82009-08-28 20:26:05432 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
433 // which override the handling of those URLs.
[email protected]d3cfa482009-10-17 13:54:57434 URLOverrideMap chrome_url_overrides_;
[email protected]86c008e82009-08-28 20:26:05435
[email protected]b30e0dd2010-01-29 23:33:21436 // Describes the space of URLs that are displayed in the app's custom frame.
437 URLPatternList app_extent_;
[email protected]581b0ad2010-01-12 21:54:38438
[email protected]92bcd162010-01-15 08:47:48439 // The URL an app should launch to.
440 GURL app_launch_url_;
[email protected]3b355642010-02-05 16:01:49441
[email protected]28375ae2010-02-05 04:45:50442 // The type of window to start when the application is launched.
443 AppLaunchWindowType app_launch_window_type_;
[email protected]3b355642010-02-05 16:01:49444
[email protected]ceefd3d2010-03-12 09:10:29445 // The web security origin associated with the app. This origin will be
446 // granted the permissions the app requests.
447 GURL app_origin_;
448
[email protected]e95ad332009-08-03 19:44:25449 // Runtime data:
450
451 // True if the background page is ready.
452 bool background_page_ready_;
[email protected]b29682ba22009-06-18 19:53:56453
[email protected]1e8c93f2010-02-08 22:58:31454 // True while the extension is being upgraded.
455 bool being_upgraded_;
456
[email protected]ae7fe712009-07-02 20:33:58457 FRIEND_TEST(ExtensionTest, LoadPageActionHelper);
[email protected]3b355642010-02-05 16:01:49458 FRIEND_TEST(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58459
[email protected]894bb502009-05-21 22:39:57460 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33461};
462
[email protected]b1748b1d82009-11-30 20:32:56463typedef std::vector<Extension*> ExtensionList;
464
[email protected]c6d474f82009-12-16 21:11:06465// Handy struct to pass core extension info around.
466struct ExtensionInfo {
467 ExtensionInfo(const DictionaryValue* manifest,
468 const std::string& id,
469 const FilePath& path,
470 Extension::Location location)
471 : extension_id(id),
472 extension_path(path),
473 extension_location(location) {
474 if (manifest)
475 extension_manifest.reset(
476 static_cast<DictionaryValue*>(manifest->DeepCopy()));
477 }
478
479 scoped_ptr<DictionaryValue> extension_manifest;
480 std::string extension_id;
481 FilePath extension_path;
482 Extension::Location extension_location;
483
484 private:
485 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
486};
487
[email protected]5b1a0e22009-05-26 19:00:58488#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_