1 /* 2 * Copyright (C) 2006 Zack Rusin <zack (at) kde.org> 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef ChromeClientQt_h 30 #define ChromeClientQt_h 31 32 #include "ChromeClient.h" 33 #include "FloatRect.h" 34 #include "KURL.h" 35 #include "PlatformString.h" 36 #include "QtPlatformPlugin.h" 37 #include <wtf/RefCounted.h> 38 39 QT_BEGIN_NAMESPACE 40 class QEventLoop; 41 QT_END_NAMESPACE 42 43 class QWebPage; 44 45 namespace WebCore { 46 47 class FileChooser; 48 class FloatRect; 49 class Page; 50 struct FrameLoadRequest; 51 class QtAbstractWebPopup; 52 struct ViewportArguments; 53 #if ENABLE(VIDEO) 54 class FullScreenVideoQt; 55 #endif 56 57 class ChromeClientQt : public ChromeClient { 58 public: 59 ChromeClientQt(QWebPage*); 60 virtual ~ChromeClientQt(); 61 virtual void chromeDestroyed(); 62 63 virtual void setWindowRect(const FloatRect&); 64 virtual FloatRect windowRect(); 65 66 virtual FloatRect pageRect(); 67 68 virtual float scaleFactor(); 69 70 virtual void focus(); 71 virtual void unfocus(); 72 73 virtual bool canTakeFocus(FocusDirection); 74 virtual void takeFocus(FocusDirection); 75 76 virtual void focusedNodeChanged(Node*); 77 virtual void focusedFrameChanged(Frame*); 78 79 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&); 80 virtual void show(); 81 82 virtual bool canRunModal(); 83 virtual void runModal(); 84 85 virtual void setToolbarsVisible(bool); 86 virtual bool toolbarsVisible(); 87 88 virtual void setStatusbarVisible(bool); 89 virtual bool statusbarVisible(); 90 91 virtual void setScrollbarsVisible(bool); 92 virtual bool scrollbarsVisible(); 93 94 virtual void setMenubarVisible(bool); 95 virtual bool menubarVisible(); 96 97 virtual void setResizable(bool); 98 99 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID); 100 101 virtual bool canRunBeforeUnloadConfirmPanel(); 102 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame*); 103 104 virtual void closeWindowSoon(); 105 106 virtual void runJavaScriptAlert(Frame*, const String&); 107 virtual bool runJavaScriptConfirm(Frame*, const String&); 108 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result); 109 virtual bool shouldInterruptJavaScript(); 110 111 virtual void setStatusbarText(const String&); 112 113 virtual KeyboardUIMode keyboardUIMode(); 114 virtual IntRect windowResizerRect() const; 115 116 virtual void invalidateWindow(const IntRect&, bool); 117 virtual void invalidateContentsAndWindow(const IntRect&, bool); 118 virtual void invalidateContentsForSlowScroll(const IntRect&, bool); 119 virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); 120 #if ENABLE(TILED_BACKING_STORE) 121 virtual void delegatedScrollRequested(const IntPoint& scrollPoint); 122 #endif 123 124 virtual IntPoint screenToWindow(const IntPoint&) const; 125 virtual IntRect windowToScreen(const IntRect&) const; 126 virtual PlatformPageClient platformPageClient() const; 127 virtual void contentsSizeChanged(Frame*, const IntSize&) const; 128 129 virtual void scrollbarsModeDidChange() const { } 130 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); 131 132 virtual void setToolTip(const String&, TextDirection); 133 134 virtual void print(Frame*); 135 #if ENABLE(DATABASE) 136 virtual void exceededDatabaseQuota(Frame*, const String&); 137 #endif 138 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 139 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); 140 virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*); 141 #endif 142 #if ENABLE(CONTEXT_MENUS) 143 virtual void showContextMenu() { } 144 #endif 145 146 #if ENABLE(NOTIFICATIONS) 147 virtual NotificationPresenter* notificationPresenter() const; 148 #endif 149 150 #if USE(ACCELERATED_COMPOSITING) 151 // This is a hook for WebCore to tell us what we need to do with the GraphicsLayers. 152 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*); 153 virtual void setNeedsOneShotDrawingSynchronization(); 154 virtual void scheduleCompositingLayerSync(); 155 virtual CompositingTriggerFlags allowedCompositingTriggers() const; 156 #endif 157 158 #if ENABLE(TILED_BACKING_STORE) 159 virtual IntRect visibleRectForTiledBackingStore() const; 160 #endif 161 162 #if ENABLE(TOUCH_EVENTS) 163 virtual void needTouchEvents(bool) { } 164 #endif 165 166 #if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) 167 virtual bool supportsFullscreenForNode(const Node*); 168 virtual void enterFullscreenForNode(Node*); 169 virtual void exitFullscreenForNode(Node*); 170 virtual bool requiresFullscreenForVideoPlayback(); 171 FullScreenVideoQt* fullScreenVideo(); 172 #endif 173 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); 174 virtual void chooseIconForFiles(const Vector<String>&, FileChooser*); 175 176 virtual void formStateDidChange(const Node*) { } 177 178 virtual void setCursor(const Cursor&); 179 180 virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const { } 181 182 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) { } 183 virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { } 184 185 virtual bool selectItemWritingDirectionIsNatural(); 186 virtual bool selectItemAlignmentFollowsMenuWritingDirection(); 187 virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; 188 virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; 189 virtual void populateVisitedLinks(); 190 191 QWebSelectMethod* createSelectPopup() const; 192 193 virtual void dispatchViewportDataDidChange(const ViewportArguments&) const; 194 195 QWebPage* m_webPage; 196 KURL lastHoverURL; 197 String lastHoverTitle; 198 String lastHoverContent; 199 200 bool toolBarsVisible; 201 bool statusBarVisible; 202 bool menuBarVisible; 203 QEventLoop* m_eventLoop; 204 205 #if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) 206 FullScreenVideoQt* m_fullScreenVideo; 207 #endif 208 209 static bool dumpVisitedLinksCallbacks; 210 211 mutable QtPlatformPlugin m_platformPlugin; 212 }; 213 } 214 215 #endif 216