| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 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 CHROME_BROWSER_VIEWS_ACCESSIBLE_TOOLBAR_VIEW_H_ | |
| 6 #define CHROME_BROWSER_VIEWS_ACCESSIBLE_TOOLBAR_VIEW_H_ | |
| 7 | |
| 8 #include "views/view.h" | |
| 9 | |
| 10 // This class provides keyboard access to any view that extends it by intiating | |
| 11 // ALT+SHIFT+T. And once you press TAB or SHIFT-TAB, it will traverse all the | |
| 12 // toolbars within Chrome. Child views are traversed in the order they were | |
| 13 // added. | |
| 14 | |
| 15 class AccessibleToolbarView : public views::View { | |
| 16 public: | |
| 17 AccessibleToolbarView(); | |
| 18 virtual ~AccessibleToolbarView(); | |
| 19 | |
| 20 // Initiate the traversal on the toolbar. | |
| 21 void InitiateTraversal(); | |
| 22 | |
| 23 // Overridden from views::View: | |
| 24 virtual void DidGainFocus(); | |
| 25 virtual void WillLoseFocus(); | |
| 26 virtual bool OnKeyPressed(const views::KeyEvent& e); | |
| 27 virtual bool OnKeyReleased(const views::KeyEvent& e); | |
| 28 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); | |
| 29 virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); | |
| 30 virtual void RequestFocus(); | |
| 31 virtual bool GetAccessibleName(std::wstring* name); | |
| 32 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | |
| 33 virtual void SetAccessibleName(const std::wstring& name); | |
| 34 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | |
| 35 virtual View* GetAccFocusedChildView() { return selected_focused_view_; } | |
| 36 | |
| 37 protected: | |
| 38 // Returns the index of the next view of the toolbar, starting from the given | |
| 39 // view index. |forward| when true means it will navigate from left to right, | |
| 40 // and vice versa when false. If |view_index| is -1 the first accessible child | |
| 41 // is returned. | |
| 42 int GetNextAccessibleViewIndex(int view_index, bool forward); | |
| 43 | |
| 44 // Invoked from GetNextAccessibleViewIndex to determine if |view| can be | |
| 45 // traversed to. Default implementation returns true, override to return false | |
| 46 // for views you don't want reachable. | |
| 47 virtual bool IsAccessibleViewTraversable(views::View* view); | |
| 48 | |
| 49 private: | |
| 50 // Sets the focus to the currently |acc_focused_view_| view. | |
| 51 void SetFocusToAccessibleView(); | |
| 52 | |
| 53 // Storage of strings needed for accessibility. | |
| 54 std::wstring accessible_name_; | |
| 55 | |
| 56 // Selected child view currently having accessibility focus. | |
| 57 views::View* selected_focused_view_; | |
| 58 | |
| 59 // Last focused view that issued this traversal. | |
| 60 int last_focused_view_storage_id_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(AccessibleToolbarView); | |
| 63 }; | |
| 64 | |
| 65 #endif // CHROME_BROWSER_VIEWS_ACCESSIBLE_TOOLBAR_VIEW_H_ | |
| OLD | NEW |