1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple, Inc. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef ChromeClient_h 21 #define ChromeClient_h 22 23 #include "GraphicsContext.h" 24 #include "FocusDirection.h" 25 #include "ScrollTypes.h" 26 #include "HostWindow.h" 27 #include <wtf/Forward.h> 28 #include <wtf/Vector.h> 29 30 #if PLATFORM(MAC) 31 #include "WebCoreKeyboardUIMode.h" 32 #endif 33 34 #ifndef __OBJC__ 35 class NSMenu; 36 class NSResponder; 37 #endif 38 39 namespace WebCore { 40 41 class AtomicString; 42 class FileChooser; 43 class FloatRect; 44 class Frame; 45 class HitTestResult; 46 class IntRect; 47 class Node; 48 class Page; 49 class String; 50 class Widget; 51 52 struct FrameLoadRequest; 53 struct WindowFeatures; 54 55 class ChromeClient { 56 public: 57 virtual void chromeDestroyed() = 0; 58 59 virtual void setWindowRect(const FloatRect&) = 0; 60 virtual FloatRect windowRect() = 0; 61 62 virtual FloatRect pageRect() = 0; 63 64 virtual float scaleFactor() = 0; 65 66 virtual void focus() = 0; 67 virtual void unfocus() = 0; 68 69 virtual bool canTakeFocus(FocusDirection) = 0; 70 virtual void takeFocus(FocusDirection) = 0; 71 72 // The Frame pointer provides the ChromeClient with context about which 73 // Frame wants to create the new Page. Also, the newly created window 74 // should not be shown to the user until the ChromeClient of the newly 75 // created Page has its show method called. 76 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) = 0; 77 virtual void show() = 0; 78 79 virtual bool canRunModal() = 0; 80 virtual void runModal() = 0; 81 82 virtual void setToolbarsVisible(bool) = 0; 83 virtual bool toolbarsVisible() = 0; 84 85 virtual void setStatusbarVisible(bool) = 0; 86 virtual bool statusbarVisible() = 0; 87 88 virtual void setScrollbarsVisible(bool) = 0; 89 virtual bool scrollbarsVisible() = 0; 90 91 virtual void setMenubarVisible(bool) = 0; 92 virtual bool menubarVisible() = 0; 93 94 virtual void setResizable(bool) = 0; 95 96 virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) = 0; 97 98 virtual bool canRunBeforeUnloadConfirmPanel() = 0; 99 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0; 100 101 virtual void closeWindowSoon() = 0; 102 103 virtual void runJavaScriptAlert(Frame*, const String&) = 0; 104 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0; 105 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0; 106 virtual void setStatusbarText(const String&) = 0; 107 virtual bool shouldInterruptJavaScript() = 0; 108 virtual bool tabsToLinks() const = 0; 109 110 virtual IntRect windowResizerRect() const = 0; 111 112 // Methods used by HostWindow. 113 virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false) = 0; 114 virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) = 0; 115 virtual IntPoint screenToWindow(const IntPoint&) const = 0; 116 virtual IntRect windowToScreen(const IntRect&) const = 0; 117 virtual PlatformWidget platformWindow() const = 0; 118 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0; scrollRectIntoView(const IntRect &,const ScrollView *)119 virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {} // Platforms other than Mac can implement this if it ever becomes necessary for them to do so. 120 // End methods used by HostWindow. 121 122 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0; 123 124 virtual void setToolTip(const String&) = 0; 125 126 virtual void print(Frame*) = 0; 127 128 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0; 129 130 #if ENABLE(DASHBOARD_SUPPORT) 131 virtual void dashboardRegionsChanged(); 132 #endif 133 134 virtual void populateVisitedLinks(); 135 136 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect); 137 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, 138 bool behindText, bool entireLine); 139 140 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename); 141 virtual String generateReplacementFile(const String& path); 142 143 virtual void enableSuddenTermination(); 144 virtual void disableSuddenTermination(); 145 146 virtual bool paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, 147 ScrollbarControlState, ScrollbarPart pressedPart, bool vertical, 148 float value, float proportion, ScrollbarControlPartMask); 149 virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&); 150 151 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0; 152 153 // Notification that the given form element has changed. This function 154 // will be called frequently, so handling should be very fast. 155 virtual void formStateDidChange(const Node*) = 0; 156 157 #if PLATFORM(MAC) keyboardUIMode()158 virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; } 159 firstResponder()160 virtual NSResponder *firstResponder() { return 0; } makeFirstResponder(NSResponder *)161 virtual void makeFirstResponder(NSResponder *) { } 162 willPopUpMenu(NSMenu *)163 virtual void willPopUpMenu(NSMenu *) { } 164 #endif 165 166 protected: ~ChromeClient()167 virtual ~ChromeClient() { } 168 }; 169 170 } 171 172 #endif // ChromeClient_h 173