Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / launcher_context_menu.h
blob9995cc61a0dfbe155eb680405c95a418e9b2fa33
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.
5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
8 #include "ash/shelf/shelf_alignment_menu.h"
9 #include "ash/shelf/shelf_item_types.h"
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/base/models/simple_menu_model.h"
15 class ChromeLauncherController;
17 namespace ash {
18 class ShelfItemDelegate;
21 namespace aura {
22 class Window;
25 namespace extensions {
26 class ContextMenuMatcher;
29 // Context menu shown for a launcher item.
30 class LauncherContextMenu : public ui::SimpleMenuModel,
31 public ui::SimpleMenuModel::Delegate {
32 public:
33 // |item| is NULL if the context menu is for the launcher (the user right
34 // |clicked on an area with no icons).
35 LauncherContextMenu(ChromeLauncherController* controller,
36 const ash::ShelfItem* item,
37 aura::Window* root_window);
39 // Creates a menu used by item created by ShelfWindowWatcher.
40 LauncherContextMenu(ChromeLauncherController* controller,
41 ash::ShelfItemDelegate* item_delegate,
42 ash::ShelfItem* item,
43 aura::Window* root_window);
45 // Creates a menu used as a desktop context menu on |root_window|.
46 LauncherContextMenu(ChromeLauncherController* controller,
47 aura::Window* root_window);
48 ~LauncherContextMenu() override;
50 void Init();
52 // ID of the item we're showing the context menu for.
53 ash::ShelfID id() const { return item_.id; }
55 // ui::SimpleMenuModel::Delegate overrides:
56 bool IsItemForCommandIdDynamic(int command_id) const override;
57 base::string16 GetLabelForCommandId(int command_id) const override;
58 bool IsCommandIdChecked(int command_id) const override;
59 bool IsCommandIdEnabled(int command_id) const override;
60 bool GetAcceleratorForCommandId(int command_id,
61 ui::Accelerator* accelerator) override;
62 void ExecuteCommand(int command_id, int event_flags) override;
64 private:
65 FRIEND_TEST_ALL_PREFIXES(
66 LauncherContextMenuTest,
67 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff);
68 FRIEND_TEST_ALL_PREFIXES(
69 LauncherContextMenuTest,
70 NewWindowMenuIsDisabledWhenIncognitoModeForced);
71 FRIEND_TEST_ALL_PREFIXES(
72 LauncherContextMenuTest,
73 AutoHideOptionInMaximizedMode);
75 enum MenuItem {
76 MENU_OPEN_NEW,
77 MENU_CLOSE,
78 MENU_PIN,
79 LAUNCH_TYPE_PINNED_TAB,
80 LAUNCH_TYPE_REGULAR_TAB,
81 LAUNCH_TYPE_FULLSCREEN,
82 LAUNCH_TYPE_WINDOW,
83 MENU_AUTO_HIDE,
84 MENU_NEW_WINDOW,
85 MENU_NEW_INCOGNITO_WINDOW,
86 MENU_ALIGNMENT_MENU,
87 #if defined(OS_CHROMEOS)
88 MENU_CHANGE_WALLPAPER,
89 #endif
92 // Does |item_| represent a valid item? See description of constructor for
93 // details on why it may not be valid.
94 bool is_valid_item() const { return item_.id != 0; }
96 ChromeLauncherController* controller_;
98 ash::ShelfItem item_;
100 ash::ShelfAlignmentMenu shelf_alignment_menu_;
102 scoped_ptr<extensions::ContextMenuMatcher> extension_items_;
104 aura::Window* root_window_;
106 // Not owned.
107 ash::ShelfItemDelegate* item_delegate_;
109 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu);
112 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_