| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 , m_isUnique(other->m_isUnique) | 140 , m_isUnique(other->m_isUnique) |
| 141 , m_universalAccess(other->m_universalAccess) | 141 , m_universalAccess(other->m_universalAccess) |
| 142 , m_domainWasSetInDOM(other->m_domainWasSetInDOM) | 142 , m_domainWasSetInDOM(other->m_domainWasSetInDOM) |
| 143 , m_canLoadLocalResources(other->m_canLoadLocalResources) | 143 , m_canLoadLocalResources(other->m_canLoadLocalResources) |
| 144 , m_enforceFilePathSeparation(other->m_enforceFilePathSeparation) | 144 , m_enforceFilePathSeparation(other->m_enforceFilePathSeparation) |
| 145 { | 145 { |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool SecurityOrigin::isEmpty() const | 148 bool SecurityOrigin::isEmpty() const |
| 149 { | 149 { |
| 150 ASSERT(!m_protocol.isEmpty() || m_isUnique); |
| 150 return m_protocol.isEmpty(); | 151 return m_protocol.isEmpty(); |
| 151 } | 152 } |
| 152 | 153 |
| 153 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url, SandboxFlags
sandboxFlags) | 154 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url, SandboxFlags
sandboxFlags) |
| 154 { | 155 { |
| 155 if (!url.isValid()) | 156 if (!url.isValid()) |
| 156 return adoptRef(new SecurityOrigin(KURL(), sandboxFlags)); | 157 return adoptRef(new SecurityOrigin(KURL(), sandboxFlags)); |
| 157 return adoptRef(new SecurityOrigin(url, sandboxFlags)); | 158 return adoptRef(new SecurityOrigin(url, sandboxFlags)); |
| 158 } | 159 } |
| 159 | 160 |
| 160 PassRefPtr<SecurityOrigin> SecurityOrigin::createEmpty() | 161 PassRefPtr<SecurityOrigin> SecurityOrigin::createEmpty() |
| 161 { | 162 { |
| 162 return create(KURL()); | 163 return create(KURL()); |
| 163 } | 164 } |
| 164 | 165 |
| 165 PassRefPtr<SecurityOrigin> SecurityOrigin::threadsafeCopy() | 166 PassRefPtr<SecurityOrigin> SecurityOrigin::threadsafeCopy() |
| 166 { | 167 { |
| 167 return adoptRef(new SecurityOrigin(this)); | 168 return adoptRef(new SecurityOrigin(this)); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void SecurityOrigin::setDomainFromDOM(const String& newDomain) | 171 void SecurityOrigin::setDomainFromDOM(const String& newDomain) |
| 171 { | 172 { |
| 172 m_domainWasSetInDOM = true; | 173 m_domainWasSetInDOM = true; |
| 173 m_domain = newDomain.lower(); | 174 m_domain = newDomain.lower(); |
| 174 } | 175 } |
| 175 | 176 |
| 177 // FIXME: This should move to SchemeRegistry! |
| 176 static HashSet<String>& schemesForbiddenFromDomainRelaxation() | 178 static HashSet<String>& schemesForbiddenFromDomainRelaxation() |
| 177 { | 179 { |
| 178 DEFINE_STATIC_LOCAL(HashSet<String>, schemes, ()); | 180 DEFINE_STATIC_LOCAL(HashSet<String>, schemes, ()); |
| 179 return schemes; | 181 return schemes; |
| 180 } | 182 } |
| 181 | 183 |
| 182 void SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(bool forbidden, co
nst String& scheme) | 184 void SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(bool forbidden, co
nst String& scheme) |
| 183 { | 185 { |
| 184 if (scheme.isEmpty()) | 186 if (scheme.isEmpty()) |
| 185 return; | 187 return; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ASSERT(isLocal()); | 368 ASSERT(isLocal()); |
| 367 m_enforceFilePathSeparation = true; | 369 m_enforceFilePathSeparation = true; |
| 368 } | 370 } |
| 369 | 371 |
| 370 bool SecurityOrigin::isLocal() const | 372 bool SecurityOrigin::isLocal() const |
| 371 { | 373 { |
| 372 return SchemeRegistry::shouldTreatURLSchemeAsLocal(m_protocol); | 374 return SchemeRegistry::shouldTreatURLSchemeAsLocal(m_protocol); |
| 373 } | 375 } |
| 374 | 376 |
| 375 bool SecurityOrigin::isSecureTransitionTo(const KURL& url) const | 377 bool SecurityOrigin::isSecureTransitionTo(const KURL& url) const |
| 376 { | 378 { |
| 377 // New window created by the application | 379 // This origin represents a new window created by the application. |
| 378 if (isEmpty()) | 380 if (isEmpty()) |
| 379 return true; | 381 return true; |
| 380 | 382 |
| 381 RefPtr<SecurityOrigin> other = SecurityOrigin::create(url); | 383 RefPtr<SecurityOrigin> other = SecurityOrigin::create(url); |
| 382 return canAccess(other.get()); | 384 return canAccess(other.get()); |
| 383 } | 385 } |
| 384 | 386 |
| 385 String SecurityOrigin::toString() const | 387 String SecurityOrigin::toString() const |
| 386 { | 388 { |
| 387 if (isEmpty()) | |
| 388 return "null"; | |
| 389 | |
| 390 if (isUnique()) | 389 if (isUnique()) |
| 391 return "null"; | 390 return "null"; |
| 392 | 391 |
| 393 if (m_protocol == "file") { | 392 if (m_protocol == "file") { |
| 394 if (m_enforceFilePathSeparation) | 393 if (m_enforceFilePathSeparation) |
| 395 return "null"; | 394 return "null"; |
| 396 return "file://"; | 395 return "file://"; |
| 397 } | 396 } |
| 398 | 397 |
| 399 Vector<UChar> result; | 398 Vector<UChar> result; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 579 |
| 581 void SecurityOrigin::resetOriginAccessWhitelists() | 580 void SecurityOrigin::resetOriginAccessWhitelists() |
| 582 { | 581 { |
| 583 ASSERT(isMainThread()); | 582 ASSERT(isMainThread()); |
| 584 OriginAccessMap& map = originAccessMap(); | 583 OriginAccessMap& map = originAccessMap(); |
| 585 deleteAllValues(map); | 584 deleteAllValues(map); |
| 586 map.clear(); | 585 map.clear(); |
| 587 } | 586 } |
| 588 | 587 |
| 589 } // namespace WebCore | 588 } // namespace WebCore |
| OLD | NEW |