Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 , m_needsDatabaseIdentifierQuirkForFiles(false) | 127 , m_needsDatabaseIdentifierQuirkForFiles(false) |
| 128 { | 128 { |
| 129 // document.domain starts as m_host, but can be set by the DOM. | 129 // document.domain starts as m_host, but can be set by the DOM. |
| 130 m_domain = m_host; | 130 m_domain = m_host; |
| 131 | 131 |
| 132 if (isDefaultPortForProtocol(m_port, m_protocol)) | 132 if (isDefaultPortForProtocol(m_port, m_protocol)) |
| 133 m_port = InvalidPort; | 133 m_port = InvalidPort; |
| 134 | 134 |
| 135 // By default, only local SecurityOrigins can load local resources. | 135 // By default, only local SecurityOrigins can load local resources. |
| 136 m_canLoadLocalResources = isLocal(); | 136 m_canLoadLocalResources = isLocal(); |
| 137 | |
| 138 if (m_canLoadLocalResources) | |
| 139 m_filePath = url.path(); // In case enforceFilePathSeparation() is calle d. | |
| 140 } | 137 } |
| 141 | 138 |
| 142 SecurityOrigin::SecurityOrigin() | 139 SecurityOrigin::SecurityOrigin() |
| 143 : m_protocol("") | 140 : m_protocol("") |
| 144 , m_host("") | 141 , m_host("") |
| 145 , m_domain("") | 142 , m_domain("") |
| 146 , m_port(InvalidPort) | 143 , m_port(InvalidPort) |
| 147 , m_isUnique(true) | 144 , m_isUnique(true) |
| 148 , m_universalAccess(false) | 145 , m_universalAccess(false) |
| 149 , m_domainWasSetInDOM(false) | 146 , m_domainWasSetInDOM(false) |
| 150 , m_canLoadLocalResources(false) | 147 , m_canLoadLocalResources(false) |
| 151 , m_enforceFilePathSeparation(false) | 148 , m_enforceFilePathSeparation(false) |
| 152 , m_needsDatabaseIdentifierQuirkForFiles(false) | 149 , m_needsDatabaseIdentifierQuirkForFiles(false) |
| 153 { | 150 { |
| 154 } | 151 } |
| 155 | 152 |
| 156 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) | 153 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) |
| 157 : m_protocol(other->m_protocol.isolatedCopy()) | 154 : m_protocol(other->m_protocol.isolatedCopy()) |
| 158 , m_host(other->m_host.isolatedCopy()) | 155 , m_host(other->m_host.isolatedCopy()) |
| 159 , m_domain(other->m_domain.isolatedCopy()) | 156 , m_domain(other->m_domain.isolatedCopy()) |
| 160 , m_filePath(other->m_filePath.isolatedCopy()) | |
| 161 , m_port(other->m_port) | 157 , m_port(other->m_port) |
| 162 , m_isUnique(other->m_isUnique) | 158 , m_isUnique(other->m_isUnique) |
| 163 , m_universalAccess(other->m_universalAccess) | 159 , m_universalAccess(other->m_universalAccess) |
| 164 , m_domainWasSetInDOM(other->m_domainWasSetInDOM) | 160 , m_domainWasSetInDOM(other->m_domainWasSetInDOM) |
| 165 , m_canLoadLocalResources(other->m_canLoadLocalResources) | 161 , m_canLoadLocalResources(other->m_canLoadLocalResources) |
| 166 , m_enforceFilePathSeparation(other->m_enforceFilePathSeparation) | 162 , m_enforceFilePathSeparation(other->m_enforceFilePathSeparation) |
| 167 , m_needsDatabaseIdentifierQuirkForFiles(other->m_needsDatabaseIdentifierQui rkForFiles) | 163 , m_needsDatabaseIdentifierQuirkForFiles(other->m_needsDatabaseIdentifierQui rkForFiles) |
| 168 { | 164 { |
| 169 } | 165 } |
| 170 | 166 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 if (canAccess && isLocal()) | 264 if (canAccess && isLocal()) |
| 269 canAccess = passesFileCheck(other); | 265 canAccess = passesFileCheck(other); |
| 270 | 266 |
| 271 return canAccess; | 267 return canAccess; |
| 272 } | 268 } |
| 273 | 269 |
| 274 bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const | 270 bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const |
| 275 { | 271 { |
| 276 ASSERT(isLocal() && other->isLocal()); | 272 ASSERT(isLocal() && other->isLocal()); |
| 277 | 273 |
| 278 if (!m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation) | 274 return !m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation; |
|
dcheng
2015/06/01 21:08:53
I think we should rename m_enforceFilePathSeparati
TheJH
2015/06/02 11:59:19
What would be a good name? m_treatFileAsUniqueOrig
| |
| 279 return true; | |
| 280 | |
| 281 return (m_filePath == other->m_filePath); | |
| 282 } | 275 } |
| 283 | 276 |
| 284 bool SecurityOrigin::canRequest(const KURL& url) const | 277 bool SecurityOrigin::canRequest(const KURL& url) const |
| 285 { | 278 { |
| 286 if (m_universalAccess) | 279 if (m_universalAccess) |
| 287 return true; | 280 return true; |
| 288 | 281 |
| 289 if (cachedOrigin(url) == this) | 282 if (cachedOrigin(url) == this) |
| 290 return true; | 283 return true; |
| 291 | 284 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 } | 527 } |
| 535 | 528 |
| 536 void SecurityOrigin::transferPrivilegesFrom(const SecurityOrigin& origin) | 529 void SecurityOrigin::transferPrivilegesFrom(const SecurityOrigin& origin) |
| 537 { | 530 { |
| 538 m_universalAccess = origin.m_universalAccess; | 531 m_universalAccess = origin.m_universalAccess; |
| 539 m_canLoadLocalResources = origin.m_canLoadLocalResources; | 532 m_canLoadLocalResources = origin.m_canLoadLocalResources; |
| 540 m_enforceFilePathSeparation = origin.m_enforceFilePathSeparation; | 533 m_enforceFilePathSeparation = origin.m_enforceFilePathSeparation; |
| 541 } | 534 } |
| 542 | 535 |
| 543 } // namespace blink | 536 } // namespace blink |
| OLD | NEW |