OLD | NEW |
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 CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ |
6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Returns true if sending system exclusive messages is allowed. | 164 // Returns true if sending system exclusive messages is allowed. |
165 bool CanSendMidiSysExMessage(int child_id); | 165 bool CanSendMidiSysExMessage(int child_id); |
166 | 166 |
167 private: | 167 private: |
168 friend class ChildProcessSecurityPolicyInProcessBrowserTest; | 168 friend class ChildProcessSecurityPolicyInProcessBrowserTest; |
169 friend class ChildProcessSecurityPolicyTest; | 169 friend class ChildProcessSecurityPolicyTest; |
170 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, | 170 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, |
171 NoLeak); | 171 NoLeak); |
172 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); | 172 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); |
173 | 173 |
174 class SecurityState; | |
175 | |
176 typedef std::set<std::string> SchemeSet; | |
177 typedef std::map<int, SecurityState*> SecurityStateMap; | |
178 typedef std::map<int, int> WorkerToMainProcessMap; | |
179 typedef std::map<storage::FileSystemType, int> FileSystemPermissionPolicyMap; | |
180 | |
181 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance(). | 174 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance(). |
182 ChildProcessSecurityPolicyImpl(); | 175 ChildProcessSecurityPolicyImpl(); |
183 friend struct base::DefaultSingletonTraits<ChildProcessSecurityPolicyImpl>; | 176 friend struct base::DefaultSingletonTraits<ChildProcessSecurityPolicyImpl>; |
184 | 177 |
185 // Adds child process during registration. | |
186 void AddChild(int child_id); | |
187 | |
188 // Determines if certain permissions were granted for a file to given child | |
189 // process. |permissions| is an internally defined bit-set. | |
190 bool ChildProcessHasPermissionsForFile(int child_id, | |
191 const base::FilePath& file, | |
192 int permissions); | |
193 | |
194 // Grant a particular permission set for a file. |permissions| is an | |
195 // internally defined bit-set. | |
196 void GrantPermissionsForFile(int child_id, | |
197 const base::FilePath& file, | |
198 int permissions); | |
199 | |
200 // Grants access permission to the given isolated file system | |
201 // identified by |filesystem_id|. See comments for | |
202 // ChildProcessSecurityPolicy::GrantReadFileSystem() for more details. | |
203 void GrantPermissionsForFileSystem( | |
204 int child_id, | |
205 const std::string& filesystem_id, | |
206 int permission); | |
207 | |
208 // Determines if certain permissions were granted for a file. |permissions| | |
209 // is an internally defined bit-set. If |child_id| is a worker process, | |
210 // this returns true if either the worker process or its parent renderer | |
211 // has permissions for the file. | |
212 bool HasPermissionsForFile(int child_id, | |
213 const base::FilePath& file, | |
214 int permissions); | |
215 | |
216 // Determines if certain permissions were granted for a file in FileSystem | |
217 // API. |permissions| is an internally defined bit-set. | |
218 bool HasPermissionsForFileSystemFile(int child_id, | |
219 const storage::FileSystemURL& url, | |
220 int permissions); | |
221 | |
222 // Determines if certain permissions were granted for a file system. | |
223 // |permissions| is an internally defined bit-set. | |
224 bool HasPermissionsForFileSystem( | |
225 int child_id, | |
226 const std::string& filesystem_id, | |
227 int permission); | |
228 | |
229 // You must acquire this lock before reading or writing any members of this | |
230 // class. You must not block while holding this lock. | |
231 base::Lock lock_; | |
232 | |
233 // These schemes are white-listed for all child processes. This set is | |
234 // protected by |lock_|. | |
235 SchemeSet web_safe_schemes_; | |
236 | |
237 // These schemes do not actually represent retrievable URLs. For example, | |
238 // the the URLs in the "about" scheme are aliases to other URLs. This set is | |
239 // protected by |lock_|. | |
240 SchemeSet pseudo_schemes_; | |
241 | |
242 // This map holds a SecurityState for each child process. The key for the | |
243 // map is the ID of the ChildProcessHost. The SecurityState objects are | |
244 // owned by this object and are protected by |lock_|. References to them must | |
245 // not escape this class. | |
246 SecurityStateMap security_state_; | |
247 | |
248 // This maps keeps the record of which js worker thread child process | |
249 // corresponds to which main js thread child process. | |
250 WorkerToMainProcessMap worker_map_; | |
251 | |
252 FileSystemPermissionPolicyMap file_system_policy_map_; | |
253 | |
254 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); | 178 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); |
255 }; | 179 }; |
256 | 180 |
257 } // namespace content | 181 } // namespace content |
258 | 182 |
259 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ | 183 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ |
OLD | NEW |