| 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 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/websockets/DOMWebSocket.h" | 32 #include "modules/websockets/DOMWebSocket.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 36 #include "core/dom/DOMArrayBuffer.h" | 36 #include "core/dom/DOMArrayBuffer.h" |
| 37 #include "core/dom/DOMArrayBufferView.h" | 37 #include "core/dom/DOMArrayBufferView.h" |
| 38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
| 39 #include "core/dom/ExceptionCode.h" | 39 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/dom/ExecutionContext.h" | 40 #include "core/dom/ExecutionContext.h" |
| 41 #include "core/dom/SecurityContext.h" |
| 41 #include "core/events/MessageEvent.h" | 42 #include "core/events/MessageEvent.h" |
| 42 #include "core/fileapi/Blob.h" | 43 #include "core/fileapi/Blob.h" |
| 43 #include "core/frame/ConsoleTypes.h" | 44 #include "core/frame/ConsoleTypes.h" |
| 44 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
| 45 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 46 #include "core/frame/csp/ContentSecurityPolicy.h" | 47 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 47 #include "core/inspector/ConsoleMessage.h" | 48 #include "core/inspector/ConsoleMessage.h" |
| 48 #include "core/inspector/ScriptCallStack.h" | 49 #include "core/inspector/ScriptCallStack.h" |
| 49 #include "modules/websockets/CloseEvent.h" | 50 #include "modules/websockets/CloseEvent.h" |
| 50 #include "platform/Logging.h" | 51 #include "platform/Logging.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 265 |
| 265 DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url,
const String& protocol, ExceptionState& exceptionState) | 266 DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url,
const String& protocol, ExceptionState& exceptionState) |
| 266 { | 267 { |
| 267 Vector<String> protocols; | 268 Vector<String> protocols; |
| 268 protocols.append(protocol); | 269 protocols.append(protocol); |
| 269 return create(context, url, protocols, exceptionState); | 270 return create(context, url, protocols, exceptionState); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void DOMWebSocket::connect(const String& url, const Vector<String>& protocols, E
xceptionState& exceptionState) | 273 void DOMWebSocket::connect(const String& url, const Vector<String>& protocols, E
xceptionState& exceptionState) |
| 273 { | 274 { |
| 275 |
| 274 WTF_LOG(Network, "WebSocket %p connect() url='%s'", this, url.utf8().data())
; | 276 WTF_LOG(Network, "WebSocket %p connect() url='%s'", this, url.utf8().data())
; |
| 275 m_url = KURL(KURL(), url); | 277 m_url = KURL(KURL(), url); |
| 276 | 278 |
| 279 if (executionContext()->securityContext().insecureContentPolicy() == Securit
yContext::InsecureContentUpgrade && m_url.protocol() == "ws") { |
| 280 m_url.setProtocol("wss"); |
| 281 if (m_url.port() == 80) |
| 282 m_url.setPort(443); |
| 283 } |
| 284 |
| 277 if (!m_url.isValid()) { | 285 if (!m_url.isValid()) { |
| 278 m_state = CLOSED; | 286 m_state = CLOSED; |
| 279 exceptionState.throwDOMException(SyntaxError, "The URL '" + url + "' is
invalid."); | 287 exceptionState.throwDOMException(SyntaxError, "The URL '" + url + "' is
invalid."); |
| 280 return; | 288 return; |
| 281 } | 289 } |
| 282 if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) { | 290 if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) { |
| 283 m_state = CLOSED; | 291 m_state = CLOSED; |
| 284 exceptionState.throwDOMException(SyntaxError, "The URL's scheme must be
either 'ws' or 'wss'. '" + m_url.protocol() + "' is not allowed."); | 292 exceptionState.throwDOMException(SyntaxError, "The URL's scheme must be
either 'ws' or 'wss'. '" + m_url.protocol() + "' is not allowed."); |
| 285 return; | 293 return; |
| 286 } | 294 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 void DOMWebSocket::trace(Visitor* visitor) | 666 void DOMWebSocket::trace(Visitor* visitor) |
| 659 { | 667 { |
| 660 visitor->trace(m_channel); | 668 visitor->trace(m_channel); |
| 661 visitor->trace(m_eventQueue); | 669 visitor->trace(m_eventQueue); |
| 662 WebSocketChannelClient::trace(visitor); | 670 WebSocketChannelClient::trace(visitor); |
| 663 RefCountedGarbageCollectedEventTargetWithInlineData<DOMWebSocket>::trace(vis
itor); | 671 RefCountedGarbageCollectedEventTargetWithInlineData<DOMWebSocket>::trace(vis
itor); |
| 664 ActiveDOMObject::trace(visitor); | 672 ActiveDOMObject::trace(visitor); |
| 665 } | 673 } |
| 666 | 674 |
| 667 } // namespace blink | 675 } // namespace blink |
| OLD | NEW |