OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/cross_site_document_classifier.h" | 5 #include "content/common/cross_site_document_classifier.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return CROSS_SITE_DOCUMENT_MIME_TYPE_OTHERS; | 75 return CROSS_SITE_DOCUMENT_MIME_TYPE_OTHERS; |
76 } | 76 } |
77 | 77 |
78 bool CrossSiteDocumentClassifier::IsBlockableScheme(const GURL& url) { | 78 bool CrossSiteDocumentClassifier::IsBlockableScheme(const GURL& url) { |
79 // We exclude ftp:// from here. FTP doesn't provide a Content-Type | 79 // We exclude ftp:// from here. FTP doesn't provide a Content-Type |
80 // header which our policy depends on, so we cannot protect any | 80 // header which our policy depends on, so we cannot protect any |
81 // document from FTP servers. | 81 // document from FTP servers. |
82 return url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme); | 82 return url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme); |
83 } | 83 } |
84 | 84 |
85 bool CrossSiteDocumentClassifier::IsSameSite(const GURL& frame_origin, | 85 bool CrossSiteDocumentClassifier::IsSameSite(const url::Origin& frame_origin, |
86 const GURL& response_url) { | 86 const GURL& response_url) { |
87 if (!frame_origin.is_valid() || !response_url.is_valid()) | 87 if (frame_origin.unique() || !response_url.is_valid()) |
88 return false; | 88 return false; |
89 | 89 |
90 if (frame_origin.scheme() != response_url.scheme()) | 90 if (frame_origin.scheme() != response_url.scheme()) |
91 return false; | 91 return false; |
92 | 92 |
93 // SameDomainOrHost() extracts the effective domains (public suffix plus one) | 93 // SameDomainOrHost() extracts the effective domains (public suffix plus one) |
94 // from the two URLs and compare them. | 94 // from the two URLs and compare them. |
95 return net::registry_controlled_domains::SameDomainOrHost( | 95 return net::registry_controlled_domains::SameDomainOrHost( |
96 frame_origin, response_url, | 96 response_url, frame_origin, |
97 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 97 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
98 } | 98 } |
99 | 99 |
100 // We don't use Webkit's existing CORS policy implementation since | 100 // We don't use Webkit's existing CORS policy implementation since |
101 // their policy works in terms of origins, not sites. For example, | 101 // their policy works in terms of origins, not sites. For example, |
102 // when frame is sub.a.com and it is not allowed to access a document | 102 // when frame is sub.a.com and it is not allowed to access a document |
103 // with sub1.a.com. But under Site Isolation, it's allowed. | 103 // with sub1.a.com. But under Site Isolation, it's allowed. |
104 bool CrossSiteDocumentClassifier::IsValidCorsHeaderSet( | 104 bool CrossSiteDocumentClassifier::IsValidCorsHeaderSet( |
105 const GURL& frame_origin, | 105 const url::Origin& frame_origin, |
106 const GURL& website_origin, | 106 const GURL& website_origin, |
107 const std::string& access_control_origin) { | 107 const std::string& access_control_origin) { |
108 // Many websites are sending back "\"*\"" instead of "*". This is | 108 // Many websites are sending back "\"*\"" instead of "*". This is |
109 // non-standard practice, and not supported by Chrome. Refer to | 109 // non-standard practice, and not supported by Chrome. Refer to |
110 // CrossOriginAccessControl::passesAccessControlCheck(). | 110 // CrossOriginAccessControl::passesAccessControlCheck(). |
111 | 111 |
112 // TODO(dsjang): * is not allowed for the response from a request | 112 // TODO(dsjang): * is not allowed for the response from a request |
113 // with cookies. This allows for more than what the renderer will | 113 // with cookies. This allows for more than what the renderer will |
114 // eventually be able to receive, so we won't see illegal cross-site | 114 // eventually be able to receive, so we won't see illegal cross-site |
115 // documents allowed by this. We have to find a way to see if this | 115 // documents allowed by this. We have to find a way to see if this |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 case kColonState: | 238 case kColonState: |
239 case kTerminalState: | 239 case kTerminalState: |
240 NOTREACHED(); | 240 NOTREACHED(); |
241 break; | 241 break; |
242 } | 242 } |
243 } | 243 } |
244 return state == kColonState; | 244 return state == kColonState; |
245 } | 245 } |
246 | 246 |
247 } // namespace content | 247 } // namespace content |
OLD | NEW |