blob: 51d693115456cd3a804f18a36dd1151fd9bac405 [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]c28071ad2010-03-12 17:28:5670 enum AppLaunchType {
71 LAUNCH_WINDOW,
72 LAUNCH_PANEL,
73 LAUNCH_TAB
[email protected]28375ae2010-02-05 04:45:5074 };
75
[email protected]c3e3def742009-07-17 07:51:0676 // Icon sizes used by the extension system.
[email protected]d2817012009-08-04 06:46:2177 static const int kIconSizes[];
[email protected]c3e3def742009-07-17 07:51:0678
[email protected]4c4f8192009-10-17 01:03:2679 // Max size (both dimensions) for browser and page actions.
80 static const int kPageActionIconMaxSize;
81 static const int kBrowserActionIconMaxSize;
82
[email protected]35506352009-08-07 18:58:1983 // Each permission is a module that the extension is permitted to use.
[email protected]aeb53b32009-10-29 07:34:4584 static const char* kTabPermission;
85 static const char* kBookmarkPermission;
[email protected]0faf2aa82009-11-24 22:10:4986 static const char* kNotificationPermission;
[email protected]ea99c3a2010-01-07 00:40:1987 static const char* kExperimentalPermission;
[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]ceefd3d2010-03-12 09:10:29284 // App stuff.
285 const URLPatternList& app_extent() const { return app_extent_; }
286 const GURL& app_launch_url() const { return app_launch_url_; }
287 bool IsApp() const { return !app_launch_url_.is_empty(); }
[email protected]c28071ad2010-03-12 17:28:56288 AppLaunchType app_launch_type() { return app_launch_type_; }
[email protected]ceefd3d2010-03-12 09:10:29289 const GURL& app_origin() const { return app_origin_; }
290
[email protected]e95ad332009-08-03 19:44:25291 // Runtime data:
292 // Put dynamic data about the state of a running extension below.
293
294 // Whether the background page, if any, is ready. We don't load other
295 // components until then. If there is no background page, we consider it to
296 // be ready.
297 bool GetBackgroundPageReady();
298 void SetBackgroundPageReady();
299
[email protected]1e8c93f2010-02-08 22:58:31300 // Getter and setter for the flag that specifies whether the extension is
301 // being upgraded.
302 bool being_upgraded() const { return being_upgraded_; }
303 void set_being_upgraded(bool value) { being_upgraded_ = value; }
304
[email protected]4a8d3272009-03-10 19:15:08305 private:
[email protected]3cfbd0e2009-03-18 21:26:24306 // Helper method that loads a UserScript object from a
307 // dictionary in the content_script list of the manifest.
308 bool LoadUserScriptHelper(const DictionaryValue* content_script,
309 int definition_index,
310 std::string* error,
311 UserScript* result);
[email protected]f7f3a5f2009-05-01 22:02:34312
[email protected]6657afa62009-11-04 02:15:20313 // Helper method that loads either the include_globs or exclude_globs list
314 // from an entry in the content_script lists of the manifest.
315 bool LoadGlobsHelper(const DictionaryValue* content_script,
316 int content_script_index,
317 const wchar_t* globs_property_name,
318 std::string* error,
[email protected]11f4857282009-11-13 19:56:17319 void(UserScript::*add_method)(const std::string& glob),
[email protected]6657afa62009-11-04 02:15:20320 UserScript *instance);
321
[email protected]5d246db22009-10-27 06:17:57322 // Helper method to load an ExtensionAction from the page_action or
[email protected]92c6f9b92009-10-24 04:35:08323 // browser_action entries in the manifest.
[email protected]5d246db22009-10-27 06:17:57324 ExtensionAction* LoadExtensionActionHelper(
[email protected]92c6f9b92009-10-24 04:35:08325 const DictionaryValue* extension_action, std::string* error);
326
[email protected]e2eb43112009-05-29 21:19:54327 // Figures out if a source contains keys not associated with themes - we
328 // don't want to allow scripts and such to be bundled with themes.
329 bool ContainsNonThemeKeys(const DictionaryValue& source);
330
[email protected]581b0ad2010-01-12 21:54:38331 // Apps don't have access to all extension features. This enforces those
332 // restrictions.
333 bool ContainsNonAppKeys(const DictionaryValue& source);
334
335 // Helper method to verify the app section of the manifest.
336 bool LoadAppHelper(const DictionaryValue* app, std::string* error);
337
[email protected]1952c7d2010-03-04 23:48:34338 // Returns true if the string is one of the known api permissions (see
339 // kPermissionNames).
340 bool IsAPIPermission(const std::string& permission);
341
[email protected]4a8d3272009-03-10 19:15:08342 // The absolute path to the directory the extension is stored in.
343 FilePath path_;
344
345 // The base extension url for the extension.
346 GURL extension_url_;
[email protected]eab9b452009-01-23 20:48:59347
[email protected]631cf822009-05-15 07:01:25348 // The location the extension was loaded from.
349 Location location_;
350
[email protected]7713d632008-12-02 07:52:33351 // A human-readable ID for the extension. The convention is to use something
352 // like 'com.example.myextension', but this is not currently enforced. An
353 // extension's ID is used in things like directory structures and URLs, and
354 // is expected to not change across versions. In the case of conflicts,
355 // updates will only be allowed if the extension can be validated using the
356 // previous version's update key.
[email protected]e1cec06c2008-12-18 01:22:23357 std::string id_;
[email protected]82891262008-12-24 00:21:26358
[email protected]64a02b802009-01-12 19:36:42359 // The extension's version.
[email protected]cc655912009-01-29 23:19:19360 scoped_ptr<Version> version_;
[email protected]64a02b802009-01-12 19:36:42361
[email protected]82891262008-12-24 00:21:26362 // The extension's human-readable name.
[email protected]e1cec06c2008-12-18 01:22:23363 std::string name_;
[email protected]82891262008-12-24 00:21:26364
[email protected]4a8d3272009-03-10 19:15:08365 // An optional longer description of the extension.
[email protected]e1cec06c2008-12-18 01:22:23366 std::string description_;
[email protected]82891262008-12-24 00:21:26367
[email protected]6657afa62009-11-04 02:15:20368 // True if the extension was generated from a user script. (We show slightly
369 // different UI if so).
370 bool converted_from_user_script_;
371
[email protected]82891262008-12-24 00:21:26372 // Paths to the content scripts the extension contains.
[email protected]34aa8dc2009-02-19 07:03:05373 UserScriptList content_scripts_;
[email protected]7713d632008-12-02 07:52:33374
[email protected]37e960e2009-10-13 23:17:50375 // The extension's page action, if any.
[email protected]5d246db22009-10-27 06:17:57376 scoped_ptr<ExtensionAction> page_action_;
[email protected]671e6c1ce2009-09-26 03:18:46377
378 // The extension's browser action, if any.
[email protected]5d246db22009-10-27 06:17:57379 scoped_ptr<ExtensionAction> browser_action_;
[email protected]ec9ac0df2009-10-01 18:06:47380
[email protected]c533bb22009-06-03 19:06:11381 // Optional list of NPAPI plugins and associated properties.
382 std::vector<PluginInfo> plugins_;
[email protected]367230c52009-02-21 01:44:30383
[email protected]c64631652009-04-29 22:24:31384 // Optional URL to a master page of which a single instance should be always
385 // loaded in the background.
386 GURL background_url_;
387
[email protected]43919ac92009-10-16 18:34:28388 // Optional URL to a page for setting options/preferences.
389 GURL options_url_;
390
[email protected]bbc945542009-07-26 00:11:42391 // Optional list of toolstrips_ and associated properties.
392 std::vector<ToolstripInfo> toolstrips_;
[email protected]4a8d3272009-03-10 19:15:08393
[email protected]fbcc40302009-06-12 20:45:45394 // The public key ('key' in the manifest) used to sign the contents of the
395 // crx package ('signature' in the manifest)
396 std::string public_key_;
[email protected]cc655912009-01-29 23:19:19397
[email protected]07c00d992009-03-04 20:27:04398 // A map of resource id's to relative file paths.
[email protected]bbb436f2009-05-09 16:51:07399 scoped_ptr<DictionaryValue> theme_images_;
[email protected]4a190632009-05-09 01:07:42400
401 // A map of color names to colors.
[email protected]bbb436f2009-05-09 16:51:07402 scoped_ptr<DictionaryValue> theme_colors_;
[email protected]4a190632009-05-09 01:07:42403
404 // A map of color names to colors.
[email protected]bbb436f2009-05-09 16:51:07405 scoped_ptr<DictionaryValue> theme_tints_;
[email protected]4a190632009-05-09 01:07:42406
[email protected]7895ea22009-06-02 20:53:50407 // A map of display properties.
408 scoped_ptr<DictionaryValue> theme_display_properties_;
409
[email protected]4a190632009-05-09 01:07:42410 // Whether the extension is a theme - if it is, certain things are disabled.
411 bool is_theme_;
[email protected]07c00d992009-03-04 20:27:04412
[email protected]35506352009-08-07 18:58:19413 // The set of module-level APIs this extension can use.
414 std::vector<std::string> api_permissions_;
415
[email protected]c64631652009-04-29 22:24:31416 // The sites this extension has permission to talk to (using XHR, etc).
[email protected]b30e0dd2010-01-29 23:33:21417 URLPatternList host_permissions_;
[email protected]7197f4992009-03-23 05:05:49418
[email protected]c3e3def742009-07-17 07:51:06419 // The paths to the icons the extension contains mapped by their width.
420 std::map<int, std::string> icons_;
421
[email protected]b29682ba22009-06-18 19:53:56422 // URL for fetching an update manifest
423 GURL update_url_;
[email protected]d6336a92009-08-13 17:25:12424
[email protected]b6ab96d2009-08-20 18:58:19425 // A copy of the manifest that this extension was created from.
426 scoped_ptr<DictionaryValue> manifest_value_;
427
[email protected]9428edc2009-11-18 18:02:47428 // Default locale for fall back. Can be empty if extension is not localized.
429 std::string default_locale_;
430
[email protected]86c008e82009-08-28 20:26:05431 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
432 // which override the handling of those URLs.
[email protected]d3cfa482009-10-17 13:54:57433 URLOverrideMap chrome_url_overrides_;
[email protected]86c008e82009-08-28 20:26:05434
[email protected]b30e0dd2010-01-29 23:33:21435 // Describes the space of URLs that are displayed in the app's custom frame.
436 URLPatternList app_extent_;
[email protected]581b0ad2010-01-12 21:54:38437
[email protected]92bcd162010-01-15 08:47:48438 // The URL an app should launch to.
439 GURL app_launch_url_;
[email protected]3b355642010-02-05 16:01:49440
[email protected]c28071ad2010-03-12 17:28:56441 // How to start when the application is launched.
442 AppLaunchType app_launch_type_;
[email protected]3b355642010-02-05 16:01:49443
[email protected]ceefd3d2010-03-12 09:10:29444 // The web security origin associated with the app. This origin will be
445 // granted the permissions the app requests.
446 GURL app_origin_;
447
[email protected]e95ad332009-08-03 19:44:25448 // Runtime data:
449
450 // True if the background page is ready.
451 bool background_page_ready_;
[email protected]b29682ba22009-06-18 19:53:56452
[email protected]1e8c93f2010-02-08 22:58:31453 // True while the extension is being upgraded.
454 bool being_upgraded_;
455
[email protected]ae7fe712009-07-02 20:33:58456 FRIEND_TEST(ExtensionTest, LoadPageActionHelper);
[email protected]3b355642010-02-05 16:01:49457 FRIEND_TEST(TabStripModelTest, Apps);
[email protected]ae7fe712009-07-02 20:33:58458
[email protected]894bb502009-05-21 22:39:57459 DISALLOW_COPY_AND_ASSIGN(Extension);
[email protected]7713d632008-12-02 07:52:33460};
461
[email protected]b1748b1d82009-11-30 20:32:56462typedef std::vector<Extension*> ExtensionList;
463
[email protected]c6d474f82009-12-16 21:11:06464// Handy struct to pass core extension info around.
465struct ExtensionInfo {
466 ExtensionInfo(const DictionaryValue* manifest,
467 const std::string& id,
468 const FilePath& path,
469 Extension::Location location)
470 : extension_id(id),
471 extension_path(path),
472 extension_location(location) {
473 if (manifest)
474 extension_manifest.reset(
475 static_cast<DictionaryValue*>(manifest->DeepCopy()));
476 }
477
478 scoped_ptr<DictionaryValue> extension_manifest;
479 std::string extension_id;
480 FilePath extension_path;
481 Extension::Location extension_location;
482
483 private:
484 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo);
485};
486
[email protected]5b1a0e22009-05-26 19:00:58487#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_