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. 4 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_MAC_H_ 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_MAC_H_ 7 8 #import <Cocoa/Cocoa.h> 9 #include <stdint.h> 10 11 #include <map> 12 #include <vector> 13 14 #include "base/macros.h" 15 #include "base/strings/string16.h" 16 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 17 #include "content/browser/accessibility/browser_accessibility_manager.h" 18 #include "content/public/browser/ax_event_notification_details.h" 19 20 namespace content { 21 22 class CONTENT_EXPORT BrowserAccessibilityManagerMac 23 : public BrowserAccessibilityManager { 24 public: 25 BrowserAccessibilityManagerMac( 26 const ui::AXTreeUpdate& initial_tree, 27 BrowserAccessibilityDelegate* delegate, 28 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); 29 30 ~BrowserAccessibilityManagerMac() override; 31 32 static ui::AXTreeUpdate GetEmptyDocument(); 33 34 BrowserAccessibility* GetFocus() const override; 35 36 // Implementation of BrowserAccessibilityManager. 37 void FireFocusEvent(BrowserAccessibility* node) override; 38 void FireBlinkEvent(ax::mojom::Event event_type, 39 BrowserAccessibility* node) override; 40 void FireGeneratedEvent(ui::AXEventGenerator::Event event_type, 41 BrowserAccessibility* node) override; 42 43 bool OnAccessibilityEvents( 44 const AXEventNotificationDetails& details) override; 45 46 id GetParentView(); 47 id GetWindow(); 48 49 private: 50 void FireNativeMacNotification(NSString* mac_notification, 51 BrowserAccessibility* node); 52 53 // AXTreeObserver methods. 54 void OnAtomicUpdateFinished(ui::AXTree* tree, 55 bool root_changed, 56 const std::vector<Change>& changes) override; 57 58 // Returns an autoreleased object. 59 NSDictionary* GetUserInfoForSelectedTextChangedNotification(); 60 61 // Returns an autoreleased object. 62 NSDictionary* GetUserInfoForValueChangedNotification( 63 const BrowserAccessibilityCocoa* native_node, 64 const base::string16& deleted_text, 65 const base::string16& inserted_text) const; 66 67 void AnnounceActiveDescendant(BrowserAccessibility* node) const; 68 69 bool IsInGeneratedEventBatch(ui::AXEventGenerator::Event event_type) const; 70 71 // Keeps track of any edits that have been made by the user during a tree 72 // update. Used by NSAccessibilityValueChangedNotification. 73 // Maps AXNode IDs to value attribute changes. 74 std::map<int32_t, AXTextEdit> text_edits_; 75 76 // This gives BrowserAccessibilityManager::Create access to the class 77 // constructor. 78 friend class BrowserAccessibilityManager; 79 80 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerMac); 81 }; 82 83 } 84 85 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_MAC_H_ 86