Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKitLegacy / mac / WebCoreSupport / WebChromeClient.h
1 /*
2  * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
3  * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #import <WebCore/ChromeClient.h>
31 #import <WebCore/FocusDirection.h>
32 #import <wtf/Forward.h>
33
34 @class WebView;
35
36 // FIXME: This class is used as a concrete class on Mac, but on iOS this is an abstract
37 // base class of the concrete class, WebChromeClientIOS. Because of that, this class and
38 // many of its functions are not marked final. That is messy way to organize things.
39 class WebChromeClient : public WebCore::ChromeClient {
40 public:
41     WebChromeClient(WebView*);
42
43     WebView* webView() const { return m_webView; }
44
45 private:
46     void chromeDestroyed() final;
47
48     void setWindowRect(const WebCore::FloatRect&) override;
49     WebCore::FloatRect windowRect() override;
50
51     WebCore::FloatRect pageRect() final;
52
53     void focus() override;
54     void unfocus() final;
55
56     bool canTakeFocus(WebCore::FocusDirection) final;
57     void takeFocus(WebCore::FocusDirection) override;
58
59     void focusedElementChanged(WebCore::Element*) override;
60     void focusedFrameChanged(WebCore::Frame*) final;
61
62     WebCore::Page* createWindow(WebCore::Frame&, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&) final;
63     void show() final;
64
65     bool canRunModal() final;
66     void runModal() final;
67
68     void setToolbarsVisible(bool) final;
69     bool toolbarsVisible() final;
70
71     void setStatusbarVisible(bool) final;
72     bool statusbarVisible() final;
73
74     void setScrollbarsVisible(bool) final;
75     bool scrollbarsVisible() final;
76
77     void setMenubarVisible(bool) final;
78     bool menubarVisible() final;
79
80     void setResizable(bool) final;
81
82     void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceURL) final;
83
84     bool canRunBeforeUnloadConfirmPanel() final;
85     bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final;
86
87     void closeWindowSoon() final;
88
89     void runJavaScriptAlert(WebCore::Frame&, const String&) override;
90     bool runJavaScriptConfirm(WebCore::Frame&, const String&) override;
91     bool runJavaScriptPrompt(WebCore::Frame&, const String& message, const String& defaultValue, String& result) override;
92
93     bool supportsImmediateInvalidation() final;
94     void invalidateRootView(const WebCore::IntRect&) final;
95     void invalidateContentsAndRootView(const WebCore::IntRect&) final;
96     void invalidateContentsForSlowScroll(const WebCore::IntRect&) final;
97     void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect) final;
98
99     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const final;
100     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const final;
101
102 #if PLATFORM(IOS_FAMILY)
103     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final;
104     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final;
105 #endif
106
107     PlatformPageClient platformPageClient() const final;
108     void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final;
109     void scrollRectIntoView(const WebCore::IntRect&) const final;
110
111     void setStatusbarText(const String&) override;
112
113     bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
114     void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
115     void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final;
116
117     void setToolTip(const String&, WebCore::TextDirection) final;
118
119     void print(WebCore::Frame&) final;
120     void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final;
121     void reachedMaxAppCacheSize(int64_t spaceNeeded) final;
122     void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t totalSpaceNeeded) final;
123
124 #if ENABLE(DASHBOARD_SUPPORT)
125     void annotatedRegionsChanged() final;
126 #endif
127
128     void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) override;
129     void showShareSheet(WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&) override;
130
131     void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final;
132     RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) override;
133
134 #if !PLATFORM(IOS_FAMILY)
135     void setCursor(const WebCore::Cursor&) final;
136     void setCursorHiddenUntilMouseMoves(bool) final;
137 #endif
138
139 #if ENABLE(INPUT_TYPE_COLOR)
140     std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final;
141 #endif
142
143 #if ENABLE(DATALIST_ELEMENT)
144     std::unique_ptr<WebCore::DataListSuggestionPicker> createDataListSuggestionPicker(WebCore::DataListSuggestionsClient&) final;
145 #endif
146
147 #if ENABLE(POINTER_LOCK)
148     bool requestPointerLock() final;
149     void requestPointerUnlock() final;
150 #endif
151
152     WebCore::KeyboardUIMode keyboardUIMode() final;
153
154     NSResponder *firstResponder() final;
155     void makeFirstResponder(NSResponder *) final;
156
157     void enableSuddenTermination() final;
158     void disableSuddenTermination() final;
159
160     bool shouldReplaceWithGeneratedFileForUpload(const String& path, String &generatedFilename) final;
161     String generateReplacementFile(const String& path) final;
162
163 #if !PLATFORM(IOS_FAMILY)
164     void elementDidFocus(WebCore::Element&) override;
165     void elementDidBlur(WebCore::Element&) override;
166 #endif
167
168     bool shouldPaintEntireContents() const final;
169
170     void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) override;
171     void attachViewOverlayGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final;
172     void setNeedsOneShotDrawingSynchronization() final;
173     void scheduleCompositingLayerFlush() final;
174
175     CompositingTriggerFlags allowedCompositingTriggers() const final
176     {
177         return static_cast<CompositingTriggerFlags>(
178             ThreeDTransformTrigger |
179             VideoTrigger |
180             PluginTrigger| 
181             CanvasTrigger |
182 #if PLATFORM(IOS_FAMILY)
183             AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iOS: <rdar://problem/7830677>
184 #endif
185             AnimationTrigger);
186     }
187
188 #if ENABLE(VIDEO) && PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
189     void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
190     void clearPlaybackControlsManager() final;
191 #endif
192
193 #if ENABLE(VIDEO)
194     bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
195     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
196     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
197     void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
198 #endif
199
200 #if ENABLE(FULLSCREEN_API)
201     bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final;
202     void enterFullScreenForElement(WebCore::Element&) final;
203     void exitFullScreenForElement(WebCore::Element*) final;
204 #endif
205
206     bool selectItemWritingDirectionIsNatural() override;
207     bool selectItemAlignmentFollowsMenuWritingDirection() override;
208     RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient&) const override;
209     RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient&) const override;
210
211     void wheelEventHandlersChanged(bool) final { }
212
213 #if ENABLE(WEB_CRYPTO)
214     bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
215     bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
216 #endif
217
218 #if ENABLE(SERVICE_CONTROLS)
219     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
220     bool hasRelevantSelectionServices(bool isTextOnly) const final;
221 #endif
222
223 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
224     void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final;
225     void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final;
226     void showPlaybackTargetPicker(uint64_t /*contextId*/, const WebCore::IntPoint&, bool /* hasVideo */) final;
227     void playbackTargetPickerClientStateDidChange(uint64_t /*contextId*/, WebCore::MediaProducer::MediaStateFlags) final;
228     void setMockMediaPlaybackTargetPickerEnabled(bool) final;
229     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
230 #endif
231
232     String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final;
233
234     WebView *m_webView;
235 };