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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_win.cc

Issue 329053004: Fix race in BrowserAccessibilityManagerWin creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simpler fix 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/accessibility/browser_accessibility_manager_win.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 10 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
(...skipping 18 matching lines...) Expand all
29 return static_cast<BrowserAccessibilityManagerWin*>(this); 29 return static_cast<BrowserAccessibilityManagerWin*>(this);
30 } 30 }
31 31
32 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( 32 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin(
33 LegacyRenderWidgetHostHWND* accessible_hwnd, 33 LegacyRenderWidgetHostHWND* accessible_hwnd,
34 IAccessible* parent_iaccessible, 34 IAccessible* parent_iaccessible,
35 const ui::AXTreeUpdate& initial_tree, 35 const ui::AXTreeUpdate& initial_tree,
36 BrowserAccessibilityDelegate* delegate, 36 BrowserAccessibilityDelegate* delegate,
37 BrowserAccessibilityFactory* factory) 37 BrowserAccessibilityFactory* factory)
38 : BrowserAccessibilityManager(initial_tree, delegate, factory), 38 : BrowserAccessibilityManager(initial_tree, delegate, factory),
39 parent_hwnd_(accessible_hwnd->GetParent()),
40 parent_iaccessible_(parent_iaccessible), 39 parent_iaccessible_(parent_iaccessible),
41 tracked_scroll_object_(NULL), 40 tracked_scroll_object_(NULL),
42 accessible_hwnd_(accessible_hwnd) { 41 accessible_hwnd_(accessible_hwnd) {
43 accessible_hwnd_->set_browser_accessibility_manager(this); 42 if (accessible_hwnd_) {
43 accessible_hwnd_->set_browser_accessibility_manager(this);
44 parent_hwnd_ = accessible_hwnd->GetParent();
45 }
44 } 46 }
45 47
46 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { 48 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() {
47 if (tracked_scroll_object_) { 49 if (tracked_scroll_object_) {
48 tracked_scroll_object_->Release(); 50 tracked_scroll_object_->Release();
49 tracked_scroll_object_ = NULL; 51 tracked_scroll_object_ = NULL;
50 } 52 }
51 if (accessible_hwnd_) 53 if (accessible_hwnd_)
52 accessible_hwnd_->OnManagerDeleted(); 54 accessible_hwnd_->OnManagerDeleted();
53 } 55 }
54 56
55 // static 57 // static
56 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() { 58 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() {
57 ui::AXNodeData empty_document; 59 ui::AXNodeData empty_document;
58 empty_document.id = 0; 60 empty_document.id = 0;
59 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 61 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
60 empty_document.state = 62 empty_document.state =
61 (1 << ui::AX_STATE_ENABLED) | 63 (1 << ui::AX_STATE_ENABLED) |
62 (1 << ui::AX_STATE_READ_ONLY) | 64 (1 << ui::AX_STATE_READ_ONLY) |
63 (1 << ui::AX_STATE_BUSY); 65 (1 << ui::AX_STATE_BUSY);
64 66
65 ui::AXTreeUpdate update; 67 ui::AXTreeUpdate update;
66 update.nodes.push_back(empty_document); 68 update.nodes.push_back(empty_document);
67 return update; 69 return update;
68 } 70 }
69 71
72 void BrowserAccessibilityManagerWin::SetAccessibleHWND(
73 LegacyRenderWidgetHostHWND* accessible_hwnd) {
74 accessible_hwnd_ = accessible_hwnd;
75 accessible_hwnd_->set_browser_accessibility_manager(this);
76 parent_hwnd_ = accessible_hwnd->GetParent();
77 }
78
70 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, 79 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event,
71 LONG child_id) { 80 LONG child_id) {
72 // Don't fire events if this view isn't hooked up to its parent. 81 // Don't fire events if this view isn't hooked up to its parent.
73 if (!parent_iaccessible()) 82 if (!parent_iaccessible() || !parent_hwnd())
74 return; 83 return;
75 84
76 // If on Win 7 and complete accessibility is enabled, use the fake child HWND 85 // If on Win 7 and complete accessibility is enabled, use the fake child HWND
77 // to use as the root of the accessibility tree. See comments above 86 // to use as the root of the accessibility tree. See comments above
78 // LegacyRenderWidgetHostHWND for details. 87 // LegacyRenderWidgetHostHWND for details.
79 if (BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser()) { 88 if (BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser()) {
80 DCHECK(accessible_hwnd_); 89 DCHECK(accessible_hwnd_);
81 parent_hwnd_ = accessible_hwnd_->hwnd(); 90 parent_hwnd_ = accessible_hwnd_->hwnd();
82 parent_iaccessible_ = accessible_hwnd_->window_accessible(); 91 parent_iaccessible_ = accessible_hwnd_->window_accessible();
83 } 92 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // |parent_iaccessible_| are no longer valid either, since they were 268 // |parent_iaccessible_| are no longer valid either, since they were
260 // derived from AccessibleHWND. We don't have to restore them to 269 // derived from AccessibleHWND. We don't have to restore them to
261 // previous values, though, because this should only happen 270 // previous values, though, because this should only happen
262 // during the destruct sequence for this window. 271 // during the destruct sequence for this window.
263 accessible_hwnd_ = NULL; 272 accessible_hwnd_ = NULL;
264 parent_hwnd_ = NULL; 273 parent_hwnd_ = NULL;
265 parent_iaccessible_ = NULL; 274 parent_iaccessible_ = NULL;
266 } 275 }
267 276
268 } // namespace content 277 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698