Chromium Code Reviews| 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 #include "chrome/browser/ui/gtk/tabs/context_menu_controller.h" | |
| 6 | |
| 7 #include "chrome/browser/tabs/tab_strip_model.h" | |
| 8 #include "chrome/browser/ui/gtk/accelerators_gtk.h" | |
| 9 #include "chrome/browser/ui/gtk/menu_gtk.h" | |
| 10 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" | |
| 11 | |
| 12 ContextMenuController::ContextMenuController(TabGtk* tab, | |
|
Evan Stade
2011/05/11 20:58:27
this class should probably be TabStripContextMenuC
dpapad
2011/05/11 23:30:20
Done.
| |
| 13 TabStripModel* model, | |
| 14 int index) | |
| 15 : tab_(tab), | |
| 16 model_(this, model, index) { | |
| 17 menu_.reset(new MenuGtk(this, &model_)); | |
| 18 } | |
| 19 | |
| 20 void ContextMenuController::RunMenu(const gfx::Point& point, | |
| 21 guint32 event_time) { | |
| 22 menu_->PopupAsContext(point, event_time); | |
| 23 } | |
| 24 | |
| 25 void ContextMenuController::Cancel() { | |
| 26 tab_ = NULL; | |
| 27 menu_->Cancel(); | |
| 28 } | |
| 29 | |
| 30 bool ContextMenuController::IsCommandIdChecked(int command_id) const { | |
| 31 return false; | |
| 32 } | |
| 33 | |
| 34 bool ContextMenuController::IsCommandIdEnabled(int command_id) const { | |
| 35 return tab_ && tab_->delegate()->IsCommandEnabledForTab( | |
| 36 static_cast<TabStripModel::ContextMenuCommand>(command_id), | |
| 37 tab_); | |
| 38 } | |
| 39 | |
| 40 bool ContextMenuController::GetAcceleratorForCommandId( | |
| 41 int command_id, | |
| 42 ui::Accelerator* accelerator) { | |
| 43 int browser_command; | |
| 44 if (!TabStripModel::ContextMenuCommandToBrowserCommand(command_id, | |
| 45 &browser_command)) | |
| 46 return false; | |
| 47 const ui::AcceleratorGtk* accelerator_gtk = | |
| 48 AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand( | |
| 49 browser_command); | |
| 50 if (accelerator_gtk) | |
| 51 *accelerator = *accelerator_gtk; | |
| 52 return !!accelerator_gtk; | |
| 53 } | |
| 54 | |
| 55 void ContextMenuController::ExecuteCommand(int command_id) { | |
| 56 if (!tab_) | |
|
Evan Stade
2011/05/11 20:58:27
when would this be null?
dpapad
2011/05/11 23:30:20
Again, I did not change these checks. tab_ is set
Evan Stade
2011/05/12 00:05:27
so I guess it depends on whether you could call Ca
dpapad
2011/05/12 00:34:25
I will try and see and also ask James, since svn b
| |
| 57 return; | |
| 58 tab_->delegate()->ExecuteCommandForTab( | |
| 59 static_cast<TabStripModel::ContextMenuCommand>(command_id), tab_); | |
| 60 } | |
| 61 | |
| 62 GtkWidget* ContextMenuController::GetImageForCommandId(int command_id) const { | |
| 63 int browser_cmd_id; | |
| 64 return TabStripModel::ContextMenuCommandToBrowserCommand(command_id, | |
| 65 &browser_cmd_id) ? | |
| 66 MenuGtk::Delegate::GetDefaultImageForCommandId(browser_cmd_id) : | |
| 67 NULL; | |
| 68 } | |
| OLD | NEW |