1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_RENDER_WIDGET_HOST_DELEGATE_H_ 6 #define CONTENT_BROWSER_RENDER_WIDGET_HOST_DELEGATE_H_ 7 8 #include "build/build_config.h" 9 #include "content/common/content_export.h" 10 #include "ui/gfx/native_widget_types.h" 11 12 namespace blink { 13 class WebMouseWheelEvent; 14 class WebGestureEvent; 15 } 16 17 namespace content { 18 19 class RenderWidgetHostImpl; 20 struct NativeWebKeyboardEvent; 21 22 // 23 // RenderWidgetHostDelegate 24 // 25 // An interface implemented by an object interested in knowing about the state 26 // of the RenderWidgetHost. 27 class CONTENT_EXPORT RenderWidgetHostDelegate { 28 public: 29 // The RenderWidgetHost is going to be deleted. 30 virtual void RenderWidgetDeleted(RenderWidgetHostImpl* render_widget_host) {} 31 32 // Callback to give the browser a chance to handle the specified keyboard 33 // event before sending it to the renderer. 34 // Returns true if the |event| was handled. Otherwise, if the |event| would 35 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut, 36 // |*is_keyboard_shortcut| should be set to true. 37 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 38 bool* is_keyboard_shortcut); 39 40 // Callback to inform the browser that the renderer did not process the 41 // specified events. This gives an opportunity to the browser to process the 42 // event (used for keyboard shortcuts). 43 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} 44 45 // Callback to inform the browser that the renderer did not process the 46 // specified mouse wheel event. Returns true if the browser has handled 47 // the event itself. 48 virtual bool HandleWheelEvent(const blink::WebMouseWheelEvent& event); 49 50 // Callback to give the browser a chance to handle the specified gesture 51 // event before sending it to the renderer. 52 // Returns true if the |event| was handled. 53 virtual bool PreHandleGestureEvent(const blink::WebGestureEvent& event); 54 55 // Callback to inform the browser that the renderer did not process the 56 // specified gesture event. Returns true if the |event| was handled. 57 virtual bool HandleGestureEvent(const blink::WebGestureEvent& event); 58 59 // Notifies that screen rects were sent to renderer process. 60 virtual void DidSendScreenRects(RenderWidgetHostImpl* rwh) {} 61 62 // Notifies that RenderWidgetHost will toggle touch emulation. 63 virtual void OnTouchEmulationEnabled(bool enabled) {} 64 65 #if defined(OS_WIN) 66 // Returns the widget's parent's NativeViewAccessible. 67 virtual gfx::NativeViewAccessible GetParentNativeViewAccessible(); 68 #endif 69 70 protected: 71 virtual ~RenderWidgetHostDelegate() {} 72 }; 73 74 } // namespace content 75 76 #endif // CONTENT_BROWSER_RENDER_WIDGET_HOST_DELEGATE_H_ 77