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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 String protocol = relevantURL.protocol().lower(); | 108 String protocol = relevantURL.protocol().lower(); |
109 | 109 |
110 if (SchemeRegistry::shouldTreatURLSchemeAsNoAccess(protocol)) | 110 if (SchemeRegistry::shouldTreatURLSchemeAsNoAccess(protocol)) |
111 return true; | 111 return true; |
112 | 112 |
113 // This is the common case. | 113 // This is the common case. |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 SecurityOrigin::SecurityOrigin(const KURL& url) | 117 SecurityOrigin::SecurityOrigin(const KURL& url) |
118 : m_protocol(url.protocol().isNull() ? "" : url.protocol().lower()), | 118 : m_protocol(url.protocol().isNull() ? emptyString() |
119 m_host(url.host().isNull() ? "" : url.host().lower()), | 119 : url.protocol().lower()), |
| 120 m_host(url.host().isNull() ? emptyString() : url.host().lower()), |
120 m_port(url.port()), | 121 m_port(url.port()), |
121 m_effectivePort(url.port() ? url.port() | 122 m_effectivePort(url.port() ? url.port() |
122 : defaultPortForProtocol(m_protocol)), | 123 : defaultPortForProtocol(m_protocol)), |
123 m_isUnique(false), | 124 m_isUnique(false), |
124 m_universalAccess(false), | 125 m_universalAccess(false), |
125 m_domainWasSetInDOM(false), | 126 m_domainWasSetInDOM(false), |
126 m_blockLocalAccessFromLocalOrigin(false), | 127 m_blockLocalAccessFromLocalOrigin(false), |
127 m_isUniqueOriginPotentiallyTrustworthy(false) { | 128 m_isUniqueOriginPotentiallyTrustworthy(false) { |
128 // Suborigins are serialized into the host, so extract it if necessary. | 129 // Suborigins are serialized into the host, so extract it if necessary. |
129 String suboriginName; | 130 String suboriginName; |
130 if (deserializeSuboriginAndProtocolAndHost(m_protocol, m_host, suboriginName, | 131 if (deserializeSuboriginAndProtocolAndHost(m_protocol, m_host, suboriginName, |
131 m_protocol, m_host)) | 132 m_protocol, m_host)) |
132 m_suborigin.setName(suboriginName); | 133 m_suborigin.setName(suboriginName); |
133 | 134 |
134 // document.domain starts as m_host, but can be set by the DOM. | 135 // document.domain starts as m_host, but can be set by the DOM. |
135 m_domain = m_host; | 136 m_domain = m_host; |
136 | 137 |
137 if (isDefaultPortForProtocol(m_port, m_protocol)) | 138 if (isDefaultPortForProtocol(m_port, m_protocol)) |
138 m_port = InvalidPort; | 139 m_port = InvalidPort; |
139 | 140 |
140 // By default, only local SecurityOrigins can load local resources. | 141 // By default, only local SecurityOrigins can load local resources. |
141 m_canLoadLocalResources = isLocal(); | 142 m_canLoadLocalResources = isLocal(); |
142 } | 143 } |
143 | 144 |
144 SecurityOrigin::SecurityOrigin() | 145 SecurityOrigin::SecurityOrigin() |
145 : m_protocol(""), | 146 : m_protocol(emptyString()), |
146 m_host(""), | 147 m_host(emptyString()), |
147 m_domain(""), | 148 m_domain(emptyString()), |
148 m_port(InvalidPort), | 149 m_port(InvalidPort), |
149 m_effectivePort(InvalidPort), | 150 m_effectivePort(InvalidPort), |
150 m_isUnique(true), | 151 m_isUnique(true), |
151 m_universalAccess(false), | 152 m_universalAccess(false), |
152 m_domainWasSetInDOM(false), | 153 m_domainWasSetInDOM(false), |
153 m_canLoadLocalResources(false), | 154 m_canLoadLocalResources(false), |
154 m_blockLocalAccessFromLocalOrigin(false), | 155 m_blockLocalAccessFromLocalOrigin(false), |
155 m_isUniqueOriginPotentiallyTrustworthy(false) {} | 156 m_isUniqueOriginPotentiallyTrustworthy(false) {} |
156 | 157 |
157 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) | 158 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 privilegeData->m_blockLocalAccessFromLocalOrigin; | 585 privilegeData->m_blockLocalAccessFromLocalOrigin; |
585 } | 586 } |
586 | 587 |
587 void SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy( | 588 void SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy( |
588 bool isUniqueOriginPotentiallyTrustworthy) { | 589 bool isUniqueOriginPotentiallyTrustworthy) { |
589 ASSERT(!isUniqueOriginPotentiallyTrustworthy || isUnique()); | 590 ASSERT(!isUniqueOriginPotentiallyTrustworthy || isUnique()); |
590 m_isUniqueOriginPotentiallyTrustworthy = isUniqueOriginPotentiallyTrustworthy; | 591 m_isUniqueOriginPotentiallyTrustworthy = isUniqueOriginPotentiallyTrustworthy; |
591 } | 592 } |
592 | 593 |
593 } // namespace blink | 594 } // namespace blink |
OLD | NEW |