1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009 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 "Console.h" 24 #include "Cursor.h" 25 #include "FocusDirection.h" 26 #include "GraphicsContext.h" 27 #include "HTMLParserQuirks.h" 28 #include "HostWindow.h" 29 #include "ScrollTypes.h" 30 #include <wtf/Forward.h> 31 #include <wtf/PassOwnPtr.h> 32 #include <wtf/Vector.h> 33 34 #if PLATFORM(MAC) 35 #include "WebCoreKeyboardUIMode.h" 36 #endif 37 38 #ifndef __OBJC__ 39 class NSMenu; 40 class NSResponder; 41 #endif 42 43 namespace WebCore { 44 45 class AtomicString; 46 class FileChooser; 47 class FloatRect; 48 class Frame; 49 class Geolocation; 50 class HTMLParserQuirks; 51 class HitTestResult; 52 class IntRect; 53 class Node; 54 class Page; 55 class String; 56 class Widget; 57 58 struct FrameLoadRequest; 59 struct WindowFeatures; 60 61 #if USE(ACCELERATED_COMPOSITING) 62 class GraphicsLayer; 63 #endif 64 65 class ChromeClient { 66 public: 67 virtual void chromeDestroyed() = 0; 68 69 virtual void setWindowRect(const FloatRect&) = 0; 70 virtual FloatRect windowRect() = 0; 71 72 virtual FloatRect pageRect() = 0; 73 74 virtual float scaleFactor() = 0; 75 76 virtual void focus() = 0; 77 virtual void unfocus() = 0; 78 79 virtual bool canTakeFocus(FocusDirection) = 0; 80 virtual void takeFocus(FocusDirection) = 0; 81 82 // The Frame pointer provides the ChromeClient with context about which 83 // Frame wants to create the new Page. Also, the newly created window 84 // should not be shown to the user until the ChromeClient of the newly 85 // created Page has its show method called. 86 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) = 0; 87 virtual void show() = 0; 88 89 virtual bool canRunModal() = 0; 90 virtual void runModal() = 0; 91 92 virtual void setToolbarsVisible(bool) = 0; 93 virtual bool toolbarsVisible() = 0; 94 95 virtual void setStatusbarVisible(bool) = 0; 96 virtual bool statusbarVisible() = 0; 97 98 virtual void setScrollbarsVisible(bool) = 0; 99 virtual bool scrollbarsVisible() = 0; 100 101 virtual void setMenubarVisible(bool) = 0; 102 virtual bool menubarVisible() = 0; 103 104 virtual void setResizable(bool) = 0; 105 106 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0; 107 108 virtual bool canRunBeforeUnloadConfirmPanel() = 0; 109 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0; 110 111 virtual void closeWindowSoon() = 0; 112 113 virtual void runJavaScriptAlert(Frame*, const String&) = 0; 114 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0; 115 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0; 116 virtual void setStatusbarText(const String&) = 0; 117 virtual bool shouldInterruptJavaScript() = 0; 118 virtual bool tabsToLinks() const = 0; 119 120 virtual IntRect windowResizerRect() const = 0; 121 122 // Methods used by HostWindow. 123 virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false) = 0; 124 virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) = 0; 125 virtual IntPoint screenToWindow(const IntPoint&) const = 0; 126 virtual IntRect windowToScreen(const IntRect&) const = 0; 127 virtual PlatformWidget platformWindow() const = 0; 128 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0; 129 virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const = 0; // Currently only Mac has a non empty implementation. 130 // End methods used by HostWindow. 131 132 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0; 133 134 virtual void setToolTip(const String&, TextDirection) = 0; 135 136 virtual void print(Frame*) = 0; 137 138 #if ENABLE(DATABASE) 139 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0; 140 #endif 141 142 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 143 // Callback invoked when the application cache fails to save a cache object 144 // because storing it would grow the database file past its defined maximum 145 // size or past the amount of free space on the device. 146 // The chrome client would need to take some action such as evicting some 147 // old caches. 148 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0; 149 #endif 150 151 #if ENABLE(DASHBOARD_SUPPORT) 152 virtual void dashboardRegionsChanged(); 153 #endif 154 155 virtual void populateVisitedLinks(); 156 157 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect); 158 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, 159 bool behindText, bool entireLine); 160 161 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename); 162 virtual String generateReplacementFile(const String& path); 163 164 virtual bool paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, 165 ScrollbarControlState, ScrollbarPart pressedPart, bool vertical, 166 float value, float proportion, ScrollbarControlPartMask); 167 virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&); 168 169 // This is an asynchronous call. The ChromeClient can display UI asking the user for permission 170 // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately. 171 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0; 172 173 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0; 174 175 virtual bool setCursor(PlatformCursorHandle) = 0; 176 177 // Notification that the given form element has changed. This function 178 // will be called frequently, so handling should be very fast. 179 virtual void formStateDidChange(const Node*) = 0; 180 formDidFocus(const Node *)181 virtual void formDidFocus(const Node*) { }; formDidBlur(const Node *)182 virtual void formDidBlur(const Node*) { }; 183 184 virtual PassOwnPtr<HTMLParserQuirks> createHTMLParserQuirks() = 0; 185 186 #if USE(ACCELERATED_COMPOSITING) 187 // Pass 0 as the GraphicsLayer to detatch the root layer. 188 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0; 189 // Sets a flag to specify that the next time content is drawn to the window, 190 // the changes appear on the screen in synchrony with updates to GraphicsLayers. 191 virtual void setNeedsOneShotDrawingSynchronization() = 0; 192 // Sets a flag to specify that the view needs to be updated, so we need 193 // to do an eager layout before the drawing. 194 virtual void scheduleCompositingLayerSync() = 0; 195 #endif 196 197 #if PLATFORM(MAC) keyboardUIMode()198 virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; } 199 firstResponder()200 virtual NSResponder *firstResponder() { return 0; } makeFirstResponder(NSResponder *)201 virtual void makeFirstResponder(NSResponder *) { } 202 willPopUpMenu(NSMenu *)203 virtual void willPopUpMenu(NSMenu *) { } 204 #endif 205 206 protected: ~ChromeClient()207 virtual ~ChromeClient() { } 208 }; 209 210 } 211 212 #endif // ChromeClient_h 213