1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #include <WebCore/ChromeClient.h> 27 #include <WebCore/COMPtr.h> 28 #include <WebCore/GraphicsContext.h> 29 #include <WebCore/FocusDirection.h> 30 #include <WebCore/ScrollTypes.h> 31 #include <wtf/Forward.h> 32 33 class WebView; 34 35 interface IWebUIDelegate; 36 interface IWebUIDelegate2; 37 interface IWebUIDelegate3; 38 interface IWebUIDelegate4; 39 40 class WebChromeClient : public WebCore::ChromeClient { 41 public: 42 WebChromeClient(WebView*); 43 44 virtual void chromeDestroyed(); 45 46 virtual void setWindowRect(const WebCore::FloatRect&); 47 virtual WebCore::FloatRect windowRect(); 48 49 virtual WebCore::FloatRect pageRect(); 50 51 virtual float scaleFactor(); 52 53 virtual void focus(); 54 virtual void unfocus(); 55 56 virtual bool canTakeFocus(WebCore::FocusDirection); 57 virtual void takeFocus(WebCore::FocusDirection); 58 59 virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); 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(const WebCore::String& message, unsigned line, const WebCore::String& url); 80 81 virtual bool canRunBeforeUnloadConfirmPanel(); 82 virtual bool runBeforeUnloadConfirmPanel(const WebCore::String& message, WebCore::Frame* frame); 83 84 virtual void closeWindowSoon(); 85 86 virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&); 87 virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&); 88 virtual bool runJavaScriptPrompt(WebCore::Frame*, const WebCore::String& message, const WebCore::String& defaultValue, WebCore::String& result); 89 virtual void setStatusbarText(const WebCore::String&); 90 virtual bool shouldInterruptJavaScript(); 91 92 virtual bool tabsToLinks() const; 93 virtual WebCore::IntRect windowResizerRect() const; 94 95 virtual void repaint(const WebCore::IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false); 96 virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); 97 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint& p) const; 98 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect& r) const; 99 virtual PlatformWidget platformWindow() const; 100 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; 101 102 virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); 103 104 virtual void setToolTip(const WebCore::String&); 105 106 virtual void print(WebCore::Frame*); 107 108 virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&); 109 110 virtual void populateVisitedLinks(); 111 112 virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize, 113 WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical, 114 float value, float proportion, WebCore::ScrollbarControlPartMask); 115 virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&); 116 117 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); 118 webView()119 WebView* webView() const { return m_webView; } 120 formStateDidChange(const WebCore::Node *)121 virtual void formStateDidChange(const WebCore::Node*) { } 122 123 private: 124 COMPtr<IWebUIDelegate> uiDelegate(); 125 COMPtr<IWebUIDelegate2> uiDelegate2(); 126 COMPtr<IWebUIDelegate3> uiDelegate3(); 127 COMPtr<IWebUIDelegate4> uiDelegate4(); 128 129 WebView* m_webView; 130 }; 131