Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: content/browser/frame_host/render_widget_host_view_guest.cc

Issue 100473010: Adding RenderWidgetHostViewChildFrame for OOPIF view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed broken unit test Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind_helpers.h" 5 #include "base/bind_helpers.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
10 #include "content/browser/frame_host/render_widget_host_view_guest.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
11 #include "content/browser/renderer_host/render_widget_host_view_guest.h"
12 #include "content/common/browser_plugin/browser_plugin_messages.h" 12 #include "content/common/browser_plugin/browser_plugin_messages.h"
13 #include "content/common/gpu/gpu_messages.h" 13 #include "content/common/gpu/gpu_messages.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 #include "content/common/webplugin_geometry.h" 15 #include "content/common/webplugin_geometry.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "skia/ext/platform_canvas.h" 17 #include "skia/ext/platform_canvas.h"
18 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 18 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
19 19
20 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
21 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 21 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
(...skipping 22 matching lines...) Expand all
44 return gesture_event; 44 return gesture_event;
45 } 45 }
46 #endif // defined(OS_WIN) || defined(USE_AURA) 46 #endif // defined(OS_WIN) || defined(USE_AURA)
47 47
48 } // namespace 48 } // namespace
49 49
50 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( 50 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest(
51 RenderWidgetHost* widget_host, 51 RenderWidgetHost* widget_host,
52 BrowserPluginGuest* guest, 52 BrowserPluginGuest* guest,
53 RenderWidgetHostView* platform_view) 53 RenderWidgetHostView* platform_view)
54 : host_(RenderWidgetHostImpl::From(widget_host)), 54 : RenderWidgetHostViewChildFrame(widget_host),
55 guest_(guest), 55 guest_(guest),
56 platform_view_(static_cast<RenderWidgetHostViewPort*>(platform_view)) { 56 platform_view_(static_cast<RenderWidgetHostViewPort*>(platform_view)) {
57 #if defined(OS_WIN) || defined(USE_AURA) 57 #if defined(OS_WIN) || defined(USE_AURA)
58 gesture_recognizer_.reset(ui::GestureRecognizer::Create()); 58 gesture_recognizer_.reset(ui::GestureRecognizer::Create());
59 gesture_recognizer_->AddGestureEventHelper(this); 59 gesture_recognizer_->AddGestureEventHelper(this);
60 #endif // defined(OS_WIN) || defined(USE_AURA) 60 #endif // defined(OS_WIN) || defined(USE_AURA)
61 host_->SetView(this);
62 } 61 }
63 62
64 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { 63 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {
65 #if defined(OS_WIN) || defined(USE_AURA) 64 #if defined(OS_WIN) || defined(USE_AURA)
66 gesture_recognizer_->RemoveGestureEventHelper(this); 65 gesture_recognizer_->RemoveGestureEventHelper(this);
67 #endif // defined(OS_WIN) || defined(USE_AURA) 66 #endif // defined(OS_WIN) || defined(USE_AURA)
68 } 67 }
69 68
70 RenderWidgetHost* RenderWidgetHostViewGuest::GetRenderWidgetHost() const {
71 return host_;
72 }
73
74 void RenderWidgetHostViewGuest::WasShown() { 69 void RenderWidgetHostViewGuest::WasShown() {
75 // If the WebContents associated with us showed an interstitial page in the 70 // If the WebContents associated with us showed an interstitial page in the
76 // beginning, the teardown path might call WasShown() while |host_| is in 71 // beginning, the teardown path might call WasShown() while |host_| is in
77 // the process of destruction. Avoid calling WasShown below in this case. 72 // the process of destruction. Avoid calling WasShown below in this case.
78 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the 73 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the
79 // first place: http://crbug.com/273089. 74 // first place: http://crbug.com/273089.
80 // 75 //
81 // |guest_| is NULL during test. 76 // |guest_| is NULL during test.
82 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden()) 77 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden())
83 return; 78 return;
84 host_->WasShown(); 79 host_->WasShown();
85 } 80 }
86 81
87 void RenderWidgetHostViewGuest::WasHidden() { 82 void RenderWidgetHostViewGuest::WasHidden() {
88 // |guest_| is NULL during test. 83 // |guest_| is NULL during test.
89 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden()) 84 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden())
90 return; 85 return;
91 host_->WasHidden(); 86 host_->WasHidden();
92 } 87 }
93 88
94 void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) { 89 void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) {
95 size_ = size; 90 size_ = size;
96 host_->WasResized(); 91 host_->WasResized();
97 } 92 }
98 93
99 gfx::Rect RenderWidgetHostViewGuest::GetBoundsInRootWindow() { 94 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) {
100 // We do not have any root window specific parts in this view. 95 SetSize(rect.size());
101 return GetViewBounds();
102 }
103
104 gfx::GLSurfaceHandle RenderWidgetHostViewGuest::GetCompositingSurface() {
105 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
106 } 96 }
107 97
108 #if defined(OS_WIN) || defined(USE_AURA) 98 #if defined(OS_WIN) || defined(USE_AURA)
109 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( 99 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent(
110 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { 100 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) {
111 // TODO(fsamuel): Currently we will only take this codepath if the guest has 101 // TODO(fsamuel): Currently we will only take this codepath if the guest has
112 // requested touch events. A better solution is to always forward touchpresses 102 // requested touch events. A better solution is to always forward touchpresses
113 // to the embedder process to target a BrowserPlugin, and then route all 103 // to the embedder process to target a BrowserPlugin, and then route all
114 // subsequent touch points of that touchdown to the appropriate guest until 104 // subsequent touch points of that touchdown to the appropriate guest until
115 // that touch point is released. 105 // that touch point is released.
116 ScopedVector<ui::TouchEvent> events; 106 ScopedVector<ui::TouchEvent> events;
117 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) 107 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES))
118 return; 108 return;
119 109
120 ui::EventResult result = (ack_result == 110 ui::EventResult result = (ack_result ==
121 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED; 111 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED;
122 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 112 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
123 end = events.end(); iter != end; ++iter) { 113 end = events.end(); iter != end; ++iter) {
124 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; 114 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
125 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( 115 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture(
126 *(*iter), result, this)); 116 *(*iter), result, this));
127 ProcessGestures(gestures.get()); 117 ProcessGestures(gestures.get());
128 } 118 }
129 } 119 }
130 #endif 120 #endif
131 121
132 void RenderWidgetHostViewGuest::Show() {
133 WasShown();
134 }
135
136 void RenderWidgetHostViewGuest::Hide() {
137 WasHidden();
138 }
139
140 bool RenderWidgetHostViewGuest::IsShowing() {
141 return !host_->is_hidden();
142 }
143
144 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { 122 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const {
145 RenderWidgetHostViewPort* rwhv = static_cast<RenderWidgetHostViewPort*>( 123 RenderWidgetHostViewPort* rwhv = static_cast<RenderWidgetHostViewPort*>(
146 guest_->GetEmbedderRenderWidgetHostView()); 124 guest_->GetEmbedderRenderWidgetHostView());
147 gfx::Rect embedder_bounds; 125 gfx::Rect embedder_bounds;
148 if (rwhv) 126 if (rwhv)
149 embedder_bounds = rwhv->GetViewBounds(); 127 embedder_bounds = rwhv->GetViewBounds();
150 gfx::Rect shifted_rect = guest_->ToGuestRect(embedder_bounds); 128 gfx::Rect shifted_rect = guest_->ToGuestRect(embedder_bounds);
151 shifted_rect.set_width(size_.width()); 129 shifted_rect.set_width(size_.width());
152 shifted_rect.set_height(size_.height()); 130 shifted_rect.set_height(size_.height());
153 return shifted_rect; 131 return shifted_rect;
154 } 132 }
155 133
156 void RenderWidgetHostViewGuest::RenderProcessGone( 134 void RenderWidgetHostViewGuest::RenderProcessGone(
157 base::TerminationStatus status, 135 base::TerminationStatus status,
158 int error_code) { 136 int error_code) {
159 platform_view_->RenderProcessGone(status, error_code); 137 platform_view_->RenderProcessGone(status, error_code);
160 // Destroy the guest view instance only, so we don't end up calling 138 // Destroy the guest view instance only, so we don't end up calling
161 // platform_view_->Destroy(). 139 // platform_view_->Destroy().
162 DestroyGuestView(); 140 DestroyGuestView();
163 } 141 }
164 142
165 void RenderWidgetHostViewGuest::Destroy() { 143 void RenderWidgetHostViewGuest::Destroy() {
166 // The RenderWidgetHost's destruction led here, so don't call it. 144 // The RenderWidgetHost's destruction led here, so don't call it.
167 DestroyGuestView(); 145 DestroyGuestView();
168 146
169 platform_view_->Destroy(); 147 platform_view_->Destroy();
170 } 148 }
171 149
150 gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const {
151 return RenderWidgetHostViewBase::GetPhysicalBackingSize();
152 }
153
172 void RenderWidgetHostViewGuest::SetTooltipText( 154 void RenderWidgetHostViewGuest::SetTooltipText(
173 const base::string16& tooltip_text) { 155 const base::string16& tooltip_text) {
174 platform_view_->SetTooltipText(tooltip_text); 156 platform_view_->SetTooltipText(tooltip_text);
175 } 157 }
176 158
177 void RenderWidgetHostViewGuest::AcceleratedSurfaceInitialized(int host_id,
178 int route_id) {
179 }
180
181 void RenderWidgetHostViewGuest::AcceleratedSurfaceBuffersSwapped( 159 void RenderWidgetHostViewGuest::AcceleratedSurfaceBuffersSwapped(
182 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 160 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
183 int gpu_host_id) { 161 int gpu_host_id) {
184 // If accelerated surface buffers are getting swapped then we're not using 162 // If accelerated surface buffers are getting swapped then we're not using
185 // the software path. 163 // the software path.
186 guest_->clear_damage_buffer(); 164 guest_->clear_damage_buffer();
187 BrowserPluginMsg_BuffersSwapped_Params guest_params; 165 BrowserPluginMsg_BuffersSwapped_Params guest_params;
188 guest_params.size = params.size; 166 guest_params.size = params.size;
189 guest_params.mailbox_name = params.mailbox_name; 167 guest_params.mailbox_name = params.mailbox_name;
190 guest_params.route_id = params.route_id; 168 guest_params.route_id = params.route_id;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 guest_->clear_damage_buffer(); 200 guest_->clear_damage_buffer();
223 guest_->SendMessageToEmbedder( 201 guest_->SendMessageToEmbedder(
224 new BrowserPluginMsg_CompositorFrameSwapped( 202 new BrowserPluginMsg_CompositorFrameSwapped(
225 guest_->instance_id(), 203 guest_->instance_id(),
226 *frame, 204 *frame,
227 host_->GetRoutingID(), 205 host_->GetRoutingID(),
228 output_surface_id, 206 output_surface_id,
229 host_->GetProcess()->GetID())); 207 host_->GetProcess()->GetID()));
230 } 208 }
231 209
232 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) {
233 SetSize(rect.size());
234 }
235
236 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { 210 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) {
237 return platform_view_->OnMessageReceived(msg); 211 return platform_view_->OnMessageReceived(msg);
238 } 212 }
239 213
240 void RenderWidgetHostViewGuest::InitAsChild( 214 void RenderWidgetHostViewGuest::InitAsChild(
241 gfx::NativeView parent_view) { 215 gfx::NativeView parent_view) {
242 platform_view_->InitAsChild(parent_view); 216 platform_view_->InitAsChild(parent_view);
243 } 217 }
244 218
245 void RenderWidgetHostViewGuest::InitAsPopup( 219 void RenderWidgetHostViewGuest::InitAsPopup(
(...skipping 21 matching lines...) Expand all
267 gfx::NativeViewAccessible RenderWidgetHostViewGuest::GetNativeViewAccessible() { 241 gfx::NativeViewAccessible RenderWidgetHostViewGuest::GetNativeViewAccessible() {
268 return guest_->GetEmbedderRenderWidgetHostView()->GetNativeViewAccessible(); 242 return guest_->GetEmbedderRenderWidgetHostView()->GetNativeViewAccessible();
269 } 243 }
270 244
271 void RenderWidgetHostViewGuest::MovePluginWindows( 245 void RenderWidgetHostViewGuest::MovePluginWindows(
272 const gfx::Vector2d& scroll_offset, 246 const gfx::Vector2d& scroll_offset,
273 const std::vector<WebPluginGeometry>& moves) { 247 const std::vector<WebPluginGeometry>& moves) {
274 platform_view_->MovePluginWindows(scroll_offset, moves); 248 platform_view_->MovePluginWindows(scroll_offset, moves);
275 } 249 }
276 250
277 void RenderWidgetHostViewGuest::Focus() {
278 }
279
280 void RenderWidgetHostViewGuest::Blur() {
281 }
282
283 bool RenderWidgetHostViewGuest::HasFocus() const {
284 return false;
285 }
286
287 bool RenderWidgetHostViewGuest::IsSurfaceAvailableForCopy() const {
288 NOTIMPLEMENTED();
289 return false;
290 }
291
292 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) { 251 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) {
293 platform_view_->UpdateCursor(cursor); 252 platform_view_->UpdateCursor(cursor);
294 } 253 }
295 254
296 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) { 255 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) {
297 platform_view_->SetIsLoading(is_loading); 256 platform_view_->SetIsLoading(is_loading);
298 } 257 }
299 258
300 void RenderWidgetHostViewGuest::TextInputTypeChanged( 259 void RenderWidgetHostViewGuest::TextInputTypeChanged(
301 ui::TextInputType type, 260 ui::TextInputType type,
(...skipping 27 matching lines...) Expand all
329 size_t offset, 288 size_t offset,
330 const gfx::Range& range) { 289 const gfx::Range& range) {
331 platform_view_->SelectionChanged(text, offset, range); 290 platform_view_->SelectionChanged(text, offset, range);
332 } 291 }
333 292
334 void RenderWidgetHostViewGuest::SelectionBoundsChanged( 293 void RenderWidgetHostViewGuest::SelectionBoundsChanged(
335 const ViewHostMsg_SelectionBounds_Params& params) { 294 const ViewHostMsg_SelectionBounds_Params& params) {
336 platform_view_->SelectionBoundsChanged(params); 295 platform_view_->SelectionBoundsChanged(params);
337 } 296 }
338 297
339 void RenderWidgetHostViewGuest::ScrollOffsetChanged() {
340 }
341
342 BackingStore* RenderWidgetHostViewGuest::AllocBackingStore(
343 const gfx::Size& size) {
344 NOTREACHED();
345 return NULL;
346 }
347
348 void RenderWidgetHostViewGuest::CopyFromCompositingSurface(
349 const gfx::Rect& src_subrect,
350 const gfx::Size& /* dst_size */,
351 const base::Callback<void(bool, const SkBitmap&)>& callback) {
352 callback.Run(false, SkBitmap());
353 }
354
355 void RenderWidgetHostViewGuest::CopyFromCompositingSurfaceToVideoFrame(
356 const gfx::Rect& src_subrect,
357 const scoped_refptr<media::VideoFrame>& target,
358 const base::Callback<void(bool)>& callback) {
359 NOTIMPLEMENTED();
360 callback.Run(false);
361 }
362
363 bool RenderWidgetHostViewGuest::CanCopyToVideoFrame() const {
364 return false;
365 }
366
367 void RenderWidgetHostViewGuest::AcceleratedSurfaceSuspend() {
368 NOTREACHED();
369 }
370
371 void RenderWidgetHostViewGuest::AcceleratedSurfaceRelease() {
372 }
373
374 bool RenderWidgetHostViewGuest::HasAcceleratedSurface(
375 const gfx::Size& desired_size) {
376 return false;
377 }
378
379 void RenderWidgetHostViewGuest::SetBackground(const SkBitmap& background) { 298 void RenderWidgetHostViewGuest::SetBackground(const SkBitmap& background) {
380 platform_view_->SetBackground(background); 299 platform_view_->SetBackground(background);
381 } 300 }
382 301
383 #if defined(OS_WIN) && !defined(USE_AURA)
384 void RenderWidgetHostViewGuest::SetClickthroughRegion(SkRegion* region) {
385 }
386 #endif
387
388 void RenderWidgetHostViewGuest::SetHasHorizontalScrollbar( 302 void RenderWidgetHostViewGuest::SetHasHorizontalScrollbar(
389 bool has_horizontal_scrollbar) { 303 bool has_horizontal_scrollbar) {
390 platform_view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar); 304 platform_view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar);
391 } 305 }
392 306
393 void RenderWidgetHostViewGuest::SetScrollOffsetPinning( 307 void RenderWidgetHostViewGuest::SetScrollOffsetPinning(
394 bool is_pinned_to_left, bool is_pinned_to_right) { 308 bool is_pinned_to_left, bool is_pinned_to_right) {
395 platform_view_->SetScrollOffsetPinning( 309 platform_view_->SetScrollOffsetPinning(
396 is_pinned_to_left, is_pinned_to_right); 310 is_pinned_to_left, is_pinned_to_right);
397 } 311 }
398 312
399 void RenderWidgetHostViewGuest::OnAcceleratedCompositingStateChange() {
400 }
401
402 bool RenderWidgetHostViewGuest::LockMouse() { 313 bool RenderWidgetHostViewGuest::LockMouse() {
403 return platform_view_->LockMouse(); 314 return platform_view_->LockMouse();
404 } 315 }
405 316
406 void RenderWidgetHostViewGuest::UnlockMouse() { 317 void RenderWidgetHostViewGuest::UnlockMouse() {
407 return platform_view_->UnlockMouse(); 318 return platform_view_->UnlockMouse();
408 } 319 }
409 320
410 void RenderWidgetHostViewGuest::GetScreenInfo(blink::WebScreenInfo* results) { 321 void RenderWidgetHostViewGuest::GetScreenInfo(blink::WebScreenInfo* results) {
411 RenderWidgetHostViewPort* embedder_view = 322 RenderWidgetHostViewPort* embedder_view =
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return; 500 return;
590 for (ui::GestureRecognizer::Gestures::iterator g_it = gestures->begin(); 501 for (ui::GestureRecognizer::Gestures::iterator g_it = gestures->begin();
591 g_it != gestures->end(); 502 g_it != gestures->end();
592 ++g_it) { 503 ++g_it) {
593 ForwardGestureEventToRenderer(*g_it); 504 ForwardGestureEventToRenderer(*g_it);
594 } 505 }
595 } 506 }
596 507
597 508
598 } // namespace content 509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698