Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "ash/desktop_background/user_wallpaper_delegate.h" | |
| 10 #include "ash/shelf/shelf.h" | |
| 11 #include "ash/shelf/shelf_item_types.h" | |
| 12 #include "ash/shell.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | |
| 15 #include "chrome/common/pref_names.h" | |
| 16 #include "chrome/grit/generated_resources.h" | |
| 17 #include "grit/ash_strings.h" | |
| 18 #include "ui/base/l10n/l10n_util.h" | |
| 19 | |
| 20 ArcLauncherContextMenu::ArcLauncherContextMenu( | |
| 21 ChromeLauncherController* controller, | |
| 22 const ash::ShelfItem* item, | |
| 23 ash::Shelf* shelf) | |
| 24 : LauncherContextMenu(controller, item, shelf) { | |
| 25 Init(); | |
| 26 } | |
| 27 | |
| 28 ArcLauncherContextMenu::~ArcLauncherContextMenu() {} | |
| 29 | |
| 30 void ArcLauncherContextMenu::Init() { | |
| 31 AddItem(MENU_OPEN_NEW, | |
| 32 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_ACTIVATE_ARC)); | |
| 33 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 34 AddPinMenu(); | |
| 35 if (controller()->IsOpen(item().id)) | |
| 36 AddItem(MENU_CLOSE, | |
| 37 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | |
| 38 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 39 AddAutohideAlignmentWallpaperMenu(); | |
| 40 } | |
| 41 | |
| 42 base::string16 ArcLauncherContextMenu::GetLabelForCommandId( | |
| 43 int command_id) const { | |
| 44 if (command_id == MENU_OPEN_NEW) | |
| 45 return l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_ACTIVATE_ARC); | |
|
khmel
2016/03/29 20:31:27
Why do you need return label here? it is already s
lgcheng
2016/03/29 22:02:16
Done.
| |
| 46 NOTREACHED(); | |
| 47 return base::string16(); | |
| 48 } | |
| 49 | |
| 50 bool ArcLauncherContextMenu::IsCommandIdEnabled(int command_id) const { | |
| 51 switch (command_id) { | |
| 52 case MENU_OPEN_NEW: | |
| 53 return true; | |
| 54 case MENU_CLOSE: | |
| 55 return controller()->IsOpen(item().id); | |
|
khmel
2016/03/29 20:31:27
Why not to handle it in base class?
MENU_CLOSE, M
lgcheng
2016/03/29 22:02:16
Reimplemented
| |
| 56 case MENU_PIN: | |
| 57 return controller()->IsPinnable(item().id); | |
| 58 case MENU_CHANGE_WALLPAPER: | |
| 59 return ash::Shell::GetInstance() | |
| 60 ->user_wallpaper_delegate() | |
| 61 ->CanOpenSetWallpaperPage(); | |
| 62 case MENU_AUTO_HIDE: | |
| 63 return CanUserModifyShelfAutoHideBehavior(); | |
| 64 case MENU_ALIGNMENT_MENU: | |
| 65 return true; | |
| 66 default: | |
| 67 NOTREACHED(); | |
| 68 return false; | |
| 69 } | |
| 70 } | |
| OLD | NEW |