| OLD | NEW |
| (Empty) |
| 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_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "content/browser/renderer_host/render_widget_host_view_base.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "ui/events/event.h" | |
| 14 #include "ui/events/gestures/gesture_recognizer.h" | |
| 15 #include "ui/events/gestures/gesture_types.h" | |
| 16 #include "ui/gfx/native_widget_types.h" | |
| 17 #include "ui/gfx/rect.h" | |
| 18 #include "ui/gfx/vector2d_f.h" | |
| 19 #include "webkit/common/cursors/webcursor.h" | |
| 20 | |
| 21 #if defined(TOOLKIT_GTK) | |
| 22 #include "content/browser/renderer_host/gtk_plugin_container_manager.h" | |
| 23 #endif // defined(TOOLKIT_GTK) | |
| 24 | |
| 25 namespace content { | |
| 26 class RenderWidgetHost; | |
| 27 class RenderWidgetHostImpl; | |
| 28 class BrowserPluginGuest; | |
| 29 struct NativeWebKeyboardEvent; | |
| 30 | |
| 31 // ----------------------------------------------------------------------------- | |
| 32 // See comments in render_widget_host_view.h about this class and its members. | |
| 33 // This version is for the webview plugin which handles a lot of the | |
| 34 // functionality in a diffent place and isn't platform specific. | |
| 35 // | |
| 36 // Some elements that are platform specific will be deal with by delegating | |
| 37 // the relevant calls to the platform view. | |
| 38 // ----------------------------------------------------------------------------- | |
| 39 class CONTENT_EXPORT RenderWidgetHostViewGuest | |
| 40 : public RenderWidgetHostViewBase, | |
| 41 public ui::GestureConsumer, | |
| 42 public ui::GestureEventHelper { | |
| 43 public: | |
| 44 RenderWidgetHostViewGuest(RenderWidgetHost* widget, | |
| 45 BrowserPluginGuest* guest, | |
| 46 RenderWidgetHostView* platform_view); | |
| 47 virtual ~RenderWidgetHostViewGuest(); | |
| 48 | |
| 49 // RenderWidgetHostView implementation. | |
| 50 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | |
| 51 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | |
| 52 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; | |
| 53 virtual void SetSize(const gfx::Size& size) OVERRIDE; | |
| 54 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; | |
| 55 virtual gfx::NativeView GetNativeView() const OVERRIDE; | |
| 56 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; | |
| 57 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | |
| 58 virtual bool HasFocus() const OVERRIDE; | |
| 59 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; | |
| 60 virtual void Show() OVERRIDE; | |
| 61 virtual void Hide() OVERRIDE; | |
| 62 virtual bool IsShowing() OVERRIDE; | |
| 63 virtual gfx::Rect GetViewBounds() const OVERRIDE; | |
| 64 virtual void SetBackground(const SkBitmap& background) OVERRIDE; | |
| 65 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 66 virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; | |
| 67 #endif | |
| 68 | |
| 69 // RenderWidgetHostViewPort implementation. | |
| 70 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | |
| 71 const gfx::Rect& pos) OVERRIDE; | |
| 72 virtual void InitAsFullscreen( | |
| 73 RenderWidgetHostView* reference_host_view) OVERRIDE; | |
| 74 virtual void WasShown() OVERRIDE; | |
| 75 virtual void WasHidden() OVERRIDE; | |
| 76 virtual void MovePluginWindows( | |
| 77 const gfx::Vector2d& scroll_offset, | |
| 78 const std::vector<WebPluginGeometry>& moves) OVERRIDE; | |
| 79 virtual void Focus() OVERRIDE; | |
| 80 virtual void Blur() OVERRIDE; | |
| 81 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; | |
| 82 virtual void SetIsLoading(bool is_loading) OVERRIDE; | |
| 83 virtual void TextInputTypeChanged(ui::TextInputType type, | |
| 84 ui::TextInputMode input_mode, | |
| 85 bool can_compose_inline) OVERRIDE; | |
| 86 virtual void ImeCancelComposition() OVERRIDE; | |
| 87 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | |
| 88 virtual void ImeCompositionRangeChanged( | |
| 89 const gfx::Range& range, | |
| 90 const std::vector<gfx::Rect>& character_bounds) OVERRIDE; | |
| 91 #endif | |
| 92 virtual void DidUpdateBackingStore( | |
| 93 const gfx::Rect& scroll_rect, | |
| 94 const gfx::Vector2d& scroll_delta, | |
| 95 const std::vector<gfx::Rect>& copy_rects, | |
| 96 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; | |
| 97 virtual void RenderProcessGone(base::TerminationStatus status, | |
| 98 int error_code) OVERRIDE; | |
| 99 virtual void Destroy() OVERRIDE; | |
| 100 virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {} | |
| 101 virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; | |
| 102 virtual void SelectionChanged(const base::string16& text, | |
| 103 size_t offset, | |
| 104 const gfx::Range& range) OVERRIDE; | |
| 105 virtual void SelectionBoundsChanged( | |
| 106 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; | |
| 107 virtual void ScrollOffsetChanged() OVERRIDE; | |
| 108 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; | |
| 109 virtual void CopyFromCompositingSurface( | |
| 110 const gfx::Rect& src_subrect, | |
| 111 const gfx::Size& dst_size, | |
| 112 const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE; | |
| 113 virtual void CopyFromCompositingSurfaceToVideoFrame( | |
| 114 const gfx::Rect& src_subrect, | |
| 115 const scoped_refptr<media::VideoFrame>& target, | |
| 116 const base::Callback<void(bool)>& callback) OVERRIDE; | |
| 117 virtual bool CanCopyToVideoFrame() const OVERRIDE; | |
| 118 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; | |
| 119 virtual void AcceleratedSurfaceInitialized(int host_id, | |
| 120 int route_id) OVERRIDE; | |
| 121 virtual void AcceleratedSurfaceBuffersSwapped( | |
| 122 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | |
| 123 int gpu_host_id) OVERRIDE; | |
| 124 virtual void AcceleratedSurfacePostSubBuffer( | |
| 125 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | |
| 126 int gpu_host_id) OVERRIDE; | |
| 127 virtual void OnSwapCompositorFrame( | |
| 128 uint32 output_surface_id, | |
| 129 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; | |
| 130 virtual void AcceleratedSurfaceSuspend() OVERRIDE; | |
| 131 virtual void AcceleratedSurfaceRelease() OVERRIDE; | |
| 132 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; | |
| 133 virtual void SetHasHorizontalScrollbar( | |
| 134 bool has_horizontal_scrollbar) OVERRIDE; | |
| 135 virtual void SetScrollOffsetPinning( | |
| 136 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | |
| 137 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; | |
| 138 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; | |
| 139 #if defined(OS_WIN) || defined(USE_AURA) | |
| 140 virtual void ProcessAckedTouchEvent( | |
| 141 const TouchEventWithLatencyInfo& touch, | |
| 142 InputEventAckState ack_result) OVERRIDE; | |
| 143 #endif // defined(OS_WIN) || defined(USE_AURA) | |
| 144 virtual bool LockMouse() OVERRIDE; | |
| 145 virtual void UnlockMouse() OVERRIDE; | |
| 146 virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE; | |
| 147 | |
| 148 #if defined(OS_MACOSX) | |
| 149 // RenderWidgetHostView implementation. | |
| 150 virtual void SetActive(bool active) OVERRIDE; | |
| 151 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; | |
| 152 virtual void SetWindowVisibility(bool visible) OVERRIDE; | |
| 153 virtual void WindowFrameChanged() OVERRIDE; | |
| 154 virtual void ShowDefinitionForSelection() OVERRIDE; | |
| 155 virtual bool SupportsSpeech() const OVERRIDE; | |
| 156 virtual void SpeakSelection() OVERRIDE; | |
| 157 virtual bool IsSpeaking() const OVERRIDE; | |
| 158 virtual void StopSpeaking() OVERRIDE; | |
| 159 | |
| 160 // RenderWidgetHostViewPort implementation. | |
| 161 virtual bool PostProcessEventForPluginIme( | |
| 162 const NativeWebKeyboardEvent& event) OVERRIDE; | |
| 163 #endif // defined(OS_MACOSX) | |
| 164 | |
| 165 #if defined(OS_ANDROID) | |
| 166 // RenderWidgetHostViewPort implementation. | |
| 167 virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, | |
| 168 const SkBitmap& zoomed_bitmap) OVERRIDE; | |
| 169 virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE; | |
| 170 #endif // defined(OS_ANDROID) | |
| 171 | |
| 172 #if defined(TOOLKIT_GTK) | |
| 173 virtual GdkEventButton* GetLastMouseDown() OVERRIDE; | |
| 174 virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; | |
| 175 #endif // defined(TOOLKIT_GTK) | |
| 176 | |
| 177 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 178 virtual void WillWmDestroy() OVERRIDE; | |
| 179 #endif // defined(OS_WIN) && !defined(USE_AURA) | |
| 180 | |
| 181 #if defined(OS_WIN) && defined(USE_AURA) | |
| 182 virtual void SetParentNativeViewAccessible( | |
| 183 gfx::NativeViewAccessible accessible_parent) OVERRIDE; | |
| 184 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE; | |
| 185 #endif | |
| 186 | |
| 187 // Overridden from ui::GestureEventHelper. | |
| 188 virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) OVERRIDE; | |
| 189 virtual void DispatchPostponedGestureEvent(ui::GestureEvent* event) OVERRIDE; | |
| 190 virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
| 191 | |
| 192 protected: | |
| 193 friend class RenderWidgetHostView; | |
| 194 | |
| 195 private: | |
| 196 // Destroys this view without calling |Destroy| on |platform_view_|. | |
| 197 void DestroyGuestView(); | |
| 198 | |
| 199 // Builds and forwards a WebKitGestureEvent to the renderer. | |
| 200 bool ForwardGestureEventToRenderer(ui::GestureEvent* gesture); | |
| 201 | |
| 202 // Process all of the given gestures (passes them on to renderer) | |
| 203 void ProcessGestures(ui::GestureRecognizer::Gestures* gestures); | |
| 204 | |
| 205 // The model object. | |
| 206 RenderWidgetHostImpl* host_; | |
| 207 | |
| 208 BrowserPluginGuest *guest_; | |
| 209 gfx::Size size_; | |
| 210 // The platform view for this RenderWidgetHostView. | |
| 211 // RenderWidgetHostViewGuest mostly only cares about stuff related to | |
| 212 // compositing, the rest are directly forwared to this |platform_view_|. | |
| 213 RenderWidgetHostViewPort* platform_view_; | |
| 214 #if defined(OS_WIN) || defined(USE_AURA) | |
| 215 scoped_ptr<ui::GestureRecognizer> gesture_recognizer_; | |
| 216 #endif // defined(OS_WIN) || defined(USE_AURA) | |
| 217 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuest); | |
| 218 }; | |
| 219 | |
| 220 } // namespace content | |
| 221 | |
| 222 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ | |
| OLD | NEW |