OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 m_port = InvalidPort; | 144 m_port = InvalidPort; |
145 | 145 |
146 // By default, only local SecurityOrigins can load local resources. | 146 // By default, only local SecurityOrigins can load local resources. |
147 m_canLoadLocalResources = isLocal(); | 147 m_canLoadLocalResources = isLocal(); |
148 } | 148 } |
149 | 149 |
150 SecurityOrigin::SecurityOrigin() | 150 SecurityOrigin::SecurityOrigin() |
151 : m_protocol(emptyString), | 151 : m_protocol(emptyString), |
152 m_host(emptyString), | 152 m_host(emptyString), |
153 m_domain(emptyString), | 153 m_domain(emptyString), |
| 154 m_uniqueID(base::UnguessableToken::Create()), |
154 m_port(InvalidPort), | 155 m_port(InvalidPort), |
155 m_effectivePort(InvalidPort), | 156 m_effectivePort(InvalidPort), |
156 m_isUnique(true), | 157 m_isUnique(true), |
157 m_universalAccess(false), | 158 m_universalAccess(false), |
158 m_domainWasSetInDOM(false), | 159 m_domainWasSetInDOM(false), |
159 m_canLoadLocalResources(false), | 160 m_canLoadLocalResources(false), |
160 m_blockLocalAccessFromLocalOrigin(false), | 161 m_blockLocalAccessFromLocalOrigin(false), |
161 m_isUniqueOriginPotentiallyTrustworthy(false) {} | 162 m_isUniqueOriginPotentiallyTrustworthy(false) {} |
162 | 163 |
163 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) | 164 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) |
164 : m_protocol(other->m_protocol.isolatedCopy()), | 165 : m_protocol(other->m_protocol.isolatedCopy()), |
165 m_host(other->m_host.isolatedCopy()), | 166 m_host(other->m_host.isolatedCopy()), |
166 m_domain(other->m_domain.isolatedCopy()), | 167 m_domain(other->m_domain.isolatedCopy()), |
167 m_suborigin(other->m_suborigin), | 168 m_suborigin(other->m_suborigin), |
| 169 m_uniqueID(other->m_uniqueID), |
168 m_port(other->m_port), | 170 m_port(other->m_port), |
169 m_effectivePort(other->m_effectivePort), | 171 m_effectivePort(other->m_effectivePort), |
170 m_isUnique(other->m_isUnique), | 172 m_isUnique(other->m_isUnique), |
171 m_universalAccess(other->m_universalAccess), | 173 m_universalAccess(other->m_universalAccess), |
172 m_domainWasSetInDOM(other->m_domainWasSetInDOM), | 174 m_domainWasSetInDOM(other->m_domainWasSetInDOM), |
173 m_canLoadLocalResources(other->m_canLoadLocalResources), | 175 m_canLoadLocalResources(other->m_canLoadLocalResources), |
174 m_blockLocalAccessFromLocalOrigin( | 176 m_blockLocalAccessFromLocalOrigin( |
175 other->m_blockLocalAccessFromLocalOrigin), | 177 other->m_blockLocalAccessFromLocalOrigin), |
176 m_isUniqueOriginPotentiallyTrustworthy( | 178 m_isUniqueOriginPotentiallyTrustworthy( |
177 other->m_isUniqueOriginPotentiallyTrustworthy) {} | 179 other->m_isUniqueOriginPotentiallyTrustworthy) {} |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 return false; | 223 return false; |
222 } | 224 } |
223 | 225 |
224 bool SecurityOrigin::canAccess(const SecurityOrigin* other) const { | 226 bool SecurityOrigin::canAccess(const SecurityOrigin* other) const { |
225 if (m_universalAccess) | 227 if (m_universalAccess) |
226 return true; | 228 return true; |
227 | 229 |
228 if (this == other) | 230 if (this == other) |
229 return true; | 231 return true; |
230 | 232 |
231 if (isUnique() || other->isUnique()) | 233 if (isUnique() || other->isUnique()) { |
232 return false; | 234 return isUnique() && other->isUnique() ? m_uniqueID == other->m_uniqueID |
| 235 : false; |
| 236 } |
233 | 237 |
234 // document.domain handling, as per | 238 // document.domain handling, as per |
235 // https://html.spec.whatwg.org/multipage/browsers.html#dom-document-domain: | 239 // https://html.spec.whatwg.org/multipage/browsers.html#dom-document-domain: |
236 // | 240 // |
237 // 1) Neither document has set document.domain. In this case, we insist | 241 // 1) Neither document has set document.domain. In this case, we insist |
238 // that the scheme, host, and port of the URLs match. | 242 // that the scheme, host, and port of the URLs match. |
239 // | 243 // |
240 // 2) Both documents have set document.domain. In this case, we insist | 244 // 2) Both documents have set document.domain. In this case, we insist |
241 // that the documents have set document.domain to the same value and | 245 // that the documents have set document.domain to the same value and |
242 // that the scheme of the URLs match. Ports do not need to match. | 246 // that the scheme of the URLs match. Ports do not need to match. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 utf8.data(), url::Component(0, utf8.length()), &canonOutput, &outHost); | 622 utf8.data(), url::Component(0, utf8.length()), &canonOutput, &outHost); |
619 } else { | 623 } else { |
620 *success = url::CanonicalizeHost(host.characters16(), | 624 *success = url::CanonicalizeHost(host.characters16(), |
621 url::Component(0, host.length()), | 625 url::Component(0, host.length()), |
622 &canonOutput, &outHost); | 626 &canonOutput, &outHost); |
623 } | 627 } |
624 return String::fromUTF8(canonOutput.data(), canonOutput.length()); | 628 return String::fromUTF8(canonOutput.data(), canonOutput.length()); |
625 } | 629 } |
626 | 630 |
627 } // namespace blink | 631 } // namespace blink |
OLD | NEW |