1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef Chrome_h 22 #define Chrome_h 23 24 #include "Cursor.h" 25 #include "FileChooser.h" 26 #include "FocusDirection.h" 27 #include "HostWindow.h" 28 #include "PopupMenu.h" 29 #include "SearchPopupMenu.h" 30 #include <wtf/Forward.h> 31 #include <wtf/RefPtr.h> 32 33 #if PLATFORM(MAC) 34 #ifndef __OBJC__ 35 class NSView; 36 #endif 37 #endif 38 39 namespace WebCore { 40 41 class ChromeClient; 42 class ContextMenu; 43 class FloatRect; 44 class Frame; 45 class Geolocation; 46 class HitTestResult; 47 class IntRect; 48 class NavigationAction; 49 class Node; 50 class Page; 51 class PopupMenuClient; 52 #if ENABLE(NOTIFICATIONS) 53 class NotificationPresenter; 54 #endif 55 56 struct FrameLoadRequest; 57 struct ViewportArguments; 58 struct WindowFeatures; 59 60 class Chrome : public HostWindow { 61 public: 62 Chrome(Page*, ChromeClient*); 63 ~Chrome(); 64 client()65 ChromeClient* client() { return m_client; } 66 67 // HostWindow methods. 68 69 virtual void invalidateWindow(const IntRect&, bool); 70 virtual void invalidateContentsAndWindow(const IntRect&, bool); 71 virtual void invalidateContentsForSlowScroll(const IntRect&, bool); 72 virtual void scroll(const IntSize&, const IntRect&, const IntRect&); 73 #if ENABLE(TILED_BACKING_STORE) 74 virtual void delegatedScrollRequested(const IntPoint& scrollPoint); 75 #endif 76 virtual IntPoint screenToWindow(const IntPoint&) const; 77 virtual IntRect windowToScreen(const IntRect&) const; 78 virtual PlatformPageClient platformPageClient() const; 79 virtual void scrollbarsModeDidChange() const; 80 virtual void setCursor(const Cursor&); 81 #if ENABLE(REQUEST_ANIMATION_FRAME) 82 virtual void scheduleAnimation(); 83 #endif 84 85 void scrollRectIntoView(const IntRect&) const; 86 87 void contentsSizeChanged(Frame*, const IntSize&) const; 88 89 void setWindowRect(const FloatRect&) const; 90 FloatRect windowRect() const; 91 92 FloatRect pageRect() const; 93 94 float scaleFactor(); 95 96 void focus() const; 97 void unfocus() const; 98 99 bool canTakeFocus(FocusDirection) const; 100 void takeFocus(FocusDirection) const; 101 102 void focusedNodeChanged(Node*) const; 103 void focusedFrameChanged(Frame*) const; 104 105 Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) const; 106 void show() const; 107 108 bool canRunModal() const; 109 bool canRunModalNow() const; 110 void runModal() const; 111 112 void setToolbarsVisible(bool) const; 113 bool toolbarsVisible() const; 114 115 void setStatusbarVisible(bool) const; 116 bool statusbarVisible() const; 117 118 void setScrollbarsVisible(bool) const; 119 bool scrollbarsVisible() const; 120 121 void setMenubarVisible(bool) const; 122 bool menubarVisible() const; 123 124 void setResizable(bool) const; 125 126 bool canRunBeforeUnloadConfirmPanel(); 127 bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame); 128 129 void closeWindowSoon(); 130 131 void runJavaScriptAlert(Frame*, const String&); 132 bool runJavaScriptConfirm(Frame*, const String&); 133 bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result); 134 void setStatusbarText(Frame*, const String&); 135 bool shouldInterruptJavaScript(); 136 137 #if ENABLE(REGISTER_PROTOCOL_HANDLER) 138 void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title); 139 #endif 140 141 IntRect windowResizerRect() const; 142 143 void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); 144 145 void setToolTip(const HitTestResult&); 146 147 void print(Frame*); 148 149 // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373 150 // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061 151 void requestGeolocationPermissionForFrame(Frame*, Geolocation*); 152 void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*); 153 154 void runOpenPanel(Frame*, PassRefPtr<FileChooser>); 155 void chooseIconForFiles(const Vector<String>&, FileChooser*); 156 #if ENABLE(DIRECTORY_UPLOAD) 157 void enumerateChosenDirectory(const String&, FileChooser*); 158 #endif 159 160 void dispatchViewportDataDidChange(const ViewportArguments&) const; 161 162 bool requiresFullscreenForVideoPlayback(); 163 164 #if PLATFORM(MAC) 165 void focusNSView(NSView*); 166 #endif 167 168 #if ENABLE(NOTIFICATIONS) 169 NotificationPresenter* notificationPresenter() const; 170 #endif 171 172 bool selectItemWritingDirectionIsNatural(); 173 bool selectItemAlignmentFollowsMenuWritingDirection(); 174 PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; 175 PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; 176 177 #if ENABLE(CONTEXT_MENUS) 178 void showContextMenu(); 179 #endif 180 181 void willRunModalHTMLDialog(const Frame*) const; 182 183 private: 184 Page* m_page; 185 ChromeClient* m_client; 186 }; 187 } 188 189 #endif // Chrome_h 190