2 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef WebChromeClient_h
28 #define WebChromeClient_h
31 #include <WebCore/ChromeClient.h>
32 #include <WebCore/ViewportArguments.h>
33 #include <wtf/text/WTFString.h>
39 class WebChromeClient : public WebCore::ChromeClient {
41 WebChromeClient(WebPage* page)
42 : m_cachedMainFrameHasHorizontalScrollbar(false)
43 , m_cachedMainFrameHasVerticalScrollbar(false)
48 WebPage* page() const { return m_page; }
50 virtual void* webView() const { return 0; }
53 virtual void chromeDestroyed() override;
55 virtual void setWindowRect(const WebCore::FloatRect&) override;
56 virtual WebCore::FloatRect windowRect() override;
58 virtual WebCore::FloatRect pageRect() override;
60 virtual void focus() override;
61 virtual void unfocus() override;
63 virtual bool canTakeFocus(WebCore::FocusDirection) override;
64 virtual void takeFocus(WebCore::FocusDirection) override;
66 virtual void focusedElementChanged(WebCore::Element*) override;
67 virtual void focusedFrameChanged(WebCore::Frame*) override;
69 // The Frame pointer provides the ChromeClient with context about which
70 // Frame wants to create the new Page. Also, the newly created window
71 // should not be shown to the user until the ChromeClient of the newly
72 // created Page has its show method called.
73 virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&) override;
74 virtual void show() override;
76 virtual bool canRunModal() override;
77 virtual void runModal() override;
79 virtual void setToolbarsVisible(bool) override;
80 virtual bool toolbarsVisible() override;
82 virtual void setStatusbarVisible(bool) override;
83 virtual bool statusbarVisible() override;
85 virtual void setScrollbarsVisible(bool) override;
86 virtual bool scrollbarsVisible() override;
88 virtual void setMenubarVisible(bool) override;
89 virtual bool menubarVisible() override;
91 virtual void setResizable(bool) override;
93 virtual void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) override;
95 virtual bool canRunBeforeUnloadConfirmPanel() override;
96 virtual bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame*) override;
98 virtual void closeWindowSoon() override;
100 virtual void runJavaScriptAlert(WebCore::Frame*, const String&) override;
101 virtual bool runJavaScriptConfirm(WebCore::Frame*, const String&) override;
102 virtual bool runJavaScriptPrompt(WebCore::Frame*, const String& message, const String& defaultValue, String& result) override;
103 virtual void setStatusbarText(const String&) override;
105 virtual WebCore::KeyboardUIMode keyboardUIMode() override;
107 // HostWindow member function overrides.
108 virtual void invalidateRootView(const WebCore::IntRect&) override;
109 virtual void invalidateContentsAndRootView(const WebCore::IntRect&) override;
110 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&) override;
111 virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect) override;
112 #if USE(COORDINATED_GRAPHICS)
113 virtual void delegatedScrollRequested(const WebCore::IntPoint& scrollOffset) override;
115 virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const override;
116 virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const override;
118 virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const override;
119 virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const override;
121 virtual PlatformPageClient platformPageClient() const override;
122 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const override;
123 virtual void scrollRectIntoView(const WebCore::IntRect&) const override; // Currently only Mac has a non empty implementation.
125 virtual bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const override;
126 virtual void unavailablePluginButtonClicked(WebCore::Element*, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const override;
128 virtual void scrollbarsModeDidChange() const override;
129 virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) override;
131 virtual void didBeginTrackingPotentialLongMousePress(const WebCore::IntPoint& mouseDownPosition, const WebCore::HitTestResult&) override;
132 virtual void didRecognizeLongMousePress() override;
133 virtual void didCancelTrackingPotentialLongMousePress() override;
135 virtual void setToolTip(const String&, WebCore::TextDirection) override;
137 virtual void print(WebCore::Frame*) override;
139 virtual void exceededDatabaseQuota(WebCore::Frame*, const String& databaseName, WebCore::DatabaseDetails) override;
141 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) override;
142 virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t spaceNeeded) override;
144 #if ENABLE(DASHBOARD_SUPPORT)
145 virtual void annotatedRegionsChanged() override;
148 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) override;
149 virtual String generateReplacementFile(const String& path) override;
151 #if ENABLE(INPUT_TYPE_COLOR)
152 virtual std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) override;
155 #if ENABLE(IOS_TOUCH_EVENTS)
156 virtual void didPreventDefaultForEvent() override;
160 virtual void didReceiveMobileDocType(bool) override;
161 virtual void setNeedsScrollNotifications(WebCore::Frame*, bool) override;
162 virtual void observedContentChange(WebCore::Frame*) override;
163 virtual void clearContentChangeObservers(WebCore::Frame*) override;
164 virtual void notifyRevealedSelectionByScrollingFrame(WebCore::Frame*) override;
165 virtual bool isStopping() override;
167 virtual void didLayout(LayoutType = NormalLayout) override;
168 virtual void didStartOverflowScroll() override;
169 virtual void didEndOverflowScroll() override;
170 virtual bool hasStablePageScaleFactor() const override;
172 // FIXME: See <rdar://problem/5975559>
173 virtual void suppressFormNotifications() override;
174 virtual void restoreFormNotifications() override;
176 virtual void addOrUpdateScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const WebCore::IntSize& scrollSize, bool allowHorizontalScrollbar, bool allowVerticalScrollbar) override;
177 virtual void removeScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) override;
179 virtual void webAppOrientationsUpdated() override;
180 virtual void showPlaybackTargetPicker(bool hasVideo) override;
182 virtual std::chrono::milliseconds eventThrottlingDelay() override;
185 #if ENABLE(ORIENTATION_EVENTS)
186 virtual int deviceOrientation() const override;
189 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>) override;
190 virtual void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader*) override;
193 virtual void setCursor(const WebCore::Cursor&) override;
194 virtual void setCursorHiddenUntilMouseMoves(bool) override;
196 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
197 virtual void scheduleAnimation() override;
200 virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) override;
201 virtual bool shouldNotifyOnFormChanges() override;
203 virtual bool selectItemWritingDirectionIsNatural() override;
204 virtual bool selectItemAlignmentFollowsMenuWritingDirection() override;
205 virtual bool hasOpenedPopup() const override;
206 virtual RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const override;
207 virtual RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const override;
209 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const override;
210 virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
211 virtual void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
212 virtual void setNeedsOneShotDrawingSynchronization() override;
213 virtual void scheduleCompositingLayerFlush() override;
214 virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
216 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
217 virtual RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
220 virtual CompositingTriggerFlags allowedCompositingTriggers() const override
222 return static_cast<CompositingTriggerFlags>(
223 ThreeDTransformTrigger |
228 AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iPhone: <rdar://problem/7830677>
233 virtual bool layerTreeStateIsFrozen() const override;
235 #if ENABLE(ASYNC_SCROLLING)
236 virtual PassRefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page*) const override;
239 #if ENABLE(TOUCH_EVENTS)
240 virtual void needTouchEvents(bool) override { }
244 virtual void elementDidFocus(const WebCore::Node*) override;
245 virtual void elementDidBlur(const WebCore::Node*) override;
249 virtual bool supportsVideoFullscreen() override;
250 virtual void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
251 virtual void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) override;
254 #if ENABLE(FULLSCREEN_API)
255 virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard) override;
256 virtual void enterFullScreenForElement(WebCore::Element*) override;
257 virtual void exitFullScreenForElement(WebCore::Element*) override;
261 virtual void makeFirstResponder() override;
264 virtual void enableSuddenTermination() override;
265 virtual void disableSuddenTermination() override;
268 virtual WebCore::FloatSize screenSize() const override;
269 virtual WebCore::FloatSize availableScreenSize() const override;
271 virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const override;
273 virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) override;
274 virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) override;
276 virtual WTF::Optional<WebCore::ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() override;
278 virtual WebCore::Color underlayColor() const override;
280 virtual void pageExtendedBackgroundColorDidChange(WebCore::Color) const override;
282 virtual void wheelEventHandlersChanged(bool) override;
284 virtual String plugInStartLabelTitle(const String& mimeType) const override;
285 virtual String plugInStartLabelSubtitle(const String& mimeType) const override;
286 virtual String plugInExtraStyleSheet() const override;
287 virtual String plugInExtraScript() const override;
289 virtual void didAddHeaderLayer(WebCore::GraphicsLayer*) override;
290 virtual void didAddFooterLayer(WebCore::GraphicsLayer*) override;
292 virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) const override;
294 virtual void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) override;
295 virtual void setPageActivityState(WebCore::PageActivityState::Flags) override;
297 #if ENABLE(MEDIA_SESSION)
298 virtual void hasMediaSessionWithActiveMediaElementsDidChange(bool) override;
299 virtual void mediaSessionMetadataDidChange(const WebCore::MediaSessionMetadata&) override;
300 virtual void focusedContentMediaElementDidChange(uint64_t) override;
303 #if ENABLE(SUBTLE_CRYPTO)
304 virtual bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override;
305 virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override;
308 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
309 virtual void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&) override;
311 #if ENABLE(SERVICE_CONTROLS)
312 virtual void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) override;
313 virtual bool hasRelevantSelectionServices(bool isTextOnly) const override;
316 virtual bool shouldDispatchFakeMouseMoveEvents() const override;
318 virtual void handleAutoFillButtonClick(WebCore::HTMLInputElement&) override;
320 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
321 virtual void addPlaybackTargetPickerClient(uint64_t /*contextId*/) override;
322 virtual void removePlaybackTargetPickerClient(uint64_t /*contextId*/) override;
323 virtual void showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint&, bool) override;
324 virtual void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) override;
328 virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
330 virtual void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) override;
334 String m_cachedToolTip;
335 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
336 mutable bool m_cachedMainFrameHasHorizontalScrollbar;
337 mutable bool m_cachedMainFrameHasVerticalScrollbar;
342 } // namespace WebKit
344 #endif // WebChromeClient_h