Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / frame_host / render_widget_host_view_guest.h
blobc5a6e72c9fb1fbe607e262a71c4f69f59ffdbe3e
1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
12 #include "content/common/content_export.h"
13 #include "content/common/cursors/webcursor.h"
14 #include "ui/events/event.h"
15 #include "ui/events/gestures/gesture_recognizer.h"
16 #include "ui/events/gestures/gesture_types.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/vector2d_f.h"
19 #include "ui/gfx/native_widget_types.h"
21 namespace content {
22 class BrowserPluginGuest;
23 class RenderWidgetHost;
24 class RenderWidgetHostImpl;
25 struct NativeWebKeyboardEvent;
27 // See comments in render_widget_host_view.h about this class and its members.
28 // This version is for the BrowserPlugin which handles a lot of the
29 // functionality in a diffent place and isn't platform specific.
30 // The BrowserPlugin is currently a special case for out-of-process rendered
31 // content and therefore inherits from RenderWidgetHostViewChildFrame.
32 // Eventually all RenderWidgetHostViewGuest code will be subsumed by
33 // RenderWidgetHostViewChildFrame and this class will be removed.
35 // Some elements that are platform specific will be deal with by delegating
36 // the relevant calls to the platform view.
37 class CONTENT_EXPORT RenderWidgetHostViewGuest
38 : public RenderWidgetHostViewChildFrame,
39 public ui::GestureConsumer,
40 public ui::GestureEventHelper {
41 public:
42 RenderWidgetHostViewGuest(
43 RenderWidgetHost* widget,
44 BrowserPluginGuest* guest,
45 base::WeakPtr<RenderWidgetHostViewBase> platform_view);
46 ~RenderWidgetHostViewGuest() override;
48 bool OnMessageReceivedFromEmbedder(const IPC::Message& message,
49 RenderWidgetHostImpl* embedder);
51 // RenderWidgetHostView implementation.
52 bool OnMessageReceived(const IPC::Message& msg) override;
53 void InitAsChild(gfx::NativeView parent_view) override;
54 void SetSize(const gfx::Size& size) override;
55 void SetBounds(const gfx::Rect& rect) override;
56 void Focus() override;
57 bool HasFocus() const override;
58 void Show() override;
59 void Hide() override;
60 gfx::NativeView GetNativeView() const override;
61 gfx::NativeViewId GetNativeViewId() const override;
62 gfx::NativeViewAccessible GetNativeViewAccessible() override;
63 gfx::Rect GetViewBounds() const override;
64 void SetBackgroundColor(SkColor color) override;
65 gfx::Size GetPhysicalBackingSize() const override;
66 base::string16 GetSelectedText() const override;
68 // RenderWidgetHostViewBase implementation.
69 void InitAsPopup(RenderWidgetHostView* parent_host_view,
70 const gfx::Rect& bounds) override;
71 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override;
72 void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override;
73 void UpdateCursor(const WebCursor& cursor) override;
74 void SetIsLoading(bool is_loading) override;
75 void TextInputTypeChanged(ui::TextInputType type,
76 ui::TextInputMode input_mode,
77 bool can_compose_inline,
78 int flags) override;
79 void ImeCancelComposition() override;
80 #if defined(OS_MACOSX) || defined(USE_AURA)
81 void ImeCompositionRangeChanged(
82 const gfx::Range& range,
83 const std::vector<gfx::Rect>& character_bounds) override;
84 #endif
85 void RenderProcessGone(base::TerminationStatus status,
86 int error_code) override;
87 void Destroy() override;
88 void SetTooltipText(const base::string16& tooltip_text) override;
89 void SelectionChanged(const base::string16& text,
90 size_t offset,
91 const gfx::Range& range) override;
92 void SelectionBoundsChanged(
93 const ViewHostMsg_SelectionBounds_Params& params) override;
94 void OnSwapCompositorFrame(uint32 output_surface_id,
95 scoped_ptr<cc::CompositorFrame> frame) override;
96 #if defined(USE_AURA)
97 void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
98 InputEventAckState ack_result) override;
99 #endif
100 bool LockMouse() override;
101 void UnlockMouse() override;
102 void GetScreenInfo(blink::WebScreenInfo* results) override;
104 #if defined(OS_MACOSX)
105 // RenderWidgetHostView implementation.
106 void SetActive(bool active) override;
107 void SetWindowVisibility(bool visible) override;
108 void WindowFrameChanged() override;
109 void ShowDefinitionForSelection() override;
110 bool SupportsSpeech() const override;
111 void SpeakSelection() override;
112 bool IsSpeaking() const override;
113 void StopSpeaking() override;
115 // RenderWidgetHostViewBase implementation.
116 bool PostProcessEventForPluginIme(
117 const NativeWebKeyboardEvent& event) override;
118 #endif // defined(OS_MACOSX)
120 #if defined(OS_ANDROID) || defined(TOOLKIT_VIEWS)
121 // RenderWidgetHostViewBase implementation.
122 void ShowDisambiguationPopup(const gfx::Rect& rect_pixels,
123 const SkBitmap& zoomed_bitmap) override;
124 #endif // defined(OS_ANDROID) || defined(TOOLKIT_VIEWS)
126 #if defined(OS_ANDROID)
127 void LockCompositingSurface() override;
128 void UnlockCompositingSurface() override;
129 #endif // defined(OS_ANDROID)
131 #if defined(OS_WIN)
132 virtual void SetParentNativeViewAccessible(
133 gfx::NativeViewAccessible accessible_parent) override;
134 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const override;
135 #endif
137 // Overridden from ui::GestureEventHelper.
138 bool CanDispatchToConsumer(ui::GestureConsumer* consumer) override;
139 void DispatchGestureEvent(ui::GestureEvent* event) override;
140 void DispatchCancelTouchEvent(ui::TouchEvent* event) override;
142 SkColorType PreferredReadbackFormat() override;
144 protected:
145 friend class RenderWidgetHostView;
147 private:
148 // Destroys this view without calling |Destroy| on |platform_view_|.
149 void DestroyGuestView();
151 // Builds and forwards a WebKitGestureEvent to the renderer.
152 bool ForwardGestureEventToRenderer(ui::GestureEvent* gesture);
154 // Process all of the given gestures (passes them on to renderer)
155 void ProcessGestures(ui::GestureRecognizer::Gestures* gestures);
157 RenderWidgetHostViewBase* GetOwnerRenderWidgetHostView() const;
159 void OnHandleInputEvent(RenderWidgetHostImpl* embedder,
160 int browser_plugin_instance_id,
161 const gfx::Rect& guest_window_rect,
162 const blink::WebInputEvent* event);
164 // BrowserPluginGuest and RenderWidgetHostViewGuest's lifetimes are not tied
165 // to one another, therefore we access |guest_| through WeakPtr.
166 base::WeakPtr<BrowserPluginGuest> guest_;
167 gfx::Size size_;
168 // The platform view for this RenderWidgetHostView.
169 // RenderWidgetHostViewGuest mostly only cares about stuff related to
170 // compositing, the rest are directly forwared to this |platform_view_|.
171 base::WeakPtr<RenderWidgetHostViewBase> platform_view_;
172 #if defined(USE_AURA)
173 scoped_ptr<ui::GestureRecognizer> gesture_recognizer_;
174 #endif
175 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuest);
178 } // namespace content
180 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_