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 #if ENABLE(NOTIFICATIONS) 66 class NotificationPresenter; 67 #endif 68 69 class ChromeClient { 70 public: 71 virtual void chromeDestroyed() = 0; 72 73 virtual void setWindowRect(const FloatRect&) = 0; 74 virtual FloatRect windowRect() = 0; 75 76 virtual FloatRect pageRect() = 0; 77 78 virtual float scaleFactor() = 0; 79 80 #ifdef ANDROID_USER_GESTURE 81 virtual void focus(bool userGesture) = 0; 82 #else 83 virtual void focus() = 0; 84 #endif 85 virtual void unfocus() = 0; 86 87 virtual bool canTakeFocus(FocusDirection) = 0; 88 virtual void takeFocus(FocusDirection) = 0; 89 90 virtual void focusedNodeChanged(Node*) = 0; 91 92 // The Frame pointer provides the ChromeClient with context about which 93 // Frame wants to create the new Page. Also, the newly created window 94 // should not be shown to the user until the ChromeClient of the newly 95 // created Page has its show method called. 96 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) = 0; 97 virtual void show() = 0; 98 99 virtual bool canRunModal() = 0; 100 virtual void runModal() = 0; 101 102 virtual void setToolbarsVisible(bool) = 0; 103 virtual bool toolbarsVisible() = 0; 104 105 virtual void setStatusbarVisible(bool) = 0; 106 virtual bool statusbarVisible() = 0; 107 108 virtual void setScrollbarsVisible(bool) = 0; 109 virtual bool scrollbarsVisible() = 0; 110 111 virtual void setMenubarVisible(bool) = 0; 112 virtual bool menubarVisible() = 0; 113 114 virtual void setResizable(bool) = 0; 115 116 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0; 117 118 virtual bool canRunBeforeUnloadConfirmPanel() = 0; 119 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0; 120 121 virtual void closeWindowSoon() = 0; 122 123 virtual void runJavaScriptAlert(Frame*, const String&) = 0; 124 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0; 125 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0; 126 virtual void setStatusbarText(const String&) = 0; 127 virtual bool shouldInterruptJavaScript() = 0; 128 virtual bool tabsToLinks() const = 0; 129 registerProtocolHandler(const String &,const String &,const String &,const String &)130 virtual void registerProtocolHandler(const String&, const String&, const String&, const String&) { } registerContentHandler(const String &,const String &,const String &,const String &)131 virtual void registerContentHandler(const String&, const String&, const String&, const String&) { } 132 133 virtual IntRect windowResizerRect() const = 0; 134 135 // Methods used by HostWindow. 136 virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false) = 0; 137 virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) = 0; 138 virtual IntPoint screenToWindow(const IntPoint&) const = 0; 139 virtual IntRect windowToScreen(const IntRect&) const = 0; 140 virtual PlatformPageClient platformPageClient() const = 0; 141 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0; 142 virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const = 0; // Currently only Mac has a non empty implementation. 143 // End methods used by HostWindow. 144 145 virtual void scrollbarsModeDidChange() const = 0; 146 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0; 147 148 virtual void setToolTip(const String&, TextDirection) = 0; 149 150 virtual void print(Frame*) = 0; 151 152 #if ENABLE(DATABASE) 153 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0; 154 #endif 155 156 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 157 // Callback invoked when the application cache fails to save a cache object 158 // because storing it would grow the database file past its defined maximum 159 // size or past the amount of free space on the device. 160 // The chrome client would need to take some action such as evicting some 161 // old caches. 162 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0; 163 #endif 164 165 #if ENABLE(DASHBOARD_SUPPORT) 166 virtual void dashboardRegionsChanged(); 167 #endif 168 169 #if ENABLE(NOTIFICATIONS) 170 virtual NotificationPresenter* notificationPresenter() const = 0; 171 #endif 172 173 virtual void populateVisitedLinks(); 174 175 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect); 176 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, 177 bool behindText, bool entireLine); 178 179 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename); 180 virtual String generateReplacementFile(const String& path); 181 182 virtual bool paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, 183 ScrollbarControlState, ScrollbarPart pressedPart, bool vertical, 184 float value, float proportion, ScrollbarControlPartMask); 185 virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&); 186 187 // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission 188 // to use Geolocation. 189 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0; 190 virtual void cancelGeolocationPermissionRequestForFrame(Frame*) = 0; 191 192 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0; 193 194 virtual bool setCursor(PlatformCursorHandle) = 0; 195 196 // Notification that the given form element has changed. This function 197 // will be called frequently, so handling should be very fast. 198 virtual void formStateDidChange(const Node*) = 0; 199 formDidFocus(const Node *)200 virtual void formDidFocus(const Node*) { }; formDidBlur(const Node *)201 virtual void formDidBlur(const Node*) { }; 202 203 virtual PassOwnPtr<HTMLParserQuirks> createHTMLParserQuirks() = 0; 204 205 #if USE(ACCELERATED_COMPOSITING) 206 // Pass 0 as the GraphicsLayer to detatch the root layer. 207 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0; 208 // Sets a flag to specify that the next time content is drawn to the window, 209 // the changes appear on the screen in synchrony with updates to GraphicsLayers. 210 virtual void setNeedsOneShotDrawingSynchronization() = 0; 211 // Sets a flag to specify that the view needs to be updated, so we need 212 // to do an eager layout before the drawing. 213 virtual void scheduleCompositingLayerSync() = 0; 214 #endif 215 supportsFullscreenForNode(const Node *)216 virtual bool supportsFullscreenForNode(const Node*) { return false; } enterFullscreenForNode(Node *)217 virtual void enterFullscreenForNode(Node*) { } exitFullscreenForNode(Node *)218 virtual void exitFullscreenForNode(Node*) { } 219 220 #if PLATFORM(MAC) keyboardUIMode()221 virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; } 222 firstResponder()223 virtual NSResponder *firstResponder() { return 0; } makeFirstResponder(NSResponder *)224 virtual void makeFirstResponder(NSResponder *) { } 225 willPopUpMenu(NSMenu *)226 virtual void willPopUpMenu(NSMenu *) { } 227 #endif 228 229 #if ENABLE(TOUCH_EVENTS) 230 virtual void needTouchEvents(bool) = 0; 231 #endif 232 233 protected: ~ChromeClient()234 virtual ~ChromeClient() { } 235 }; 236 237 } 238 239 #endif // ChromeClient_h 240