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/tab_strip_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 TabStripMenuController::TabStripMenuController(TabGtk* tab, | |
| 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 TabStripMenuController::RunMenu(const gfx::Point& point, | |
| 21 guint32 event_time) { | |
| 22 menu_->PopupAsContext(point, event_time); | |
| 23 } | |
| 24 | |
| 25 void TabStripMenuController::Cancel() { | |
| 26 tab_ = NULL; | |
| 27 menu_->Cancel(); | |
| 28 } | |
| 29 | |
| 30 bool TabStripMenuController::IsCommandIdChecked(int command_id) const { | |
| 31 return false; | |
| 32 } | |
| 33 | |
| 34 bool TabStripMenuController::IsCommandIdEnabled(int command_id) const { | |
| 35 return tab_ && tab_->delegate()->IsCommandEnabledForTab( | |
| 36 static_cast<TabStripModel::ContextMenuCommand>(command_id), | |
| 37 tab_); | |
| 38 } | |
| 39 | |
| 40 bool TabStripMenuController::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 TabStripMenuController::ExecuteCommand(int command_id) { | |
| 56 if (!tab_) | |
|
James Hawkins
2011/05/12 00:53:54
Under what circumstances is |tab_| NULL here?
dpapad
2011/05/12 16:37:08
That was Evan's question I was deferring to you. I
| |
| 57 return; | |
| 58 tab_->delegate()->ExecuteCommandForTab( | |
| 59 static_cast<TabStripModel::ContextMenuCommand>(command_id), tab_); | |
| 60 } | |
| 61 | |
| 62 GtkWidget* TabStripMenuController::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) : | |
|
James Hawkins
2011/05/12 00:53:54
nit: This is somewhat hard to read. I'd not use a
dpapad
2011/05/12 16:37:08
Done.
| |
| 67 NULL; | |
| 68 } | |
| OLD | NEW |