| 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. The last focused view is stored in |
| 21 // the ViewStorage with the corresponding |view_storage_id|. |
| 22 void InitiateTraversal(int view_storage_id); |
| 23 |
| 24 // Overridden from views::View: |
| 25 virtual void DidGainFocus(); |
| 26 virtual void WillLoseFocus(); |
| 27 virtual bool OnKeyPressed(const views::KeyEvent& e); |
| 28 virtual bool OnKeyReleased(const views::KeyEvent& e); |
| 29 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); |
| 30 virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); |
| 31 virtual void RequestFocus(); |
| 32 virtual bool GetAccessibleName(std::wstring* name); |
| 33 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
| 34 virtual void SetAccessibleName(const std::wstring& name); |
| 35 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
| 36 virtual View* GetAccFocusedChildView() { return selected_focused_view_; } |
| 37 |
| 38 protected: |
| 39 // Returns the next accessible view on the toolbar, starting from the given |
| 40 // |view_index|. |forward| when true means it will navigate from left to right |
| 41 // and vice versa when false. If |view_index| is -1 the first accessible child |
| 42 // is returned. |
| 43 views::View* GetNextAccessibleView(int view_index, bool forward); |
| 44 |
| 45 // Invoked from GetNextAccessibleViewIndex to determine if |view| can be |
| 46 // traversed to. Default implementation returns true, override to return false |
| 47 // for views you don't want reachable. |
| 48 virtual bool IsAccessibleViewTraversable(views::View* view); |
| 49 |
| 50 private: |
| 51 // Sets the focus to the currently |acc_focused_view_| view. |
| 52 void SetFocusToAccessibleView(); |
| 53 |
| 54 // Retrieve the focused view from the storage so we can request focus back |
| 55 // to it. If |focus_view| is null, we place focus on the default view. |
| 56 // |selected_focused_view_| doesn't need to reset here since it will be |
| 57 // dealt within the WillLoseFocus method. |
| 58 void SetFocusToLastFocusedView(); |
| 59 |
| 60 // Storage of strings needed for accessibility. |
| 61 std::wstring accessible_name_; |
| 62 |
| 63 // Selected child view currently having accessibility focus. |
| 64 views::View* selected_focused_view_; |
| 65 |
| 66 // Last focused view that issued this traversal. |
| 67 int last_focused_view_storage_id_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(AccessibleToolbarView); |
| 70 }; |
| 71 |
| 72 #endif // CHROME_BROWSER_VIEWS_ACCESSIBLE_TOOLBAR_VIEW_H_ |
| OLD | NEW |