| 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" |
| 15 #include "chrome/browser/views/go_button.h" | 16 #include "chrome/browser/views/go_button.h" |
| 16 #include "chrome/browser/views/location_bar_view.h" | 17 #include "chrome/browser/views/location_bar_view.h" |
| 17 #include "chrome/common/pref_member.h" | 18 #include "chrome/common/pref_member.h" |
| 18 #include "views/controls/button/menu_button.h" | 19 #include "views/controls/button/menu_button.h" |
| 19 #include "views/controls/menu/menu.h" | 20 #include "views/controls/menu/menu.h" |
| 20 #include "views/controls/menu/simple_menu_model.h" | 21 #include "views/controls/menu/simple_menu_model.h" |
| 21 #include "views/controls/menu/view_menu_delegate.h" | 22 #include "views/controls/menu/view_menu_delegate.h" |
| 22 #include "views/view.h" | 23 #include "views/view.h" |
| 23 | 24 |
| 24 class BackForwardMenuModelViews; | 25 class BackForwardMenuModelViews; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 public: | 57 public: |
| 57 explicit ZoomMenuModel(views::SimpleMenuModel::Delegate* delegate); | 58 explicit ZoomMenuModel(views::SimpleMenuModel::Delegate* delegate); |
| 58 virtual ~ZoomMenuModel() {} | 59 virtual ~ZoomMenuModel() {} |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 void Build(); | 62 void Build(); |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); | 64 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 // The Browser Window's toolbar. Used within BrowserView. | 67 // The Browser Window's toolbar. |
| 67 class ToolbarView : public views::View, | 68 class ToolbarView : public AccessibleToolbarView, |
| 68 public views::ViewMenuDelegate, | 69 public views::ViewMenuDelegate, |
| 69 public views::DragController, | 70 public views::DragController, |
| 70 public views::SimpleMenuModel::Delegate, | 71 public views::SimpleMenuModel::Delegate, |
| 71 public LocationBarView::Delegate, | 72 public LocationBarView::Delegate, |
| 72 public NotificationObserver, | 73 public NotificationObserver, |
| 73 public GetProfilesHelper::Delegate, | 74 public GetProfilesHelper::Delegate, |
| 74 public CommandUpdater::CommandObserver, | 75 public CommandUpdater::CommandObserver, |
| 75 public views::ButtonListener, | 76 public views::ButtonListener, |
| 76 public BubblePositioner { | 77 public BubblePositioner { |
| 77 public: | 78 public: |
| 78 explicit ToolbarView(Browser* browser); | 79 explicit ToolbarView(Browser* browser); |
| 79 virtual ~ToolbarView(); | 80 virtual ~ToolbarView(); |
| 80 | 81 |
| 81 // Create the contents of the Browser Toolbar | 82 // Create the contents of the Browser Toolbar |
| 82 void Init(Profile* profile); | 83 void Init(Profile* profile); |
| 83 | 84 |
| 84 // Sets the profile which is active on the currently-active tab. | 85 // Sets the profile which is active on the currently-active tab. |
| 85 void SetProfile(Profile* profile); | 86 void SetProfile(Profile* profile); |
| 86 Profile* profile() { return profile_; } | 87 Profile* profile() { return profile_; } |
| 87 | 88 |
| 88 // Updates the toolbar (and transitively the location bar) with the states of | 89 // Updates the toolbar (and transitively the location bar) with the states of |
| 89 // the specified |tab|. If |should_restore_state| is true, we're switching | 90 // the specified |tab|. If |should_restore_state| is true, we're switching |
| 90 // (back?) to this tab and should restore any previous location bar state | 91 // (back?) to this tab and should restore any previous location bar state |
| 91 // (such as user editing) as well. | 92 // (such as user editing) as well. |
| 92 void Update(TabContents* tab, bool should_restore_state); | 93 void Update(TabContents* tab, bool should_restore_state); |
| 93 | 94 |
| 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 | |
| 107 // Accessors... | 95 // Accessors... |
| 108 Browser* browser() const { return browser_; } | 96 Browser* browser() const { return browser_; } |
| 109 BrowserActionsContainer* browser_actions() const { return browser_actions_; } | 97 BrowserActionsContainer* browser_actions() const { return browser_actions_; } |
| 110 ToolbarStarToggle* star_button() const { return star_; } | 98 ToolbarStarToggle* star_button() const { return star_; } |
| 111 GoButton* go_button() const { return go_; } | 99 GoButton* go_button() const { return go_; } |
| 112 LocationBarView* location_bar() const { return location_bar_; } | 100 LocationBarView* location_bar() const { return location_bar_; } |
| 113 views::MenuButton* page_menu() const { return page_menu_; } | 101 views::MenuButton* page_menu() const { return page_menu_; } |
| 114 views::MenuButton* app_menu() const { return app_menu_; } | 102 views::MenuButton* app_menu() const { return app_menu_; } |
| 115 | 103 |
| 104 // Overridden from AccessibleToolbarView: |
| 105 virtual bool IsAccessibleViewTraversable(views::View* view); |
| 106 |
| 116 // Overridden from Menu::BaseControllerDelegate: | 107 // Overridden from Menu::BaseControllerDelegate: |
| 117 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); | 108 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); |
| 118 | 109 |
| 119 // Overridden from views::MenuDelegate: | 110 // Overridden from views::MenuDelegate: |
| 120 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 111 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
| 121 | 112 |
| 122 // Overridden from GetProfilesHelper::Delegate: | 113 // Overridden from GetProfilesHelper::Delegate: |
| 123 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); | 114 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); |
| 124 | 115 |
| 125 // Overridden from LocationBarView::Delegate: | 116 // Overridden from LocationBarView::Delegate: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 145 virtual bool IsCommandIdEnabled(int command_id) const; | 136 virtual bool IsCommandIdEnabled(int command_id) const; |
| 146 virtual bool GetAcceleratorForCommandId(int command_id, | 137 virtual bool GetAcceleratorForCommandId(int command_id, |
| 147 views::Accelerator* accelerator); | 138 views::Accelerator* accelerator); |
| 148 virtual void ExecuteCommand(int command_id); | 139 virtual void ExecuteCommand(int command_id); |
| 149 | 140 |
| 150 // Overridden from views::View: | 141 // Overridden from views::View: |
| 151 virtual gfx::Size GetPreferredSize(); | 142 virtual gfx::Size GetPreferredSize(); |
| 152 virtual void Layout(); | 143 virtual void Layout(); |
| 153 virtual void Paint(gfx::Canvas* canvas); | 144 virtual void Paint(gfx::Canvas* canvas); |
| 154 virtual void ThemeChanged(); | 145 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_; } | |
| 166 | 146 |
| 167 private: | 147 private: |
| 168 // Overridden from views::DragController: | 148 // Overridden from views::DragController: |
| 169 virtual void WriteDragData(View* sender, | 149 virtual void WriteDragData(View* sender, |
| 170 int press_x, | 150 int press_x, |
| 171 int press_y, | 151 int press_y, |
| 172 OSExchangeData* data); | 152 OSExchangeData* data); |
| 173 virtual int GetDragOperations(View* sender, int x, int y); | 153 virtual int GetDragOperations(View* sender, int x, int y); |
| 174 | 154 |
| 175 // Returns the number of pixels above the location bar in non-normal display. | 155 // Returns the number of pixels above the location bar in non-normal display. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 204 bool IsDisplayModeNormal() const { | 184 bool IsDisplayModeNormal() const { |
| 205 return display_mode_ == DISPLAYMODE_NORMAL; | 185 return display_mode_ == DISPLAYMODE_NORMAL; |
| 206 } | 186 } |
| 207 | 187 |
| 208 scoped_ptr<BackForwardMenuModelViews> back_menu_model_; | 188 scoped_ptr<BackForwardMenuModelViews> back_menu_model_; |
| 209 scoped_ptr<BackForwardMenuModelViews> forward_menu_model_; | 189 scoped_ptr<BackForwardMenuModelViews> forward_menu_model_; |
| 210 | 190 |
| 211 // The model that contains the security level, text, icon to display... | 191 // The model that contains the security level, text, icon to display... |
| 212 ToolbarModel* model_; | 192 ToolbarModel* model_; |
| 213 | 193 |
| 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 | |
| 221 // Controls | 194 // Controls |
| 222 views::ImageButton* back_; | 195 views::ImageButton* back_; |
| 223 views::ImageButton* forward_; | 196 views::ImageButton* forward_; |
| 224 views::ImageButton* reload_; | 197 views::ImageButton* reload_; |
| 225 views::ImageButton* home_; | 198 views::ImageButton* home_; |
| 226 ToolbarStarToggle* star_; | 199 ToolbarStarToggle* star_; |
| 227 LocationBarView* location_bar_; | 200 LocationBarView* location_bar_; |
| 228 GoButton* go_; | 201 GoButton* go_; |
| 229 BrowserActionsContainer* browser_actions_; | 202 BrowserActionsContainer* browser_actions_; |
| 230 views::MenuButton* page_menu_; | 203 views::MenuButton* page_menu_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 252 scoped_ptr<EncodingMenuModel> encoding_menu_contents_; | 225 scoped_ptr<EncodingMenuModel> encoding_menu_contents_; |
| 253 scoped_ptr<views::SimpleMenuModel> devtools_menu_contents_; | 226 scoped_ptr<views::SimpleMenuModel> devtools_menu_contents_; |
| 254 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; | 227 scoped_ptr<views::SimpleMenuModel> app_menu_contents_; |
| 255 | 228 |
| 256 // TODO(beng): build these into MenuButton. | 229 // TODO(beng): build these into MenuButton. |
| 257 scoped_ptr<views::Menu2> page_menu_menu_; | 230 scoped_ptr<views::Menu2> page_menu_menu_; |
| 258 scoped_ptr<views::Menu2> app_menu_menu_; | 231 scoped_ptr<views::Menu2> app_menu_menu_; |
| 259 }; | 232 }; |
| 260 | 233 |
| 261 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 234 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| OLD | NEW |