| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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/views/aura/launcher/launcher_context_menu.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.h" | |
| 8 #include "grit/generated_resources.h" | |
| 9 #include "ui/base/l10n/l10n_util.h" | |
| 10 | |
| 11 LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate, | |
| 12 ash::LauncherID id) | |
| 13 : ui::SimpleMenuModel(NULL), | |
| 14 delegate_(delegate), | |
| 15 id_(id) { | |
| 16 set_delegate(this); | |
| 17 ash::LauncherItem item; | |
| 18 item.id = id; | |
| 19 AddItem(MENU_OPEN, | |
| 20 delegate->GetTitle(item)); | |
| 21 AddItem(MENU_PIN, | |
| 22 delegate->IsPinned(id) ? | |
| 23 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN) : | |
| 24 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN)); | |
| 25 if (delegate->IsOpen(id)) { | |
| 26 AddItem(MENU_CLOSE, | |
| 27 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 LauncherContextMenu::~LauncherContextMenu() { | |
| 32 } | |
| 33 | |
| 34 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { | |
| 35 return false; | |
| 36 } | |
| 37 | |
| 38 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { | |
| 39 switch (static_cast<MenuItem>(command_id)) { | |
| 40 case MENU_OPEN: | |
| 41 return true; | |
| 42 case MENU_CLOSE: | |
| 43 return true; | |
| 44 case MENU_PIN: | |
| 45 return delegate_->IsPinnable(id_); | |
| 46 } | |
| 47 return false; | |
| 48 } | |
| 49 | |
| 50 bool LauncherContextMenu::GetAcceleratorForCommandId( | |
| 51 int command_id, | |
| 52 ui::Accelerator* accelerator) { | |
| 53 return false; | |
| 54 } | |
| 55 | |
| 56 void LauncherContextMenu::ExecuteCommand(int command_id) { | |
| 57 switch (static_cast<MenuItem>(command_id)) { | |
| 58 case MENU_OPEN: | |
| 59 delegate_->Open(id_); | |
| 60 break; | |
| 61 case MENU_CLOSE: | |
| 62 delegate_->Close(id_); | |
| 63 break; | |
| 64 case MENU_PIN: | |
| 65 delegate_->TogglePinned(id_); | |
| 66 break; | |
| 67 } | |
| 68 } | |
| OLD | NEW |