| 1 | /* |
| 2 | * Copyright (C) 2011 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 | #include "config.h" |
| 27 | #include "WebFullScreenManagerProxy.h" |
| 28 | |
| 29 | #if ENABLE(FULLSCREEN_API) |
| 30 | |
| 31 | #include "APIFullscreenClient.h" |
| 32 | #include "WebAutomationSession.h" |
| 33 | #include "WebFullScreenManagerMessages.h" |
| 34 | #include "WebFullScreenManagerProxyMessages.h" |
| 35 | #include "WebPageProxy.h" |
| 36 | #include "WebProcessPool.h" |
| 37 | #include "WebProcessProxy.h" |
| 38 | #include <WebCore/IntRect.h> |
| 39 | |
| 40 | namespace WebKit { |
| 41 | using namespace WebCore; |
| 42 | |
| 43 | WebFullScreenManagerProxy::WebFullScreenManagerProxy(WebPageProxy& page, WebFullScreenManagerProxyClient& client) |
| 44 | : m_page(page) |
| 45 | , m_client(client) |
| 46 | { |
| 47 | m_page.process().addMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page.pageID(), *this); |
| 48 | } |
| 49 | |
| 50 | WebFullScreenManagerProxy::~WebFullScreenManagerProxy() |
| 51 | { |
| 52 | m_page.process().removeMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page.pageID()); |
| 53 | m_client.closeFullScreenManager(); |
| 54 | } |
| 55 | |
| 56 | void WebFullScreenManagerProxy::willEnterFullScreen() |
| 57 | { |
| 58 | m_page.fullscreenClient().willEnterFullscreen(&m_page); |
| 59 | m_page.process().send(Messages::WebFullScreenManager::WillEnterFullScreen(), m_page.pageID()); |
| 60 | } |
| 61 | |
| 62 | void WebFullScreenManagerProxy::didEnterFullScreen() |
| 63 | { |
| 64 | m_page.fullscreenClient().didEnterFullscreen(&m_page); |
| 65 | m_page.process().send(Messages::WebFullScreenManager::DidEnterFullScreen(), m_page.pageID()); |
| 66 | |
| 67 | if (m_page.isControlledByAutomation()) { |
| 68 | if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession()) |
| 69 | automationSession->didEnterFullScreenForPage(m_page); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | void WebFullScreenManagerProxy::willExitFullScreen() |
| 74 | { |
| 75 | m_page.fullscreenClient().willExitFullscreen(&m_page); |
| 76 | m_page.process().send(Messages::WebFullScreenManager::WillExitFullScreen(), m_page.pageID()); |
| 77 | } |
| 78 | |
| 79 | void WebFullScreenManagerProxy::didExitFullScreen() |
| 80 | { |
| 81 | m_page.fullscreenClient().didExitFullscreen(&m_page); |
| 82 | m_page.process().send(Messages::WebFullScreenManager::DidExitFullScreen(), m_page.pageID()); |
| 83 | |
| 84 | if (m_page.isControlledByAutomation()) { |
| 85 | if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession()) |
| 86 | automationSession->didExitFullScreenForPage(m_page); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | void WebFullScreenManagerProxy::setAnimatingFullScreen(bool animating) |
| 91 | { |
| 92 | m_page.process().send(Messages::WebFullScreenManager::SetAnimatingFullScreen(animating), m_page.pageID()); |
| 93 | } |
| 94 | |
| 95 | void WebFullScreenManagerProxy::requestExitFullScreen() |
| 96 | { |
| 97 | m_page.process().send(Messages::WebFullScreenManager::RequestExitFullScreen(), m_page.pageID()); |
| 98 | } |
| 99 | |
| 100 | void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, CompletionHandler<void(bool)>&& completionHandler) |
| 101 | { |
| 102 | #if PLATFORM(IOS_FAMILY) |
| 103 | completionHandler(!withKeyboard); |
| 104 | #else |
| 105 | completionHandler(true); |
| 106 | #endif |
| 107 | } |
| 108 | |
| 109 | void WebFullScreenManagerProxy::saveScrollPosition() |
| 110 | { |
| 111 | m_page.process().send(Messages::WebFullScreenManager::SaveScrollPosition(), m_page.pageID()); |
| 112 | } |
| 113 | |
| 114 | void WebFullScreenManagerProxy::restoreScrollPosition() |
| 115 | { |
| 116 | m_page.process().send(Messages::WebFullScreenManager::RestoreScrollPosition(), m_page.pageID()); |
| 117 | } |
| 118 | |
| 119 | void WebFullScreenManagerProxy::setFullscreenInsets(const WebCore::FloatBoxExtent& insets) |
| 120 | { |
| 121 | m_page.process().send(Messages::WebFullScreenManager::SetFullscreenInsets(insets), m_page.pageID()); |
| 122 | } |
| 123 | |
| 124 | void WebFullScreenManagerProxy::setFullscreenAutoHideDuration(Seconds duration) |
| 125 | { |
| 126 | m_page.process().send(Messages::WebFullScreenManager::SetFullscreenAutoHideDuration(duration), m_page.pageID()); |
| 127 | } |
| 128 | |
| 129 | void WebFullScreenManagerProxy::setFullscreenControlsHidden(bool hidden) |
| 130 | { |
| 131 | m_page.process().send(Messages::WebFullScreenManager::SetFullscreenControlsHidden(hidden), m_page.pageID()); |
| 132 | } |
| 133 | |
| 134 | void WebFullScreenManagerProxy::close() |
| 135 | { |
| 136 | m_client.closeFullScreenManager(); |
| 137 | } |
| 138 | |
| 139 | bool WebFullScreenManagerProxy::isFullScreen() |
| 140 | { |
| 141 | return m_client.isFullScreen(); |
| 142 | } |
| 143 | |
| 144 | void WebFullScreenManagerProxy::enterFullScreen() |
| 145 | { |
| 146 | m_client.enterFullScreen(); |
| 147 | } |
| 148 | |
| 149 | void WebFullScreenManagerProxy::exitFullScreen() |
| 150 | { |
| 151 | m_client.exitFullScreen(); |
| 152 | } |
| 153 | |
| 154 | void WebFullScreenManagerProxy::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) |
| 155 | { |
| 156 | m_client.beganEnterFullScreen(initialFrame, finalFrame); |
| 157 | } |
| 158 | |
| 159 | void WebFullScreenManagerProxy::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) |
| 160 | { |
| 161 | m_client.beganExitFullScreen(initialFrame, finalFrame); |
| 162 | } |
| 163 | |
| 164 | } // namespace WebKit |
| 165 | |
| 166 | #endif // ENABLE(FULLSCREEN_API) |
| 167 | |