OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/mus/context_menu_mus.h" |
| 6 |
| 7 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_types.h" |
| 10 #include "ash/shell.h" |
| 11 #include "grit/ash_strings.h" |
| 12 |
| 13 namespace ash { |
| 14 |
| 15 ContextMenuMus::ContextMenuMus(ash::Shelf* shelf) |
| 16 : ui::SimpleMenuModel(nullptr), shelf_(shelf), alignment_menu_(shelf) { |
| 17 DCHECK(shelf_); |
| 18 set_delegate(this); |
| 19 AddCheckItemWithStringId(MENU_AUTO_HIDE, |
| 20 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); |
| 21 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, |
| 22 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, &alignment_menu_); |
| 23 #if defined(OS_CHROMEOS) |
| 24 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); |
| 25 #endif |
| 26 } |
| 27 |
| 28 ContextMenuMus::~ContextMenuMus() {} |
| 29 |
| 30 bool ContextMenuMus::IsCommandIdChecked(int command_id) const { |
| 31 if (command_id == MENU_AUTO_HIDE) |
| 32 return shelf_->GetAutoHideBehavior() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
| 33 return false; |
| 34 } |
| 35 |
| 36 bool ContextMenuMus::IsCommandIdEnabled(int command_id) const { |
| 37 Shell* shell = Shell::GetInstance(); |
| 38 if (command_id == MENU_CHANGE_WALLPAPER) |
| 39 return shell->user_wallpaper_delegate()->CanOpenSetWallpaperPage(); |
| 40 return true; |
| 41 } |
| 42 |
| 43 bool ContextMenuMus::GetAcceleratorForCommandId(int command_id, |
| 44 ui::Accelerator* accelerator) { |
| 45 return false; |
| 46 } |
| 47 |
| 48 void ContextMenuMus::ExecuteCommand(int command_id, int event_flags) { |
| 49 if (command_id == MENU_AUTO_HIDE) { |
| 50 shelf_->SetAutoHideBehavior(shelf_->GetAutoHideBehavior() == |
| 51 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS |
| 52 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
| 53 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 54 } else if (command_id == MENU_CHANGE_WALLPAPER) { |
| 55 Shell::GetInstance()->user_wallpaper_delegate()->OpenSetWallpaperPage(); |
| 56 } |
| 57 } |
| 58 |
| 59 } // namespace ash |
OLD | NEW |