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

Side by Side Diff: extensions/common/permissions/permissions_data.h

Issue 321533003: Separate PermissionsData::CanExecuteScriptOnPage into two functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 class PolicyDelegate { 40 class PolicyDelegate {
41 public: 41 public:
42 virtual ~PolicyDelegate() {} 42 virtual ~PolicyDelegate() {}
43 43
44 // Returns false if script access should be blocked on this page. 44 // Returns false if script access should be blocked on this page.
45 // Otherwise, default policy should decide. 45 // Otherwise, default policy should decide.
46 virtual bool CanExecuteScriptOnPage(const Extension* extension, 46 virtual bool CanExecuteScriptOnPage(const Extension* extension,
47 const GURL& document_url, 47 const GURL& document_url,
48 const GURL& top_document_url, 48 const GURL& top_document_url,
49 int tab_id, 49 int tab_id,
50 const UserScript* script,
51 int process_id, 50 int process_id,
52 std::string* error) = 0; 51 std::string* error) = 0;
53 }; 52 };
54 53
55 static void SetPolicyDelegate(PolicyDelegate* delegate); 54 static void SetPolicyDelegate(PolicyDelegate* delegate);
56 55
57 PermissionsData(const Extension* extension); 56 PermissionsData(const Extension* extension);
58 virtual ~PermissionsData(); 57 virtual ~PermissionsData();
59 58
60 // Returns true if the |extension| can silently increase its permission level. 59 // Returns true if the |extension| can silently increase its permission level.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 PermissionMessages GetPermissionMessages() const; 117 PermissionMessages GetPermissionMessages() const;
119 118
120 // Returns the full list of permission messages that should display at install 119 // Returns the full list of permission messages that should display at install
121 // time as strings. 120 // time as strings.
122 std::vector<base::string16> GetPermissionMessageStrings() const; 121 std::vector<base::string16> GetPermissionMessageStrings() const;
123 122
124 // Returns the full list of permission details for messages that should 123 // Returns the full list of permission details for messages that should
125 // display at install time as strings. 124 // display at install time as strings.
126 std::vector<base::string16> GetPermissionMessageDetailsStrings() const; 125 std::vector<base::string16> GetPermissionMessageDetailsStrings() const;
127 126
128 // Returns true if the given |extension| can execute script on a page. If a 127 // Returns true if the |extension| has permission to access and interact with
129 // UserScript object is passed, permission to run that specific script is 128 // the specified page, in order to do things like inject scripts or modify
130 // checked (using its matches list). Otherwise, permission to execute script 129 // the content.
131 // programmatically is checked (using the extension's host permission). 130 // If this returns false and |error| is non-NULL, |error| will be popualted
132 // 131 // with the reason the extension cannot access the page.
133 // This method is also aware of certain special pages that extensions are 132 bool CanAccessPage(const Extension* extension,
134 // usually not allowed to run script on. 133 const GURL& document_url,
135 bool CanExecuteScriptOnPage(const Extension* extension, 134 const GURL& top_document_url,
136 const GURL& document_url, 135 int tab_id,
137 const GURL& top_document_url, 136 int process_id,
138 int tab_id, 137 std::string* error) const;
139 const UserScript* script, 138
140 int process_id, 139 // Returns true if the |extension| has permission to inject a content script
141 std::string* error) const; 140 // on the page.
141 // If this returns false and |error| is non-NULL, |error| will be popualted
142 // with the reason the extension cannot script the page.
143 // NOTE: You almost certainly want to use CanAccessPage() instead of this
144 // method.
145 bool CanRunContentScriptOnPage(const Extension* extension,
146 const GURL& document_url,
147 const GURL& top_document_url,
148 int tab_id,
149 int process_id,
150 std::string* error) const;
142 151
143 // Returns true if extension is allowed to obtain the contents of a page as 152 // Returns true if extension is allowed to obtain the contents of a page as
144 // an image. Since a page may contain sensitive information, this is 153 // an image. Since a page may contain sensitive information, this is
145 // restricted to the extension's host permissions as well as the extension 154 // restricted to the extension's host permissions as well as the extension
146 // page itself. 155 // page itself.
147 bool CanCaptureVisiblePage(int tab_id, std::string* error) const; 156 bool CanCaptureVisiblePage(int tab_id, std::string* error) const;
148 157
149 // Returns true if the user should be alerted that the |extension| is running 158 // Returns true if the user should be alerted that the |extension| is running
150 // a script. If |tab_id| and |url| are included, this also considers tab- 159 // a script. If |tab_id| and |url| are included, this also considers tab-
151 // specific permissions. 160 // specific permissions.
(...skipping 22 matching lines...) Expand all
174 scoped_refptr<const PermissionSet> GetTabSpecificPermissions( 183 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(
175 int tab_id) const; 184 int tab_id) const;
176 185
177 // Returns true if the |extension| has tab-specific permission to operate on 186 // Returns true if the |extension| has tab-specific permission to operate on
178 // the tab specified by |tab_id| with the given |url|. 187 // the tab specified by |tab_id| with the given |url|.
179 // Note that if this returns false, it doesn't mean the extension can't run on 188 // Note that if this returns false, it doesn't mean the extension can't run on
180 // the given tab, only that it does not have tab-specific permission to do so. 189 // the given tab, only that it does not have tab-specific permission to do so.
181 bool HasTabSpecificPermissionToExecuteScript(int tab_id, 190 bool HasTabSpecificPermissionToExecuteScript(int tab_id,
182 const GURL& url) const; 191 const GURL& url) const;
183 192
193 // Returns true if the extension is permitted to run on the given page,
194 // checking against |permitted_url_patterns| in addition to blocking special
195 // sites (like the webstore or chrome:// urls).
196 bool CanRunOnPage(const Extension* extension,
197 const GURL& document_url,
198 const GURL& top_document_url,
199 int tab_id,
200 int process_id,
201 const URLPatternSet& permitted_url_patterns,
202 std::string* error) const;
203
184 // The associated extension's id. 204 // The associated extension's id.
185 std::string extension_id_; 205 std::string extension_id_;
186 206
187 // The associated extension's manifest type. 207 // The associated extension's manifest type.
188 Manifest::Type manifest_type_; 208 Manifest::Type manifest_type_;
189 209
190 mutable base::Lock runtime_lock_; 210 mutable base::Lock runtime_lock_;
191 211
192 // The permission's which are currently active on the extension during 212 // The permission's which are currently active on the extension during
193 // runtime. 213 // runtime.
194 // Unsafe indicates that we must lock anytime this is directly accessed. 214 // Unsafe indicates that we must lock anytime this is directly accessed.
195 // Unless you need to change |active_permissions_unsafe_|, use the (safe) 215 // Unless you need to change |active_permissions_unsafe_|, use the (safe)
196 // active_permissions() accessor. 216 // active_permissions() accessor.
197 mutable scoped_refptr<const PermissionSet> active_permissions_unsafe_; 217 mutable scoped_refptr<const PermissionSet> active_permissions_unsafe_;
198 218
199 mutable TabPermissionsMap tab_specific_permissions_; 219 mutable TabPermissionsMap tab_specific_permissions_;
200 220
201 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 221 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
202 }; 222 };
203 223
204 } // namespace extensions 224 } // namespace extensions
205 225
206 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 226 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698