Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chrome/common/extensions/extension.h

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: many more tests Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
554 // Gets all active host permissions for all tabs. This includes both those
555 // from active permissions as well as those for each tab.
556 //
557 // This is a weak pointer. Callers should create a copy before mutating the
558 // active permissions or any tab specific permissions.
559 const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
560
561 // Explicitly gets/sets the tab-specific host permissions for every tab.
562 // These methods are for marshalling this to/from ExtensionMsg_Loaded_Params.
563 // Puts the tab-specific origins for every tab in |out|.
564 void GetAllTabSpecificHostPermissions(
565 std::map<int, URLPatternSet>* out) const;
566 void SetAllTabSpecificHostPermissions(
567 const std::map<int, URLPatternSet>& origins) const;
568
537 // Accessors: 569 // Accessors:
538 570
539 const FilePath& path() const { return path_; } 571 const FilePath& path() const { return path_; }
540 const GURL& url() const { return extension_url_; } 572 const GURL& url() const { return extension_url_; }
541 Location location() const; 573 Location location() const;
542 const std::string& id() const; 574 const std::string& id() const;
543 const Version* version() const { return version_.get(); } 575 const Version* version() const { return version_.get(); }
544 const std::string VersionString() const; 576 const std::string VersionString() const;
545 const std::string& name() const { return name_; } 577 const std::string& name() const { return name_; }
546 const std::string& non_localized_name() const { return non_localized_name_; } 578 const std::string& non_localized_name() const { return non_localized_name_; }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 710
679 class RuntimeData { 711 class RuntimeData {
680 public: 712 public:
681 RuntimeData(); 713 RuntimeData();
682 explicit RuntimeData(const ExtensionPermissionSet* active); 714 explicit RuntimeData(const ExtensionPermissionSet* active);
683 ~RuntimeData(); 715 ~RuntimeData();
684 716
685 void SetActivePermissions(const ExtensionPermissionSet* active); 717 void SetActivePermissions(const ExtensionPermissionSet* active);
686 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; 718 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
687 719
720 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
721 void SetTabSpecificHostPermissions(int tab_id,
722 const URLPatternSet& permissions);
723 void ClearTabSpecificHostPermissions(int tab_id);
724
725 const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
726
727 void GetAllTabSpecificHostPermissions(
728 std::map<int, URLPatternSet>* out) const;
729 void SetAllTabSpecificHostPermissions(
730 const std::map<int, URLPatternSet>& in);
731
688 private: 732 private:
689 friend class base::RefCountedThreadSafe<RuntimeData>; 733 friend class base::RefCountedThreadSafe<RuntimeData>;
734
690 scoped_refptr<const ExtensionPermissionSet> active_permissions_; 735 scoped_refptr<const ExtensionPermissionSet> active_permissions_;
736
737 typedef std::map<int, linked_ptr<URLPatternSet> > TabHostPermissionsMap;
738 TabHostPermissionsMap tab_specific_host_permissions_;
739
740 mutable scoped_ptr<URLPatternSet> active_host_permissions_for_all_tabs_;
691 }; 741 };
692 742
693 // Chooses the extension ID for an extension based on a variety of criteria. 743 // Chooses the extension ID for an extension based on a variety of criteria.
694 // The chosen ID will be set in |manifest|. 744 // The chosen ID will be set in |manifest|.
695 static bool InitExtensionID(extensions::Manifest* manifest, 745 static bool InitExtensionID(extensions::Manifest* manifest,
696 const FilePath& path, 746 const FilePath& path,
697 const std::string& explicit_id, 747 const std::string& explicit_id,
698 int creation_flags, 748 int creation_flags,
699 string16* error); 749 string16* error);
700 750
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1182
1133 UpdatedExtensionPermissionsInfo( 1183 UpdatedExtensionPermissionsInfo(
1134 const Extension* extension, 1184 const Extension* extension,
1135 const ExtensionPermissionSet* permissions, 1185 const ExtensionPermissionSet* permissions,
1136 Reason reason); 1186 Reason reason);
1137 }; 1187 };
1138 1188
1139 } // namespace extensions 1189 } // namespace extensions
1140 1190
1141 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1191 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698