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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2238573002: Add WebWidgetTestProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing files Created 4 years, 4 months 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
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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return content::RenderWidgetMusConnection::GetOrCreate( 205 return content::RenderWidgetMusConnection::GetOrCreate(
206 widget->routing_id()); 206 widget->routing_id());
207 } 207 }
208 #endif 208 #endif
209 // If we don't have a connection to the Mojo shell, then we want to route IPCs 209 // If we don't have a connection to the Mojo shell, then we want to route IPCs
210 // back to the browser process rather than Mus so we use the |widget| as the 210 // back to the browser process rather than Mus so we use the |widget| as the
211 // RenderWidgetInputHandlerDelegate. 211 // RenderWidgetInputHandlerDelegate.
212 return widget; 212 return widget;
213 } 213 }
214 214
215 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget =
216 nullptr;
217
218 content::RenderWidget::RenderWidgetInitializedCallback
219 g_render_widget_initialized = nullptr;
220
215 } // namespace 221 } // namespace
216 222
217 namespace content { 223 namespace content {
218 224
219 // RenderWidget --------------------------------------------------------------- 225 // RenderWidget ---------------------------------------------------------------
220 226
221 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 227 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
222 blink::WebPopupType popup_type, 228 blink::WebPopupType popup_type,
223 const blink::WebScreenInfo& screen_info, 229 const blink::WebScreenInfo& screen_info,
224 bool swapped_out, 230 bool swapped_out,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 286
281 RenderWidget::~RenderWidget() { 287 RenderWidget::~RenderWidget() {
282 DCHECK(!webwidget_) << "Leaking our WebWidget!"; 288 DCHECK(!webwidget_) << "Leaking our WebWidget!";
283 289
284 // If we are swapped out, we have released already. 290 // If we are swapped out, we have released already.
285 if (!is_swapped_out_ && RenderProcess::current()) 291 if (!is_swapped_out_ && RenderProcess::current())
286 RenderProcess::current()->ReleaseProcess(); 292 RenderProcess::current()->ReleaseProcess();
287 } 293 }
288 294
289 // static 295 // static
296 void RenderWidget::InstallCreateHook(
297 CreateRenderWidgetFunction create_render_widget,
298 RenderWidgetInitializedCallback render_widget_initialized) {
299 CHECK(!g_create_render_widget && !g_render_widget_initialized);
300 g_create_render_widget = create_render_widget;
301 g_render_widget_initialized = render_widget_initialized;
302 }
303
304 // static
290 RenderWidget* RenderWidget::Create(int32_t opener_id, 305 RenderWidget* RenderWidget::Create(int32_t opener_id,
291 CompositorDependencies* compositor_deps, 306 CompositorDependencies* compositor_deps,
292 blink::WebPopupType popup_type, 307 blink::WebPopupType popup_type,
293 const blink::WebScreenInfo& screen_info) { 308 const blink::WebScreenInfo& screen_info) {
294 DCHECK(opener_id != MSG_ROUTING_NONE); 309 DCHECK(opener_id != MSG_ROUTING_NONE);
295 scoped_refptr<RenderWidget> widget(new RenderWidget( 310 scoped_refptr<RenderWidget> widget(new RenderWidget(
296 compositor_deps, popup_type, screen_info, false, false, false)); 311 compositor_deps, popup_type, screen_info, false, false, false));
297 if (widget->Init(opener_id)) { // adds reference on success. 312 if (widget->Init(opener_id)) { // adds reference on success.
298 return widget.get(); 313 return widget.get();
299 } 314 }
(...skipping 11 matching lines...) Expand all
311 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the 326 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the
312 // same routing ID for both the view routing ID and the main frame widget 327 // same routing ID for both the view routing ID and the main frame widget
313 // routing ID. https://crbug.com/545684 328 // routing ID. https://crbug.com/545684
314 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); 329 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id);
315 if (view) { 330 if (view) {
316 view->AttachWebFrameWidget( 331 view->AttachWebFrameWidget(
317 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); 332 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame));
318 return view->GetWidget(); 333 return view->GetWidget();
319 } 334 }
320 scoped_refptr<RenderWidget> widget( 335 scoped_refptr<RenderWidget> widget(
321 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info, 336 g_create_render_widget
322 false, hidden, false)); 337 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone,
338 screen_info, false, hidden, false)
339 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone,
340 screen_info, false, hidden, false));
323 widget->SetRoutingID(routing_id); 341 widget->SetRoutingID(routing_id);
324 widget->for_oopif_ = true; 342 widget->for_oopif_ = true;
325 // DoInit increments the reference count on |widget|, keeping it alive after 343 // DoInit increments the reference count on |widget|, keeping it alive after
326 // this function returns. 344 // this function returns.
327 if (widget->DoInit(MSG_ROUTING_NONE, 345 if (widget->DoInit(MSG_ROUTING_NONE,
328 RenderWidget::CreateWebFrameWidget(widget.get(), frame), 346 RenderWidget::CreateWebFrameWidget(widget.get(), frame),
329 nullptr)) { 347 nullptr)) {
348 if (g_render_widget_initialized)
349 g_render_widget_initialized(widget.get());
330 return widget.get(); 350 return widget.get();
331 } 351 }
332 return nullptr; 352 return nullptr;
333 } 353 }
334 354
335 // static 355 // static
336 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget( 356 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget(
337 RenderWidget* render_widget, 357 RenderWidget* render_widget,
338 blink::WebLocalFrame* frame) { 358 blink::WebLocalFrame* frame) {
339 if (!frame->parent()) { 359 if (!frame->parent()) {
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 void RenderWidget::requestPointerUnlock() { 2085 void RenderWidget::requestPointerUnlock() {
2066 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2086 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2067 } 2087 }
2068 2088
2069 bool RenderWidget::isPointerLocked() { 2089 bool RenderWidget::isPointerLocked() {
2070 return mouse_lock_dispatcher_->IsMouseLockedTo( 2090 return mouse_lock_dispatcher_->IsMouseLockedTo(
2071 webwidget_mouse_lock_target_.get()); 2091 webwidget_mouse_lock_target_.get());
2072 } 2092 }
2073 2093
2074 } // namespace content 2094 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/shell/renderer/layout_test/layout_test_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698