summaryrefslogtreecommitdiffstats
path: root/chrome/browser/accessibility/browser_accessibility_manager_mac.mm
blob: 6e39cd1ff6a88f1b14720e8c36fb3fc339654bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/accessibility/browser_accessibility_manager_mac.h"

#import "chrome/browser/accessibility/browser_accessibility_cocoa.h"

// static
BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
    gfx::NativeView parent_view,
    const WebAccessibility& src,
    BrowserAccessibilityDelegate* delegate,
    BrowserAccessibilityFactory* factory) {
  return new BrowserAccessibilityManagerMac(
      parent_view, src, delegate, factory);
}

BrowserAccessibility* BrowserAccessibilityFactory::Create() {
  return BrowserAccessibility::Create();
}

BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac(
    gfx::NativeView parent_window,
    const webkit_glue::WebAccessibility& src,
    BrowserAccessibilityDelegate* delegate,
    BrowserAccessibilityFactory* factory)
        : BrowserAccessibilityManager(parent_window, src, delegate, factory) {
}

void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
    ViewHostMsg_AccessibilityNotification_Params::NotificationType n,
    BrowserAccessibility* node) {
  // Refer to AXObjectCache.mm (webkit).
  NSString* event_id = @"";
  switch (n) {
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_CHECK_STATE_CHANGED:
      // Does not exist on Mac.
      return;
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_CHILDREN_CHANGED:
      // TODO(dtseng): no clear equivalent on Mac.
      return;
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_FOCUS_CHANGED:
      event_id = NSAccessibilityFocusedUIElementChangedNotification;
      break;
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_LOAD_COMPLETE:
      event_id = @"AXLoadComplete";
      break;
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_VALUE_CHANGED:
      event_id = NSAccessibilityValueChangedNotification;
      break;
    case ViewHostMsg_AccessibilityNotification_Params::
        NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED:
      event_id = NSAccessibilitySelectedTextChangedNotification;
      break;
  }
  BrowserAccessibilityCocoa* native_node = node->toBrowserAccessibilityCocoa();
  DCHECK(native_node);
  NSAccessibilityPostNotification(native_node, event_id);
}