WebChromeClient.h revision 81bc750723a18f21cd17d1b173cd2a4dda9cea6e
1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 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 * 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. 13 * 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. 25 */ 26 27#ifndef WebChromeClient_h 28#define WebChromeClient_h 29 30#include <WebCore/ChromeClient.h> 31#include <WebCore/ViewportArguments.h> 32#include <wtf/text/WTFString.h> 33 34namespace WebKit { 35 36class WebFrame; 37class WebPage; 38 39class WebChromeClient : public WebCore::ChromeClient { 40public: 41 WebChromeClient(WebPage* page) 42 : m_cachedMainFrameHasHorizontalScrollbar(false) 43 , m_cachedMainFrameHasVerticalScrollbar(false) 44 , m_page(page) 45 { 46 } 47 48 WebPage* page() const { return m_page; } 49 50private: 51 virtual void chromeDestroyed(); 52 53 virtual void setWindowRect(const WebCore::FloatRect&); 54 virtual WebCore::FloatRect windowRect(); 55 56 virtual WebCore::FloatRect pageRect(); 57 58 virtual float scaleFactor(); 59 60 virtual void focus(); 61 virtual void unfocus(); 62 63 virtual bool canTakeFocus(WebCore::FocusDirection); 64 virtual void takeFocus(WebCore::FocusDirection); 65 66 virtual void focusedNodeChanged(WebCore::Node*); 67 virtual void focusedFrameChanged(WebCore::Frame*); 68 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&); 74 virtual void show(); 75 76 virtual bool canRunModal(); 77 virtual void runModal(); 78 79 virtual void setToolbarsVisible(bool); 80 virtual bool toolbarsVisible(); 81 82 virtual void setStatusbarVisible(bool); 83 virtual bool statusbarVisible(); 84 85 virtual void setScrollbarsVisible(bool); 86 virtual bool scrollbarsVisible(); 87 88 virtual void setMenubarVisible(bool); 89 virtual bool menubarVisible(); 90 91 virtual void setResizable(bool); 92 93 virtual void addMessageToConsole(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID); 94 95 virtual bool canRunBeforeUnloadConfirmPanel(); 96 virtual bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame* frame); 97 98 virtual void closeWindowSoon(); 99 100 virtual void runJavaScriptAlert(WebCore::Frame*, const String&); 101 virtual bool runJavaScriptConfirm(WebCore::Frame*, const String&); 102 virtual bool runJavaScriptPrompt(WebCore::Frame*, const String& message, const String& defaultValue, String& result); 103 virtual void setStatusbarText(const String&); 104 virtual bool shouldInterruptJavaScript(); 105 106 virtual WebCore::KeyboardUIMode keyboardUIMode(); 107 108 virtual WebCore::IntRect windowResizerRect() const; 109 110 // Methods used by HostWindow. 111 virtual void invalidateWindow(const WebCore::IntRect&, bool); 112 virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); 113 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); 114 virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); 115#if ENABLE(TILED_BACKING_STORE) 116 virtual void delegatedScrollRequested(const WebCore::IntSize& scrollOffset); 117#endif 118 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; 119 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; 120 virtual PlatformPageClient platformPageClient() const; 121 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; 122 virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; // Currently only Mac has a non empty implementation. 123 // End methods used by HostWindow. 124 125 virtual bool shouldMissingPluginMessageBeButton() const; 126 virtual void missingPluginButtonClicked(WebCore::Element*) const; 127 128 virtual void scrollbarsModeDidChange() const; 129 virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); 130 131 virtual void setToolTip(const String&, WebCore::TextDirection); 132 133 virtual void print(WebCore::Frame*); 134 135#if ENABLE(DATABASE) 136 virtual void exceededDatabaseQuota(WebCore::Frame*, const String& databaseName); 137#endif 138 139#if ENABLE(OFFLINE_WEB_APPLICATIONS) 140 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); 141 virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*); 142#endif 143 144#if ENABLE(DASHBOARD_SUPPORT) 145 virtual void dashboardRegionsChanged(); 146#endif 147 148 virtual void populateVisitedLinks(); 149 150 virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect); 151 virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, 152 bool behindText, bool entireLine); 153 154 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename); 155 virtual String generateReplacementFile(const String& path); 156 157 virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize, 158 WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical, 159 float value, float proportion, WebCore::ScrollbarControlPartMask); 160 virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&); 161 162 virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&); 163 164 // This is an asynchronous call. The ChromeClient can display UI asking the user for permission 165 // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately. 166 virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*); 167 virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*); 168 169 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); 170 virtual void chooseIconForFiles(const Vector<String>&, WebCore::FileChooser*); 171 172 virtual void setCursor(const WebCore::Cursor&); 173 174 // Notification that the given form element has changed. This function 175 // will be called frequently, so handling should be very fast. 176 virtual void formStateDidChange(const WebCore::Node*); 177 178 virtual void formDidFocus(const WebCore::Node*); 179 virtual void formDidBlur(const WebCore::Node*); 180 181 virtual bool selectItemWritingDirectionIsNatural(); 182 virtual bool selectItemAlignmentFollowsMenuWritingDirection(); 183 virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; 184 virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const; 185 186#if ENABLE(CONTEXT_MENUS) 187 virtual void showContextMenu(); 188#endif 189 190#if USE(ACCELERATED_COMPOSITING) 191 virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*); 192 virtual void setNeedsOneShotDrawingSynchronization(); 193 virtual void scheduleCompositingLayerSync(); 194#endif 195 196#if ENABLE(NOTIFICATIONS) 197 virtual WebCore::NotificationPresenter* notificationPresenter() const; 198#endif 199 200#if ENABLE(TOUCH_EVENTS) 201 virtual void needTouchEvents(bool); 202#endif 203 204#if PLATFORM(WIN) 205 virtual void setLastSetCursorToCurrentCursor(); 206#endif 207 208 virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const; 209 210 virtual void didCompleteRubberBandForMainFrame(const WebCore::IntSize&) const; 211 212 String m_cachedToolTip; 213 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; 214 mutable bool m_cachedMainFrameHasHorizontalScrollbar; 215 mutable bool m_cachedMainFrameHasVerticalScrollbar; 216 217 WebPage* m_page; 218}; 219 220} // namespace WebKit 221 222#endif // WebChromeClient_h 223