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> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 int policy); | 186 int policy); |
187 | 187 |
188 // Returns true if sending system exclusive messages is allowed. | 188 // Returns true if sending system exclusive messages is allowed. |
189 bool CanSendMidiSysExMessage(int child_id); | 189 bool CanSendMidiSysExMessage(int child_id); |
190 | 190 |
191 // Add an origin to the list of origins that require process isolation. | 191 // Add an origin to the list of origins that require process isolation. |
192 // When making process model decisions for such origins, the full | 192 // When making process model decisions for such origins, the full |
193 // scheme+host+port tuple rather than scheme and eTLD+1 will be used. | 193 // scheme+host+port tuple rather than scheme and eTLD+1 will be used. |
194 // SiteInstances for these origins will also use the full origin as site URL. | 194 // SiteInstances for these origins will also use the full origin as site URL. |
195 // | 195 // |
| 196 // Subdomains of an isolated origin are considered to be part of that |
| 197 // origin's site. For example, if https://isolated.foo.com is added as an |
| 198 // isolated origin, then https://bar.isolated.foo.com will be considered part |
| 199 // of the site for https://isolated.foo.com. |
| 200 // |
196 // Note that |origin| must not be unique. URLs that render with | 201 // Note that |origin| must not be unique. URLs that render with |
197 // unique origins, such as data: URLs, are not supported. Suborigins (see | 202 // unique origins, such as data: URLs, are not supported. Suborigins (see |
198 // https://w3c.github.io/webappsec-suborigins/ -- not to be confused with | 203 // https://w3c.github.io/webappsec-suborigins/ -- not to be confused with |
199 // subdomains) and non-standard schemes are also not supported. Sandboxed | 204 // subdomains) and non-standard schemes are also not supported. Sandboxed |
200 // frames (e.g., <iframe sandbox>) | 205 // frames (e.g., <iframe sandbox>) *are* supported, since process placement |
201 // *are* supported, since process placement decisions will be based on the | 206 // decisions will be based on the URLs such frames navigate to, and not the |
202 // URLs such frames navigate to, and not the origin of committed documents | 207 // origin of committed documents (which might be unique). If an isolated |
203 // (which might be unique). If an isolated origin opens an about:blank | 208 // origin opens an about:blank popup, it will stay in the isolated origin's |
204 // popup, it will stay in the isolated origin's process. Nested URLs | 209 // process. Nested URLs (filesystem: and blob:) retain process isolation |
205 // (filesystem: and blob:) retain process isolation behavior of their inner | 210 // behavior of their inner origin. |
206 // origin. | |
207 void AddIsolatedOrigin(const url::Origin& origin); | 211 void AddIsolatedOrigin(const url::Origin& origin); |
208 | 212 |
209 // Register a set of isolated origins as specified on the command line with | 213 // Register a set of isolated origins as specified on the command line with |
210 // the --isolate-origins flag. |origin_list| is the flag's value, which | 214 // the --isolate-origins flag. |origin_list| is the flag's value, which |
211 // contains the list of comma-separated scheme-host-port origins. See | 215 // contains the list of comma-separated scheme-host-port origins. See |
212 // AddIsolatedOrigin for definition of an isolated origin. | 216 // AddIsolatedOrigin for definition of an isolated origin. |
213 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); | 217 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); |
214 | 218 |
215 // Helper to check whether an origin requires origin-wide process isolation. | 219 // Check whether |origin| requires origin-wide process isolation. |
| 220 // |
| 221 // Subdomains of an isolated origin are considered part of that isolated |
| 222 // origin. Thus, if https://isolated.foo.com/ had been added as an isolated |
| 223 // origin, this will return true for https://isolated.foo.com/, |
| 224 // https://bar.isolated.foo.com/, or https://baz.bar.isolated.foo.com/; and |
| 225 // it will return false for https://foo.com/ or https://unisolated.foo.com/. |
| 226 // |
| 227 // Note that unlike site URLs for regular web sites, isolated origins care |
| 228 // about port. |
216 bool IsIsolatedOrigin(const url::Origin& origin); | 229 bool IsIsolatedOrigin(const url::Origin& origin); |
217 | 230 |
| 231 // This function will check whether |origin| requires process isolation, and |
| 232 // if so, it will return true and put the most specific matching isolated |
| 233 // origin into |result|. |
| 234 // |
| 235 // If |origin| does not require process isolation, this function will return |
| 236 // false, and |result| will be a unique origin. This means that neither |
| 237 // |origin|, nor any origins for which |origin| is a subdomain, have been |
| 238 // registered as isolated origins. |
| 239 // |
| 240 // For example, if both https://isolated.com/ and |
| 241 // https://bar.foo.isolated.com/ are registered as isolated origins, then the |
| 242 // values returned in |result| are: |
| 243 // https://isolated.com/ --> https://isolated.com/ |
| 244 // https://foo.isolated.com/ --> https://isolated.com/ |
| 245 // https://bar.foo.isolated.com/ --> https://bar.foo.isolated.com/ |
| 246 // https://baz.bar.foo.isolated.com/ --> https://bar.foo.isolated.com/ |
| 247 // https://unisolated.com/ --> (unique origin) |
| 248 bool GetMatchingIsolatedOrigin(const url::Origin& origin, |
| 249 url::Origin* result); |
| 250 |
| 251 // Removes a previously added isolated origin, currently only used in tests. |
| 252 // |
| 253 // TODO(alexmos): Exposing this more generally will require extra care, such |
| 254 // as ensuring that there are no active SiteInstances in that origin. |
| 255 void RemoveIsolatedOriginForTesting(const url::Origin& origin); |
| 256 |
218 private: | 257 private: |
219 friend class ChildProcessSecurityPolicyInProcessBrowserTest; | 258 friend class ChildProcessSecurityPolicyInProcessBrowserTest; |
220 friend class ChildProcessSecurityPolicyTest; | 259 friend class ChildProcessSecurityPolicyTest; |
221 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, | 260 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, |
222 NoLeak); | 261 NoLeak); |
223 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); | 262 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); |
224 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, | 263 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, |
225 IsolateOriginsFromCommandLine); | 264 IsolateOriginsFromCommandLine); |
226 | 265 |
227 class SecurityState; | 266 class SecurityState; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // eTLD+1. Each of these origins requires a dedicated process. This set is | 351 // eTLD+1. Each of these origins requires a dedicated process. This set is |
313 // protected by |lock_|. | 352 // protected by |lock_|. |
314 std::set<url::Origin> isolated_origins_; | 353 std::set<url::Origin> isolated_origins_; |
315 | 354 |
316 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); | 355 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); |
317 }; | 356 }; |
318 | 357 |
319 } // namespace content | 358 } // namespace content |
320 | 359 |
321 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ | 360 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ |
OLD | NEW |