1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple, Inc. All rights reserved. 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef ChromeClient_h 23 #define ChromeClient_h 24 25 #include "core/accessibility/AXObjectCache.h" 26 #include "core/inspector/ConsoleAPITypes.h" 27 #include "core/loader/FrameLoader.h" 28 #include "core/loader/NavigationPolicy.h" 29 #include "core/frame/ConsoleTypes.h" 30 #include "core/page/FocusType.h" 31 #include "core/rendering/RenderEmbeddedObject.h" 32 #include "core/rendering/style/RenderStyleConstants.h" 33 #include "platform/Cursor.h" 34 #include "platform/HostWindow.h" 35 #include "platform/PopupMenu.h" 36 #include "platform/PopupMenuClient.h" 37 #include "platform/scroll/ScrollTypes.h" 38 #include "wtf/Forward.h" 39 #include "wtf/PassOwnPtr.h" 40 #include "wtf/Vector.h" 41 42 43 #ifndef __OBJC__ 44 class NSMenu; 45 class NSResponder; 46 #endif 47 48 namespace WebCore { 49 50 class AXObject; 51 class ColorChooser; 52 class ColorChooserClient; 53 class DateTimeChooser; 54 class DateTimeChooserClient; 55 class Element; 56 class FileChooser; 57 class FloatRect; 58 class Frame; 59 class GraphicsContext; 60 class GraphicsLayer; 61 class GraphicsLayerFactory; 62 class HitTestResult; 63 class HTMLFormControlElement; 64 class HTMLInputElement; 65 class IntRect; 66 class LocalFrame; 67 class Node; 68 class Page; 69 class PagePopup; 70 class PagePopupClient; 71 class PagePopupDriver; 72 class PopupMenuClient; 73 class SecurityOrigin; 74 class Widget; 75 76 struct DateTimeChooserParameters; 77 struct FrameLoadRequest; 78 struct GraphicsDeviceAdapter; 79 struct ViewportDescription; 80 struct WindowFeatures; 81 82 class ChromeClient { 83 public: 84 virtual void chromeDestroyed() = 0; 85 86 virtual void setWindowRect(const FloatRect&) = 0; 87 virtual FloatRect windowRect() = 0; 88 89 virtual FloatRect pageRect() = 0; 90 91 virtual void focus() = 0; 92 93 virtual bool canTakeFocus(FocusType) = 0; 94 virtual void takeFocus(FocusType) = 0; 95 96 virtual void focusedNodeChanged(Node*) = 0; 97 98 virtual void focusedFrameChanged(LocalFrame*) = 0; 99 100 // The LocalFrame pointer provides the ChromeClient with context about which 101 // LocalFrame wants to create the new Page. Also, the newly created window 102 // should not be shown to the user until the ChromeClient of the newly 103 // created Page has its show method called. 104 // The FrameLoadRequest parameter is only for ChromeClient to check if the 105 // request could be fulfilled. The ChromeClient should not load the request. 106 virtual Page* createWindow(LocalFrame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) = 0; 107 virtual void show(NavigationPolicy) = 0; 108 109 virtual bool canRunModal() = 0; 110 virtual void runModal() = 0; 111 112 virtual void setToolbarsVisible(bool) = 0; 113 virtual bool toolbarsVisible() = 0; 114 115 virtual void setStatusbarVisible(bool) = 0; 116 virtual bool statusbarVisible() = 0; 117 118 virtual void setScrollbarsVisible(bool) = 0; 119 virtual bool scrollbarsVisible() = 0; 120 121 virtual void setMenubarVisible(bool) = 0; 122 virtual bool menubarVisible() = 0; 123 124 virtual void setResizable(bool) = 0; 125 126 virtual bool shouldReportDetailedMessageForSource(const String& source) = 0; 127 virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) = 0; 128 129 virtual bool canRunBeforeUnloadConfirmPanel() = 0; 130 virtual bool runBeforeUnloadConfirmPanel(const String& message, LocalFrame*) = 0; 131 132 virtual void closeWindowSoon() = 0; 133 134 virtual void runJavaScriptAlert(LocalFrame*, const String&) = 0; 135 virtual bool runJavaScriptConfirm(LocalFrame*, const String&) = 0; 136 virtual bool runJavaScriptPrompt(LocalFrame*, const String& message, const String& defaultValue, String& result) = 0; 137 virtual void setStatusbarText(const String&) = 0; 138 virtual bool tabsToLinks() = 0; 139 140 virtual void* webView() const = 0; 141 142 virtual IntRect windowResizerRect() const = 0; 143 144 // Methods used by HostWindow. 145 virtual void invalidateContentsAndRootView(const IntRect&) = 0; 146 virtual void invalidateContentsForSlowScroll(const IntRect&) = 0; 147 virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0; 148 virtual IntRect rootViewToScreen(const IntRect&) const = 0; 149 virtual blink::WebScreenInfo screenInfo() const = 0; 150 virtual void setCursor(const Cursor&) = 0; 151 virtual void scheduleAnimation() = 0; 152 // End methods used by HostWindow. 153 dispatchViewportPropertiesDidChange(const ViewportDescription &)154 virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const { } 155 156 virtual void contentsSizeChanged(LocalFrame*, const IntSize&) const = 0; deviceOrPageScaleFactorChanged()157 virtual void deviceOrPageScaleFactorChanged() const { } layoutUpdated(LocalFrame *)158 virtual void layoutUpdated(LocalFrame*) const { } 159 160 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0; 161 162 virtual void setToolTip(const String&, TextDirection) = 0; 163 164 virtual void print(LocalFrame*) = 0; 165 166 virtual void annotatedRegionsChanged() = 0; 167 168 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) = 0; 169 170 virtual PassOwnPtr<ColorChooser> createColorChooser(LocalFrame*, ColorChooserClient*, const Color&) = 0; 171 172 // This function is used for: 173 // - Mandatory date/time choosers if !ENABLE(INPUT_MULTIPLE_FIELDS_UI) 174 // - Date/time choosers for types for which RenderTheme::supportsCalendarPicker 175 // returns true, if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 176 // - <datalist> UI for date/time input types regardless of 177 // ENABLE(INPUT_MULTIPLE_FIELDS_UI) 178 virtual PassRefPtrWillBeRawPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) = 0; 179 180 virtual void openTextDataListChooser(HTMLInputElement&) = 0; 181 182 virtual void runOpenPanel(LocalFrame*, PassRefPtr<FileChooser>) = 0; 183 184 // Asychronous request to enumerate all files in a directory chosen by the user. 185 virtual void enumerateChosenDirectory(FileChooser*) = 0; 186 187 // Allows ports to customize the type of graphics layers created by this page. graphicsLayerFactory()188 virtual GraphicsLayerFactory* graphicsLayerFactory() const { return 0; } 189 190 // Pass 0 as the GraphicsLayer to detatch the root layer. 191 virtual void attachRootGraphicsLayer(GraphicsLayer*) = 0; 192 enterFullScreenForElement(Element *)193 virtual void enterFullScreenForElement(Element*) { } exitFullScreenForElement(Element *)194 virtual void exitFullScreenForElement(Element*) { } 195 196 virtual void needTouchEvents(bool) = 0; 197 198 virtual void setTouchAction(TouchAction) = 0; 199 200 // Checks if there is an opened popup, called by RenderMenuList::showPopup(). 201 virtual bool hasOpenedPopup() const = 0; 202 virtual PassRefPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const = 0; 203 // For testing. 204 virtual void setPagePopupDriver(PagePopupDriver*) = 0; 205 virtual void resetPagePopupDriver() = 0; 206 postAccessibilityNotification(AXObject *,AXObjectCache::AXNotification)207 virtual void postAccessibilityNotification(AXObject*, AXObjectCache::AXNotification) { } 208 virtual String acceptLanguages() = 0; 209 210 enum DialogType { 211 AlertDialog = 0, 212 ConfirmDialog = 1, 213 PromptDialog = 2, 214 HTMLDialog = 3 215 }; shouldRunModalDialogDuringPageDismissal(const DialogType &,const String &,Document::PageDismissalType)216 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String&, Document::PageDismissalType) const { return true; } 217 isSVGImageChromeClient()218 virtual bool isSVGImageChromeClient() const { return false; } 219 requestPointerLock()220 virtual bool requestPointerLock() { return false; } requestPointerUnlock()221 virtual void requestPointerUnlock() { } 222 minimumWindowSize()223 virtual FloatSize minimumWindowSize() const { return FloatSize(100, 100); }; 224 isChromeClientImpl()225 virtual bool isChromeClientImpl() const { return false; } 226 didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element>> &)227 virtual void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >&) { }; didChangeValueInTextField(HTMLFormControlElement &)228 virtual void didChangeValueInTextField(HTMLFormControlElement&) { } didEndEditingOnTextField(HTMLInputElement &)229 virtual void didEndEditingOnTextField(HTMLInputElement&) { } handleKeyboardEventOnTextField(HTMLInputElement &,KeyboardEvent &)230 virtual void handleKeyboardEventOnTextField(HTMLInputElement&, KeyboardEvent&) { } 231 232 // FIXME: Remove this method once we have input routing in the browser 233 // process. See http://crbug.com/339659. forwardInputEvent(WebCore::Frame *,WebCore::Event *)234 virtual void forwardInputEvent(WebCore::Frame*, WebCore::Event*) { } 235 236 // Input mehtod editor related functions. didCancelCompositionOnSelectionChange()237 virtual void didCancelCompositionOnSelectionChange() { } willSetInputMethodState()238 virtual void willSetInputMethodState() { } didUpdateTextOfFocusedElementByNonUserInput()239 virtual void didUpdateTextOfFocusedElementByNonUserInput() { } 240 241 protected: ~ChromeClient()242 virtual ~ChromeClient() { } 243 }; 244 245 } 246 #endif // ChromeClient_h 247