| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/fileapi/Blob.h" | 37 #include "core/fileapi/Blob.h" |
| 38 #include "core/fileapi/FileReaderLoader.h" | 38 #include "core/fileapi/FileReaderLoader.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/loader/FrameLoader.h" | 41 #include "core/loader/FrameLoader.h" |
| 42 #include "core/loader/FrameLoaderClient.h" | 42 #include "core/loader/FrameLoaderClient.h" |
| 43 #include "core/loader/MixedContentChecker.h" |
| 43 #include "core/loader/UniqueIdentifier.h" | 44 #include "core/loader/UniqueIdentifier.h" |
| 44 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
| 45 #include "modules/websockets/WebSocketChannelClient.h" | 46 #include "modules/websockets/WebSocketChannelClient.h" |
| 46 #include "platform/Logging.h" | 47 #include "platform/Logging.h" |
| 47 #include "platform/network/SocketStreamError.h" | 48 #include "platform/network/SocketStreamError.h" |
| 48 #include "platform/network/SocketStreamHandle.h" | 49 #include "platform/network/SocketStreamHandle.h" |
| 49 #include "wtf/ArrayBuffer.h" | 50 #include "wtf/ArrayBuffer.h" |
| 50 #include "wtf/FastMalloc.h" | 51 #include "wtf/FastMalloc.h" |
| 51 #include "wtf/HashMap.h" | 52 #include "wtf/HashMap.h" |
| 52 #include "wtf/OwnPtr.h" | 53 #include "wtf/OwnPtr.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 , m_lineNumberAtConstruction(lineNumber) | 81 , m_lineNumberAtConstruction(lineNumber) |
| 81 { | 82 { |
| 82 if (m_document->page()) | 83 if (m_document->page()) |
| 83 m_identifier = createUniqueIdentifier(); | 84 m_identifier = createUniqueIdentifier(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 MainThreadWebSocketChannel::~MainThreadWebSocketChannel() | 87 MainThreadWebSocketChannel::~MainThreadWebSocketChannel() |
| 87 { | 88 { |
| 88 } | 89 } |
| 89 | 90 |
| 90 void MainThreadWebSocketChannel::connect(const KURL& url, const String& protocol
) | 91 bool MainThreadWebSocketChannel::connect(const KURL& url, const String& protocol
) |
| 91 { | 92 { |
| 92 WTF_LOG(Network, "MainThreadWebSocketChannel %p connect()", this); | 93 WTF_LOG(Network, "MainThreadWebSocketChannel %p connect()", this); |
| 93 ASSERT(!m_handle); | 94 ASSERT(!m_handle); |
| 94 ASSERT(!m_suspended); | 95 ASSERT(!m_suspended); |
| 96 |
| 97 if (m_document->frame() && !m_document->frame()->loader().mixedContentChecke
r()->canConnectInsecureWebSocket(m_document->securityOrigin(), url)) |
| 98 return false; |
| 99 if (MixedContentChecker::isMixedContent(m_document->securityOrigin(), url))
{ |
| 100 String message = "Connecting to a non-secure WebSocket server from a sec
ure origin is deprecated."; |
| 101 m_document->addConsoleMessage(JSMessageSource, WarningMessageLevel, mess
age); |
| 102 } |
| 103 |
| 95 m_handshake = adoptPtr(new WebSocketHandshake(url, protocol, m_document)); | 104 m_handshake = adoptPtr(new WebSocketHandshake(url, protocol, m_document)); |
| 96 m_handshake->reset(); | 105 m_handshake->reset(); |
| 97 m_handshake->addExtensionProcessor(m_perMessageDeflate.createExtensionProces
sor()); | 106 m_handshake->addExtensionProcessor(m_perMessageDeflate.createExtensionProces
sor()); |
| 98 m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor(
)); | 107 m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor(
)); |
| 99 if (m_identifier) | 108 if (m_identifier) |
| 100 InspectorInstrumentation::didCreateWebSocket(m_document, m_identifier, u
rl, protocol); | 109 InspectorInstrumentation::didCreateWebSocket(m_document, m_identifier, u
rl, protocol); |
| 101 ref(); | 110 ref(); |
| 102 m_handle = SocketStreamHandle::create(m_handshake->url(), this); | 111 m_handle = SocketStreamHandle::create(m_handshake->url(), this); |
| 112 return true; |
| 103 } | 113 } |
| 104 | 114 |
| 105 String MainThreadWebSocketChannel::subprotocol() | 115 String MainThreadWebSocketChannel::subprotocol() |
| 106 { | 116 { |
| 107 WTF_LOG(Network, "MainThreadWebSocketChannel %p subprotocol()", this); | 117 WTF_LOG(Network, "MainThreadWebSocketChannel %p subprotocol()", this); |
| 108 if (!m_handshake || m_handshake->mode() != WebSocketHandshake::Connected) | 118 if (!m_handshake || m_handshake->mode() != WebSocketHandshake::Connected) |
| 109 return ""; | 119 return ""; |
| 110 String serverProtocol = m_handshake->serverWebSocketProtocol(); | 120 String serverProtocol = m_handshake->serverWebSocketProtocol(); |
| 111 if (serverProtocol.isNull()) | 121 if (serverProtocol.isNull()) |
| 112 return ""; | 122 return ""; |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 } | 831 } |
| 822 | 832 |
| 823 Vector<char> frameData; | 833 Vector<char> frameData; |
| 824 frame.makeFrameData(frameData); | 834 frame.makeFrameData(frameData); |
| 825 | 835 |
| 826 m_perMessageDeflate.resetDeflateBuffer(); | 836 m_perMessageDeflate.resetDeflateBuffer(); |
| 827 return m_handle->send(frameData.data(), frameData.size()); | 837 return m_handle->send(frameData.data(), frameData.size()); |
| 828 } | 838 } |
| 829 | 839 |
| 830 } // namespace WebCore | 840 } // namespace WebCore |
| OLD | NEW |