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
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
7 #import "content/browser/accessibility/browser_accessibility_mac.h"
9 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
10 #import "content/browser/accessibility/browser_accessibility_delegate_mac.h"
11 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
16 BrowserAccessibility* BrowserAccessibility::Create() {
17 return new BrowserAccessibilityMac();
20 BrowserAccessibilityMac::BrowserAccessibilityMac()
21 : browser_accessibility_cocoa_(NULL) {
24 void BrowserAccessibilityMac::PreInitialize() {
25 BrowserAccessibility::PreInitialize();
27 if (browser_accessibility_cocoa_)
30 // We take ownership of the cocoa obj here.
31 BrowserAccessibilityManagerMac* manager =
32 static_cast<BrowserAccessibilityManagerMac*>(manager_);
33 browser_accessibility_cocoa_ = [[BrowserAccessibilityCocoa alloc]
36 (id<BrowserAccessibilityDelegateCocoa>)manager->parent_view()];
39 void BrowserAccessibilityMac::NativeReleaseReference() {
40 // Detach this object from |browser_accessibility_cocoa_| so it
41 // no longer has a pointer to this object.
42 [browser_accessibility_cocoa_ detach];
43 // Now, release it - but at this point, other processes may have a
44 // reference to the cocoa object.
45 [browser_accessibility_cocoa_ release];
46 // Finally, it's safe to delete this since we've detached.
50 bool BrowserAccessibilityMac::IsNative() const {
54 void BrowserAccessibilityMac::DetachTree(
55 std::vector<BrowserAccessibility*>* nodes) {
56 [browser_accessibility_cocoa_ childrenChanged];
57 BrowserAccessibility::DetachTree(nodes);
60 void BrowserAccessibilityMac::SwapChildren(
61 std::vector<BrowserAccessibility*>& children) {
62 [browser_accessibility_cocoa_ childrenChanged];
63 BrowserAccessibility::SwapChildren(children);
66 BrowserAccessibilityCocoa* BrowserAccessibility::ToBrowserAccessibilityCocoa() {
67 return static_cast<BrowserAccessibilityMac*>(this)->
71 } // namespace content