OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 TYPE_HOSTED_APP, | 93 TYPE_HOSTED_APP, |
94 TYPE_PACKAGED_APP | 94 TYPE_PACKAGED_APP |
95 }; | 95 }; |
96 | 96 |
97 // An NPAPI plugin included in the extension. | 97 // An NPAPI plugin included in the extension. |
98 struct PluginInfo { | 98 struct PluginInfo { |
99 FilePath path; // Path to the plugin. | 99 FilePath path; // Path to the plugin. |
100 bool is_public; // False if only this extension can load this plugin. | 100 bool is_public; // False if only this extension can load this plugin. |
101 }; | 101 }; |
102 | 102 |
103 // Contains a subset of the extension's data that doesn't change once | |
104 // initialized, and therefore shareable across threads without locking. | |
105 struct StaticData : public base::RefCountedThreadSafe<StaticData> { | |
106 StaticData(); | |
107 | |
108 // A persistent, globally unique ID. An extension's ID is used in things | |
109 // like directory structures and URLs, and is expected to not change across | |
110 // versions. It is generated as a SHA-256 hash of the extension's public | |
111 // key, or as a hash of the path in the case of unpacked extensions. | |
112 std::string id; | |
113 | |
114 // The extension's human-readable name. Name is used for display purpose. It | |
115 // might be wrapped with unicode bidi control characters so that it is | |
116 // displayed correctly in RTL context. | |
117 // NOTE: Name is UTF-8 and may contain non-ascii characters. | |
118 std::string name; | |
119 | |
120 // The absolute path to the directory the extension is stored in. | |
121 FilePath path; | |
122 | |
123 // Default locale for fall back. Can be empty if extension is not localized. | |
124 std::string default_locale; | |
125 | |
126 // If true, a separate process will be used for the extension in incognito | |
127 // mode. | |
128 bool incognito_split_mode; | |
129 | |
130 // Defines the set of URLs in the extension's web content. | |
131 ExtensionExtent extent; | |
132 | |
133 // The set of host permissions that the extension effectively has access to, | |
134 // which is a merge of host_permissions_ and all of the match patterns in | |
135 // any content scripts the extension has. This is used to determine which | |
136 // URLs have the ability to load an extension's resources via embedded | |
137 // chrome-extension: URLs (see extension_protocols.cc). | |
138 ExtensionExtent effective_host_permissions; | |
139 | |
140 // The set of module-level APIs this extension can use. | |
141 std::set<std::string> api_permissions; | |
142 | |
143 // The icons for the extension. | |
144 ExtensionIconSet icons; | |
145 | |
146 // The base extension url for the extension. | |
147 GURL extension_url; | |
148 | |
149 // The location the extension was loaded from. | |
150 Location location; | |
151 | |
152 // The extension's version. | |
153 scoped_ptr<Version> version; | |
154 | |
155 // An optional longer description of the extension. | |
156 std::string description; | |
157 | |
158 // True if the extension was generated from a user script. (We show slightly | |
159 // different UI if so). | |
160 bool converted_from_user_script; | |
161 | |
162 // Paths to the content scripts the extension contains. | |
163 UserScriptList content_scripts; | |
164 | |
165 // The extension's page action, if any. | |
166 scoped_ptr<ExtensionAction> page_action; | |
167 | |
168 // The extension's browser action, if any. | |
169 scoped_ptr<ExtensionAction> browser_action; | |
170 | |
171 // Optional list of NPAPI plugins and associated properties. | |
172 std::vector<PluginInfo> plugins; | |
173 | |
174 // Optional URL to a master page of which a single instance should be always | |
175 // loaded in the background. | |
176 GURL background_url; | |
177 | |
178 // Optional URL to a page for setting options/preferences. | |
179 GURL options_url; | |
180 | |
181 // Optional URL to a devtools extension page. | |
182 GURL devtools_url; | |
183 | |
184 // Optional list of toolstrips and associated properties. | |
185 std::vector<GURL> toolstrips; | |
186 | |
187 // The public key used to sign the contents of the crx package. | |
188 std::string public_key; | |
189 | |
190 // A map of resource id's to relative file paths. | |
191 scoped_ptr<DictionaryValue> theme_images; | |
192 | |
193 // A map of color names to colors. | |
194 scoped_ptr<DictionaryValue> theme_colors; | |
195 | |
196 // A map of color names to colors. | |
197 scoped_ptr<DictionaryValue> theme_tints; | |
198 | |
199 // A map of display properties. | |
200 scoped_ptr<DictionaryValue> theme_display_properties; | |
201 | |
202 // Whether the extension is a theme. | |
203 bool is_theme; | |
204 | |
205 // The sites this extension has permission to talk to (using XHR, etc). | |
206 URLPatternList host_permissions; | |
207 | |
208 // The homepage for this extension. Useful if it is not hosted by Google and | |
209 // therefore does not have a Gallery URL. | |
210 GURL homepage_url; | |
211 | |
212 // URL for fetching an update manifest | |
213 GURL update_url; | |
214 | |
215 // A copy of the manifest that this extension was created from. | |
216 scoped_ptr<DictionaryValue> manifest_value; | |
217 | |
218 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs | |
219 // which override the handling of those URLs. | |
220 URLOverrideMap chrome_url_overrides; | |
221 | |
222 // Whether this extension uses app features. | |
223 bool is_app; | |
224 | |
225 // The local path inside the extension to use with the launcher. | |
226 std::string launch_local_path; | |
227 | |
228 // A web url to use with the launcher. Note that this might be relative or | |
229 // absolute. If relative, it is relative to web_origin. | |
230 std::string launch_web_url; | |
231 | |
232 // The type of container to launch into. | |
233 extension_misc::LaunchContainer launch_container; | |
234 | |
235 // The default size of the container when launching. Only respected for | |
236 // containers like panels and windows. | |
237 int launch_width; | |
238 int launch_height; | |
239 | |
240 // The Omnibox keyword for this extension, or empty if there is none. | |
241 std::string omnibox_keyword; | |
242 | |
243 protected: | |
244 friend class base::RefCountedThreadSafe<StaticData>; | |
245 ~StaticData(); | |
246 }; | |
247 | |
248 // Contains the subset of the extension's (private) data that can be modified | 103 // Contains the subset of the extension's (private) data that can be modified |
249 // after initialization. This class should only be accessed on the UI thread. | 104 // after initialization. This class should only be accessed on the UI thread. |
250 struct RuntimeData { | 105 struct RuntimeData { |
251 // We keep a cache of images loaded from extension resources based on their | 106 // We keep a cache of images loaded from extension resources based on their |
252 // path and a string representation of a size that may have been used to | 107 // path and a string representation of a size that may have been used to |
253 // scale it (or the empty string if the image is at its original size). | 108 // scale it (or the empty string if the image is at its original size). |
254 typedef std::pair<FilePath, std::string> ImageCacheKey; | 109 typedef std::pair<FilePath, std::string> ImageCacheKey; |
255 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; | 110 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
256 | 111 |
257 RuntimeData(); | 112 RuntimeData(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 static bool CanExecuteScriptOnPage( | 312 static bool CanExecuteScriptOnPage( |
458 const GURL& page_url, | 313 const GURL& page_url, |
459 bool can_execute_script_everywhere, | 314 bool can_execute_script_everywhere, |
460 const std::vector<URLPattern>* allowed_pages, | 315 const std::vector<URLPattern>* allowed_pages, |
461 UserScript* script, | 316 UserScript* script, |
462 std::string* error); | 317 std::string* error); |
463 | 318 |
464 // Adds an extension to the scripting whitelist. Used for testing only. | 319 // Adds an extension to the scripting whitelist. Used for testing only. |
465 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); | 320 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
466 | 321 |
467 const StaticData* static_data() const { return static_data_; } | |
468 | |
469 const FilePath& path() const { return static_data_->path; } | |
470 const GURL& url() const { return static_data_->extension_url; } | |
471 Location location() const { return static_data_->location; } | |
472 const std::string& id() const { return static_data_->id; } | |
473 const Version* version() const { return static_data_->version.get(); } | |
474 // String representation of the version number. | |
475 const std::string VersionString() const; | |
476 const std::string& name() const { return static_data_->name; } | |
477 const std::string& public_key() const { return static_data_->public_key; } | |
478 const std::string& description() const { return static_data_->description; } | |
479 bool converted_from_user_script() const { | |
480 return static_data_->converted_from_user_script; | |
481 } | |
482 const UserScriptList& content_scripts() const { | |
483 return static_data_->content_scripts; | |
484 } | |
485 ExtensionAction* page_action() const { | |
486 return static_data_->page_action.get(); | |
487 } | |
488 ExtensionAction* browser_action() const { | |
489 return static_data_->browser_action.get(); | |
490 } | |
491 const std::vector<PluginInfo>& plugins() const { | |
492 return static_data_->plugins; | |
493 } | |
494 const GURL& background_url() const { return static_data_->background_url; } | |
495 const GURL& options_url() const { return static_data_->options_url; } | |
496 const GURL& devtools_url() const { return static_data_->devtools_url; } | |
497 const std::vector<GURL>& toolstrips() const { | |
498 return static_data_->toolstrips; | |
499 } | |
500 const std::set<std::string>& api_permissions() const { | |
501 return static_data_->api_permissions; | |
502 } | |
503 const URLPatternList& host_permissions() const { | |
504 return static_data_->host_permissions; | |
505 } | |
506 | |
507 // Returns true if the extension has the specified API permission. | 322 // Returns true if the extension has the specified API permission. |
508 static bool HasApiPermission(const std::set<std::string>& api_permissions, | 323 static bool HasApiPermission(const std::set<std::string>& api_permissions, |
509 const std::string& function_name); | 324 const std::string& function_name); |
510 | 325 |
511 bool HasApiPermission(const std::string& function_name) const { | 326 bool HasApiPermission(const std::string& function_name) const { |
512 return HasApiPermission(this->api_permissions(), function_name); | 327 return HasApiPermission(this->api_permissions(), function_name); |
513 } | 328 } |
514 | 329 |
515 const ExtensionExtent& GetEffectiveHostPermissions() const { | 330 const ExtensionExtent& GetEffectiveHostPermissions() const { |
516 return static_data_->effective_host_permissions; | 331 return effective_host_permissions_; |
517 } | 332 } |
518 | 333 |
519 // Whether or not the extension is allowed permission for a URL pattern from | 334 // Whether or not the extension is allowed permission for a URL pattern from |
520 // the manifest. http, https, and chrome://favicon/ is allowed for all | 335 // the manifest. http, https, and chrome://favicon/ is allowed for all |
521 // extensions, while component extensions are allowed access to | 336 // extensions, while component extensions are allowed access to |
522 // chrome://resources. | 337 // chrome://resources. |
523 bool CanSpecifyHostPermission(const URLPattern& pattern) const; | 338 bool CanSpecifyHostPermission(const URLPattern& pattern) const; |
524 | 339 |
525 // Whether the extension has access to the given URL. | 340 // Whether the extension has access to the given URL. |
526 bool HasHostPermission(const GURL& url) const; | 341 bool HasHostPermission(const GURL& url) const; |
527 | 342 |
528 // Whether the extension has effective access to all hosts. This is true if | 343 // Whether the extension has effective access to all hosts. This is true if |
529 // there is a content script that matches all hosts, if there is a host | 344 // there is a content script that matches all hosts, if there is a host |
530 // permission grants access to all hosts (like <all_urls>) or an api | 345 // permission grants access to all hosts (like <all_urls>) or an api |
531 // permission that effectively grants access to all hosts (e.g. proxy, | 346 // permission that effectively grants access to all hosts (e.g. proxy, |
532 // network, etc.) | 347 // network, etc.) |
533 bool HasEffectiveAccessToAllHosts() const; | 348 bool HasEffectiveAccessToAllHosts() const; |
534 | 349 |
535 const GURL& update_url() const { return static_data_->update_url; } | |
536 | |
537 const ExtensionIconSet& icons() const { | |
538 return static_data_->icons; | |
539 } | |
540 | |
541 // Returns the Homepage URL for this extension. If homepage_url was not | 350 // Returns the Homepage URL for this extension. If homepage_url was not |
542 // specified in the manifest, this returns the Google Gallery URL. For | 351 // specified in the manifest, this returns the Google Gallery URL. For |
543 // third-party extensions, this returns a blank GURL. | 352 // third-party extensions, this returns a blank GURL. |
544 GURL GetHomepageURL() const; | 353 GURL GetHomepageURL() const; |
545 | 354 |
546 // Theme-related. | |
547 DictionaryValue* GetThemeImages() const { | |
548 return static_data_->theme_images.get(); | |
549 } | |
550 DictionaryValue* GetThemeColors() const { | |
551 return static_data_->theme_colors.get(); | |
552 } | |
553 DictionaryValue* GetThemeTints() const { | |
554 return static_data_->theme_tints.get(); | |
555 } | |
556 DictionaryValue* GetThemeDisplayProperties() const { | |
557 return static_data_->theme_display_properties.get(); | |
558 } | |
559 bool is_theme() const { return static_data_->is_theme; } | |
560 | |
561 // Returns a list of paths (relative to the extension dir) for images that | 355 // Returns a list of paths (relative to the extension dir) for images that |
562 // the browser might load (like themes and page action icons). | 356 // the browser might load (like themes and page action icons). |
563 std::set<FilePath> GetBrowserImages() const; | 357 std::set<FilePath> GetBrowserImages() const; |
564 | 358 |
565 // Get an extension icon as a resource or URL. | 359 // Get an extension icon as a resource or URL. |
566 ExtensionResource GetIconResource( | 360 ExtensionResource GetIconResource( |
567 int size, ExtensionIconSet::MatchType match_type) const; | 361 int size, ExtensionIconSet::MatchType match_type) const; |
568 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; | 362 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; |
569 | 363 |
570 const DictionaryValue* manifest_value() const { | |
571 return static_data_->manifest_value.get(); | |
572 } | |
573 | |
574 const std::string default_locale() const { | |
575 return static_data_->default_locale; | |
576 } | |
577 | |
578 // Chrome URL overrides (see ExtensionOverrideUI). | |
579 const URLOverrideMap& GetChromeURLOverrides() const { | |
580 return static_data_->chrome_url_overrides; | |
581 } | |
582 | |
583 const std::string omnibox_keyword() const { | |
584 return static_data_->omnibox_keyword; | |
585 } | |
586 | |
587 bool is_app() const { return static_data_->is_app; } | |
588 const ExtensionExtent& web_extent() const { | |
589 return static_data_->extent; | |
590 } | |
591 const std::string& launch_local_path() const { | |
592 return static_data_->launch_local_path; | |
593 } | |
594 const std::string& launch_web_url() const { | |
595 return static_data_->launch_web_url; | |
596 } | |
597 extension_misc::LaunchContainer launch_container() const { | |
598 return static_data_->launch_container; | |
599 } | |
600 int launch_width() const { return static_data_->launch_width; } | |
601 int launch_height() const { return static_data_->launch_height; } | |
602 bool incognito_split_mode() const { | |
603 return static_data_->incognito_split_mode; | |
604 } | |
605 | 364 |
606 // Gets the fully resolved absolute launch URL. | 365 // Gets the fully resolved absolute launch URL. |
607 GURL GetFullLaunchURL() const; | 366 GURL GetFullLaunchURL() const; |
608 | 367 |
| 368 // Image cache related methods. These are only valid on the UI thread and |
| 369 // not maintained by this class. See ImageLoadingTracker for usage. The |
| 370 // |original_size| parameter should be the size of the image at |source| |
| 371 // before any scaling may have been done to produce the pixels in |image|. |
| 372 void SetCachedImage(const ExtensionResource& source, |
| 373 const SkBitmap& image, |
| 374 const gfx::Size& original_size) const; |
| 375 bool HasCachedImage(const ExtensionResource& source, |
| 376 const gfx::Size& max_size) const; |
| 377 SkBitmap GetCachedImage(const ExtensionResource& source, |
| 378 const gfx::Size& max_size) const; |
| 379 // Returns true if this extension is a COMPONENT extension, or if it is |
| 380 // on the whitelist of extensions that can script all pages. |
| 381 bool CanExecuteScriptEverywhere() const; |
| 382 |
| 383 // Accessors: |
| 384 |
| 385 const FilePath& path() const { return path_; } |
| 386 const GURL& url() const { return extension_url_; } |
| 387 Location location() const { return location_; } |
| 388 const std::string& id() const { return id_; } |
| 389 const Version* version() const { return version_.get(); } |
| 390 const std::string VersionString() const; |
| 391 const std::string& name() const { return name_; } |
| 392 const std::string& public_key() const { return public_key_; } |
| 393 const std::string& description() const { return description_; } |
| 394 bool converted_from_user_script() const { |
| 395 return converted_from_user_script_; |
| 396 } |
| 397 const UserScriptList& content_scripts() const { return content_scripts_; } |
| 398 ExtensionAction* page_action() const { return page_action_.get(); } |
| 399 ExtensionAction* browser_action() const { return browser_action_.get(); } |
| 400 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 401 const GURL& background_url() const { return background_url_; } |
| 402 const GURL& options_url() const { return options_url_; } |
| 403 const GURL& devtools_url() const { return devtools_url_; } |
| 404 const std::vector<GURL>& toolstrips() const { return toolstrips_; } |
| 405 const std::set<std::string>& api_permissions() const { |
| 406 return api_permissions_; |
| 407 } |
| 408 const URLPatternList& host_permissions() const { return host_permissions_; } |
| 409 const GURL& update_url() const { return update_url_; } |
| 410 const ExtensionIconSet& icons() const { return icons_; } |
| 411 const DictionaryValue* manifest_value() const { |
| 412 return manifest_value_.get(); |
| 413 } |
| 414 const std::string default_locale() const { return default_locale_; } |
| 415 const URLOverrideMap& GetChromeURLOverrides() const { |
| 416 return chrome_url_overrides_; |
| 417 } |
| 418 const std::string omnibox_keyword() const { return omnibox_keyword_; } |
| 419 bool incognito_split_mode() const { return incognito_split_mode_; } |
| 420 |
| 421 // App-related. |
| 422 bool is_app() const { return is_app_; } |
| 423 bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); } |
| 424 bool is_packaged_app() const { return is_app() && web_extent().is_empty(); } |
| 425 const ExtensionExtent& web_extent() const { return extent_; } |
| 426 const std::string& launch_local_path() const { return launch_local_path_; } |
| 427 const std::string& launch_web_url() const { return launch_web_url_; } |
| 428 extension_misc::LaunchContainer launch_container() const { |
| 429 return launch_container_; |
| 430 } |
| 431 int launch_width() const { return launch_width_; } |
| 432 int launch_height() const { return launch_height_; } |
| 433 |
| 434 // Theme-related. |
| 435 bool is_theme() const { return is_theme_; } |
| 436 DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 437 DictionaryValue* GetThemeColors() const {return theme_colors_.get(); } |
| 438 DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
| 439 DictionaryValue* GetThemeDisplayProperties() const { |
| 440 return theme_display_properties_.get(); |
| 441 } |
| 442 |
609 // Whether the background page, if any, is ready. We don't load other | 443 // Whether the background page, if any, is ready. We don't load other |
610 // components until then. If there is no background page, we consider it to | 444 // components until then. If there is no background page, we consider it to |
611 // be ready. | 445 // be ready. |
612 bool GetBackgroundPageReady() const; | 446 bool GetBackgroundPageReady() const; |
613 void SetBackgroundPageReady() const; | 447 void SetBackgroundPageReady() const; |
614 | 448 |
615 // Getter and setter for the flag that specifies whether the extension is | 449 // Getter and setter for the flag that specifies whether the extension is |
616 // being upgraded. | 450 // being upgraded. |
617 bool being_upgraded() const { return GetRuntimeData()->being_upgraded; } | 451 bool being_upgraded() const { return GetRuntimeData()->being_upgraded; } |
618 void set_being_upgraded(bool value) const { | 452 void set_being_upgraded(bool value) const { |
619 GetRuntimeData()->being_upgraded = value; | 453 GetRuntimeData()->being_upgraded = value; |
620 } | 454 } |
621 | 455 |
622 // Image cache related methods. These are only valid on the UI thread and | |
623 // not maintained by this class. See ImageLoadingTracker for usage. The | |
624 // |original_size| parameter should be the size of the image at |source| | |
625 // before any scaling may have been done to produce the pixels in |image|. | |
626 void SetCachedImage(const ExtensionResource& source, | |
627 const SkBitmap& image, | |
628 const gfx::Size& original_size) const; | |
629 bool HasCachedImage(const ExtensionResource& source, | |
630 const gfx::Size& max_size) const; | |
631 SkBitmap GetCachedImage(const ExtensionResource& source, | |
632 const gfx::Size& max_size) const; | |
633 bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); } | |
634 bool is_packaged_app() const { return is_app() && web_extent().is_empty(); } | |
635 | |
636 // Returns true if this extension is a COMPONENT extension, or if it is | |
637 // on the whitelist of extensions that can script all pages. | |
638 bool CanExecuteScriptEverywhere() const; | |
639 | |
640 private: | 456 private: |
641 friend class base::RefCountedThreadSafe<Extension>; | 457 friend class base::RefCountedThreadSafe<Extension>; |
642 | 458 |
643 // Normalize the path for use by the extension. On Windows, this will make | 459 // Normalize the path for use by the extension. On Windows, this will make |
644 // sure the drive letter is uppercase. | 460 // sure the drive letter is uppercase. |
645 static FilePath MaybeNormalizePath(const FilePath& path); | 461 static FilePath MaybeNormalizePath(const FilePath& path); |
646 | 462 |
647 Extension(const FilePath& path, Location location); | 463 Extension(const FilePath& path, Location location); |
648 ~Extension(); | 464 ~Extension(); |
649 | 465 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 std::set<string16> GetSimplePermissionMessages() const; | 529 std::set<string16> GetSimplePermissionMessages() const; |
714 | 530 |
715 // The permission message displayed related to the host permissions for | 531 // The permission message displayed related to the host permissions for |
716 // this extension. | 532 // this extension. |
717 string16 GetHostPermissionMessage() const; | 533 string16 GetHostPermissionMessage() const; |
718 | 534 |
719 // Returns a mutable pointer to our runtime data. Can only be called on | 535 // Returns a mutable pointer to our runtime data. Can only be called on |
720 // the UI thread. | 536 // the UI thread. |
721 RuntimeData* GetRuntimeData() const; | 537 RuntimeData* GetRuntimeData() const; |
722 | 538 |
723 // Collection of extension data that doesn't change doesn't change once an | |
724 // Extension object has been initialized. The mutable version is valid only | |
725 // until InitFromValue finishes, to ensure we don't accidentally modify it | |
726 // post-initialization. | |
727 StaticData* mutable_static_data_; | |
728 scoped_refptr<const StaticData> static_data_; | |
729 | |
730 // Runtime data. | 539 // Runtime data. |
731 const RuntimeData runtime_data_; | 540 const RuntimeData runtime_data_; |
732 | 541 |
| 542 // A persistent, globally unique ID. An extension's ID is used in things |
| 543 // like directory structures and URLs, and is expected to not change across |
| 544 // versions. It is generated as a SHA-256 hash of the extension's public |
| 545 // key, or as a hash of the path in the case of unpacked extensions. |
| 546 std::string id_; |
| 547 |
| 548 // The extension's human-readable name. Name is used for display purpose. It |
| 549 // might be wrapped with unicode bidi control characters so that it is |
| 550 // displayed correctly in RTL context. |
| 551 // NOTE: Name is UTF-8 and may contain non-ascii characters. |
| 552 std::string name_; |
| 553 |
| 554 // The absolute path to the directory the extension is stored in. |
| 555 FilePath path_; |
| 556 |
| 557 // Default locale for fall back. Can be empty if extension is not localized. |
| 558 std::string default_locale_; |
| 559 |
| 560 // If true, a separate process will be used for the extension in incognito |
| 561 // mode. |
| 562 bool incognito_split_mode_; |
| 563 |
| 564 // Defines the set of URLs in the extension's web content. |
| 565 ExtensionExtent extent_; |
| 566 |
| 567 // The set of host permissions that the extension effectively has access to, |
| 568 // which is a merge of host_permissions_ and all of the match patterns in |
| 569 // any content scripts the extension has. This is used to determine which |
| 570 // URLs have the ability to load an extension's resources via embedded |
| 571 // chrome-extension: URLs (see extension_protocols.cc). |
| 572 ExtensionExtent effective_host_permissions_; |
| 573 |
| 574 // The set of module-level APIs this extension can use. |
| 575 std::set<std::string> api_permissions_; |
| 576 |
| 577 // The icons for the extension. |
| 578 ExtensionIconSet icons_; |
| 579 |
| 580 // The base extension url for the extension. |
| 581 GURL extension_url_; |
| 582 |
| 583 // The location the extension was loaded from. |
| 584 Location location_; |
| 585 |
| 586 // The extension's version. |
| 587 scoped_ptr<Version> version_; |
| 588 |
| 589 // An optional longer description of the extension. |
| 590 std::string description_; |
| 591 |
| 592 // True if the extension was generated from a user script. (We show slightly |
| 593 // different UI if so). |
| 594 bool converted_from_user_script_; |
| 595 |
| 596 // Paths to the content scripts the extension contains. |
| 597 UserScriptList content_scripts_; |
| 598 |
| 599 // The extension's page action, if any. |
| 600 scoped_ptr<ExtensionAction> page_action_; |
| 601 |
| 602 // The extension's browser action, if any. |
| 603 scoped_ptr<ExtensionAction> browser_action_; |
| 604 |
| 605 // Optional list of NPAPI plugins and associated properties. |
| 606 std::vector<PluginInfo> plugins_; |
| 607 |
| 608 // Optional URL to a master page of which a single instance should be always |
| 609 // loaded in the background. |
| 610 GURL background_url_; |
| 611 |
| 612 // Optional URL to a page for setting options/preferences. |
| 613 GURL options_url_; |
| 614 |
| 615 // Optional URL to a devtools extension page. |
| 616 GURL devtools_url_; |
| 617 |
| 618 // Optional list of toolstrips and associated properties. |
| 619 std::vector<GURL> toolstrips_; |
| 620 |
| 621 // The public key used to sign the contents of the crx package. |
| 622 std::string public_key_; |
| 623 |
| 624 // A map of resource id's to relative file paths. |
| 625 scoped_ptr<DictionaryValue> theme_images_; |
| 626 |
| 627 // A map of color names to colors. |
| 628 scoped_ptr<DictionaryValue> theme_colors_; |
| 629 |
| 630 // A map of color names to colors. |
| 631 scoped_ptr<DictionaryValue> theme_tints_; |
| 632 |
| 633 // A map of display properties. |
| 634 scoped_ptr<DictionaryValue> theme_display_properties_; |
| 635 |
| 636 // Whether the extension is a theme. |
| 637 bool is_theme_; |
| 638 |
| 639 // The sites this extension has permission to talk to (using XHR, etc). |
| 640 URLPatternList host_permissions_; |
| 641 |
| 642 // The homepage for this extension. Useful if it is not hosted by Google and |
| 643 // therefore does not have a Gallery URL. |
| 644 GURL homepage_url_; |
| 645 |
| 646 // URL for fetching an update manifest |
| 647 GURL update_url_; |
| 648 |
| 649 // A copy of the manifest that this extension was created from. |
| 650 scoped_ptr<DictionaryValue> manifest_value_; |
| 651 |
| 652 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 653 // which override the handling of those URLs. (see ExtensionOverrideUI). |
| 654 URLOverrideMap chrome_url_overrides_; |
| 655 |
| 656 // Whether this extension uses app features. |
| 657 bool is_app_; |
| 658 |
| 659 // The local path inside the extension to use with the launcher. |
| 660 std::string launch_local_path_; |
| 661 |
| 662 // A web url to use with the launcher. Note that this might be relative or |
| 663 // absolute. If relative, it is relative to web_origin. |
| 664 std::string launch_web_url_; |
| 665 |
| 666 // The type of container to launch into. |
| 667 extension_misc::LaunchContainer launch_container_; |
| 668 |
| 669 // The default size of the container when launching. Only respected for |
| 670 // containers like panels and windows. |
| 671 int launch_width_; |
| 672 int launch_height_; |
| 673 |
| 674 // The Omnibox keyword for this extension, or empty if there is none. |
| 675 std::string omnibox_keyword_; |
| 676 |
733 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); | 677 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); |
734 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueInvalid); | 678 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueInvalid); |
735 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueValid); | 679 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueValid); |
736 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueValidNameInRTL); | 680 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, InitFromValueValidNameInRTL); |
737 FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps); | 681 FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, Apps); |
738 | 682 |
739 DISALLOW_COPY_AND_ASSIGN(Extension); | 683 DISALLOW_COPY_AND_ASSIGN(Extension); |
740 }; | 684 }; |
741 | 685 |
742 typedef std::vector< scoped_refptr<const Extension> > ExtensionList; | 686 typedef std::vector< scoped_refptr<const Extension> > ExtensionList; |
(...skipping 26 matching lines...) Expand all Loading... |
769 std::set<std::string> extension_api_permissions; | 713 std::set<std::string> extension_api_permissions; |
770 // TODO(akalin): Once we have a unified ExtensionType, replace the | 714 // TODO(akalin): Once we have a unified ExtensionType, replace the |
771 // below member variables with a member of that type. | 715 // below member variables with a member of that type. |
772 bool is_theme; | 716 bool is_theme; |
773 bool is_app; | 717 bool is_app; |
774 bool converted_from_user_script; | 718 bool converted_from_user_script; |
775 GURL update_url; | 719 GURL update_url; |
776 }; | 720 }; |
777 | 721 |
778 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 722 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |