b8e20c69d801e9d33a2cd3c4da6a936acf3942ae
[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     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final;
103     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final;
104
105     PlatformPageClient platformPageClient() const final;
106     void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final;
107     void scrollRectIntoView(const WebCore::IntRect&) const final;
108
109     void setStatusbarText(const String&) override;
110
111     bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
112     void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
113     void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final;
114
115     void setToolTip(const String&, WebCore::TextDirection) final;
116
117     void print(WebCore::Frame&) final;
118     void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final;
119     void reachedMaxAppCacheSize(int64_t spaceNeeded) final;
120     void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t totalSpaceNeeded) final;
121
122 #if ENABLE(DASHBOARD_SUPPORT)
123     void annotatedRegionsChanged() final;
124 #endif
125
126     void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) override;
127     void showShareSheet(WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&) override;
128
129     void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final;
130     RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) override;
131
132 #if !PLATFORM(IOS_FAMILY)
133     void setCursor(const WebCore::Cursor&) final;
134     void setCursorHiddenUntilMouseMoves(bool) final;
135 #endif
136
137 #if ENABLE(INPUT_TYPE_COLOR)
138     std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final;
139 #endif
140
141 #if ENABLE(DATALIST_ELEMENT)
142     std::unique_ptr<WebCore::DataListSuggestionPicker> createDataListSuggestionPicker(WebCore::DataListSuggestionsClient&) final;
143 #endif
144
145 #if ENABLE(POINTER_LOCK)
146     bool requestPointerLock() final;
147     void requestPointerUnlock() final;
148 #endif
149
150     WebCore::KeyboardUIMode keyboardUIMode() final;
151
152     NSResponder *firstResponder() final;
153     void makeFirstResponder(NSResponder *) final;
154
155     void enableSuddenTermination() final;
156     void disableSuddenTermination() final;
157
158     bool shouldReplaceWithGeneratedFileForUpload(const String& path, String &generatedFilename) final;
159     String generateReplacementFile(const String& path) final;
160
161 #if !PLATFORM(IOS_FAMILY)
162     void elementDidFocus(WebCore::Element&) override;
163     void elementDidBlur(WebCore::Element&) override;
164 #endif
165
166     bool shouldPaintEntireContents() const final;
167
168     void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) override;
169     void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) final;
170     void setNeedsOneShotDrawingSynchronization() final;
171     void scheduleCompositingLayerFlush() final;
172
173     CompositingTriggerFlags allowedCompositingTriggers() const final
174     {
175         return static_cast<CompositingTriggerFlags>(
176             ThreeDTransformTrigger |
177             VideoTrigger |
178             PluginTrigger| 
179             CanvasTrigger |
180 #if PLATFORM(IOS_FAMILY)
181             AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iOS: <rdar://problem/7830677>
182 #endif
183             AnimationTrigger);
184     }
185
186 #if ENABLE(VIDEO) && PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
187     void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
188     void clearPlaybackControlsManager() final;
189 #endif
190
191 #if ENABLE(VIDEO)
192     bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
193     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
194     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
195     void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
196 #endif
197
198 #if ENABLE(FULLSCREEN_API)
199     bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final;
200     void enterFullScreenForElement(WebCore::Element&) final;
201     void exitFullScreenForElement(WebCore::Element*) final;
202 #endif
203
204     bool selectItemWritingDirectionIsNatural() override;
205     bool selectItemAlignmentFollowsMenuWritingDirection() override;
206     RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient&) const override;
207     RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient&) const override;
208
209     void wheelEventHandlersChanged(bool) final { }
210
211 #if ENABLE(WEB_CRYPTO)
212     bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
213     bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
214 #endif
215
216 #if ENABLE(SERVICE_CONTROLS)
217     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
218     bool hasRelevantSelectionServices(bool isTextOnly) const final;
219 #endif
220
221 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
222     void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final;
223     void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final;
224     void showPlaybackTargetPicker(uint64_t /*contextId*/, const WebCore::IntPoint&, bool /* hasVideo */) final;
225     void playbackTargetPickerClientStateDidChange(uint64_t /*contextId*/, WebCore::MediaProducer::MediaStateFlags) final;
226     void setMockMediaPlaybackTargetPickerEnabled(bool) final;
227     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
228 #endif
229
230     String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final;
231
232     WebView *m_webView;
233 };