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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 329053004: Fix race in BrowserAccessibilityManagerWin creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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/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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 1012 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
1013 // This is not true in Aura where we have only HWND which is the main Aura 1013 // This is not true in Aura where we have only HWND which is the main Aura
1014 // window. If we return this window to plugins like Flash then it causes the 1014 // window. If we return this window to plugins like Flash then it causes the
1015 // coordinate translations done by these plugins to break. 1015 // coordinate translations done by these plugins to break.
1016 // Additonally the legacy dummy window is needed for accessibility and for 1016 // Additonally the legacy dummy window is needed for accessibility and for
1017 // scrolling to work in legacy drivers for trackpoints/trackpads, etc. 1017 // scrolling to work in legacy drivers for trackpoints/trackpads, etc.
1018 if (GetNativeViewId()) { 1018 if (GetNativeViewId()) {
1019 if (!legacy_render_widget_host_HWND_) { 1019 if (!legacy_render_widget_host_HWND_) {
1020 legacy_render_widget_host_HWND_ = LegacyRenderWidgetHostHWND::Create( 1020 legacy_render_widget_host_HWND_ = LegacyRenderWidgetHostHWND::Create(
1021 reinterpret_cast<HWND>(GetNativeViewId())); 1021 reinterpret_cast<HWND>(GetNativeViewId()));
1022 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
1023 if (manager) {
1024 legacy_render_widget_host_HWND_->set_browser_accessibility_manager(
ananta 2014/06/12 18:30:17 This will crash in Windows 8 ASH. You may want to
1025 static_cast<BrowserAccessibilityManagerWin*>(manager));
1026 }
1022 } 1027 }
1023 if (legacy_render_widget_host_HWND_) { 1028 if (legacy_render_widget_host_HWND_) {
1024 legacy_render_widget_host_HWND_->SetBounds( 1029 legacy_render_widget_host_HWND_->SetBounds(
1025 window_->GetBoundsInRootWindow()); 1030 window_->GetBoundsInRootWindow());
1026 } 1031 }
1027 } 1032 }
1028 1033
1029 if (mouse_locked_) 1034 if (mouse_locked_)
1030 UpdateMouseLockRegion(); 1035 UpdateMouseLockRegion();
1031 #endif 1036 #endif
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 if (frame->software_frame_data) { 1093 if (frame->software_frame_data) {
1089 DLOG(ERROR) << "Unable to use software frame in aura"; 1094 DLOG(ERROR) << "Unable to use software frame in aura";
1090 RecordAction( 1095 RecordAction(
1091 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); 1096 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura"));
1092 host_->GetProcess()->ReceivedBadMessage(); 1097 host_->GetProcess()->ReceivedBadMessage();
1093 return; 1098 return;
1094 } 1099 }
1095 } 1100 }
1096 1101
1097 #if defined(OS_WIN) 1102 #if defined(OS_WIN)
1098 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1103 HWND RenderWidgetHostViewAura::GetAccessibleParentHWND() const {
1099 gfx::NativeViewAccessible accessible_parent) { 1104 if (!legacy_render_widget_host_HWND_)
1100 if (GetBrowserAccessibilityManager()) { 1105 return NULL;
1101 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1106 return legacy_render_widget_host_HWND_->hwnd();
1102 ->set_parent_iaccessible(accessible_parent); 1107 }
1103 } 1108
1109 IAccessible* RenderWidgetHostViewAura::GetParentIAccessible() const {
1110 if (!legacy_render_widget_host_HWND_)
1111 return NULL;
1112 return legacy_render_widget_host_HWND_->window_accessible();
1104 } 1113 }
1105 1114
1106 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1115 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1107 const { 1116 const {
1108 if (legacy_render_widget_host_HWND_) { 1117 if (legacy_render_widget_host_HWND_) {
1109 return reinterpret_cast<gfx::NativeViewId>( 1118 return reinterpret_cast<gfx::NativeViewId>(
1110 legacy_render_widget_host_HWND_->hwnd()); 1119 legacy_render_widget_host_HWND_->hwnd());
1111 } 1120 }
1112 return NULL; 1121 return NULL;
1113 } 1122 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 ? INPUT_EVENT_ACK_STATE_CONSUMED 1258 ? INPUT_EVENT_ACK_STATE_CONSUMED
1250 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1259 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1251 } 1260 }
1252 1261
1253 void RenderWidgetHostViewAura::CreateBrowserAccessibilityManagerIfNeeded() { 1262 void RenderWidgetHostViewAura::CreateBrowserAccessibilityManagerIfNeeded() {
1254 if (GetBrowserAccessibilityManager()) 1263 if (GetBrowserAccessibilityManager())
1255 return; 1264 return;
1256 1265
1257 BrowserAccessibilityManager* manager = NULL; 1266 BrowserAccessibilityManager* manager = NULL;
1258 #if defined(OS_WIN) 1267 #if defined(OS_WIN)
1259 aura::WindowTreeHost* host = window_->GetHost(); 1268 manager = new BrowserAccessibilityManagerWin(
1260 if (!host) 1269 BrowserAccessibilityManagerWin::GetEmptyDocument(), host_);
1261 return;
1262 HWND hwnd = host->GetAcceleratedWidget();
1263
1264 // The accessible_parent may be NULL at this point. The WebContents will pass
1265 // it down to this instance (by way of the RenderViewHost and
1266 // RenderWidgetHost) when it is known. This instance will then set it on its
1267 // BrowserAccessibilityManager.
1268 gfx::NativeViewAccessible accessible_parent =
1269 host_->GetParentNativeViewAccessible();
1270
1271 if (legacy_render_widget_host_HWND_) { 1270 if (legacy_render_widget_host_HWND_) {
1272 manager = new BrowserAccessibilityManagerWin( 1271 legacy_render_widget_host_HWND_->set_browser_accessibility_manager(
1273 legacy_render_widget_host_HWND_.get(), accessible_parent, 1272 static_cast<BrowserAccessibilityManagerWin*>(manager));
1274 BrowserAccessibilityManagerWin::GetEmptyDocument(), host_);
1275 } 1273 }
1276 #else 1274 #else
1277 manager = BrowserAccessibilityManager::Create( 1275 manager = BrowserAccessibilityManager::Create(
1278 BrowserAccessibilityManager::GetEmptyDocument(), host_); 1276 BrowserAccessibilityManager::GetEmptyDocument(), host_);
1279 #endif 1277 #endif
1280 SetBrowserAccessibilityManager(manager); 1278 SetBrowserAccessibilityManager(manager);
1281 } 1279 }
1282 1280
1283 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { 1281 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() {
1284 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); 1282 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle();
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 event_filter_for_popup_exit_.reset(); 2182 event_filter_for_popup_exit_.reset();
2185 aura::client::SetTooltipText(window_, NULL); 2183 aura::client::SetTooltipText(window_, NULL);
2186 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); 2184 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this);
2187 2185
2188 // This call is usually no-op since |this| object is already removed from the 2186 // This call is usually no-op since |this| object is already removed from the
2189 // Aura root window and we don't have a way to get an input method object 2187 // Aura root window and we don't have a way to get an input method object
2190 // associated with the window, but just in case. 2188 // associated with the window, but just in case.
2191 DetachFromInputMethod(); 2189 DetachFromInputMethod();
2192 2190
2193 #if defined(OS_WIN) 2191 #if defined(OS_WIN)
2192 if (legacy_render_widget_host_HWND_.get())
2193 legacy_render_widget_host_HWND_->OnManagerDeleted();
2194 legacy_render_widget_host_HWND_.reset(NULL); 2194 legacy_render_widget_host_HWND_.reset(NULL);
2195 #endif 2195 #endif
2196 } 2196 }
2197 2197
2198 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 2198 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
2199 const gfx::Point screen_point = 2199 const gfx::Point screen_point =
2200 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 2200 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
2201 aura::Window* root_window = window_->GetRootWindow(); 2201 aura::Window* root_window = window_->GetRootWindow();
2202 if (!root_window) 2202 if (!root_window)
2203 return; 2203 return;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 2461
2462 //////////////////////////////////////////////////////////////////////////////// 2462 ////////////////////////////////////////////////////////////////////////////////
2463 // RenderWidgetHostViewBase, public: 2463 // RenderWidgetHostViewBase, public:
2464 2464
2465 // static 2465 // static
2466 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2466 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2467 GetScreenInfoForWindow(results, NULL); 2467 GetScreenInfoForWindow(results, NULL);
2468 } 2468 }
2469 2469
2470 } // namespace content 2470 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698