| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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_UI_VIEWS_COMPACT_NAV_COMPACT_OPTIONS_BAR_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_OPTIONS_BAR_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/command_updater.h" |
| 14 #include "ui/base/models/simple_menu_model.h" |
| 15 #include "views/controls/button/button.h" |
| 16 #include "views/controls/menu/view_menu_delegate.h" |
| 17 #include "views/view.h" |
| 18 |
| 19 class BrowserView; |
| 20 class WrenchMenu; |
| 21 |
| 22 namespace views { |
| 23 class MenuButton; |
| 24 class MenuListener; |
| 25 } // namespace views |
| 26 |
| 27 // This class provides a small options bar that includes browser actions and |
| 28 // the wrench menu button. |
| 29 class CompactOptionsBar : public views::View, |
| 30 public views::ViewMenuDelegate, |
| 31 public ui::AcceleratorProvider, |
| 32 public views::ButtonListener { |
| 33 public: |
| 34 explicit CompactOptionsBar(BrowserView* browser_view); |
| 35 virtual ~CompactOptionsBar(); |
| 36 |
| 37 // Must be called before anything else, but after adding this view to the |
| 38 // widget. |
| 39 void Init(); |
| 40 |
| 41 // Add a listener to receive a callback when the menu opens. |
| 42 void AddMenuListener(views::MenuListener* listener); |
| 43 |
| 44 // Remove a menu listener. |
| 45 void RemoveMenuListener(views::MenuListener* listener); |
| 46 |
| 47 // Overridden from views::View. |
| 48 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 49 virtual void Layout() OVERRIDE; |
| 50 |
| 51 // Overridden from views::MenuDelegate: |
| 52 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; |
| 53 |
| 54 // Overridden from ui::AcceleratorProvider: |
| 55 virtual bool GetAcceleratorForCommandId( |
| 56 int command_id, |
| 57 ui::Accelerator* accelerator) OVERRIDE; |
| 58 |
| 59 private: |
| 60 // views::ButtonListener implementation. |
| 61 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 62 |
| 63 // Load the images for the back and forward buttons. |
| 64 void LoadImages(); |
| 65 |
| 66 BrowserView* browser_view_; |
| 67 |
| 68 bool initialized_; |
| 69 |
| 70 // Button and models for the wrench/app menu. |
| 71 views::MenuButton* app_menu_; |
| 72 scoped_ptr<ui::SimpleMenuModel> wrench_menu_model_; |
| 73 scoped_refptr<WrenchMenu> wrench_menu_; |
| 74 std::vector<views::MenuListener*> menu_listeners_; |
| 75 |
| 76 // TODO(stevet): Add the BrowserActionsContainer. |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(CompactOptionsBar); |
| 79 }; |
| 80 |
| 81 #endif // CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_OPTIONS_BAR_H_ |
| OLD | NEW |