OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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. | |
not at google - send to devlin
2014/06/06 18:46:52
"CanContentScriptPage" ... still looks a little bi
Devlin
2014/06/06 19:25:02
Done and done.
| |
143 bool CanContentScriptPage(const Extension* extension, | |
144 const GURL& document_url, | |
145 const GURL& top_document_url, | |
146 int tab_id, | |
147 int process_id, | |
148 std::string* error) const; | |
142 | 149 |
143 // Returns true if extension is allowed to obtain the contents of a page as | 150 // 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 | 151 // an image. Since a page may contain sensitive information, this is |
145 // restricted to the extension's host permissions as well as the extension | 152 // restricted to the extension's host permissions as well as the extension |
146 // page itself. | 153 // page itself. |
147 bool CanCaptureVisiblePage(int tab_id, std::string* error) const; | 154 bool CanCaptureVisiblePage(int tab_id, std::string* error) const; |
148 | 155 |
149 // Returns true if the user should be alerted that the |extension| is running | 156 // 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- | 157 // a script. If |tab_id| and |url| are included, this also considers tab- |
151 // specific permissions. | 158 // specific permissions. |
(...skipping 22 matching lines...) Expand all Loading... | |
174 scoped_refptr<const PermissionSet> GetTabSpecificPermissions( | 181 scoped_refptr<const PermissionSet> GetTabSpecificPermissions( |
175 int tab_id) const; | 182 int tab_id) const; |
176 | 183 |
177 // Returns true if the |extension| has tab-specific permission to operate on | 184 // Returns true if the |extension| has tab-specific permission to operate on |
178 // the tab specified by |tab_id| with the given |url|. | 185 // 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 | 186 // 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. | 187 // the given tab, only that it does not have tab-specific permission to do so. |
181 bool HasTabSpecificPermissionToExecuteScript(int tab_id, | 188 bool HasTabSpecificPermissionToExecuteScript(int tab_id, |
182 const GURL& url) const; | 189 const GURL& url) const; |
183 | 190 |
191 // Returns true if the extension is permitted to run on the given page, | |
192 // checking against |permitted_url_patterns| in addition to blocking special | |
193 // sites (like the webstore or chrome:// urls). | |
194 bool CanRunOnPage(const Extension* extension, | |
195 const GURL& document_url, | |
196 const GURL& top_document_url, | |
197 int tab_id, | |
198 int process_id, | |
199 const URLPatternSet& permitted_url_patterns, | |
200 std::string* error) const; | |
201 | |
184 // The associated extension's id. | 202 // The associated extension's id. |
185 std::string extension_id_; | 203 std::string extension_id_; |
186 | 204 |
187 // The associated extension's manifest type. | 205 // The associated extension's manifest type. |
188 Manifest::Type manifest_type_; | 206 Manifest::Type manifest_type_; |
189 | 207 |
190 mutable base::Lock runtime_lock_; | 208 mutable base::Lock runtime_lock_; |
191 | 209 |
192 // The permission's which are currently active on the extension during | 210 // The permission's which are currently active on the extension during |
193 // runtime. | 211 // runtime. |
194 // Unsafe indicates that we must lock anytime this is directly accessed. | 212 // Unsafe indicates that we must lock anytime this is directly accessed. |
195 // Unless you need to change |active_permissions_unsafe_|, use the (safe) | 213 // Unless you need to change |active_permissions_unsafe_|, use the (safe) |
196 // active_permissions() accessor. | 214 // active_permissions() accessor. |
197 mutable scoped_refptr<const PermissionSet> active_permissions_unsafe_; | 215 mutable scoped_refptr<const PermissionSet> active_permissions_unsafe_; |
198 | 216 |
199 mutable TabPermissionsMap tab_specific_permissions_; | 217 mutable TabPermissionsMap tab_specific_permissions_; |
200 | 218 |
201 DISALLOW_COPY_AND_ASSIGN(PermissionsData); | 219 DISALLOW_COPY_AND_ASSIGN(PermissionsData); |
202 }; | 220 }; |
203 | 221 |
204 } // namespace extensions | 222 } // namespace extensions |
205 | 223 |
206 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ | 224 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ |
OLD | NEW |