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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 387353004: Create only a single LegacyRenderWidgetHostHWND per WebContentsViewAura. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_ax_3
Patch Set: Rebase Created 6 years, 2 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/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "ui/base/dragdrop/os_exchange_data.h" 60 #include "ui/base/dragdrop/os_exchange_data.h"
61 #include "ui/base/hit_test.h" 61 #include "ui/base/hit_test.h"
62 #include "ui/compositor/layer.h" 62 #include "ui/compositor/layer.h"
63 #include "ui/compositor/scoped_layer_animation_settings.h" 63 #include "ui/compositor/scoped_layer_animation_settings.h"
64 #include "ui/events/event.h" 64 #include "ui/events/event.h"
65 #include "ui/events/event_utils.h" 65 #include "ui/events/event_utils.h"
66 #include "ui/gfx/canvas.h" 66 #include "ui/gfx/canvas.h"
67 #include "ui/gfx/image/image.h" 67 #include "ui/gfx/image/image.h"
68 #include "ui/gfx/image/image_png_rep.h" 68 #include "ui/gfx/image/image_png_rep.h"
69 #include "ui/gfx/image/image_skia.h" 69 #include "ui/gfx/image/image_skia.h"
70 #include "ui/gfx/native_widget_types.h"
70 #include "ui/gfx/screen.h" 71 #include "ui/gfx/screen.h"
71 #include "ui/wm/public/drag_drop_client.h" 72 #include "ui/wm/public/drag_drop_client.h"
72 #include "ui/wm/public/drag_drop_delegate.h" 73 #include "ui/wm/public/drag_drop_delegate.h"
73 74
75 #if defined(OS_WIN)
76 #include "content/browser/accessibility/browser_accessibility_manager.h"
77 #include "content/browser/accessibility/browser_accessibility_win.h"
78 #include "ui/base/win/hidden_window.h"
79 #endif
80
74 namespace content { 81 namespace content {
75 WebContentsView* CreateWebContentsView( 82 WebContentsView* CreateWebContentsView(
76 WebContentsImpl* web_contents, 83 WebContentsImpl* web_contents,
77 WebContentsViewDelegate* delegate, 84 WebContentsViewDelegate* delegate,
78 RenderViewHostDelegateView** render_view_host_delegate_view) { 85 RenderViewHostDelegateView** render_view_host_delegate_view) {
79 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); 86 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate);
80 *render_view_host_delegate_view = rv; 87 *render_view_host_delegate_view = rv;
81 return rv; 88 return rv;
82 } 89 }
83 90
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 host_window_ = NULL; 642 host_window_ = NULL;
636 } 643 }
637 } 644 }
638 645
639 virtual void OnWindowAddedToRootWindow(aura::Window* window) override { 646 virtual void OnWindowAddedToRootWindow(aura::Window* window) override {
640 if (window == view_->window_) { 647 if (window == view_->window_) {
641 window->GetHost()->AddObserver(this); 648 window->GetHost()->AddObserver(this);
642 #if defined(OS_WIN) 649 #if defined(OS_WIN)
643 if (!window->GetRootWindow()->HasObserver(this)) 650 if (!window->GetRootWindow()->HasObserver(this))
644 window->GetRootWindow()->AddObserver(this); 651 window->GetRootWindow()->AddObserver(this);
652 if (view_->legacy_hwnd_) {
653 view_->legacy_hwnd_->UpdateParent(
654 window->GetHost()->GetAcceleratedWidget());
655 }
645 #endif 656 #endif
646 } 657 }
647 } 658 }
648 659
649 virtual void OnWindowRemovingFromRootWindow(aura::Window* window, 660 virtual void OnWindowRemovingFromRootWindow(aura::Window* window,
650 aura::Window* new_root) override { 661 aura::Window* new_root) override {
651 if (window == view_->window_) { 662 if (window == view_->window_) {
652 window->GetHost()->RemoveObserver(this); 663 window->GetHost()->RemoveObserver(this);
653 #if defined(OS_WIN) 664 #if defined(OS_WIN)
654 window->GetRootWindow()->RemoveObserver(this); 665 window->GetRootWindow()->RemoveObserver(this);
655 666
656 const aura::Window::Windows& root_children = 667 const aura::Window::Windows& root_children =
657 window->GetRootWindow()->children(); 668 window->GetRootWindow()->children();
658 for (size_t i = 0; i < root_children.size(); ++i) { 669 for (size_t i = 0; i < root_children.size(); ++i) {
659 if (root_children[i] != view_->window_ && 670 if (root_children[i] != view_->window_ &&
660 root_children[i] != host_window_) { 671 root_children[i] != host_window_) {
661 root_children[i]->RemoveObserver(this); 672 root_children[i]->RemoveObserver(this);
662 } 673 }
663 } 674 }
675
676 if (view_->legacy_hwnd_)
677 view_->legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
664 #endif 678 #endif
665 } 679 }
666 } 680 }
667 681
668 // Overridden WindowTreeHostObserver: 682 // Overridden WindowTreeHostObserver:
669 virtual void OnHostMoved(const aura::WindowTreeHost* host, 683 virtual void OnHostMoved(const aura::WindowTreeHost* host,
670 const gfx::Point& new_origin) override { 684 const gfx::Point& new_origin) override {
671 TRACE_EVENT1("ui", 685 TRACE_EVENT1("ui",
672 "WebContentsViewAura::WindowObserver::OnHostMoved", 686 "WebContentsViewAura::WindowObserver::OnHostMoved",
673 "new_origin", new_origin.ToString()); 687 "new_origin", new_origin.ToString());
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 1021
1008 void WebContentsViewAura::GetContainerBounds(gfx::Rect *out) const { 1022 void WebContentsViewAura::GetContainerBounds(gfx::Rect *out) const {
1009 *out = window_->GetBoundsInScreen(); 1023 *out = window_->GetBoundsInScreen();
1010 } 1024 }
1011 1025
1012 void WebContentsViewAura::SizeContents(const gfx::Size& size) { 1026 void WebContentsViewAura::SizeContents(const gfx::Size& size) {
1013 gfx::Rect bounds = window_->bounds(); 1027 gfx::Rect bounds = window_->bounds();
1014 if (bounds.size() != size) { 1028 if (bounds.size() != size) {
1015 bounds.set_size(size); 1029 bounds.set_size(size);
1016 window_->SetBounds(bounds); 1030 window_->SetBounds(bounds);
1031 #if defined(OS_WIN)
1032 if (legacy_hwnd_)
1033 legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
1034 #endif
1017 } else { 1035 } else {
1018 // Our size matches what we want but the renderers size may not match. 1036 // Our size matches what we want but the renderers size may not match.
1019 // Pretend we were resized so that the renderers size is updated too. 1037 // Pretend we were resized so that the renderers size is updated too.
1020 SizeChangedCommon(size); 1038 SizeChangedCommon(size);
1021 } 1039 }
1022 } 1040 }
1023 1041
1024 void WebContentsViewAura::Focus() { 1042 void WebContentsViewAura::Focus() {
1025 if (web_contents_->GetInterstitialPage()) { 1043 if (web_contents_->GetInterstitialPage()) {
1026 web_contents_->GetInterstitialPage()->Focus(); 1044 web_contents_->GetInterstitialPage()->Focus();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 // 1) guests do not support NPAPI plugins. 1118 // 1) guests do not support NPAPI plugins.
1101 // 2) guests' window bounds are supposed to come from its embedder. 1119 // 2) guests' window bounds are supposed to come from its embedder.
1102 if (!BrowserPluginGuest::IsGuest(web_contents_)) 1120 if (!BrowserPluginGuest::IsGuest(web_contents_))
1103 window_observer_.reset(new WindowObserver(this)); 1121 window_observer_.reset(new WindowObserver(this));
1104 1122
1105 // delegate_->GetDragDestDelegate() creates a new delegate on every call. 1123 // delegate_->GetDragDestDelegate() creates a new delegate on every call.
1106 // Hence, we save a reference to it locally. Similar model is used on other 1124 // Hence, we save a reference to it locally. Similar model is used on other
1107 // platforms as well. 1125 // platforms as well.
1108 if (delegate_) 1126 if (delegate_)
1109 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); 1127 drag_dest_delegate_ = delegate_->GetDragDestDelegate();
1128
1129 #if defined(OS_WIN)
1130 HWND parent_hwnd;
1131 if (context && context->GetHost())
1132 parent_hwnd = context->GetHost()->GetAcceleratedWidget();
1133 else
1134 parent_hwnd = ::GetDesktopWindow();
ananta 2014/10/08 18:30:13 I am still not convinced about creating the legacy
dmazzoni 2014/10/10 21:09:50 Done.
1135 legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this));
1136 #endif
1110 } 1137 }
1111 1138
1112 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( 1139 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
1113 RenderWidgetHost* render_widget_host) { 1140 RenderWidgetHost* render_widget_host) {
1114 if (render_widget_host->GetView()) { 1141 if (render_widget_host->GetView()) {
1115 // During testing, the view will already be set up in most cases to the 1142 // During testing, the view will already be set up in most cases to the
1116 // test view, so we don't want to clobber it with a real one. To verify that 1143 // test view, so we don't want to clobber it with a real one. To verify that
1117 // this actually is happening (and somebody isn't accidentally creating the 1144 // this actually is happening (and somebody isn't accidentally creating the
1118 // view twice), we check for the RVH Factory, which will be set when we're 1145 // view twice), we check for the RVH Factory, which will be set when we're
1119 // making special ones (which go along with the special views). 1146 // making special ones (which go along with the special views).
(...skipping 20 matching lines...) Expand all
1140 // We listen to drag drop events in the newly created view's window. 1167 // We listen to drag drop events in the newly created view's window.
1141 aura::client::SetDragDropDelegate(view->GetNativeView(), this); 1168 aura::client::SetDragDropDelegate(view->GetNativeView(), this);
1142 1169
1143 if (view->overscroll_controller() && 1170 if (view->overscroll_controller() &&
1144 (!web_contents_->GetDelegate() || 1171 (!web_contents_->GetDelegate() ||
1145 web_contents_->GetDelegate()->CanOverscrollContent())) { 1172 web_contents_->GetDelegate()->CanOverscrollContent())) {
1146 InstallOverscrollControllerDelegate(view); 1173 InstallOverscrollControllerDelegate(view);
1147 } 1174 }
1148 1175
1149 AttachTouchEditableToRenderView(); 1176 AttachTouchEditableToRenderView();
1177
1178 #if defined(OS_WIN)
1179 view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
1180 #endif
1181
1150 return view; 1182 return view;
1151 } 1183 }
1152 1184
1153 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( 1185 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
1154 RenderWidgetHost* render_widget_host) { 1186 RenderWidgetHost* render_widget_host) {
1155 return new RenderWidgetHostViewAura(render_widget_host); 1187 RenderWidgetHostViewAura* view =
1188 new RenderWidgetHostViewAura(render_widget_host);
1189 #if defined(OS_WIN)
1190 view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
1191 #endif
1192 return view;
1156 } 1193 }
1157 1194
1158 void WebContentsViewAura::SetPageTitle(const base::string16& title) { 1195 void WebContentsViewAura::SetPageTitle(const base::string16& title) {
1159 window_->SetTitle(title); 1196 window_->SetTitle(title);
1160 } 1197 }
1161 1198
1162 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { 1199 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) {
1163 } 1200 }
1164 1201
1165 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { 1202 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 } 1662 }
1626 return; 1663 return;
1627 } 1664 }
1628 if (visible) { 1665 if (visible) {
1629 if (!web_contents_->should_normally_be_visible()) 1666 if (!web_contents_->should_normally_be_visible())
1630 web_contents_->WasShown(); 1667 web_contents_->WasShown();
1631 } else { 1668 } else {
1632 if (web_contents_->should_normally_be_visible()) 1669 if (web_contents_->should_normally_be_visible())
1633 web_contents_->WasHidden(); 1670 web_contents_->WasHidden();
1634 } 1671 }
1672
1673 #if defined(OS_WIN)
1674 if (!legacy_hwnd_)
1675 return;
1676
1677 if (visible && GetNativeView() && GetNativeView()->GetHost()) {
1678 legacy_hwnd_->UpdateParent(
1679 GetNativeView()->GetHost()->GetAcceleratedWidget());
1680 legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
1681 legacy_hwnd_->Show();
1682 } else {
1683 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global
1684 // hidden window on the same lines as Windowed plugin windows.
1685 legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
1686 legacy_hwnd_->Hide();
1687 }
1688 #endif
1635 } 1689 }
1636 1690
1691 #if defined(OS_WIN)
1692 gfx::NativeViewAccessible
1693 WebContentsViewAura::GetNativeViewAccessible() {
1694 BrowserAccessibilityManager* manager =
1695 web_contents_->GetRootBrowserAccessibilityManager();
1696 if (!manager)
1697 return NULL;
1698
1699 return manager->GetRoot()->ToBrowserAccessibilityWin();
1700 }
1701 #endif
1702
1637 } // namespace content 1703 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | ui/views/controls/webview/webview_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698