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.webPageID(), *this);
|
---|
48 | }
|
---|
49 |
|
---|
50 | WebFullScreenManagerProxy::~WebFullScreenManagerProxy()
|
---|
51 | {
|
---|
52 | m_page.process().removeMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page.webPageID());
|
---|
53 | m_client.closeFullScreenManager();
|
---|
54 | callCloseCompletionHandlers();
|
---|
55 | }
|
---|
56 |
|
---|
57 | void WebFullScreenManagerProxy::willEnterFullScreen()
|
---|
58 | {
|
---|
59 | m_fullscreenState = FullscreenState::EnteringFullscreen;
|
---|
60 | m_page.fullscreenClient().willEnterFullscreen(&m_page);
|
---|
61 | m_page.send(Messages::WebFullScreenManager::WillEnterFullScreen());
|
---|
62 | }
|
---|
63 |
|
---|
64 | void WebFullScreenManagerProxy::didEnterFullScreen()
|
---|
65 | {
|
---|
66 | m_fullscreenState = FullscreenState::InFullscreen;
|
---|
67 | m_page.fullscreenClient().didEnterFullscreen(&m_page);
|
---|
68 | m_page.send(Messages::WebFullScreenManager::DidEnterFullScreen());
|
---|
69 |
|
---|
70 | if (m_page.isControlledByAutomation()) {
|
---|
71 | if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession())
|
---|
72 | automationSession->didEnterFullScreenForPage(m_page);
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | void WebFullScreenManagerProxy::willExitFullScreen()
|
---|
77 | {
|
---|
78 | m_fullscreenState = FullscreenState::ExitingFullscreen;
|
---|
79 | m_page.fullscreenClient().willExitFullscreen(&m_page);
|
---|
80 | m_page.send(Messages::WebFullScreenManager::WillExitFullScreen());
|
---|
81 | }
|
---|
82 |
|
---|
83 | void WebFullScreenManagerProxy::callCloseCompletionHandlers()
|
---|
84 | {
|
---|
85 | auto closeMediaCallbacks = WTFMove(m_closeCompletionHandlers);
|
---|
86 | for (auto& callback : closeMediaCallbacks)
|
---|
87 | callback();
|
---|
88 | }
|
---|
89 |
|
---|
90 | void WebFullScreenManagerProxy::closeWithCallback(CompletionHandler<void()>&& completionHandler)
|
---|
91 | {
|
---|
92 | m_closeCompletionHandlers.append(WTFMove(completionHandler));
|
---|
93 | close();
|
---|
94 | }
|
---|
95 |
|
---|
96 | void WebFullScreenManagerProxy::didExitFullScreen()
|
---|
97 | {
|
---|
98 | m_fullscreenState = FullscreenState::NotInFullscreen;
|
---|
99 | m_page.fullscreenClient().didExitFullscreen(&m_page);
|
---|
100 | m_page.send(Messages::WebFullScreenManager::DidExitFullScreen());
|
---|
101 |
|
---|
102 | if (m_page.isControlledByAutomation()) {
|
---|
103 | if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession())
|
---|
104 | automationSession->didExitFullScreenForPage(m_page);
|
---|
105 | }
|
---|
106 | callCloseCompletionHandlers();
|
---|
107 | }
|
---|
108 |
|
---|
109 | void WebFullScreenManagerProxy::setAnimatingFullScreen(bool animating)
|
---|
110 | {
|
---|
111 | m_page.send(Messages::WebFullScreenManager::SetAnimatingFullScreen(animating));
|
---|
112 | }
|
---|
113 |
|
---|
114 | void WebFullScreenManagerProxy::requestEnterFullScreen()
|
---|
115 | {
|
---|
116 | m_page.send(Messages::WebFullScreenManager::RequestEnterFullScreen());
|
---|
117 | }
|
---|
118 |
|
---|
119 | void WebFullScreenManagerProxy::requestExitFullScreen()
|
---|
120 | {
|
---|
121 | m_page.send(Messages::WebFullScreenManager::RequestExitFullScreen());
|
---|
122 | }
|
---|
123 |
|
---|
124 | void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, CompletionHandler<void(bool)>&& completionHandler)
|
---|
125 | {
|
---|
126 | #if PLATFORM(IOS_FAMILY)
|
---|
127 | completionHandler(!withKeyboard);
|
---|
128 | #else
|
---|
129 | completionHandler(true);
|
---|
130 | #endif
|
---|
131 | }
|
---|
132 |
|
---|
133 | void WebFullScreenManagerProxy::saveScrollPosition()
|
---|
134 | {
|
---|
135 | m_page.send(Messages::WebFullScreenManager::SaveScrollPosition());
|
---|
136 | }
|
---|
137 |
|
---|
138 | void WebFullScreenManagerProxy::restoreScrollPosition()
|
---|
139 | {
|
---|
140 | m_page.send(Messages::WebFullScreenManager::RestoreScrollPosition());
|
---|
141 | }
|
---|
142 |
|
---|
143 | void WebFullScreenManagerProxy::setFullscreenInsets(const WebCore::FloatBoxExtent& insets)
|
---|
144 | {
|
---|
145 | m_page.send(Messages::WebFullScreenManager::SetFullscreenInsets(insets));
|
---|
146 | }
|
---|
147 |
|
---|
148 | void WebFullScreenManagerProxy::setFullscreenAutoHideDuration(Seconds duration)
|
---|
149 | {
|
---|
150 | m_page.send(Messages::WebFullScreenManager::SetFullscreenAutoHideDuration(duration));
|
---|
151 | }
|
---|
152 |
|
---|
153 | void WebFullScreenManagerProxy::setFullscreenControlsHidden(bool hidden)
|
---|
154 | {
|
---|
155 | m_page.send(Messages::WebFullScreenManager::SetFullscreenControlsHidden(hidden));
|
---|
156 | }
|
---|
157 |
|
---|
158 | void WebFullScreenManagerProxy::close()
|
---|
159 | {
|
---|
160 | m_client.closeFullScreenManager();
|
---|
161 | }
|
---|
162 |
|
---|
163 | bool WebFullScreenManagerProxy::isFullScreen()
|
---|
164 | {
|
---|
165 | return m_client.isFullScreen();
|
---|
166 | }
|
---|
167 |
|
---|
168 | bool WebFullScreenManagerProxy::blocksReturnToFullscreenFromPictureInPicture() const
|
---|
169 | {
|
---|
170 | return m_blocksReturnToFullscreenFromPictureInPicture;
|
---|
171 | }
|
---|
172 |
|
---|
173 | void WebFullScreenManagerProxy::enterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture)
|
---|
174 | {
|
---|
175 | m_blocksReturnToFullscreenFromPictureInPicture = blocksReturnToFullscreenFromPictureInPicture;
|
---|
176 | m_client.enterFullScreen();
|
---|
177 | }
|
---|
178 |
|
---|
179 | void WebFullScreenManagerProxy::exitFullScreen()
|
---|
180 | {
|
---|
181 | m_client.exitFullScreen();
|
---|
182 | }
|
---|
183 |
|
---|
184 | void WebFullScreenManagerProxy::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
|
---|
185 | {
|
---|
186 | m_client.beganEnterFullScreen(initialFrame, finalFrame);
|
---|
187 | }
|
---|
188 |
|
---|
189 | void WebFullScreenManagerProxy::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
|
---|
190 | {
|
---|
191 | m_client.beganExitFullScreen(initialFrame, finalFrame);
|
---|
192 | }
|
---|
193 |
|
---|
194 | } // namespace WebKit
|
---|
195 |
|
---|
196 | #endif // ENABLE(FULLSCREEN_API)
|
---|