blob: 19c2cf25bdd0580cca60840565459f1c0e794b4b [file] [log] [blame]
antonm@chromium.orgcb4428b2011-03-01 15:14:091/*
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''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#import "config.h"
27#import "PluginControllerProxy.h"
28
29#if ENABLE(PLUGIN_PROCESS)
30
weinig@apple.com6e48de22012-03-05 22:53:4331#import "LayerHostingContext.h"
andersca@apple.comb7d08e72012-03-28 00:16:5232#import "PluginCreationParameters.h"
antonm@chromium.orgcb4428b2011-03-01 15:14:0933#import "PluginProcess.h"
andersca@apple.com4aa72cd2013-05-15 18:55:3034#import "PluginProcessProxyMessages.h"
andersca@apple.comd92f29c2011-08-19 22:50:4735#import "PluginProxyMessages.h"
andersca@apple.comd92f29c2011-08-19 22:50:4736#import "WebProcessConnection.h"
37#import <QuartzCore/QuartzCore.h>
antonm@chromium.orgcb4428b2011-03-01 15:14:0938
39using namespace WebCore;
40
41namespace WebKit {
42
andersca@apple.comb77fa502011-08-22 21:35:2343void PluginControllerProxy::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus)
44{
45 m_connection->connection()->send(Messages::PluginProxy::PluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus), m_pluginInstanceID);
46}
47
andersca@apple.comd92f29c2011-08-19 22:50:4748void PluginControllerProxy::setComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState)
49{
andersca@apple.com2b4a6172011-08-26 01:02:2550 m_connection->connection()->send(Messages::PluginProxy::SetComplexTextInputState(pluginComplexTextInputState), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
andersca@apple.comd92f29c2011-08-19 22:50:4751}
52
53mach_port_t PluginControllerProxy::compositingRenderServerPort()
54{
55 return PluginProcess::shared().compositingRenderServerPort();
56}
57
andersca@apple.com4aa72cd2013-05-15 18:55:3058void PluginControllerProxy::openPluginPreferencePane()
59{
60 PluginProcess::shared().parentProcessConnection()->send(Messages::PluginProcessProxy::OpenPluginPreferencePane(), 0);
61}
62
andersca@apple.comb7d08e72012-03-28 00:16:5263void PluginControllerProxy::platformInitialize(const PluginCreationParameters& creationParameters)
antonm@chromium.orgcb4428b2011-03-01 15:14:0964{
weinig@apple.com6e48de22012-03-05 22:53:4365 ASSERT(!m_layerHostingContext);
andersca@apple.comb7d08e72012-03-28 00:16:5266 updateLayerHostingContext(creationParameters.parameters.layerHostingMode);
antonm@chromium.orgcb4428b2011-03-01 15:14:0967}
68
69void PluginControllerProxy::platformDestroy()
70{
weinig@apple.com6e48de22012-03-05 22:53:4371 if (!m_layerHostingContext)
antonm@chromium.orgcb4428b2011-03-01 15:14:0972 return;
73
weinig@apple.com6e48de22012-03-05 22:53:4374 m_layerHostingContext->invalidate();
75 m_layerHostingContext = nullptr;
antonm@chromium.orgcb4428b2011-03-01 15:14:0976}
77
78uint32_t PluginControllerProxy::remoteLayerClientID() const
79{
weinig@apple.com6e48de22012-03-05 22:53:4380 if (!m_layerHostingContext)
antonm@chromium.orgcb4428b2011-03-01 15:14:0981 return 0;
82
weinig@apple.com6e48de22012-03-05 22:53:4383 return m_layerHostingContext->contextID();
antonm@chromium.orgcb4428b2011-03-01 15:14:0984}
85
andersca@apple.comeeafef72011-04-12 19:45:1586void PluginControllerProxy::platformGeometryDidChange()
antonm@chromium.orgcb4428b2011-03-01 15:14:0987{
weinig@apple.com32b809e2012-02-27 03:12:3688 CALayer *pluginLayer = m_plugin->pluginLayer();
antonm@chromium.orgcb4428b2011-03-01 15:14:0989
90 // We don't want to animate to the new size so we disable actions for this transaction.
91 [CATransaction begin];
92 [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
andersca@apple.com6ddf0022011-11-01 00:29:0393 [pluginLayer setFrame:CGRectMake(0, 0, m_pluginSize.width(), m_pluginSize.height())];
antonm@chromium.orgcb4428b2011-03-01 15:14:0994 [CATransaction commit];
95}
96
andersca@apple.comf8250012011-04-12 19:37:4497void PluginControllerProxy::windowFocusChanged(bool hasFocus)
98{
99 m_plugin->windowFocusChanged(hasFocus);
100}
101
102void PluginControllerProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
103{
104 m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
105}
106
107void PluginControllerProxy::windowVisibilityChanged(bool isVisible)
108{
109 m_plugin->windowVisibilityChanged(isVisible);
110}
111
112void PluginControllerProxy::sendComplexTextInput(const String& textInput)
113{
114 m_plugin->sendComplexTextInput(textInput);
115}
116
andersca@apple.comb7d08e72012-03-28 00:16:52117void PluginControllerProxy::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
118{
119 LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
andersca@apple.com4921e9d2012-04-02 22:11:51120
121 m_plugin->setLayerHostingMode(layerHostingMode);
andersca@apple.comb7d08e72012-03-28 00:16:52122 updateLayerHostingContext(layerHostingMode);
123
andersca@apple.coma6efde32012-05-01 01:38:12124 if (m_layerHostingContext)
125 m_connection->connection()->send(Messages::PluginProxy::SetLayerHostingContextID(m_layerHostingContext->contextID()), m_pluginInstanceID);
andersca@apple.comb7d08e72012-03-28 00:16:52126}
127
128void PluginControllerProxy::updateLayerHostingContext(LayerHostingMode layerHostingMode)
129{
130 CALayer *platformLayer = m_plugin->pluginLayer();
131 if (!platformLayer)
132 return;
133
134 if (m_layerHostingContext) {
135 if (m_layerHostingContext->layerHostingMode() == layerHostingMode)
136 return;
137
138 m_layerHostingContext->invalidate();
139 }
140
141 switch (layerHostingMode) {
142 case LayerHostingModeDefault:
143 m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort());
144 break;
145#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
146 case LayerHostingModeInWindowServer:
147 m_layerHostingContext = LayerHostingContext::createForWindowServer();
148 break;
149#endif
150 }
151
152 m_layerHostingContext->setRootLayer(platformLayer);
153}
154
antonm@chromium.orgcb4428b2011-03-01 15:14:09155} // namespace WebKit
156
157#endif // ENABLE(PLUGIN_PROCESS)