OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "chrome/browser/bubble_positioner.h" | 12 #include "chrome/browser/bubble_positioner.h" |
13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
14 #include "chrome/browser/user_data_manager.h" | 14 #include "chrome/browser/user_data_manager.h" |
15 #include "chrome/browser/views/accessible_toolbar_view.h" | |
16 #include "chrome/browser/views/go_button.h" | 15 #include "chrome/browser/views/go_button.h" |
17 #include "chrome/browser/views/location_bar_view.h" | 16 #include "chrome/browser/views/location_bar_view.h" |
18 #include "chrome/common/pref_member.h" | 17 #include "chrome/common/pref_member.h" |
19 #include "views/controls/button/menu_button.h" | 18 #include "views/controls/button/menu_button.h" |
20 #include "views/controls/menu/menu.h" | 19 #include "views/controls/menu/menu.h" |
21 #include "views/controls/menu/simple_menu_model.h" | 20 #include "views/controls/menu/simple_menu_model.h" |
22 #include "views/controls/menu/view_menu_delegate.h" | 21 #include "views/controls/menu/view_menu_delegate.h" |
23 #include "views/view.h" | 22 #include "views/view.h" |
24 | 23 |
25 class BackForwardMenuModelViews; | 24 class BackForwardMenuModelViews; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 public: | 56 public: |
58 explicit ZoomMenuModel(views::SimpleMenuModel::Delegate* delegate); | 57 explicit ZoomMenuModel(views::SimpleMenuModel::Delegate* delegate); |
59 virtual ~ZoomMenuModel() {} | 58 virtual ~ZoomMenuModel() {} |
60 | 59 |
61 private: | 60 private: |
62 void Build(); | 61 void Build(); |
63 | 62 |
64 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); | 63 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); |
65 }; | 64 }; |
66 | 65 |
67 // The Browser Window's toolbar. | 66 // The Browser Window's toolbar. Used within BrowserView. |
68 class ToolbarView : public AccessibleToolbarView, | 67 class ToolbarView : public views::View, |
69 public views::ViewMenuDelegate, | 68 public views::ViewMenuDelegate, |
70 public views::DragController, | 69 public views::DragController, |
71 public views::SimpleMenuModel::Delegate, | 70 public views::SimpleMenuModel::Delegate, |
72 public LocationBarView::Delegate, | 71 public LocationBarView::Delegate, |
73 public NotificationObserver, | 72 public NotificationObserver, |
74 public GetProfilesHelper::Delegate, | 73 public GetProfilesHelper::Delegate, |
75 public CommandUpdater::CommandObserver, | 74 public CommandUpdater::CommandObserver, |
76 public views::ButtonListener, | 75 public views::ButtonListener, |
77 public BubblePositioner { | 76 public BubblePositioner { |
78 public: | 77 public: |
79 explicit ToolbarView(Browser* browser); | 78 explicit ToolbarView(Browser* browser); |
80 virtual ~ToolbarView(); | 79 virtual ~ToolbarView(); |
81 | 80 |
82 // Create the contents of the Browser Toolbar | 81 // Create the contents of the Browser Toolbar |
83 void Init(Profile* profile); | 82 void Init(Profile* profile); |
84 | 83 |
85 // Sets the profile which is active on the currently-active tab. | 84 // Sets the profile which is active on the currently-active tab. |
86 void SetProfile(Profile* profile); | 85 void SetProfile(Profile* profile); |
87 Profile* profile() { return profile_; } | 86 Profile* profile() { return profile_; } |
88 | 87 |
89 // Updates the toolbar (and transitively the location bar) with the states of | 88 // Updates the toolbar (and transitively the location bar) with the states of |
90 // the specified |tab|. If |should_restore_state| is true, we're switching | 89 // the specified |tab|. If |should_restore_state| is true, we're switching |
91 // (back?) to this tab and should restore any previous location bar state | 90 // (back?) to this tab and should restore any previous location bar state |
92 // (such as user editing) as well. | 91 // (such as user editing) as well. |
93 void Update(TabContents* tab, bool should_restore_state); | 92 void Update(TabContents* tab, bool should_restore_state); |
94 | 93 |
| 94 // Returns the index of the next view of the toolbar, starting from the given |
| 95 // view index (skipping the location bar), in the given navigation direction |
| 96 // (nav_left true means navigation right to left, and vice versa). -1 finds |
| 97 // first accessible child, based on the above policy. |
| 98 int GetNextAccessibleViewIndex(int view_index, bool nav_left); |
| 99 |
| 100 // Initialize the MSAA focus traversal on the toolbar. |
| 101 void InitializeTraversal(); |
| 102 |
| 103 void set_acc_focused_view(views::View* acc_focused_view) { |
| 104 acc_focused_view_ = acc_focused_view; |
| 105 } |
| 106 |
95 // Accessors... | 107 // Accessors... |
96 Browser* browser() const { return browser_; } | 108 Browser* browser() const { return browser_; } |
97 BrowserActionsContainer* browser_actions() const { return browser_actions_; } | 109 BrowserActionsContainer* browser_actions() const { return browser_actions_; } |
98 ToolbarStarToggle* star_button() const { return star_; } | 110 ToolbarStarToggle* star_button() const { return star_; } |
99 GoButton* go_button() const { return go_; } | 111 GoButton* go_button() const { return go_; } |
100 LocationBarView* location_bar() const { return location_bar_; } | 112 LocationBarView* location_bar() const { return location_bar_; } |
101 views::MenuButton* page_menu() const { return page_menu_; } | 113 views::MenuButton* page_menu() const { return page_menu_; } |
102 views::MenuButton* app_menu() const { return app_menu_; } | 114 views::MenuButton* app_menu() const { return app_menu_; } |
103 | 115 |
104 // Overridden from AccessibleToolbarView: | |
105 virtual bool IsAccessibleViewTraversable(views::View* view); | |
106 | |
107 // Overridden from Menu::BaseControllerDelegate: | 116 // Overridden from Menu::BaseControllerDelegate: |
108 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); | 117 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); |
109 | 118 |
110 // Overridden from views::MenuDelegate: | 119 // Overridden from views::MenuDelegate: |
111 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 120 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
112 | 121 |
113 // Overridden from GetProfilesHelper::Delegate: | 122 // Overridden from GetProfilesHelper::Delegate: |
114 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); | 123 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); |
115 | 124 |
116 // Overridden from LocationBarView::Delegate: | 125 // Overridden from LocationBarView::Delegate: |
(...skipping 19 matching lines...) Expand all Loading... |
136 virtual bool IsCommandIdEnabled(int command_id) const; | 145 virtual bool IsCommandIdEnabled(int command_id) const; |
137 virtual bool GetAcceleratorForCommandId(int command_id, | 146 virtual bool GetAcceleratorForCommandId(int command_id, |
138 views::Accelerator* accelerator); | 147 views::Accelerator* accelerator); |
139 virtual void ExecuteCommand(int command_id); | 148 virtual void ExecuteCommand(int command_id); |
140 | 149 |
141 // Overridden from views::View: | 150 // Overridden from views::View: |
142 virtual gfx::Size GetPreferredSize(); | 151 virtual gfx::Size GetPreferredSize(); |
143 virtual void Layout(); | 152 virtual void Layout(); |
144 virtual void Paint(gfx::Canvas* canvas); | 153 virtual void Paint(gfx::Canvas* canvas); |
145 virtual void ThemeChanged(); | 154 virtual void ThemeChanged(); |
| 155 virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); |
| 156 virtual void DidGainFocus(); |
| 157 virtual void WillLoseFocus(); |
| 158 virtual void RequestFocus(); |
| 159 virtual bool OnKeyPressed(const views::KeyEvent& e); |
| 160 virtual bool OnKeyReleased(const views::KeyEvent& e); |
| 161 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); |
| 162 virtual bool GetAccessibleName(std::wstring* name); |
| 163 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
| 164 virtual void SetAccessibleName(const std::wstring& name); |
| 165 virtual View* GetAccFocusedChildView() { return acc_focused_view_; } |
146 | 166 |
147 private: | 167 private: |
148 // Overridden from views::DragController: | 168 // Overridden from views::DragController: |
149 virtual void WriteDragData(View* sender, | 169 virtual void WriteDragData(View* sender, |
150 int press_x, | 170 int press_x, |
151 int press_y, | 171 int press_y, |
152 OSExchangeData* data); | 172 OSExchangeData* data); |
153 virtual int GetDragOperations(View* sender, int x, int y); | 173 virtual int GetDragOperations(View* sender, int x, int y); |
154 | 174 |
155 // Returns the number of pixels above the location bar in non-normal display. | 175 // Returns the number of pixels above the location bar in non-normal display. |
(...skipping 28 matching lines...) Expand all Loading... |
184 bool IsDisplayModeNormal() const { | 204 bool IsDisplayModeNormal() const { |
185 return display_mode_ == DISPLAYMODE_NORMAL; | 205 return display_mode_ == DISPLAYMODE_NORMAL; |
186 } | 206 } |
187 | 207 |
188 scoped_ptr<BackForwardMenuModelViews> back_menu_model_; | 208 scoped_ptr<BackForwardMenuModelViews> back_menu_model_; |
189 scoped_ptr<BackForwardMenuModelViews> forward_menu_model_; | 209 scoped_ptr<BackForwardMenuModelViews> forward_menu_model_; |
190 | 210 |
191 // The model that contains the security level, text, icon to display... | 211 // The model that contains the security level, text, icon to display... |
192 ToolbarModel* model_; | 212 ToolbarModel* model_; |
193 | 213 |
| 214 // Storage of strings needed for accessibility. |
| 215 std::wstring accessible_name_; |
| 216 // Child view currently having MSAA focus (location bar excluded from arrow |
| 217 // navigation). |
| 218 views::View* acc_focused_view_; |
| 219 int last_focused_view_storage_id_; |
| 220 |
194 // Controls | 221 // Controls |
195 views::ImageButton* back_; | 222 views::ImageButton* back_; |
196 views::ImageButton* forward_; | 223 views::ImageButton* forward_; |
197 views::ImageButton* reload_; | 224 views::ImageButton* reload_; |
198 views::ImageButton* home_; | 225 views::ImageButton* home_; |
199 ToolbarStarToggle* star_; | 226 ToolbarStarToggle* star_; |
200 LocationBarView* location_bar_; | 227 LocationBarView* location_bar_; |
201 GoButton* go_; | 228 GoButton* go_; |
202 BrowserActionsContainer* browser_actions_; | 229 BrowserActionsContainer* browser_actions_; |
203 views::MenuButton* page_menu_; | 230 views::MenuButton* page_menu_; |
(...skipping 21 matching lines...) Expand all Loading... |
225 scoped_ptr<EncodingMenuModel> encoding_menu_contents_; | 252 scoped_ptr<EncodingMenuModel> encoding_menu_contents_; |
226 scoped_ptr<views::SimpleMenuModel> devtools_menu_contents_; | 253 scoped_ptr<views::SimpleMenuModel> devtools_menu_contents_; |
227 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; | 254 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; |
228 | 255 |
229 // TODO(beng): build these into MenuButton. | 256 // TODO(beng): build these into MenuButton. |
230 scoped_ptr<views::Menu2> page_menu_menu_; | 257 scoped_ptr<views::Menu2> page_menu_menu_; |
231 scoped_ptr<views::Menu2> app_menu_menu_; | 258 scoped_ptr<views::Menu2> app_menu_menu_; |
232 }; | 259 }; |
233 | 260 |
234 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 261 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
OLD | NEW |