OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 const gfx::Size& max_size) const; | 487 const gfx::Size& max_size) const; |
488 | 488 |
489 // Returns true if this extension can execute script on a page. If a | 489 // Returns true if this extension can execute script on a page. If a |
490 // UserScript object is passed, permission to run that specific script is | 490 // UserScript object is passed, permission to run that specific script is |
491 // checked (using its matches list). Otherwise, permission to execute script | 491 // checked (using its matches list). Otherwise, permission to execute script |
492 // programmatically is checked (using the extension's host permission). | 492 // programmatically is checked (using the extension's host permission). |
493 // | 493 // |
494 // This method is also aware of certain special pages that extensions are | 494 // This method is also aware of certain special pages that extensions are |
495 // usually not allowed to run script on. | 495 // usually not allowed to run script on. |
496 bool CanExecuteScriptOnPage(const GURL& page_url, | 496 bool CanExecuteScriptOnPage(const GURL& page_url, |
| 497 int tab_id, |
497 const UserScript* script, | 498 const UserScript* script, |
498 std::string* error) const; | 499 std::string* error) const; |
499 | 500 |
500 // Returns true if this extension is a COMPONENT extension, or if it is | 501 // Returns true if this extension is a COMPONENT extension, or if it is |
501 // on the whitelist of extensions that can script all pages. | 502 // on the whitelist of extensions that can script all pages. |
502 bool CanExecuteScriptEverywhere() const; | 503 bool CanExecuteScriptEverywhere() const; |
503 | 504 |
504 // Returns true if this extension is allowed to obtain the contents of a | 505 // Returns true if this extension is allowed to obtain the contents of a |
505 // page as an image. Since a page may contain sensitive information, this | 506 // page as an image. Since a page may contain sensitive information, this |
506 // is restricted to the extension's host permissions as well as the | 507 // is restricted to the extension's host permissions as well as the |
507 // extension page itself. | 508 // extension page itself. |
508 bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const; | 509 bool CanCaptureVisiblePage(const GURL& page_url, |
| 510 int tab_id, |
| 511 std::string* error) const; |
509 | 512 |
510 // Returns true if this extension updates itself using the extension | 513 // Returns true if this extension updates itself using the extension |
511 // gallery. | 514 // gallery. |
512 bool UpdatesFromGallery() const; | 515 bool UpdatesFromGallery() const; |
513 | 516 |
514 // Returns true if this extension or app includes areas within |origin|. | 517 // Returns true if this extension or app includes areas within |origin|. |
515 bool OverlapsWithOrigin(const GURL& origin) const; | 518 bool OverlapsWithOrigin(const GURL& origin) const; |
516 | 519 |
517 // Returns the sync bucket to use for this extension. | 520 // Returns the sync bucket to use for this extension. |
518 SyncType GetSyncType() const; | 521 SyncType GetSyncType() const; |
519 | 522 |
520 // Returns true if the extension should be synced. | 523 // Returns true if the extension should be synced. |
521 bool IsSyncable() const; | 524 bool IsSyncable() const; |
522 | 525 |
523 // Returns true if the extension should be displayed in the launcher. | 526 // Returns true if the extension should be displayed in the launcher. |
524 bool ShouldDisplayInLauncher() const; | 527 bool ShouldDisplayInLauncher() const; |
525 | 528 |
526 // Returns true if the extension should be displayed in the extension | 529 // Returns true if the extension should be displayed in the extension |
527 // settings page (i.e. chrome://extensions). | 530 // settings page (i.e. chrome://extensions). |
528 bool ShouldDisplayInExtensionSettings() const; | 531 bool ShouldDisplayInExtensionSettings() const; |
529 | 532 |
530 // Returns true if the extension has a content script declared at |url|. | 533 // Returns true if the extension has a content script declared at |url|. |
531 bool HasContentScriptAtURL(const GURL& url) const; | 534 bool HasContentScriptAtURL(const GURL& url) const; |
532 | 535 |
533 // Returns an ExtensionAction representing the script badge that should be | 536 // Returns an ExtensionAction representing the script badge that should be |
534 // shown for this extension in the location bar. | 537 // shown for this extension in the location bar. |
535 ExtensionAction* GetScriptBadge() const; | 538 ExtensionAction* GetScriptBadge() const; |
536 | 539 |
| 540 // Gets the tab-specific host permissions of |tab_id|, or NULL if there |
| 541 // aren't any. |
| 542 // |
| 543 // This is a weak pointer. Callers should create a copy before mutating any |
| 544 // tab specific permissions. |
| 545 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const; |
| 546 |
| 547 // Sets the tab-specific host permissions of |tab_id| to |permissions|. |
| 548 void SetTabSpecificHostPermissions(int tab_id, |
| 549 const URLPatternSet& permissions) const; |
| 550 |
| 551 // Clears the tab-specific host permissions of |tab_id|. |
| 552 void ClearTabSpecificHostPermissions(int tab_id) const; |
| 553 |
537 // Accessors: | 554 // Accessors: |
538 | 555 |
539 const FilePath& path() const { return path_; } | 556 const FilePath& path() const { return path_; } |
540 const GURL& url() const { return extension_url_; } | 557 const GURL& url() const { return extension_url_; } |
541 Location location() const; | 558 Location location() const; |
542 const std::string& id() const; | 559 const std::string& id() const; |
543 const Version* version() const { return version_.get(); } | 560 const Version* version() const { return version_.get(); } |
544 const std::string VersionString() const; | 561 const std::string VersionString() const; |
545 const std::string& name() const { return name_; } | 562 const std::string& name() const { return name_; } |
546 const std::string& non_localized_name() const { return non_localized_name_; } | 563 const std::string& non_localized_name() const { return non_localized_name_; } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 695 |
679 class RuntimeData { | 696 class RuntimeData { |
680 public: | 697 public: |
681 RuntimeData(); | 698 RuntimeData(); |
682 explicit RuntimeData(const ExtensionPermissionSet* active); | 699 explicit RuntimeData(const ExtensionPermissionSet* active); |
683 ~RuntimeData(); | 700 ~RuntimeData(); |
684 | 701 |
685 void SetActivePermissions(const ExtensionPermissionSet* active); | 702 void SetActivePermissions(const ExtensionPermissionSet* active); |
686 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; | 703 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; |
687 | 704 |
| 705 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const; |
| 706 void SetTabSpecificHostPermissions(int tab_id, |
| 707 const URLPatternSet& permissions); |
| 708 void ClearTabSpecificHostPermissions(int tab_id); |
| 709 |
688 private: | 710 private: |
689 friend class base::RefCountedThreadSafe<RuntimeData>; | 711 friend class base::RefCountedThreadSafe<RuntimeData>; |
| 712 |
690 scoped_refptr<const ExtensionPermissionSet> active_permissions_; | 713 scoped_refptr<const ExtensionPermissionSet> active_permissions_; |
| 714 |
| 715 typedef std::map<int, linked_ptr<const URLPatternSet> > |
| 716 TabHostPermissionsMap; |
| 717 TabHostPermissionsMap tab_specific_host_permissions_; |
691 }; | 718 }; |
692 | 719 |
693 // Chooses the extension ID for an extension based on a variety of criteria. | 720 // Chooses the extension ID for an extension based on a variety of criteria. |
694 // The chosen ID will be set in |manifest|. | 721 // The chosen ID will be set in |manifest|. |
695 static bool InitExtensionID(extensions::Manifest* manifest, | 722 static bool InitExtensionID(extensions::Manifest* manifest, |
696 const FilePath& path, | 723 const FilePath& path, |
697 const std::string& explicit_id, | 724 const std::string& explicit_id, |
698 int creation_flags, | 725 int creation_flags, |
699 string16* error); | 726 string16* error); |
700 | 727 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 | 1163 |
1137 UpdatedExtensionPermissionsInfo( | 1164 UpdatedExtensionPermissionsInfo( |
1138 const Extension* extension, | 1165 const Extension* extension, |
1139 const ExtensionPermissionSet* permissions, | 1166 const ExtensionPermissionSet* permissions, |
1140 Reason reason); | 1167 Reason reason); |
1141 }; | 1168 }; |
1142 | 1169 |
1143 } // namespace extensions | 1170 } // namespace extensions |
1144 | 1171 |
1145 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1172 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |