1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include "config.h" 26 27#if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 28 29#include "WebPage.h" 30 31#include "ArgumentCoders.h" 32#include "Connection.h" 33#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE) 34#include "DummyType.h" 35#endif 36#include "HandleMessage.h" 37#if PLATFORM(MAC) 38#include "MachPort.h" 39#endif 40#include "MessageDecoder.h" 41#include "Plugin.h" 42#include "WebCoreArgumentCoders.h" 43#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) 44#include "WebEvent.h" 45#endif 46#include "WebPageMessages.h" 47#include "WebPreferencesStore.h" 48#include <WebCore/GraphicsLayer.h> 49#if PLATFORM(MAC) 50#include <WebCore/KeyboardEvent.h> 51#endif 52#include <WebCore/PluginData.h> 53#include <utility> 54#include <wtf/HashMap.h> 55#include <wtf/Vector.h> 56#include <wtf/text/WTFString.h> 57 58namespace Messages { 59 60namespace WebPage { 61 62GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::MessageEncoder> encoder) 63 : m_connection(connection) 64 , m_encoder(WTF::move(encoder)) 65{ 66} 67 68GetPluginProcessConnection::DelayedReply::~DelayedReply() 69{ 70 ASSERT(!m_connection); 71} 72 73bool GetPluginProcessConnection::DelayedReply::send(const IPC::Connection::Handle& connectionHandle) 74{ 75 ASSERT(m_encoder); 76 *m_encoder << connectionHandle; 77 bool _result = m_connection->sendSyncReply(WTF::move(m_encoder)); 78 m_connection = nullptr; 79 return _result; 80} 81 82TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::MessageEncoder> encoder) 83 : m_connection(connection) 84 , m_encoder(WTF::move(encoder)) 85{ 86} 87 88TestMultipleAttributes::DelayedReply::~DelayedReply() 89{ 90 ASSERT(!m_connection); 91} 92 93bool TestMultipleAttributes::DelayedReply::send() 94{ 95 ASSERT(m_encoder); 96 bool _result = m_connection->sendSyncReply(WTF::move(m_encoder)); 97 m_connection = nullptr; 98 return _result; 99} 100 101} // namespace WebPage 102 103} // namespace Messages 104 105namespace WebKit { 106 107void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) 108{ 109 if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { 110 IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); 111 return; 112 } 113#if ENABLE(TOUCH_EVENTS) 114 if (decoder.messageName() == Messages::WebPage::LoadSomething::name()) { 115 IPC::handleMessage<Messages::WebPage::LoadSomething>(decoder, this, &WebPage::loadSomething); 116 return; 117 } 118#endif 119#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) 120 if (decoder.messageName() == Messages::WebPage::TouchEvent::name()) { 121 IPC::handleMessage<Messages::WebPage::TouchEvent>(decoder, this, &WebPage::touchEvent); 122 return; 123 } 124#endif 125#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) 126 if (decoder.messageName() == Messages::WebPage::AddEvent::name()) { 127 IPC::handleMessage<Messages::WebPage::AddEvent>(decoder, this, &WebPage::addEvent); 128 return; 129 } 130#endif 131#if ENABLE(TOUCH_EVENTS) 132 if (decoder.messageName() == Messages::WebPage::LoadSomethingElse::name()) { 133 IPC::handleMessage<Messages::WebPage::LoadSomethingElse>(decoder, this, &WebPage::loadSomethingElse); 134 return; 135 } 136#endif 137 if (decoder.messageName() == Messages::WebPage::DidReceivePolicyDecision::name()) { 138 IPC::handleMessage<Messages::WebPage::DidReceivePolicyDecision>(decoder, this, &WebPage::didReceivePolicyDecision); 139 return; 140 } 141 if (decoder.messageName() == Messages::WebPage::Close::name()) { 142 IPC::handleMessage<Messages::WebPage::Close>(decoder, this, &WebPage::close); 143 return; 144 } 145 if (decoder.messageName() == Messages::WebPage::PreferencesDidChange::name()) { 146 IPC::handleMessage<Messages::WebPage::PreferencesDidChange>(decoder, this, &WebPage::preferencesDidChange); 147 return; 148 } 149 if (decoder.messageName() == Messages::WebPage::SendDoubleAndFloat::name()) { 150 IPC::handleMessage<Messages::WebPage::SendDoubleAndFloat>(decoder, this, &WebPage::sendDoubleAndFloat); 151 return; 152 } 153 if (decoder.messageName() == Messages::WebPage::SendInts::name()) { 154 IPC::handleMessage<Messages::WebPage::SendInts>(decoder, this, &WebPage::sendInts); 155 return; 156 } 157 if (decoder.messageName() == Messages::WebPage::TestParameterAttributes::name()) { 158 IPC::handleMessage<Messages::WebPage::TestParameterAttributes>(decoder, this, &WebPage::testParameterAttributes); 159 return; 160 } 161 if (decoder.messageName() == Messages::WebPage::TemplateTest::name()) { 162 IPC::handleMessage<Messages::WebPage::TemplateTest>(decoder, this, &WebPage::templateTest); 163 return; 164 } 165 if (decoder.messageName() == Messages::WebPage::SetVideoLayerID::name()) { 166 IPC::handleMessage<Messages::WebPage::SetVideoLayerID>(decoder, this, &WebPage::setVideoLayerID); 167 return; 168 } 169#if PLATFORM(MAC) 170 if (decoder.messageName() == Messages::WebPage::DidCreateWebProcessConnection::name()) { 171 IPC::handleMessage<Messages::WebPage::DidCreateWebProcessConnection>(decoder, this, &WebPage::didCreateWebProcessConnection); 172 return; 173 } 174#endif 175#if ENABLE(DEPRECATED_FEATURE) 176 if (decoder.messageName() == Messages::WebPage::DeprecatedOperation::name()) { 177 IPC::handleMessage<Messages::WebPage::DeprecatedOperation>(decoder, this, &WebPage::deprecatedOperation); 178 return; 179 } 180#endif 181#if ENABLE(EXPERIMENTAL_FEATURE) 182 if (decoder.messageName() == Messages::WebPage::ExperimentalOperation::name()) { 183 IPC::handleMessage<Messages::WebPage::ExperimentalOperation>(decoder, this, &WebPage::experimentalOperation); 184 return; 185 } 186#endif 187 UNUSED_PARAM(connection); 188 UNUSED_PARAM(decoder); 189 ASSERT_NOT_REACHED(); 190} 191 192void WebPage::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) 193{ 194 if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) { 195 IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin); 196 return; 197 } 198 if (decoder.messageName() == Messages::WebPage::RunJavaScriptAlert::name()) { 199 IPC::handleMessage<Messages::WebPage::RunJavaScriptAlert>(decoder, *replyEncoder, this, &WebPage::runJavaScriptAlert); 200 return; 201 } 202 if (decoder.messageName() == Messages::WebPage::GetPlugins::name()) { 203 IPC::handleMessage<Messages::WebPage::GetPlugins>(decoder, *replyEncoder, this, &WebPage::getPlugins); 204 return; 205 } 206 if (decoder.messageName() == Messages::WebPage::GetPluginProcessConnection::name()) { 207 IPC::handleMessageDelayed<Messages::WebPage::GetPluginProcessConnection>(connection, decoder, replyEncoder, this, &WebPage::getPluginProcessConnection); 208 return; 209 } 210 if (decoder.messageName() == Messages::WebPage::TestMultipleAttributes::name()) { 211 IPC::handleMessageDelayed<Messages::WebPage::TestMultipleAttributes>(connection, decoder, replyEncoder, this, &WebPage::testMultipleAttributes); 212 return; 213 } 214#if PLATFORM(MAC) 215 if (decoder.messageName() == Messages::WebPage::InterpretKeyEvent::name()) { 216 IPC::handleMessage<Messages::WebPage::InterpretKeyEvent>(decoder, *replyEncoder, this, &WebPage::interpretKeyEvent); 217 return; 218 } 219#endif 220 UNUSED_PARAM(connection); 221 UNUSED_PARAM(decoder); 222 UNUSED_PARAM(replyEncoder); 223 ASSERT_NOT_REACHED(); 224} 225 226} // namespace WebKit 227 228#endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 229