1 // Copyright (c) 2010 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. 4 5 #include "chrome/browser/accessibility/browser_accessibility_manager_mac.h" 6 7 #import "base/logging.h" 8 #import "chrome/browser/accessibility/browser_accessibility_cocoa.h" 9 #include "content/common/view_messages.h" 10 11 // static 12 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( 13 gfx::NativeView parent_view, 14 const WebAccessibility& src, 15 BrowserAccessibilityDelegate* delegate, 16 BrowserAccessibilityFactory* factory) { 17 return new BrowserAccessibilityManagerMac( 18 parent_view, src, delegate, factory); 19 } 20 21 BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac( 22 gfx::NativeView parent_window, 23 const webkit_glue::WebAccessibility& src, 24 BrowserAccessibilityDelegate* delegate, 25 BrowserAccessibilityFactory* factory) 26 : BrowserAccessibilityManager(parent_window, src, delegate, factory) { 27 } 28 29 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( 30 int type, 31 BrowserAccessibility* node) { 32 // Refer to AXObjectCache.mm (webkit). 33 NSString* event_id = @""; 34 switch (type) { 35 case ViewHostMsg_AccessibilityNotification_Type:: 36 NOTIFICATION_TYPE_CHECK_STATE_CHANGED: 37 // Does not exist on Mac. 38 return; 39 case ViewHostMsg_AccessibilityNotification_Type:: 40 NOTIFICATION_TYPE_CHILDREN_CHANGED: 41 // TODO(dtseng): no clear equivalent on Mac. 42 return; 43 case ViewHostMsg_AccessibilityNotification_Type:: 44 NOTIFICATION_TYPE_FOCUS_CHANGED: 45 event_id = NSAccessibilityFocusedUIElementChangedNotification; 46 break; 47 case ViewHostMsg_AccessibilityNotification_Type:: 48 NOTIFICATION_TYPE_LOAD_COMPLETE: 49 event_id = @"AXLoadComplete"; 50 break; 51 case ViewHostMsg_AccessibilityNotification_Type:: 52 NOTIFICATION_TYPE_VALUE_CHANGED: 53 event_id = NSAccessibilityValueChangedNotification; 54 break; 55 case ViewHostMsg_AccessibilityNotification_Type:: 56 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED: 57 event_id = NSAccessibilitySelectedTextChangedNotification; 58 break; 59 } 60 BrowserAccessibilityCocoa* native_node = node->toBrowserAccessibilityCocoa(); 61 DCHECK(native_node); 62 NSAccessibilityPostNotification(native_node, event_id); 63 } 64