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

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: a unit test 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 const gfx::Size& max_size) const; 478 const gfx::Size& max_size) const;
479 479
480 // Returns true if this extension can execute script on a page. If a 480 // Returns true if this extension can execute script on a page. If a
481 // UserScript object is passed, permission to run that specific script is 481 // UserScript object is passed, permission to run that specific script is
482 // checked (using its matches list). Otherwise, permission to execute script 482 // checked (using its matches list). Otherwise, permission to execute script
483 // programmatically is checked (using the extension's host permission). 483 // programmatically is checked (using the extension's host permission).
484 // 484 //
485 // This method is also aware of certain special pages that extensions are 485 // This method is also aware of certain special pages that extensions are
486 // usually not allowed to run script on. 486 // usually not allowed to run script on.
487 bool CanExecuteScriptOnPage(const GURL& page_url, 487 bool CanExecuteScriptOnPage(const GURL& page_url,
488 int tab_id,
488 const UserScript* script, 489 const UserScript* script,
489 std::string* error) const; 490 std::string* error) const;
490 491
491 // Returns true if this extension is a COMPONENT extension, or if it is 492 // Returns true if this extension is a COMPONENT extension, or if it is
492 // on the whitelist of extensions that can script all pages. 493 // on the whitelist of extensions that can script all pages.
493 bool CanExecuteScriptEverywhere() const; 494 bool CanExecuteScriptEverywhere() const;
494 495
495 // Returns true if this extension is allowed to obtain the contents of a 496 // Returns true if this extension is allowed to obtain the contents of a
496 // page as an image. Since a page may contain sensitive information, this 497 // page as an image. Since a page may contain sensitive information, this
497 // is restricted to the extension's host permissions as well as the 498 // is restricted to the extension's host permissions as well as the
498 // extension page itself. 499 // extension page itself.
499 bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const; 500 bool CanCaptureVisiblePage(const GURL& page_url,
501 int tab_id,
502 std::string* error) const;
500 503
501 // Returns true if this extension updates itself using the extension 504 // Returns true if this extension updates itself using the extension
502 // gallery. 505 // gallery.
503 bool UpdatesFromGallery() const; 506 bool UpdatesFromGallery() const;
504 507
505 // Returns true if this extension or app includes areas within |origin|. 508 // Returns true if this extension or app includes areas within |origin|.
506 bool OverlapsWithOrigin(const GURL& origin) const; 509 bool OverlapsWithOrigin(const GURL& origin) const;
507 510
508 // Returns the sync bucket to use for this extension. 511 // Returns the sync bucket to use for this extension.
509 SyncType GetSyncType() const; 512 SyncType GetSyncType() const;
510 513
511 // Returns true if the extension should be synced. 514 // Returns true if the extension should be synced.
512 bool IsSyncable() const; 515 bool IsSyncable() const;
513 516
514 // Returns true if the extension should be displayed in the launcher. 517 // Returns true if the extension should be displayed in the launcher.
515 bool ShouldDisplayInLauncher() const; 518 bool ShouldDisplayInLauncher() const;
516 519
517 // Returns true if the extension should be displayed in the extension 520 // Returns true if the extension should be displayed in the extension
518 // settings page (i.e. chrome://extensions). 521 // settings page (i.e. chrome://extensions).
519 bool ShouldDisplayInExtensionSettings() const; 522 bool ShouldDisplayInExtensionSettings() const;
520 523
521 // Returns true if the extension has a content script declared at |url|. 524 // Returns true if the extension has a content script declared at |url|.
522 bool HasContentScriptAtURL(const GURL& url) const; 525 bool HasContentScriptAtURL(const GURL& url) const;
523 526
524 // Returns an ExtensionAction representing the script badge that should be 527 // Returns an ExtensionAction representing the script badge that should be
525 // shown for this extension in the location bar. 528 // shown for this extension in the location bar.
526 ExtensionAction* GetScriptBadge() const; 529 ExtensionAction* GetScriptBadge() const;
527 530
531 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
532 // aren't any.
533 //
534 // This is a weak pointer. Callers should create a copy before mutating any
535 // tab specific permissions.
536 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
537
538 // Sets the tab-specific host permissions of |tab_id| to |permissions|.
539 void SetTabSpecificHostPermissions(int tab_id,
540 const URLPatternSet& permissions) const;
541
542 // Clears the tab-specific host permissions of |tab_id|.
543 void ClearTabSpecificHostPermissions(int tab_id) const;
544
545 // Gets all active host permissions for all tabs. This includes both those
546 // from active permissions as well as those for each tab.
547 //
548 // This is a weak pointer. Callers should create a copy before mutating the
549 // active permissions or any tab specific permissions.
550 const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
551
552 // Explicitly gets/sets the tab-specific host permissions for every tab.
553 // These methods are for marshalling this to/from ExtensionMsg_Loaded_Params.
554 // Puts the tab-specific origins for every tab in |out|.
555 void GetAllTabSpecificHostPermissions(
556 std::map<int, URLPatternSet>* out) const;
557 void SetAllTabSpecificHostPermissions(
558 const std::map<int, URLPatternSet>& origins) const;
559
528 // Accessors: 560 // Accessors:
529 561
530 const FilePath& path() const { return path_; } 562 const FilePath& path() const { return path_; }
531 const GURL& url() const { return extension_url_; } 563 const GURL& url() const { return extension_url_; }
532 Location location() const; 564 Location location() const;
533 const std::string& id() const; 565 const std::string& id() const;
534 const Version* version() const { return version_.get(); } 566 const Version* version() const { return version_.get(); }
535 const std::string VersionString() const; 567 const std::string VersionString() const;
536 const std::string& name() const { return name_; } 568 const std::string& name() const { return name_; }
537 const std::string& non_localized_name() const { return non_localized_name_; } 569 const std::string& non_localized_name() const { return non_localized_name_; }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 705
674 class RuntimeData { 706 class RuntimeData {
675 public: 707 public:
676 RuntimeData(); 708 RuntimeData();
677 explicit RuntimeData(const ExtensionPermissionSet* active); 709 explicit RuntimeData(const ExtensionPermissionSet* active);
678 ~RuntimeData(); 710 ~RuntimeData();
679 711
680 void SetActivePermissions(const ExtensionPermissionSet* active); 712 void SetActivePermissions(const ExtensionPermissionSet* active);
681 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const; 713 scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
682 714
715 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
716 void SetTabSpecificHostPermissions(int tab_id,
717 const URLPatternSet& permissions);
718 void ClearTabSpecificHostPermissions(int tab_id);
719
720 const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
721
722 void GetAllTabSpecificHostPermissions(
723 std::map<int, URLPatternSet>* out) const;
724 void SetAllTabSpecificHostPermissions(
725 const std::map<int, URLPatternSet>& in);
726
683 private: 727 private:
684 friend class base::RefCountedThreadSafe<RuntimeData>; 728 friend class base::RefCountedThreadSafe<RuntimeData>;
729
685 scoped_refptr<const ExtensionPermissionSet> active_permissions_; 730 scoped_refptr<const ExtensionPermissionSet> active_permissions_;
731
732 typedef std::map<int, linked_ptr<URLPatternSet> > TabHostPermissionsMap;
733 TabHostPermissionsMap tab_specific_host_permissions_;
734
735 mutable scoped_ptr<URLPatternSet> active_host_permissions_for_all_tabs_;
686 }; 736 };
687 737
688 // Chooses the extension ID for an extension based on a variety of criteria. 738 // Chooses the extension ID for an extension based on a variety of criteria.
689 // The chosen ID will be set in |manifest|. 739 // The chosen ID will be set in |manifest|.
690 static bool InitExtensionID(extensions::Manifest* manifest, 740 static bool InitExtensionID(extensions::Manifest* manifest,
691 const FilePath& path, 741 const FilePath& path,
692 const std::string& explicit_id, 742 const std::string& explicit_id,
693 int creation_flags, 743 int creation_flags,
694 string16* error); 744 string16* error);
695 745
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1167
1118 UpdatedExtensionPermissionsInfo( 1168 UpdatedExtensionPermissionsInfo(
1119 const Extension* extension, 1169 const Extension* extension,
1120 const ExtensionPermissionSet* permissions, 1170 const ExtensionPermissionSet* permissions,
1121 Reason reason); 1171 Reason reason);
1122 }; 1172 };
1123 1173
1124 } // namespace extensions 1174 } // namespace extensions
1125 1175
1126 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1176 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698