| 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 | #include "config.h" |
| 27 | |
| 28 | #if ENABLE(FULLSCREEN_API) |
| 29 | |
| 30 | #include "InjectedBundlePageFullScreenClient.h" |
| 31 | |
| 32 | #include "InjectedBundleNodeHandle.h" |
| 33 | #include "WKAPICast.h" |
| 34 | #include "WKBundleAPICast.h" |
| 35 | #include "WKSharedAPICast.h" |
| 36 | #include "WebCoreArgumentCoders.h" |
| 37 | #include "WebFullScreenManagerProxyMessages.h" |
| 38 | #include "WebPage.h" |
| 39 | #include <WebCore/Element.h> |
| 40 | |
| 41 | namespace WebKit { |
| 42 | using namespace WebCore; |
| 43 | |
| 44 | bool InjectedBundlePageFullScreenClient::supportsFullScreen(WebPage *page, bool withKeyboard) |
| 45 | { |
| 46 | if (m_client.supportsFullScreen) |
| 47 | return m_client.supportsFullScreen(toAPI(page), withKeyboard); |
| 48 | |
| 49 | bool supports = true; |
| 50 | page->sendSync(Messages::WebFullScreenManagerProxy::SupportsFullScreen(withKeyboard), Messages::WebFullScreenManagerProxy::SupportsFullScreen::Reply(supports)); |
| 51 | return supports; |
| 52 | } |
| 53 | |
| 54 | void InjectedBundlePageFullScreenClient::enterFullScreenForElement(WebPage *page, WebCore::Element *element) |
| 55 | { |
| 56 | if (m_client.enterFullScreenForElement) { |
| 57 | RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element); |
| 58 | m_client.enterFullScreenForElement(toAPI(page), toAPI(nodeHandle.get())); |
| 59 | } else |
| 60 | page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen()); |
| 61 | } |
| 62 | |
| 63 | void InjectedBundlePageFullScreenClient::exitFullScreenForElement(WebPage *page, WebCore::Element *element) |
| 64 | { |
| 65 | if (m_client.exitFullScreenForElement) { |
| 66 | RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element); |
| 67 | m_client.exitFullScreenForElement(toAPI(page), toAPI(nodeHandle.get())); |
| 68 | } else |
| 69 | page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen()); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | void InjectedBundlePageFullScreenClient::beganEnterFullScreen(WebPage *page, IntRect& initialFrame, IntRect& finalFrame) |
| 74 | { |
| 75 | if (m_client.beganEnterFullScreen) |
| 76 | m_client.beganEnterFullScreen(toAPI(page), toAPI(initialFrame), toAPI(finalFrame)); |
| 77 | else |
| 78 | page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreen(initialFrame, finalFrame)); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void InjectedBundlePageFullScreenClient::beganExitFullScreen(WebPage *page, IntRect& initialFrame, IntRect& finalFrame) |
| 83 | { |
| 84 | if (m_client.beganExitFullScreen) |
| 85 | m_client.beganExitFullScreen(toAPI(page), toAPI(initialFrame), toAPI(finalFrame)); |
| 86 | else |
| 87 | page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreen(initialFrame, finalFrame)); |
| 88 | } |
| 89 | |
| 90 | void InjectedBundlePageFullScreenClient::closeFullScreen(WebPage *page) |
| 91 | { |
| 92 | if (m_client.closeFullScreen) |
| 93 | m_client.closeFullScreen(toAPI(page)); |
| 94 | else |
| 95 | page->send(Messages::WebFullScreenManagerProxy::Close()); |
| 96 | } |
| 97 | |
| 98 | } // namespace WebKit |
| 99 | |
| 100 | #endif // ENABLE(FULLSCREEN_API) |
| 101 | |