OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
24 #include "base/trace_event/trace_event_synthetic_delay.h" | 24 #include "base/trace_event/trace_event_synthetic_delay.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "cc/output/compositor_frame_sink.h" | 26 #include "cc/output/compositor_frame_sink.h" |
27 #include "cc/output/copy_output_request.h" | 27 #include "cc/output/copy_output_request.h" |
28 #include "cc/scheduler/begin_frame_source.h" | 28 #include "cc/scheduler/begin_frame_source.h" |
29 #include "content/common/content_switches_internal.h" | 29 #include "content/common/content_switches_internal.h" |
30 #include "content/common/input/synthetic_gesture_packet.h" | 30 #include "content/common/input/synthetic_gesture_packet.h" |
31 #include "content/common/input_messages.h" | 31 #include "content/common/input_messages.h" |
| 32 #include "content/common/render_message_filter.mojom.h" |
32 #include "content/common/swapped_out_messages.h" | 33 #include "content/common/swapped_out_messages.h" |
33 #include "content/common/text_input_state.h" | 34 #include "content/common/text_input_state.h" |
34 #include "content/common/view_messages.h" | 35 #include "content/common/view_messages.h" |
35 #include "content/public/common/content_features.h" | 36 #include "content/public/common/content_features.h" |
36 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
37 #include "content/public/common/context_menu_params.h" | 38 #include "content/public/common/context_menu_params.h" |
38 #include "content/renderer/cursor_utils.h" | 39 #include "content/renderer/cursor_utils.h" |
39 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" | 40 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" |
40 #include "content/renderer/external_popup_menu.h" | 41 #include "content/renderer/external_popup_menu.h" |
41 #include "content/renderer/gpu/frame_swap_message_queue.h" | 42 #include "content/renderer/gpu/frame_swap_message_queue.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone, | 318 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone, |
318 screen_info, false, hidden, false) | 319 screen_info, false, hidden, false) |
319 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone, | 320 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone, |
320 screen_info, false, hidden, false)); | 321 screen_info, false, hidden, false)); |
321 widget->SetRoutingID(routing_id); | 322 widget->SetRoutingID(routing_id); |
322 widget->for_oopif_ = true; | 323 widget->for_oopif_ = true; |
323 // DoInit increments the reference count on |widget|, keeping it alive after | 324 // DoInit increments the reference count on |widget|, keeping it alive after |
324 // this function returns. | 325 // this function returns. |
325 if (widget->DoInit(MSG_ROUTING_NONE, | 326 if (widget->DoInit(MSG_ROUTING_NONE, |
326 RenderWidget::CreateWebFrameWidget(widget.get(), frame), | 327 RenderWidget::CreateWebFrameWidget(widget.get(), frame), |
327 nullptr)) { | 328 CreateWidgetCallback())) { |
328 if (g_render_widget_initialized) | 329 if (g_render_widget_initialized) |
329 g_render_widget_initialized(widget.get()); | 330 g_render_widget_initialized(widget.get()); |
330 return widget.get(); | 331 return widget.get(); |
331 } | 332 } |
332 return nullptr; | 333 return nullptr; |
333 } | 334 } |
334 | 335 |
335 // static | 336 // static |
336 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget( | 337 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget( |
337 RenderWidget* render_widget, | 338 RenderWidget* render_widget, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 375 |
375 // If we are swapping out, we will call ReleaseProcess, allowing the process | 376 // If we are swapping out, we will call ReleaseProcess, allowing the process |
376 // to exit if all of its RenderViews are swapped out. We wait until the | 377 // to exit if all of its RenderViews are swapped out. We wait until the |
377 // WasSwappedOut call to do this, to allow the unload handler to finish. | 378 // WasSwappedOut call to do this, to allow the unload handler to finish. |
378 // If we are swapping in, we call AddRefProcess to prevent the process from | 379 // If we are swapping in, we call AddRefProcess to prevent the process from |
379 // exiting. | 380 // exiting. |
380 if (!is_swapped_out_) | 381 if (!is_swapped_out_) |
381 RenderProcess::current()->AddRefProcess(); | 382 RenderProcess::current()->AddRefProcess(); |
382 } | 383 } |
383 | 384 |
| 385 bool RenderWidget::CreateWidget(int32_t opener_id, |
| 386 blink::WebPopupType popup_type, |
| 387 int32_t* routing_id) { |
| 388 RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
| 389 opener_id, popup_type, routing_id); |
| 390 return true; |
| 391 } |
| 392 |
384 bool RenderWidget::Init(int32_t opener_id) { | 393 bool RenderWidget::Init(int32_t opener_id) { |
385 bool success = DoInit( | 394 bool success = DoInit(opener_id, RenderWidget::CreateWebWidget(this), |
386 opener_id, RenderWidget::CreateWebWidget(this), | 395 base::Bind(&RenderWidget::CreateWidget, base::Unretained(this), |
387 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); | 396 opener_id, popup_type_, &routing_id_)); |
388 if (success) { | 397 if (success) { |
389 SetRoutingID(routing_id_); | 398 SetRoutingID(routing_id_); |
390 return true; | 399 return true; |
391 } | 400 } |
392 return false; | 401 return false; |
393 } | 402 } |
394 | 403 |
395 bool RenderWidget::DoInit(int32_t opener_id, | 404 bool RenderWidget::DoInit(int32_t opener_id, |
396 WebWidget* web_widget, | 405 WebWidget* web_widget, |
397 IPC::SyncMessage* create_widget_message) { | 406 CreateWidgetCallback create_widget_callback) { |
398 DCHECK(!webwidget_internal_); | 407 DCHECK(!webwidget_internal_); |
399 | 408 |
400 if (opener_id != MSG_ROUTING_NONE) | 409 if (opener_id != MSG_ROUTING_NONE) |
401 opener_id_ = opener_id; | 410 opener_id_ = opener_id; |
402 | 411 |
403 webwidget_internal_ = web_widget; | 412 webwidget_internal_ = web_widget; |
404 webwidget_mouse_lock_target_.reset( | 413 webwidget_mouse_lock_target_.reset( |
405 new WebWidgetLockTarget(webwidget_internal_)); | 414 new WebWidgetLockTarget(webwidget_internal_)); |
406 mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this)); | 415 mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this)); |
407 | 416 |
408 bool result = true; | 417 bool result = true; |
409 if (create_widget_message) | 418 if (!create_widget_callback.is_null()) |
410 result = RenderThread::Get()->Send(create_widget_message); | 419 result = std::move(create_widget_callback).Run(); |
411 | 420 |
412 if (result) { | 421 if (result) { |
413 RenderThread::Get()->AddRoute(routing_id_, this); | 422 RenderThread::Get()->AddRoute(routing_id_, this); |
414 // Take a reference on behalf of the RenderThread. This will be balanced | 423 // Take a reference on behalf of the RenderThread. This will be balanced |
415 // when we receive ViewMsg_Close. | 424 // when we receive ViewMsg_Close. |
416 AddRef(); | 425 AddRef(); |
417 if (RenderThreadImpl::current()) { | 426 if (RenderThreadImpl::current()) { |
418 RenderThreadImpl::current()->WidgetCreated(); | 427 RenderThreadImpl::current()->WidgetCreated(); |
419 if (is_hidden_) | 428 if (is_hidden_) |
420 RenderThreadImpl::current()->WidgetHidden(); | 429 RenderThreadImpl::current()->WidgetHidden(); |
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 bool RenderWidget::isPointerLocked() { | 2097 bool RenderWidget::isPointerLocked() { |
2089 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2098 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2090 webwidget_mouse_lock_target_.get()); | 2099 webwidget_mouse_lock_target_.get()); |
2091 } | 2100 } |
2092 | 2101 |
2093 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2102 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2094 return webwidget_internal_; | 2103 return webwidget_internal_; |
2095 } | 2104 } |
2096 | 2105 |
2097 } // namespace content | 2106 } // namespace content |
OLD | NEW |