OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 exceptionState.throwDOMException(SyntaxError, "The URL contains a fragme
nt identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are n
ot allowed in WebSocket URLs."); | 300 exceptionState.throwDOMException(SyntaxError, "The URL contains a fragme
nt identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are n
ot allowed in WebSocket URLs."); |
301 return; | 301 return; |
302 } | 302 } |
303 if (!portAllowed(m_url)) { | 303 if (!portAllowed(m_url)) { |
304 m_state = CLOSED; | 304 m_state = CLOSED; |
305 exceptionState.throwSecurityError("The port " + String::number(m_url.por
t()) + " is not allowed."); | 305 exceptionState.throwSecurityError("The port " + String::number(m_url.por
t()) + " is not allowed."); |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 // FIXME: Convert this to check the isolated world's Content Security Policy
once webkit.org/b/104520 is solved. | 309 // FIXME: Convert this to check the isolated world's Content Security Policy
once webkit.org/b/104520 is solved. |
310 bool shouldBypassMainWorldContentSecurityPolicy = false; | 310 bool shouldBypassMainWorldCSP = false; |
311 if (executionContext()->isDocument()) { | 311 if (executionContext()->isDocument()) { |
312 Document* document = toDocument(executionContext()); | 312 Document* document = toDocument(executionContext()); |
313 shouldBypassMainWorldContentSecurityPolicy = document->frame()->script()
.shouldBypassMainWorldContentSecurityPolicy(); | 313 shouldBypassMainWorldCSP = document->frame()->script().shouldBypassMainW
orldCSP(); |
314 } | 314 } |
315 if (!shouldBypassMainWorldContentSecurityPolicy && !executionContext()->cont
entSecurityPolicy()->allowConnectToSource(m_url)) { | 315 if (!shouldBypassMainWorldCSP && !executionContext()->contentSecurityPolicy(
)->allowConnectToSource(m_url)) { |
316 m_state = CLOSED; | 316 m_state = CLOSED; |
317 // The URL is safe to expose to JavaScript, as this check happens synchr
onously before redirection. | 317 // The URL is safe to expose to JavaScript, as this check happens synchr
onously before redirection. |
318 exceptionState.throwSecurityError("Refused to connect to '" + m_url.elid
edString() + "' because it violates the document's Content Security Policy."); | 318 exceptionState.throwSecurityError("Refused to connect to '" + m_url.elid
edString() + "' because it violates the document's Content Security Policy."); |
319 return; | 319 return; |
320 } | 320 } |
321 | 321 |
322 m_channel = createChannel(executionContext(), this); | 322 m_channel = createChannel(executionContext(), this); |
323 | 323 |
324 for (size_t i = 0; i < protocols.size(); ++i) { | 324 for (size_t i = 0; i < protocols.size(); ++i) { |
325 if (!isValidSubprotocolString(protocols[i])) { | 325 if (!isValidSubprotocolString(protocols[i])) { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 701 |
702 void WebSocket::trace(Visitor* visitor) | 702 void WebSocket::trace(Visitor* visitor) |
703 { | 703 { |
704 visitor->trace(m_channel); | 704 visitor->trace(m_channel); |
705 visitor->trace(m_eventQueue); | 705 visitor->trace(m_eventQueue); |
706 WebSocketChannelClient::trace(visitor); | 706 WebSocketChannelClient::trace(visitor); |
707 EventTargetWithInlineData::trace(visitor); | 707 EventTargetWithInlineData::trace(visitor); |
708 } | 708 } |
709 | 709 |
710 } // namespace WebCore | 710 } // namespace WebCore |
OLD | NEW |