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/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 paint_canvas_(NULL), | 446 paint_canvas_(NULL), |
447 synthetic_move_sent_(false), | 447 synthetic_move_sent_(false), |
448 cursor_visibility_state_in_renderer_(UNKNOWN), | 448 cursor_visibility_state_in_renderer_(UNKNOWN), |
449 #if defined(OS_WIN) | 449 #if defined(OS_WIN) |
450 legacy_render_widget_host_HWND_(NULL), | 450 legacy_render_widget_host_HWND_(NULL), |
451 legacy_window_destroyed_(false), | 451 legacy_window_destroyed_(false), |
452 #endif | 452 #endif |
453 has_snapped_to_boundary_(false), | 453 has_snapped_to_boundary_(false), |
454 touch_editing_client_(NULL), | 454 touch_editing_client_(NULL), |
455 is_guest_view_hack_(is_guest_view_hack), | 455 is_guest_view_hack_(is_guest_view_hack), |
| 456 begin_frame_observer_proxy_(new BeginFrameObserverProxy(this)), |
456 weak_ptr_factory_(this) { | 457 weak_ptr_factory_(this) { |
457 if (!is_guest_view_hack_) | 458 if (!is_guest_view_hack_) |
458 host_->SetView(this); | 459 host_->SetView(this); |
459 | 460 |
460 window_observer_.reset(new WindowObserver(this)); | 461 window_observer_.reset(new WindowObserver(this)); |
461 aura::client::SetTooltipText(window_, &tooltip_); | 462 aura::client::SetTooltipText(window_, &tooltip_); |
462 aura::client::SetActivationDelegate(window_, this); | 463 aura::client::SetActivationDelegate(window_, this); |
463 aura::client::SetActivationChangeObserver(window_, this); | 464 aura::client::SetActivationChangeObserver(window_, this); |
464 aura::client::SetFocusChangeObserver(window_, this); | 465 aura::client::SetFocusChangeObserver(window_, this); |
465 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 466 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
466 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 467 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
467 | 468 |
468 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 469 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
469 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 470 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
470 SetOverscrollControllerEnabled(overscroll_enabled); | 471 SetOverscrollControllerEnabled(overscroll_enabled); |
471 } | 472 } |
472 | 473 |
473 //////////////////////////////////////////////////////////////////////////////// | 474 //////////////////////////////////////////////////////////////////////////////// |
474 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 475 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
475 | 476 |
476 bool RenderWidgetHostViewAura::OnMessageReceived( | 477 bool RenderWidgetHostViewAura::OnMessageReceived( |
477 const IPC::Message& message) { | 478 const IPC::Message& message) { |
478 bool handled = true; | 479 bool handled = true; |
479 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 480 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
480 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC | 481 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC |
481 // messages for TextInput<State|Type>Changed. Corresponding code in | 482 // messages for TextInput<State|Type>Changed. Corresponding code in |
482 // RenderWidgetHostViewAndroid should also be moved at the same time. | 483 // RenderWidgetHostViewAndroid should also be moved at the same time. |
483 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 484 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
484 OnTextInputStateChanged) | 485 OnTextInputStateChanged) |
| 486 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, |
| 487 OnSetNeedsBeginFrames) |
485 IPC_MESSAGE_UNHANDLED(handled = false) | 488 IPC_MESSAGE_UNHANDLED(handled = false) |
486 IPC_END_MESSAGE_MAP() | 489 IPC_END_MESSAGE_MAP() |
487 return handled; | 490 return handled; |
488 } | 491 } |
489 | 492 |
490 void RenderWidgetHostViewAura::InitAsChild( | 493 void RenderWidgetHostViewAura::InitAsChild( |
491 gfx::NativeView parent_view) { | 494 gfx::NativeView parent_view) { |
492 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 495 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
493 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 496 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
494 window_->SetName("RenderWidgetHostViewAura"); | 497 window_->SetName("RenderWidgetHostViewAura"); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 #endif | 707 #endif |
705 | 708 |
706 NOTIMPLEMENTED(); | 709 NOTIMPLEMENTED(); |
707 return static_cast<gfx::NativeViewAccessible>(NULL); | 710 return static_cast<gfx::NativeViewAccessible>(NULL); |
708 } | 711 } |
709 | 712 |
710 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 713 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
711 return this; | 714 return this; |
712 } | 715 } |
713 | 716 |
| 717 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
| 718 begin_frame_observer_proxy_->SetNeedsBeginFrames(needs_begin_frames); |
| 719 } |
| 720 |
| 721 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { |
| 722 delegated_frame_host_->UpdateVSyncParameters(args.frame_time, args.interval); |
| 723 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 724 } |
| 725 |
714 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 726 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
715 #if defined(OS_WIN) | 727 #if defined(OS_WIN) |
716 if (CanFocus()) { | 728 if (CanFocus()) { |
717 aura::WindowTreeHost* host = window_->GetHost(); | 729 aura::WindowTreeHost* host = window_->GetHost(); |
718 if (host) | 730 if (host) |
719 ::SetFocus(host->GetAcceleratedWidget()); | 731 ::SetFocus(host->GetAcceleratedWidget()); |
720 } | 732 } |
721 #endif | 733 #endif |
722 } | 734 } |
723 | 735 |
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 | 2583 |
2572 #if defined(OS_WIN) | 2584 #if defined(OS_WIN) |
2573 // The parent may have changed here. Ensure that the legacy window is | 2585 // The parent may have changed here. Ensure that the legacy window is |
2574 // reparented accordingly. | 2586 // reparented accordingly. |
2575 if (legacy_render_widget_host_HWND_) | 2587 if (legacy_render_widget_host_HWND_) |
2576 legacy_render_widget_host_HWND_->UpdateParent( | 2588 legacy_render_widget_host_HWND_->UpdateParent( |
2577 reinterpret_cast<HWND>(GetNativeViewId())); | 2589 reinterpret_cast<HWND>(GetNativeViewId())); |
2578 #endif | 2590 #endif |
2579 | 2591 |
2580 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2592 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
| 2593 begin_frame_observer_proxy_->SetCompositor(window_->GetHost()->compositor()); |
2581 } | 2594 } |
2582 | 2595 |
2583 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2596 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2584 aura::client::CursorClient* cursor_client = | 2597 aura::client::CursorClient* cursor_client = |
2585 aura::client::GetCursorClient(window_->GetRootWindow()); | 2598 aura::client::GetCursorClient(window_->GetRootWindow()); |
2586 if (cursor_client) | 2599 if (cursor_client) |
2587 cursor_client->RemoveObserver(this); | 2600 cursor_client->RemoveObserver(this); |
2588 | 2601 |
2589 DetachFromInputMethod(); | 2602 DetachFromInputMethod(); |
2590 | 2603 |
2591 window_->GetHost()->RemoveObserver(this); | 2604 window_->GetHost()->RemoveObserver(this); |
2592 delegated_frame_host_->ResetCompositor(); | 2605 delegated_frame_host_->ResetCompositor(); |
| 2606 begin_frame_observer_proxy_->ResetCompositor(); |
2593 | 2607 |
2594 #if defined(OS_WIN) | 2608 #if defined(OS_WIN) |
2595 // Update the legacy window's parent temporarily to the desktop window. It | 2609 // Update the legacy window's parent temporarily to the desktop window. It |
2596 // will eventually get reparented to the right root. | 2610 // will eventually get reparented to the right root. |
2597 if (legacy_render_widget_host_HWND_) | 2611 if (legacy_render_widget_host_HWND_) |
2598 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2612 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
2599 #endif | 2613 #endif |
2600 } | 2614 } |
2601 | 2615 |
2602 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2616 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2713 | 2727 |
2714 //////////////////////////////////////////////////////////////////////////////// | 2728 //////////////////////////////////////////////////////////////////////////////// |
2715 // RenderWidgetHostViewBase, public: | 2729 // RenderWidgetHostViewBase, public: |
2716 | 2730 |
2717 // static | 2731 // static |
2718 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2732 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2719 GetScreenInfoForWindow(results, NULL); | 2733 GetScreenInfoForWindow(results, NULL); |
2720 } | 2734 } |
2721 | 2735 |
2722 } // namespace content | 2736 } // namespace content |
OLD | NEW |