Chromium Code Reviews| Index: content/browser/child_process_security_policy_impl.h |
| diff --git a/content/browser/child_process_security_policy_impl.h b/content/browser/child_process_security_policy_impl.h |
| index 82f0e9be22c660dd30f0c11eb4c58e775405cf78..a8028a3fc5d95d14f9830d93630e4b5ceac8a1a9 100644 |
| --- a/content/browser/child_process_security_policy_impl.h |
| +++ b/content/browser/child_process_security_policy_impl.h |
| @@ -19,6 +19,7 @@ |
| #include "content/public/browser/child_process_security_policy.h" |
| #include "content/public/common/resource_type.h" |
| #include "storage/common/fileapi/file_system_types.h" |
| +#include "url/origin.h" |
| class GURL; |
| @@ -170,12 +171,39 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl |
| // Returns true if sending system exclusive messages is allowed. |
| bool CanSendMidiSysExMessage(int child_id); |
| + // Add an origin to the list of origins that require process isolation. |
| + // When making process model decisions for such origins, the full |
| + // scheme+host+port tuple rather than scheme and eTLD+1 will be used. |
| + // SiteInstances for these origins will also use the full origin as site URL. |
| + // |
| + // Note that |origin| must not be unique. URLs that render with |
| + // unique origins, such as data: URLs, are not supported. Suborigins and |
|
Charlie Reis
2017/05/19 00:10:18
Might clarify what you mean by suborigins, since i
alexmos
2017/05/24 00:19:56
Ah, good call - I didn't realize there might be su
|
| + // non-standard schemes are also not supported. Sandboxed frames (e.g., |
| + // <iframe sandbox>) *are* supported, since process placement decisions will |
| + // be based on the URLs such frames navigate to, and not the origin of |
| + // committed documents (which might be unique). If an isolated origin opens |
| + // an about:blank popup, it will stay in the isolated origin's process. |
| + // Nested URLs (filesystem: and blob:) retain process isolation behavior of |
| + // their inner origin. |
| + void AddIsolatedOrigin(const url::Origin& origin); |
| + |
| + // Register a set of isolated origins as specified on the command line with |
| + // the --isolate-origins flag. |origin_list| is the flag's value, which |
| + // contains the list of comma-separated scheme-host-port origins. See |
| + // AddIsolatedOrigin for definition of an isolated origin. |
| + void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); |
| + |
| + // Helper to check whether an origin requires origin-wide process isolation. |
| + bool IsIsolatedOrigin(const url::Origin& origin); |
| + |
| private: |
| friend class ChildProcessSecurityPolicyInProcessBrowserTest; |
| friend class ChildProcessSecurityPolicyTest; |
| FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, |
| NoLeak); |
| FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); |
| + FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, |
| + IsolateOriginsFromCommandLine); |
| class SecurityState; |
| @@ -260,6 +288,20 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl |
| FileSystemPermissionPolicyMap file_system_policy_map_; |
| + // Protects access to isolated_origins_. This has to be a separate lock from |
| + // |lock_|, because it's possible to attempt access to isolated_origins_ via |
| + // IsIsolatedOrigin() from outside ChildProcessSecurityPolicy while already |
| + // holding |lock_|. A scenario where this happens is |
| + // CanAccessDataForOrigin() (grabs lock_) -> SiteInstance::GetSiteForURL() -> |
| + // IsIsolatedOrigin(). |
|
alexmos
2017/05/16 17:26:38
This cycle is nasty, and I'm not sure this is a go
Charlie Reis
2017/05/19 00:10:19
Ooh, this is tough. Let's find a chance to chat a
Charlie Reis
2017/05/19 16:54:07
What if we moved the GetSiteForURL call from Secur
alexmos
2017/05/24 00:19:56
Thanks for the suggestion! I went ahead and follo
|
| + base::Lock isolated_origins_lock_; |
| + |
| + // Tracks origins for which the entire origin should be treated as a site |
| + // when making process model decisions, rather than the origin's scheme and |
| + // eTLD+1. Each of these origins requires a dedicated process. This set is |
| + // protected by |isolated_origins_lock_|. |
| + std::set<url::Origin> isolated_origins_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); |
| }; |