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/win/scoped_comptr.h"
     11 #include "content/browser/accessibility/browser_accessibility_manager.h"
     12 
     13 namespace content {
     14 class BrowserAccessibilityWin;
     15 
     16 // Manages a tree of BrowserAccessibilityWin objects.
     17 class CONTENT_EXPORT BrowserAccessibilityManagerWin
     18     : public BrowserAccessibilityManager {
     19  public:
     20   BrowserAccessibilityManagerWin(
     21       HWND parent_hwnd,
     22       IAccessible* parent_iaccessible,
     23       const AccessibilityNodeData& src,
     24       BrowserAccessibilityDelegate* delegate,
     25       BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
     26 
     27   virtual ~BrowserAccessibilityManagerWin();
     28 
     29   static AccessibilityNodeData GetEmptyDocument();
     30 
     31   // Get the closest containing HWND.
     32   HWND parent_hwnd() { return parent_hwnd_; }
     33 
     34   // The IAccessible for the parent window.
     35   IAccessible* parent_iaccessible() { return parent_iaccessible_; }
     36   void set_parent_iaccessible(IAccessible* parent_iaccessible) {
     37     parent_iaccessible_ = parent_iaccessible;
     38   }
     39 
     40   // Calls NotifyWinEvent if the parent window's IAccessible pointer is known.
     41   void MaybeCallNotifyWinEvent(DWORD event, LONG child_id);
     42 
     43   // BrowserAccessibilityManager methods
     44   virtual void AddNodeToMap(BrowserAccessibility* node);
     45   virtual void RemoveNode(BrowserAccessibility* node) OVERRIDE;
     46   virtual void NotifyAccessibilityEvent(int type, BrowserAccessibility* node)
     47       OVERRIDE;
     48 
     49   // Track this object and post a VISIBLE_DATA_CHANGED notification when
     50   // its container scrolls.
     51   // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
     52   void TrackScrollingObject(BrowserAccessibilityWin* node);
     53 
     54   // Return a pointer to the object corresponding to the given windows-specific
     55   // unique id, does not make a new reference.
     56   BrowserAccessibilityWin* GetFromUniqueIdWin(LONG unique_id_win);
     57 
     58  private:
     59   // The closest ancestor HWND.
     60   HWND parent_hwnd_;
     61 
     62   // The accessibility instance for the parent window.
     63   IAccessible* parent_iaccessible_;
     64 
     65   // Give BrowserAccessibilityManager::Create access to our constructor.
     66   friend class BrowserAccessibilityManager;
     67 
     68   // Track the most recent object that has been asked to scroll and
     69   // post a notification directly on it when it reaches its destination.
     70   // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
     71   BrowserAccessibilityWin* tracked_scroll_object_;
     72 
     73   // A mapping from the Windows-specific unique IDs (unique within the
     74   // browser process) to renderer ids within this page.
     75   base::hash_map<long, int32> unique_id_to_renderer_id_map_;
     76 
     77   DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin);
     78 };
     79 
     80 }  // namespace content
     81 
     82 #endif  // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
     83