1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009 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 Computer, 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 class WebChromeClient : public WebCore::ChromeClient { 37 public: 38 WebChromeClient(WebView*); webView()39 virtual void* webView() const { return static_cast<void*>(m_webView); } 40 41 virtual void chromeDestroyed(); 42 43 virtual void setWindowRect(const WebCore::FloatRect&); 44 virtual WebCore::FloatRect windowRect(); 45 46 virtual WebCore::FloatRect pageRect(); 47 48 virtual float scaleFactor(); 49 50 virtual void focus(); 51 virtual void unfocus(); 52 53 virtual bool canTakeFocus(WebCore::FocusDirection); 54 virtual void takeFocus(WebCore::FocusDirection); 55 56 virtual void focusedNodeChanged(WebCore::Node*); 57 virtual void focusedFrameChanged(WebCore::Frame*); 58 59 virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&); 60 virtual void show(); 61 62 virtual bool canRunModal(); 63 virtual void runModal(); 64 65 virtual void setToolbarsVisible(bool); 66 virtual bool toolbarsVisible(); 67 68 virtual void setStatusbarVisible(bool); 69 virtual bool statusbarVisible(); 70 71 virtual void setScrollbarsVisible(bool); 72 virtual bool scrollbarsVisible(); 73 74 virtual void setMenubarVisible(bool); 75 virtual bool menubarVisible(); 76 77 virtual void setResizable(bool); 78 79 virtual void addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceURL); 80 81 virtual bool canRunBeforeUnloadConfirmPanel(); 82 virtual bool runBeforeUnloadConfirmPanel(const WTF::String& message, WebCore::Frame* frame); 83 84 virtual void closeWindowSoon(); 85 86 virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&); 87 virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&); 88 virtual bool runJavaScriptPrompt(WebCore::Frame*, const WTF::String& message, const WTF::String& defaultValue, WTF::String& result); 89 virtual bool shouldInterruptJavaScript(); 90 91 virtual WebCore::IntRect windowResizerRect() const; 92 93 virtual void invalidateWindow(const WebCore::IntRect&, bool); 94 virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); 95 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); 96 virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); 97 98 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; 99 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; 100 virtual PlatformPageClient platformPageClient() const; 101 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; 102 virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; 103 104 virtual void setStatusbarText(const WTF::String&); 105 scrollbarsModeDidChange()106 virtual void scrollbarsModeDidChange() const { } 107 virtual bool shouldMissingPluginMessageBeButton() const; 108 virtual void missingPluginButtonClicked(WebCore::Element*) const; 109 virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); 110 111 virtual void setToolTip(const WTF::String&, WebCore::TextDirection); 112 113 virtual void print(WebCore::Frame*); 114 #if ENABLE(DATABASE) 115 virtual void exceededDatabaseQuota(WebCore::Frame*, const WTF::String& databaseName); 116 #endif 117 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 118 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); 119 virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*); 120 #endif 121 virtual void populateVisitedLinks(); 122 123 #if ENABLE(DASHBOARD_SUPPORT) 124 virtual void dashboardRegionsChanged(); 125 #endif 126 127 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); 128 virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*); 129 130 virtual void setCursor(const WebCore::Cursor&); 131 132 virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, 133 const WebCore::FloatRect& lineRect); 134 virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, 135 const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, 136 bool behindText, bool entireLine); 137 138 virtual WebCore::KeyboardUIMode keyboardUIMode(); 139 140 virtual NSResponder *firstResponder(); 141 virtual void makeFirstResponder(NSResponder *); 142 143 virtual void willPopUpMenu(NSMenu *); 144 145 virtual bool shouldReplaceWithGeneratedFileForUpload(const WTF::String& path, WTF::String &generatedFilename); 146 virtual WTF::String generateReplacementFile(const WTF::String& path); 147 formStateDidChange(const WebCore::Node *)148 virtual void formStateDidChange(const WebCore::Node*) { } 149 150 virtual void formDidFocus(const WebCore::Node*); 151 virtual void formDidBlur(const WebCore::Node*); 152 153 #if USE(ACCELERATED_COMPOSITING) 154 virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*); 155 virtual void setNeedsOneShotDrawingSynchronization(); 156 virtual void scheduleCompositingLayerSync(); 157 #endif 158 159 #if ENABLE(VIDEO) 160 virtual bool supportsFullscreenForNode(const WebCore::Node*); 161 virtual void enterFullscreenForNode(WebCore::Node*); 162 virtual void exitFullscreenForNode(WebCore::Node*); 163 virtual void fullScreenRendererChanged(WebCore::RenderBox*); 164 #endif 165 166 #if ENABLE(FULLSCREEN_API) 167 virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard); 168 virtual void enterFullScreenForElement(WebCore::Element*); 169 virtual void exitFullScreenForElement(WebCore::Element*); 170 #endif 171 172 // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373 173 // For client-based geolocation, these two methods have moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061 requestGeolocationPermissionForFrame(WebCore::Frame *,WebCore::Geolocation *)174 virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { } cancelGeolocationPermissionRequestForFrame(WebCore::Frame *,WebCore::Geolocation *)175 virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { } 176 177 virtual bool selectItemWritingDirectionIsNatural(); 178 virtual bool selectItemAlignmentFollowsMenuWritingDirection(); 179 virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; 180 virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const; 181 182 #if ENABLE(CONTEXT_MENUS) 183 virtual void showContextMenu(); 184 #endif 185 private: 186 WebView *m_webView; 187 }; 188