Source/WebCore:
[WebKit-https.git] / Source / WebKit2 / UIProcess / ios / PageClientImplIOS.h
1 /*
2  * Copyright (C) 2012-2016 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 #ifndef PageClientImplIOS_h
27 #define PageClientImplIOS_h
28
29 #if PLATFORM(IOS)
30
31 #import "PageClient.h"
32 #import "WebFullScreenManagerProxy.h"
33 #import <wtf/RetainPtr.h>
34
35 OBJC_CLASS WKContentView;
36 OBJC_CLASS WKWebView;
37 OBJC_CLASS WKEditorUndoTargetObjC;
38
39 namespace WebKit {
40     
41 class PageClientImpl : public PageClient
42 #if ENABLE(FULLSCREEN_API)
43     , public WebFullScreenManagerProxyClient
44 #endif
45     {
46 public:
47     PageClientImpl(WKContentView *, WKWebView *);
48     virtual ~PageClientImpl();
49     
50 private:
51     // PageClient
52     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
53     void setViewNeedsDisplay(const WebCore::Region&) override;
54     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
55     WebCore::IntSize viewSize() override;
56     bool isViewWindowActive() override;
57     bool isViewFocused() override;
58     bool isViewVisible() override;
59     bool isViewInWindow() override;
60     bool isViewVisibleOrOccluded() override;
61     bool isVisuallyIdle() override;
62     void processDidExit() override;
63     void didRelaunchProcess() override;
64     void pageClosed() override;
65     void preferencesDidChange() override;
66     void toolTipChanged(const String&, const String&) override;
67     bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, API::SecurityOrigin&, GeolocationPermissionRequestProxy&) override;
68     void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
69     void handleDownloadRequest(DownloadProxy*) override;
70     void didChangeContentSize(const WebCore::IntSize&) override;
71     void setCursor(const WebCore::Cursor&) override;
72     void setCursorHiddenUntilMouseMoves(bool) override;
73     void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
74     void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) override;
75     void clearAllEditCommands() override;
76     bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
77     void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
78     void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
79     bool executeSavedCommandBySelector(const String& selector) override;
80     void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override;
81     void updateSecureInputState() override;
82     void resetSecureInputState() override;
83     void notifyInputContextAboutDiscardedComposition() override;
84     void makeFirstResponder() override;
85     WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
86     WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
87     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
88     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
89     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) override;
90     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) override;
91     void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
92 #if ENABLE(TOUCH_EVENTS)
93     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override;
94 #endif
95     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
96 #if ENABLE(CONTEXT_MENUS)
97     std::unique_ptr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override;
98 #endif
99     Ref<WebCore::ValidationBubble> createValidationBubble(const String& message) final;
100
101     void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
102     void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
103     void setTextIndicatorAnimationProgress(float) override;
104
105     void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
106     void exitAcceleratedCompositingMode() override;
107     void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
108     void setAcceleratedCompositingRootLayer(LayerOrView *) override;
109     LayerOrView *acceleratedCompositingRootLayer() const override;
110     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
111
112     PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
113     void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
114
115     void commitPotentialTapFailed() override;
116     void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) override;
117
118     void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
119     void layerTreeCommitComplete() override;
120
121     void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override;
122     void couldNotRestorePageState() override;
123     void restorePageState(const WebCore::FloatPoint&, const WebCore::FloatPoint&, const WebCore::FloatSize&, double) override;
124     void restorePageCenterAndScale(const WebCore::FloatPoint&, double) override;
125
126     void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
127     void stopAssistingNode() override;
128     bool isAssistingNode() override;
129     void selectionDidChange() override;
130     bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
131     void positionInformationDidChange(const InteractionInformationAtPosition&) override;
132     void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>) override;
133     void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) override;
134     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
135
136     bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
137     void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
138     double minimumZoomScale() const override;
139     WebCore::FloatRect documentRect() const override;
140
141     void showInspectorHighlight(const WebCore::Highlight&) override;
142     void hideInspectorHighlight() override;
143
144     void showInspectorIndication() override;
145     void hideInspectorIndication() override;
146
147     void enableInspectorNodeSearch() override;
148     void disableInspectorNodeSearch() override;
149
150     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) override;
151     void overflowScrollViewWillStartPanGesture() override;
152     void overflowScrollViewDidScroll() override;
153     void overflowScrollWillStartScroll() override;
154     void overflowScrollDidEndScroll() override;
155
156     // Auxiliary Client Creation
157 #if ENABLE(FULLSCREEN_API)
158     virual WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
159 #endif
160
161 #if ENABLE(FULLSCREEN_API)
162     // WebFullScreenManagerProxyClient
163     void closeFullScreenManager() override;
164     bool isFullScreen() override;
165     void enterFullScreen() override;
166     void exitFullScreen() override;
167     void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
168     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
169 #endif
170
171     void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
172
173     Vector<String> mimeTypesWithCustomContentProviders() override;
174
175     void navigationGestureDidBegin() override;
176     void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
177     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
178     void navigationGestureDidEnd() override;
179     void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
180     void didRemoveNavigationGestureSnapshot() override;
181
182     void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
183     void didFinishLoadForMainFrame() override;
184     void didFailLoadForMainFrame() override;
185     void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
186     void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
187
188     void didChangeBackgroundColor() override;
189
190     void refView() override;
191     void derefView() override;
192
193     void didRestoreScrollPosition() override;
194
195     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
196
197     WKContentView *m_contentView;
198     WKWebView *m_webView;
199     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
200 };
201 } // namespace WebKit
202
203 #endif // PLATFORM(IOS)
204
205 #endif // PageClientImplIOS_h