| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 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'' |
| 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.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 31 | #import "LayerHostingContext.h" |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 32 | #import "PluginCreationParameters.h" |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 33 | #import "PluginProcess.h" |
| andersca@apple.com | 4aa72cd | 2013-05-15 18:55:30 | [diff] [blame] | 34 | #import "PluginProcessProxyMessages.h" |
| andersca@apple.com | d92f29c | 2011-08-19 22:50:47 | [diff] [blame] | 35 | #import "PluginProxyMessages.h" |
| andersca@apple.com | d92f29c | 2011-08-19 22:50:47 | [diff] [blame] | 36 | #import "WebProcessConnection.h" |
| 37 | #import <QuartzCore/QuartzCore.h> |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 38 | |
| 39 | using namespace WebCore; |
| 40 | |
| 41 | namespace WebKit { |
| 42 | |
| andersca@apple.com | b77fa50 | 2011-08-22 21:35:23 | [diff] [blame] | 43 | void PluginControllerProxy::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus) |
| 44 | { |
| 45 | m_connection->connection()->send(Messages::PluginProxy::PluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus), m_pluginInstanceID); |
| 46 | } |
| 47 | |
| andersca@apple.com | d92f29c | 2011-08-19 22:50:47 | [diff] [blame] | 48 | void PluginControllerProxy::setComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState) |
| 49 | { |
| andersca@apple.com | 2b4a617 | 2011-08-26 01:02:25 | [diff] [blame] | 50 | m_connection->connection()->send(Messages::PluginProxy::SetComplexTextInputState(pluginComplexTextInputState), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); |
| andersca@apple.com | d92f29c | 2011-08-19 22:50:47 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | mach_port_t PluginControllerProxy::compositingRenderServerPort() |
| 54 | { |
| 55 | return PluginProcess::shared().compositingRenderServerPort(); |
| 56 | } |
| 57 | |
| andersca@apple.com | 4aa72cd | 2013-05-15 18:55:30 | [diff] [blame] | 58 | void PluginControllerProxy::openPluginPreferencePane() |
| 59 | { |
| 60 | PluginProcess::shared().parentProcessConnection()->send(Messages::PluginProcessProxy::OpenPluginPreferencePane(), 0); |
| 61 | } |
| 62 | |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 63 | void PluginControllerProxy::platformInitialize(const PluginCreationParameters& creationParameters) |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 64 | { |
| weinig@apple.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 65 | ASSERT(!m_layerHostingContext); |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 66 | updateLayerHostingContext(creationParameters.parameters.layerHostingMode); |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void PluginControllerProxy::platformDestroy() |
| 70 | { |
| weinig@apple.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 71 | if (!m_layerHostingContext) |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 72 | return; |
| 73 | |
| weinig@apple.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 74 | m_layerHostingContext->invalidate(); |
| 75 | m_layerHostingContext = nullptr; |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | uint32_t PluginControllerProxy::remoteLayerClientID() const |
| 79 | { |
| weinig@apple.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 80 | if (!m_layerHostingContext) |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 81 | return 0; |
| 82 | |
| weinig@apple.com | 6e48de2 | 2012-03-05 22:53:43 | [diff] [blame] | 83 | return m_layerHostingContext->contextID(); |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 84 | } |
| 85 | |
| andersca@apple.com | eeafef7 | 2011-04-12 19:45:15 | [diff] [blame] | 86 | void PluginControllerProxy::platformGeometryDidChange() |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 87 | { |
| weinig@apple.com | 32b809e | 2012-02-27 03:12:36 | [diff] [blame] | 88 | CALayer *pluginLayer = m_plugin->pluginLayer(); |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 89 | |
| 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.com | 6ddf002 | 2011-11-01 00:29:03 | [diff] [blame] | 93 | [pluginLayer setFrame:CGRectMake(0, 0, m_pluginSize.width(), m_pluginSize.height())]; |
| antonm@chromium.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 94 | [CATransaction commit]; |
| 95 | } |
| 96 | |
| andersca@apple.com | f825001 | 2011-04-12 19:37:44 | [diff] [blame] | 97 | void PluginControllerProxy::windowFocusChanged(bool hasFocus) |
| 98 | { |
| 99 | m_plugin->windowFocusChanged(hasFocus); |
| 100 | } |
| 101 | |
| 102 | void PluginControllerProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates) |
| 103 | { |
| 104 | m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates); |
| 105 | } |
| 106 | |
| 107 | void PluginControllerProxy::windowVisibilityChanged(bool isVisible) |
| 108 | { |
| 109 | m_plugin->windowVisibilityChanged(isVisible); |
| 110 | } |
| 111 | |
| 112 | void PluginControllerProxy::sendComplexTextInput(const String& textInput) |
| 113 | { |
| 114 | m_plugin->sendComplexTextInput(textInput); |
| 115 | } |
| 116 | |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 117 | void PluginControllerProxy::setLayerHostingMode(uint32_t opaqueLayerHostingMode) |
| 118 | { |
| 119 | LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode); |
| andersca@apple.com | 4921e9d | 2012-04-02 22:11:51 | [diff] [blame] | 120 | |
| 121 | m_plugin->setLayerHostingMode(layerHostingMode); |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 122 | updateLayerHostingContext(layerHostingMode); |
| 123 | |
| andersca@apple.com | a6efde3 | 2012-05-01 01:38:12 | [diff] [blame] | 124 | if (m_layerHostingContext) |
| 125 | m_connection->connection()->send(Messages::PluginProxy::SetLayerHostingContextID(m_layerHostingContext->contextID()), m_pluginInstanceID); |
| andersca@apple.com | b7d08e7 | 2012-03-28 00:16:52 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | void 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.org | cb4428b | 2011-03-01 15:14:09 | [diff] [blame] | 155 | } // namespace WebKit |
| 156 | |
| 157 | #endif // ENABLE(PLUGIN_PROCESS) |