| 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 "ash/shell_context_menu.h" |
| 6 |
| 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "ash/shell.h" |
| 9 #include "grit/ash_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" |
| 11 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 12 #include "ui/views/controls/menu/menu_runner.h" |
| 13 |
| 14 namespace ash { |
| 15 namespace internal { |
| 16 |
| 17 ShellContextMenu::ShellContextMenu() { |
| 18 } |
| 19 |
| 20 ShellContextMenu::~ShellContextMenu() { |
| 21 } |
| 22 |
| 23 void ShellContextMenu::ShowMenu(views::Widget* widget, |
| 24 const gfx::Point& location) { |
| 25 if (!Shell::GetInstance()->user_wallpaper_delegate()-> |
| 26 CanOpenSetWallpaperPage()) |
| 27 return; |
| 28 ui::SimpleMenuModel menu_model(this); |
| 29 menu_model.AddItem(MENU_CHANGE_WALLPAPER, |
| 30 l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER)); |
| 31 views::MenuModelAdapter menu_model_adapter(&menu_model); |
| 32 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); |
| 33 if (menu_runner_->RunMenuAt( |
| 34 widget, NULL, gfx::Rect(location, gfx::Size()), |
| 35 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == |
| 36 views::MenuRunner::MENU_DELETED) |
| 37 return; |
| 38 } |
| 39 |
| 40 bool ShellContextMenu::IsCommandIdChecked(int command_id) const { |
| 41 return false; |
| 42 } |
| 43 |
| 44 bool ShellContextMenu::IsCommandIdEnabled(int command_id) const { |
| 45 return true; |
| 46 } |
| 47 |
| 48 void ShellContextMenu::ExecuteCommand(int command_id) { |
| 49 switch (static_cast<MenuItem>(command_id)) { |
| 50 case MENU_CHANGE_WALLPAPER: { |
| 51 Shell::GetInstance()->user_wallpaper_delegate()-> |
| 52 OpenSetWallpaperPage(); |
| 53 break; |
| 54 } |
| 55 } |
| 56 } |
| 57 |
| 58 bool ShellContextMenu::GetAcceleratorForCommandId( |
| 59 int command_id, |
| 60 ui::Accelerator* accelerator) { |
| 61 return false; |
| 62 } |
| 63 |
| 64 } // namespace internal |
| 65 } // namespace ash |
| OLD | NEW |