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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension.h
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 9713fd89a64cfbf0125da7327053b60729bfe716..d33bee0c20c031f0feb8bc2c71145b984b36a100 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -494,6 +494,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// This method is also aware of certain special pages that extensions are
// usually not allowed to run script on.
bool CanExecuteScriptOnPage(const GURL& page_url,
+ int tab_id,
const UserScript* script,
std::string* error) const;
@@ -505,7 +506,9 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// page as an image. Since a page may contain sensitive information, this
// is restricted to the extension's host permissions as well as the
// extension page itself.
- bool CanCaptureVisiblePage(const GURL& page_url, std::string* error) const;
+ bool CanCaptureVisiblePage(const GURL& page_url,
+ int tab_id,
+ std::string* error) const;
// Returns true if this extension updates itself using the extension
// gallery.
@@ -534,6 +537,35 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// shown for this extension in the location bar.
ExtensionAction* GetScriptBadge() const;
+ // Gets the tab-specific host permissions of |tab_id|, or NULL if there
+ // aren't any.
+ //
+ // This is a weak pointer. Callers should create a copy before mutating any
+ // tab specific permissions.
+ const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
+
+ // Sets the tab-specific host permissions of |tab_id| to |permissions|.
+ void SetTabSpecificHostPermissions(int tab_id,
+ const URLPatternSet& permissions) const;
+
+ // Clears the tab-specific host permissions of |tab_id|.
+ void ClearTabSpecificHostPermissions(int tab_id) const;
+
+ // Gets all active host permissions for all tabs. This includes both those
+ // from active permissions as well as those for each tab.
+ //
+ // This is a weak pointer. Callers should create a copy before mutating the
+ // active permissions or any tab specific permissions.
+ const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
+
+ // Explicitly gets/sets the tab-specific host permissions for every tab.
+ // These methods are for marshalling this to/from ExtensionMsg_Loaded_Params.
+ // Puts the tab-specific origins for every tab in |out|.
+ void GetAllTabSpecificHostPermissions(
+ std::map<int, URLPatternSet>* out) const;
+ void SetAllTabSpecificHostPermissions(
+ const std::map<int, URLPatternSet>& origins) const;
+
// Accessors:
const FilePath& path() const { return path_; }
@@ -685,9 +717,27 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
void SetActivePermissions(const ExtensionPermissionSet* active);
scoped_refptr<const ExtensionPermissionSet> GetActivePermissions() const;
+ const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
+ void SetTabSpecificHostPermissions(int tab_id,
+ const URLPatternSet& permissions);
+ void ClearTabSpecificHostPermissions(int tab_id);
+
+ const URLPatternSet* GetActiveHostPermissionsForAllTabs() const;
+
+ void GetAllTabSpecificHostPermissions(
+ std::map<int, URLPatternSet>* out) const;
+ void SetAllTabSpecificHostPermissions(
+ const std::map<int, URLPatternSet>& in);
+
private:
friend class base::RefCountedThreadSafe<RuntimeData>;
+
scoped_refptr<const ExtensionPermissionSet> active_permissions_;
+
+ typedef std::map<int, linked_ptr<URLPatternSet> > TabHostPermissionsMap;
+ TabHostPermissionsMap tab_specific_host_permissions_;
+
+ mutable scoped_ptr<URLPatternSet> active_host_permissions_for_all_tabs_;
};
// Chooses the extension ID for an extension based on a variety of criteria.

Powered by Google App Engine
This is Rietveld 408576698