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

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

Issue 10815028: Make ActiveTabPermissionManager also grant the tabs permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <map> 10 #include <map>
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 // Parses the host and api permissions from the specified permission |key| 432 // Parses the host and api permissions from the specified permission |key|
433 // from |manifest_|. 433 // from |manifest_|.
434 bool ParsePermissions(const char* key, 434 bool ParsePermissions(const char* key,
435 string16* error, 435 string16* error,
436 APIPermissionSet* api_permissions, 436 APIPermissionSet* api_permissions,
437 URLPatternSet* host_permissions); 437 URLPatternSet* host_permissions);
438 438
439 bool HasAPIPermission(APIPermission::ID permission) const; 439 bool HasAPIPermission(APIPermission::ID permission) const;
440 bool HasAPIPermission(const std::string& function_name) const; 440 bool HasAPIPermission(const std::string& function_name) const;
441 bool HasAPIPermissionForTab(int tab_id, APIPermission::ID permission) const;
441 442
442 const URLPatternSet& GetEffectiveHostPermissions() const; 443 const URLPatternSet& GetEffectiveHostPermissions() const;
443 444
444 // Returns true if the extension can silently increase its permission level. 445 // Returns true if the extension can silently increase its permission level.
445 // Users must approve permissions for unpacked and packed extensions in the 446 // Users must approve permissions for unpacked and packed extensions in the
446 // following situations: 447 // following situations:
447 // - when installing or upgrading packed extensions 448 // - when installing or upgrading packed extensions
448 // - when installing unpacked extensions that have NPAPI plugins 449 // - when installing unpacked extensions that have NPAPI plugins
449 // - when either type of extension requests optional permissions 450 // - when either type of extension requests optional permissions
450 bool CanSilentlyIncreasePermissions() const; 451 bool CanSilentlyIncreasePermissions() const;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 553
553 // Returns true if the extension should be displayed in the extension 554 // Returns true if the extension should be displayed in the extension
554 // settings page (i.e. chrome://extensions). 555 // settings page (i.e. chrome://extensions).
555 bool ShouldDisplayInExtensionSettings() const; 556 bool ShouldDisplayInExtensionSettings() const;
556 557
557 // Returns true if the extension has a content script declared at |url|. 558 // Returns true if the extension has a content script declared at |url|.
558 bool HasContentScriptAtURL(const GURL& url) const; 559 bool HasContentScriptAtURL(const GURL& url) const;
559 560
560 // Gets the tab-specific host permissions of |tab_id|, or NULL if there 561 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
561 // aren't any. 562 // aren't any.
562 // 563 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
563 // This is a weak pointer. Callers should create a copy before mutating any 564 const;
564 // tab specific permissions.
565 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
566 565
567 // Sets the tab-specific host permissions of |tab_id| to |permissions|. 566 // Updates the tab-specific permissions of |tab_id| to includes those from
568 void SetTabSpecificHostPermissions(int tab_id, 567 // |permissions|.
569 const URLPatternSet& permissions) const; 568 void UpdateTabSpecificPermissions(int tab_id,
569 const PermissionSet* permissions) const;
570 570
571 // Clears the tab-specific host permissions of |tab_id|. 571 // Clears the tab-specific permissions of |tab_id|.
572 void ClearTabSpecificHostPermissions(int tab_id) const; 572 void ClearTabSpecificPermissions(int tab_id) const;
573 573
574 // Accessors: 574 // Accessors:
575 575
576 const FilePath& path() const { return path_; } 576 const FilePath& path() const { return path_; }
577 const GURL& url() const { return extension_url_; } 577 const GURL& url() const { return extension_url_; }
578 Location location() const; 578 Location location() const;
579 const std::string& id() const; 579 const std::string& id() const;
580 const Version* version() const { return version_.get(); } 580 const Version* version() const { return version_.get(); }
581 const std::string VersionString() const; 581 const std::string VersionString() const;
582 const std::string& name() const { return name_; } 582 const std::string& name() const { return name_; }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 713
714 class RuntimeData { 714 class RuntimeData {
715 public: 715 public:
716 RuntimeData(); 716 RuntimeData();
717 explicit RuntimeData(const PermissionSet* active); 717 explicit RuntimeData(const PermissionSet* active);
718 ~RuntimeData(); 718 ~RuntimeData();
719 719
720 void SetActivePermissions(const PermissionSet* active); 720 void SetActivePermissions(const PermissionSet* active);
721 scoped_refptr<const PermissionSet> GetActivePermissions() const; 721 scoped_refptr<const PermissionSet> GetActivePermissions() const;
722 722
723 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const; 723 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id)
724 void SetTabSpecificHostPermissions(int tab_id, 724 const;
725 const URLPatternSet& permissions); 725 void UpdateTabSpecificPermissions(int tab_id,
726 void ClearTabSpecificHostPermissions(int tab_id); 726 const PermissionSet* permissions);
727 void ClearTabSpecificPermissions(int tab_id);
727 728
728 private: 729 private:
729 friend class base::RefCountedThreadSafe<RuntimeData>; 730 friend class base::RefCountedThreadSafe<RuntimeData>;
730 731
731 scoped_refptr<const PermissionSet> active_permissions_; 732 scoped_refptr<const PermissionSet> active_permissions_;
732 733
733 typedef std::map<int, linked_ptr<const URLPatternSet> > 734 typedef std::map<int, scoped_refptr<const PermissionSet> >
734 TabHostPermissionsMap; 735 TabPermissionsMap;
735 TabHostPermissionsMap tab_specific_host_permissions_; 736 TabPermissionsMap tab_specific_permissions_;
736 }; 737 };
737 738
738 // Chooses the extension ID for an extension based on a variety of criteria. 739 // Chooses the extension ID for an extension based on a variety of criteria.
739 // The chosen ID will be set in |manifest|. 740 // The chosen ID will be set in |manifest|.
740 static bool InitExtensionID(extensions::Manifest* manifest, 741 static bool InitExtensionID(extensions::Manifest* manifest,
741 const FilePath& path, 742 const FilePath& path,
742 const std::string& explicit_id, 743 const std::string& explicit_id,
743 int creation_flags, 744 int creation_flags,
744 string16* error); 745 string16* error);
745 746
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1181
1181 UpdatedExtensionPermissionsInfo( 1182 UpdatedExtensionPermissionsInfo(
1182 const Extension* extension, 1183 const Extension* extension,
1183 const PermissionSet* permissions, 1184 const PermissionSet* permissions,
1184 Reason reason); 1185 Reason reason);
1185 }; 1186 };
1186 1187
1187 } // namespace extensions 1188 } // namespace extensions
1188 1189
1189 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1190 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698