| 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_GTK_TABS_TAB_STRIP_MENU_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_MENU_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "chrome/browser/ui/gtk/menu_gtk.h" | |
| 10 #include "chrome/browser/ui/tabs/tab_menu_model.h" | |
| 11 | |
| 12 class TabGtk; | |
| 13 class TabStripModel; | |
| 14 | |
| 15 namespace gfx { | |
| 16 class Point; | |
| 17 } | |
| 18 | |
| 19 namespace ui { | |
| 20 class Accelerator; | |
| 21 } | |
| 22 | |
| 23 // Controls the context menu of a specific tab. It is created every time a right | |
| 24 // click occurs on a tab. | |
| 25 class TabStripMenuController : public ui::SimpleMenuModel::Delegate, | |
| 26 public MenuGtk::Delegate { | |
| 27 public: | |
| 28 // |tab| is the tab for which this menu is created. |model| is the | |
| 29 // TabStripModel where this tab belongs to. |index| is the index of |tab| | |
| 30 // within the tab strip. | |
| 31 TabStripMenuController(TabGtk* tab, TabStripModel* model, int index); | |
| 32 virtual ~TabStripMenuController(); | |
| 33 void RunMenu(const gfx::Point& point, guint32 event_time); | |
| 34 void Cancel(); | |
| 35 | |
| 36 private: | |
| 37 // Overridden from ui::SimpleMenuModel::Delegate: | |
| 38 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
| 39 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
| 40 virtual bool GetAcceleratorForCommandId( | |
| 41 int command_id, | |
| 42 ui::Accelerator* accelerator) OVERRIDE; | |
| 43 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | |
| 44 | |
| 45 // Overridden from MenuGtk::Delegate: | |
| 46 virtual GtkWidget* GetImageForCommandId(int command_id) const OVERRIDE; | |
| 47 | |
| 48 // The context menu. | |
| 49 scoped_ptr<MenuGtk> menu_; | |
| 50 | |
| 51 // Weak pointer to the tab for which the context menu was brought up for. Set | |
| 52 // to NULL when the menu is canceled. | |
| 53 TabGtk* tab_; | |
| 54 | |
| 55 // The model. | |
| 56 TabMenuModel model_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(TabStripMenuController); | |
| 59 }; | |
| 60 | |
| 61 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_MENU_CONTROLLER_H_ | |
| OLD | NEW |