blob: 78e75a66430bfe66db5f8368920f689bc6775f8a [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]55a35692010-02-11 23:25:2187 static const char* kIncognitoPermission;
[email protected]24b538a2010-02-27 01:22:4488 static const char* kUnlimitedStoragePermission;
[email protected]aeb53b32009-10-29 07:34:4589
[email protected]35506352009-08-07 18:58:1990 static const char* kPermissionNames[];
91 static const size_t kNumPermissions;
92
[email protected]c533bb22009-06-03 19:06:1193 // An NPAPI plugin included in the extension.
94 struct PluginInfo {
95 FilePath path; // Path to the plugin.
96 bool is_public; // False if only this extension can load this plugin.
97 };
98
[email protected]bbc945542009-07-26 00:11:4299 // A toolstrip and its associated mole.
100 struct ToolstripInfo {
101 ToolstripInfo() : mole_height(0) {}
102
103 GURL toolstrip;
104 GURL mole;
105 int mole_height;
106 };
107
[email protected]6014d672008-12-05 00:38:25108 // The name of the manifest inside an extension.
[email protected]99efb7b12009-12-18 02:39:16109 static const FilePath::CharType kManifestFilename[];
[email protected]6014d672008-12-05 00:38:25110
[email protected]300cc58db2009-08-19 20:45:14111 // The name of locale folder inside an extension.
[email protected]99efb7b12009-12-18 02:39:16112 static const FilePath::CharType kLocaleFolder[];
[email protected]300cc58db2009-08-19 20:45:14113
114 // The name of the messages file inside an extension.
[email protected]99efb7b12009-12-18 02:39:16115 static const FilePath::CharType kMessagesFilename[];
[email protected]300cc58db2009-08-19 20:45:14116
[email protected]25b34332009-06-05 21:53:19117#if defined(OS_WIN)
118 static const char* kExtensionRegistryPath;
119#endif
120
[email protected]37eeb5a2009-02-26 23:36:17121 // The number of bytes in a legal id.
[email protected]fe0e7822009-02-26 23:51:48122 static const size_t kIdSize;
[email protected]37eeb5a2009-02-26 23:36:17123
[email protected]e435d6b72009-07-25 03:15:58124 // The mimetype used for extensions.
125 static const char kMimeType[];
126
[email protected]631cf822009-05-15 07:01:25127 explicit Extension(const FilePath& path);
[email protected]631cf822009-05-15 07:01:25128 virtual ~Extension();
129
[email protected]25b34332009-06-05 21:53:19130 // Checks to see if the extension has a valid ID.
131 static bool IdIsValid(const std::string& id);
132
[email protected]e435d6b72009-07-25 03:15:58133 // Returns true if the specified file is an extension.
134 static bool IsExtension(const FilePath& file_name);
135
[email protected]25b34332009-06-05 21:53:19136 // Whether the |location| is external or not.
137 static inline bool IsExternalLocation(Location location) {
138 return location == Extension::EXTERNAL_PREF ||
139 location == Extension::EXTERNAL_REGISTRY;
140 }
141
[email protected]07c00d992009-03-04 20:27:04142 // Returns an absolute url to a resource inside of an extension. The
[email protected]eab9b452009-01-23 20:48:59143 // |extension_url| argument should be the url() from an Extension object. The
144 // |relative_path| can be untrusted user input. The returned URL will either
145 // be invalid() or a child of |extension_url|.
146 // NOTE: Static so that it can be used from multiple threads.
147 static GURL GetResourceURL(const GURL& extension_url,
148 const std::string& relative_path);
[email protected]3cfbd0e2009-03-18 21:26:24149 GURL GetResourceURL(const std::string& relative_path) {
150 return GetResourceURL(url(), relative_path);
151 }
[email protected]eab9b452009-01-23 20:48:59152
[email protected]99efb7b12009-12-18 02:39:16153 // Returns an extension resource object. |relative_path| should be UTF8
154 // encoded.
155 ExtensionResource GetResource(const std::string& relative_path);
156
157 // As above, but with |relative_path| following the file system's encoding.
158 ExtensionResource GetResource(const FilePath& relative_path);
[email protected]eab9b452009-01-23 20:48:59159
[email protected]a17f9462009-06-09 02:56:41160 // |input| is expected to be the text of an rsa public or private key. It
161 // tolerates the presence or absence of bracking header/footer like this:
162 // -----(BEGIN|END) [RSA PUBLIC/PRIVATE] KEY-----
163 // and may contain newlines.
164 static bool ParsePEMKeyBytes(const std::string& input, std::string* output);
165
166 // Does a simple base64 encoding of |input| into |output|.
167 static bool ProducePEM(const std::string& input, std::string* output);
168
[email protected]84ac7f32009-10-06 06:17:54169 // Generates an extension ID from arbitrary input. The same input string will
170 // always generate the same output ID.
171 static bool GenerateId(const std::string& input, std::string* output);
[email protected]fbcc40302009-06-12 20:45:45172
[email protected]a17f9462009-06-09 02:56:41173 // Expects base64 encoded |input| and formats into |output| including
174 // the appropriate header & footer.
175 static bool FormatPEMForFileOutput(const std::string input,
176 std::string* output, bool is_public);
177
[email protected]2a409532009-08-28 19:39:44178 // Determine whether |new_extension| has increased privileges compared to
179 // |old_extension|.
180 static bool IsPrivilegeIncrease(Extension* old_extension,
181 Extension* new_extension);
[email protected]b24d8312009-08-27 06:47:46182
[email protected]c690a9812009-12-17 05:55:32183 // Given an extension and icon size, read it if present and decode it into
184 // result.
185 static void DecodeIcon(Extension* extension,
186 Icons icon_size,
187 scoped_ptr<SkBitmap>* result);
188
189 // Given an icon_path and icon size, read it if present and decode it into
190 // result.
191 static void DecodeIconFromPath(const FilePath& icon_path,
192 Icons icon_size,
193 scoped_ptr<SkBitmap>* result);
194
[email protected]4a8d3272009-03-10 19:15:08195 // Initialize the extension from a parsed manifest.
[email protected]1952c7d2010-03-04 23:48:34196 // Usually, the id of an extension is generated by the "key" property of
197 // its manifest, but if |require_key| is |false|, a temporary ID will be
198 // generated based on the path.
199 bool InitFromValue(const DictionaryValue& value, bool require_key,
[email protected]5bfb1eb0a2009-04-08 18:33:30200 std::string* error);
[email protected]4a8d3272009-03-10 19:15:08201
[email protected]82891262008-12-24 00:21:26202 const FilePath& path() const { return path_; }
[email protected]af1277b2009-07-28 00:47:53203 void set_path(const FilePath& path) { path_ = path; }
[email protected]5bfb1eb0a2009-04-08 18:33:30204 const GURL& url() const { return extension_url_; }
[email protected]225c8f52010-02-05 22:23:20205 Location location() const { return location_; }
[email protected]631cf822009-05-15 07:01:25206 void set_location(Location location) { location_ = location; }
[email protected]4a8d3272009-03-10 19:15:08207 const std::string& id() const { return id_; }
208 const Version* version() const { return version_.get(); }
209 // String representation of the version number.
210 const std::string VersionString() const;
211 const std::string& name() const { return name_; }
[email protected]fbcc40302009-06-12 20:45:45212 const std::string& public_key() const { return public_key_; }
[email protected]4a8d3272009-03-10 19:15:08213 const std::string& description() const { return description_; }
[email protected]6657afa62009-11-04 02:15:20214 bool converted_from_user_script() const {
215 return converted_from_user_script_;
216 }
[email protected]4a8d3272009-03-10 19:15:08217 const UserScriptList& content_scripts() const { return content_scripts_; }
[email protected]5d246db22009-10-27 06:17:57218 ExtensionAction* page_action() const { return page_action_.get(); }
219 ExtensionAction* browser_action() const { return browser_action_.get(); }
[email protected]c533bb22009-06-03 19:06:11220 const std::vector<PluginInfo>& plugins() const { return plugins_; }
[email protected]c64631652009-04-29 22:24:31221 const GURL& background_url() const { return background_url_; }
[email protected]43919ac92009-10-16 18:34:28222 const GURL& options_url() const { return options_url_; }
[email protected]bbc945542009-07-26 00:11:42223 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; }
[email protected]35506352009-08-07 18:58:19224 const std::vector<std::string>& api_permissions() const {
225 return api_permissions_;
226 }
[email protected]b30e0dd2010-01-29 23:33:21227 const URLPatternList& host_permissions() const {
[email protected]c7ad50f2009-09-11 06:28:15228 return host_permissions_;
229 }
230
[email protected]e9303b942010-02-20 08:21:19231 // Returns true if the extension has permission to execute script on a
232 // particular host.
233 // TODO(aa): Also use this in the renderer, for normal content script
234 // injection. Currently, that has its own copy of this code.
235 bool CanExecuteScriptOnHost(const GURL& url, std::string* error) const;
[email protected]b24d8312009-08-27 06:47:46236
[email protected]aeb53b32009-10-29 07:34:45237 // Returns true if the extension has the specified API permission.
238 bool HasApiPermission(const std::string& permission) const {
239 return std::find(api_permissions_.begin(), api_permissions_.end(),
240 permission) != api_permissions_.end();
241 }
242
[email protected]b24d8312009-08-27 06:47:46243 // Returns the set of hosts that the extension effectively has access to. This
244 // is used in the permissions UI and is a combination of the hosts accessible
245 // through content scripts and the hosts accessible through XHR.
246 const std::set<std::string> GetEffectiveHostPermissions() const;
247
248 // Whether the extension has access to all hosts. This is true if there is
249 // a content script that matches all hosts, or if there is a host permission
250 // for all hosts.
251 bool HasAccessToAllHosts() const;
252
[email protected]b29682ba22009-06-18 19:53:56253 const GURL& update_url() const { return update_url_; }
[email protected]0cb5f502009-10-21 21:35:47254 const std::map<int, std::string>& icons() const { return icons_; }
[email protected]4a8d3272009-03-10 19:15:08255
[email protected]25b34332009-06-05 21:53:19256 // Theme-related.
[email protected]631cf822009-05-15 07:01:25257 DictionaryValue* GetThemeImages() const { return theme_images_.get(); }
258 DictionaryValue* GetThemeColors() const { return theme_colors_.get(); }
259 DictionaryValue* GetThemeTints() const { return theme_tints_.get(); }
[email protected]7895ea22009-06-02 20:53:50260 DictionaryValue* GetThemeDisplayProperties() const {
261 return theme_display_properties_.get();
262 }
[email protected]66da08b2009-10-19 22:27:00263 bool IsTheme() const { return is_theme_; }
[email protected]631cf822009-05-15 07:01:25264
[email protected]facd7a7652009-06-05 23:15:02265 // Returns a list of paths (relative to the extension dir) for images that
266 // the browser might load (like themes and page action icons).
267 std::set<FilePath> GetBrowserImages();
268
[email protected]866930682009-08-18 22:53:47269 // Returns an absolute path to the given icon inside of the extension. Returns
270 // an empty FilePath if the extension does not have that icon.
[email protected]ecabe6ee2009-10-07 22:49:10271 ExtensionResource GetIconPath(Icons icon);
[email protected]866930682009-08-18 22:53:47272
[email protected]b6ab96d2009-08-20 18:58:19273 const DictionaryValue* manifest_value() const {
274 return manifest_value_.get();
275 }
276
[email protected]9428edc2009-11-18 18:02:47277 const std::string default_locale() const { return default_locale_; }
278
[email protected]86c008e82009-08-28 20:26:05279 // Chrome URL overrides (see ExtensionOverrideUI).
[email protected]d3cfa482009-10-17 13:54:57280 const URLOverrideMap& GetChromeURLOverrides() const {
281 return chrome_url_overrides_;
[email protected]86c008e82009-08-28 20:26:05282 }
283
[email protected]e95ad332009-08-03 19:44:25284 // Runtime data:
285 // Put dynamic data about the state of a running extension below.
286
287 // Whether the background page, if any, is ready. We don't load other
288 // components until then. If there is no background page, we consider it to
289 // be ready.
290 bool GetBackgroundPageReady();
291 void SetBackgroundPageReady();
292
[email protected]1e8c93f2010-02-08 22:58:31293 // Getter and setter for the flag that specifies whether the extension is
294 // being upgraded.
295 bool being_upgraded() const { return being_upgraded_; }
296 void set_being_upgraded(bool value) { being_upgraded_ = value; }
297
[email protected]92bcd162010-01-15 08:47:48298 // App stuff.
[email protected]b30e0dd2010-01-29 23:33:21299 const URLPatternList& app_extent() const { return app_extent_; }
[email protected]92bcd162010-01-15 08:47:48300 const GURL& app_launch_url() const { return app_launch_url_; }
301 bool IsApp() const { return !app_launch_url_.is_empty(); }
[email protected]28375ae2010-02-05 04:45:50302 AppLaunchWindowType app_launch_window_type() {
303 return app_launch_window_type_;
304 }
[email protected]581b0ad2010-01-12 21:54:38305
[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]e95ad332009-08-03 19:44:25445 // Runtime data:
446
447 // True if the background page is ready.
448 bool background_page_ready_;
[email protected]b29682ba22009-06-18 19:53:56449
[email protected]1e8c93f2010-02-08 22:58:31450 // True while the extension is being upgraded.
451 bool being_upgraded_;
452
[email protected]ae7fe712009-07-02 20:33:58453 FRIEND_TEST(ExtensionTest, LoadPageActionHelper);
[email protected]3b355642010-02-05 16:01:49454 FRIEND_TEST(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58455
[email protected]894bb502009-05-21 22:39:57456 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33457};
458
[email protected]b1748b1d82009-11-30 20:32:56459typedef std::vector<Extension*> ExtensionList;
460
[email protected]c6d474f82009-12-16 21:11:06461// Handy struct to pass core extension info around.
462struct ExtensionInfo {
463 ExtensionInfo(const DictionaryValue* manifest,
464 const std::string& id,
465 const FilePath& path,
466 Extension::Location location)
467 : extension_id(id),
468 extension_path(path),
469 extension_location(location) {
470 if (manifest)
471 extension_manifest.reset(
472 static_cast<DictionaryValue*>(manifest->DeepCopy()));
473 }
474
475 scoped_ptr<DictionaryValue> extension_manifest;
476 std::string extension_id;
477 FilePath extension_path;
478 Extension::Location extension_location;
479
480 private:
481 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
482};
483
[email protected]5b1a0e22009-05-26 19:00:58484#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_