OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 #include "content/browser/isolated_origin_util.h" | 5 #include "content/browser/isolated_origin_util.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 8 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 if (origin.port() != isolated_origin.port()) | 24 if (origin.port() != isolated_origin.port()) |
25 return false; | 25 return false; |
26 | 26 |
27 // Subdomains of an isolated origin are considered to be in the same isolated | 27 // Subdomains of an isolated origin are considered to be in the same isolated |
28 // origin. | 28 // origin. |
29 return origin.DomainIs(isolated_origin.host()); | 29 return origin.DomainIs(isolated_origin.host()); |
30 } | 30 } |
31 | 31 |
32 // static | 32 // static |
33 bool IsolatedOriginUtil::IsValidIsolatedOrigin(const url::Origin& origin) { | 33 bool IsolatedOriginUtil::IsValidIsolatedOrigin(const url::Origin& origin) { |
34 if (origin.unique()) | 34 if (origin.opaque()) |
35 return false; | 35 return false; |
36 | 36 |
37 // Isolated origins should have HTTP or HTTPS schemes. Hosts in other | 37 // Isolated origins should have HTTP or HTTPS schemes. Hosts in other |
38 // schemes may not be compatible with subdomain matching. | 38 // schemes may not be compatible with subdomain matching. |
39 GURL origin_gurl = origin.GetURL(); | 39 GURL origin_gurl = origin.GetURL(); |
40 if (!origin_gurl.SchemeIsHTTPOrHTTPS()) | 40 if (!origin_gurl.SchemeIsHTTPOrHTTPS()) |
41 return false; | 41 return false; |
42 | 42 |
43 // IP addresses are allowed. | 43 // IP addresses are allowed. |
44 if (origin_gurl.HostIsIPAddress()) | 44 if (origin_gurl.HostIsIPAddress()) |
(...skipping 13 matching lines...) Expand all Loading... |
58 // For now, disallow hosts with a trailing dot. | 58 // For now, disallow hosts with a trailing dot. |
59 // TODO(alexmos): Enabling this would require carefully thinking about | 59 // TODO(alexmos): Enabling this would require carefully thinking about |
60 // whether hosts without a trailing dot should match it. | 60 // whether hosts without a trailing dot should match it. |
61 if (origin.host().back() == '.') | 61 if (origin.host().back() == '.') |
62 return false; | 62 return false; |
63 | 63 |
64 return true; | 64 return true; |
65 } | 65 } |
66 | 66 |
67 } // namespace content | 67 } // namespace content |
OLD | NEW |