Home | History | Annotate | Download | only in accessibility
      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_WIN_H_
      6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
      7 
      8 #include <oleacc.h>
      9 
     10 #include "base/memory/scoped_ptr.h"
     11 #include "base/win/scoped_comptr.h"
     12 #include "content/browser/accessibility/browser_accessibility_manager.h"
     13 
     14 namespace content {
     15 class BrowserAccessibilityWin;
     16 
     17 class LegacyRenderWidgetHostHWND;
     18 
     19 // Manages a tree of BrowserAccessibilityWin objects.
     20 class CONTENT_EXPORT BrowserAccessibilityManagerWin
     21     : public BrowserAccessibilityManager {
     22  public:
     23   BrowserAccessibilityManagerWin(
     24       content::LegacyRenderWidgetHostHWND* accessible_hwnd,
     25       IAccessible* parent_iaccessible,
     26       const ui::AXTreeUpdate& initial_tree,
     27       BrowserAccessibilityDelegate* delegate,
     28       BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
     29 
     30   virtual ~BrowserAccessibilityManagerWin();
     31 
     32   static ui::AXTreeUpdate GetEmptyDocument();
     33 
     34   // Get the closest containing HWND.
     35   HWND parent_hwnd() { return parent_hwnd_; }
     36 
     37   // The IAccessible for the parent window.
     38   IAccessible* parent_iaccessible() { return parent_iaccessible_; }
     39   void set_parent_iaccessible(IAccessible* parent_iaccessible) {
     40     parent_iaccessible_ = parent_iaccessible;
     41   }
     42 
     43   void SetAccessibleHWND(LegacyRenderWidgetHostHWND* accessible_hwnd);
     44 
     45   // Calls NotifyWinEvent if the parent window's IAccessible pointer is known.
     46   void MaybeCallNotifyWinEvent(DWORD event, LONG child_id);
     47 
     48   // AXTree methods
     49   virtual void OnNodeWillBeDeleted(ui::AXNode* node) OVERRIDE;
     50   virtual void OnNodeCreated(ui::AXNode* node) OVERRIDE;
     51 
     52   // BrowserAccessibilityManager methods
     53   virtual void OnWindowFocused() OVERRIDE;
     54   virtual void NotifyAccessibilityEvent(
     55       ui::AXEvent event_type, BrowserAccessibility* node) OVERRIDE;
     56 
     57   // Track this object and post a VISIBLE_DATA_CHANGED notification when
     58   // its container scrolls.
     59   // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
     60   void TrackScrollingObject(BrowserAccessibilityWin* node);
     61 
     62   // Return a pointer to the object corresponding to the given windows-specific
     63   // unique id, does not make a new reference.
     64   BrowserAccessibilityWin* GetFromUniqueIdWin(LONG unique_id_win);
     65 
     66   // Called when |accessible_hwnd_| is deleted by its parent.
     67   void OnAccessibleHwndDeleted();
     68 
     69  protected:
     70   // BrowserAccessibilityManager methods
     71   virtual void OnRootChanged(ui::AXNode* new_root) OVERRIDE;
     72 
     73  private:
     74   // The closest ancestor HWND.
     75   HWND parent_hwnd_;
     76 
     77   // The accessibility instance for the parent window.
     78   IAccessible* parent_iaccessible_;
     79 
     80   // Give BrowserAccessibilityManager::Create access to our constructor.
     81   friend class BrowserAccessibilityManager;
     82 
     83   // Track the most recent object that has been asked to scroll and
     84   // post a notification directly on it when it reaches its destination.
     85   // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
     86   BrowserAccessibilityWin* tracked_scroll_object_;
     87 
     88   // A mapping from the Windows-specific unique IDs (unique within the
     89   // browser process) to accessibility ids within this page.
     90   base::hash_map<long, int32> unique_id_to_ax_id_map_;
     91 
     92   // Owned by its parent; OnAccessibleHwndDeleted gets called upon deletion.
     93   LegacyRenderWidgetHostHWND* accessible_hwnd_;
     94 
     95   // Set to true if we need to fire a focus event on the root as soon as
     96   // possible.
     97   bool focus_event_on_root_needed_;
     98 
     99   DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin);
    100 };
    101 
    102 }  // namespace content
    103 
    104 #endif  // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
    105