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 <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "content/public/browser/child_process_security_policy.h" | 19 #include "content/public/browser/child_process_security_policy.h" |
20 #include "content/public/common/resource_type.h" | 20 #include "content/public/common/resource_type.h" |
21 #include "storage/common/fileapi/file_system_types.h" | 21 #include "storage/common/fileapi/file_system_types.h" |
| 22 #include "url/origin.h" |
22 | 23 |
23 class GURL; | 24 class GURL; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class FilePath; | 27 class FilePath; |
27 } | 28 } |
28 | 29 |
29 namespace storage { | 30 namespace storage { |
30 class FileSystemURL; | 31 class FileSystemURL; |
31 } | 32 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 164 |
164 // Register FileSystem type and permission policy which should be used | 165 // Register FileSystem type and permission policy which should be used |
165 // for the type. The |policy| must be a bitwise-or'd value of | 166 // for the type. The |policy| must be a bitwise-or'd value of |
166 // storage::FilePermissionPolicy. | 167 // storage::FilePermissionPolicy. |
167 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type, | 168 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type, |
168 int policy); | 169 int policy); |
169 | 170 |
170 // Returns true if sending system exclusive messages is allowed. | 171 // Returns true if sending system exclusive messages is allowed. |
171 bool CanSendMidiSysExMessage(int child_id); | 172 bool CanSendMidiSysExMessage(int child_id); |
172 | 173 |
| 174 // Add an origin to the list of origins that require process isolation. |
| 175 // When making process model decisions for such origins, the full |
| 176 // scheme+host+port tuple rather than scheme and eTLD+1 will be used. |
| 177 // SiteInstances for these origins will also use the full origin as site URL. |
| 178 // |
| 179 // Note that |origin| must not be unique. URLs that render with |
| 180 // unique origins, such as data: URLs, are not supported. Suborigins (see |
| 181 // https://w3c.github.io/webappsec-suborigins/ -- not to be confused with |
| 182 // subdomains) and non-standard schemes are also not supported. Sandboxed |
| 183 // frames (e.g., <iframe sandbox>) |
| 184 // *are* supported, since process placement decisions will be based on the |
| 185 // URLs such frames navigate to, and not the origin of committed documents |
| 186 // (which might be unique). If an isolated origin opens an about:blank |
| 187 // popup, it will stay in the isolated origin's process. Nested URLs |
| 188 // (filesystem: and blob:) retain process isolation behavior of their inner |
| 189 // origin. |
| 190 void AddIsolatedOrigin(const url::Origin& origin); |
| 191 |
| 192 // Register a set of isolated origins as specified on the command line with |
| 193 // the --isolate-origins flag. |origin_list| is the flag's value, which |
| 194 // contains the list of comma-separated scheme-host-port origins. See |
| 195 // AddIsolatedOrigin for definition of an isolated origin. |
| 196 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); |
| 197 |
| 198 // Helper to check whether an origin requires origin-wide process isolation. |
| 199 bool IsIsolatedOrigin(const url::Origin& origin); |
| 200 |
173 private: | 201 private: |
174 friend class ChildProcessSecurityPolicyInProcessBrowserTest; | 202 friend class ChildProcessSecurityPolicyInProcessBrowserTest; |
175 friend class ChildProcessSecurityPolicyTest; | 203 friend class ChildProcessSecurityPolicyTest; |
176 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, | 204 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, |
177 NoLeak); | 205 NoLeak); |
178 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); | 206 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); |
| 207 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, |
| 208 IsolateOriginsFromCommandLine); |
179 | 209 |
180 class SecurityState; | 210 class SecurityState; |
181 | 211 |
182 typedef std::set<std::string> SchemeSet; | 212 typedef std::set<std::string> SchemeSet; |
183 typedef std::map<int, std::unique_ptr<SecurityState>> SecurityStateMap; | 213 typedef std::map<int, std::unique_ptr<SecurityState>> SecurityStateMap; |
184 typedef std::map<int, int> WorkerToMainProcessMap; | 214 typedef std::map<int, int> WorkerToMainProcessMap; |
185 typedef std::map<storage::FileSystemType, int> FileSystemPermissionPolicyMap; | 215 typedef std::map<storage::FileSystemType, int> FileSystemPermissionPolicyMap; |
186 | 216 |
187 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance(). | 217 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance(). |
188 ChildProcessSecurityPolicyImpl(); | 218 ChildProcessSecurityPolicyImpl(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // owned by this object and are protected by |lock_|. References to them must | 283 // owned by this object and are protected by |lock_|. References to them must |
254 // not escape this class. | 284 // not escape this class. |
255 SecurityStateMap security_state_; | 285 SecurityStateMap security_state_; |
256 | 286 |
257 // This maps keeps the record of which js worker thread child process | 287 // This maps keeps the record of which js worker thread child process |
258 // corresponds to which main js thread child process. | 288 // corresponds to which main js thread child process. |
259 WorkerToMainProcessMap worker_map_; | 289 WorkerToMainProcessMap worker_map_; |
260 | 290 |
261 FileSystemPermissionPolicyMap file_system_policy_map_; | 291 FileSystemPermissionPolicyMap file_system_policy_map_; |
262 | 292 |
| 293 // Tracks origins for which the entire origin should be treated as a site |
| 294 // when making process model decisions, rather than the origin's scheme and |
| 295 // eTLD+1. Each of these origins requires a dedicated process. This set is |
| 296 // protected by |lock_|. |
| 297 std::set<url::Origin> isolated_origins_; |
| 298 |
263 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); | 299 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); |
264 }; | 300 }; |
265 | 301 |
266 } // namespace content | 302 } // namespace content |
267 | 303 |
268 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ | 304 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ |
OLD | NEW |