Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_context_menu.h

Issue 1838263002: Arc app integration in shelf launcher context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Issue Correction Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
7 7
8 #include "ash/shelf/shelf_alignment_menu.h" 8 #include "ash/shelf/shelf_alignment_menu.h"
9 #include "ash/shelf/shelf_item_types.h" 9 #include "ash/shelf/shelf_item_types.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/base/models/simple_menu_model.h" 12 #include "ui/base/models/simple_menu_model.h"
14 13
15 class ChromeLauncherController; 14 class ChromeLauncherController;
khmel 2016/03/31 18:23:12 nit: do we need namespace ash { class Shelf; } It
lgcheng 2016/03/31 21:15:19 Done.
16 15
17 namespace extensions { 16 // Abstract class for context menu which is shown for a regular extension item
18 class ContextMenuMatcher; 17 // in the shelf, or for an Arc app item in the shelf, or shown when right click
19 } 18 // on desktop shell.
20
21 // Context menu shown for the ash shell desktop, or for an item in the shelf.
22 class LauncherContextMenu : public ui::SimpleMenuModel, 19 class LauncherContextMenu : public ui::SimpleMenuModel,
23 public ui::SimpleMenuModel::Delegate { 20 public ui::SimpleMenuModel::Delegate {
24 public: 21 public:
25 LauncherContextMenu(ChromeLauncherController* controller,
26 const ash::ShelfItem* item,
27 ash::Shelf* shelf);
28 ~LauncherContextMenu() override; 22 ~LauncherContextMenu() override;
29 23
30 void Init(); 24 // Static function to create contextmenu instance.
25 static LauncherContextMenu* Create(ChromeLauncherController* controller,
26 const ash::ShelfItem* item,
27 ash::Shelf* shelf);
31 28
32 // ui::SimpleMenuModel::Delegate overrides: 29 // ui::SimpleMenuModel::Delegate overrides:
33 bool IsItemForCommandIdDynamic(int command_id) const override; 30 bool IsItemForCommandIdDynamic(int command_id) const override;
34 base::string16 GetLabelForCommandId(int command_id) const override; 31 base::string16 GetLabelForCommandId(int command_id) const override;
35 bool IsCommandIdChecked(int command_id) const override; 32 bool IsCommandIdChecked(int command_id) const override;
36 bool IsCommandIdEnabled(int command_id) const override; 33 bool IsCommandIdEnabled(int command_id) const override;
37 bool GetAcceleratorForCommandId(int command_id, 34 bool GetAcceleratorForCommandId(int command_id,
38 ui::Accelerator* accelerator) override; 35 ui::Accelerator* accelerator) override;
39 void ExecuteCommand(int command_id, int event_flags) override; 36 void ExecuteCommand(int command_id, int event_flags) override;
40 37
41 private: 38 protected:
42 FRIEND_TEST_ALL_PREFIXES(
43 LauncherContextMenuTest,
44 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff);
45 FRIEND_TEST_ALL_PREFIXES(
46 LauncherContextMenuTest,
47 NewWindowMenuIsDisabledWhenIncognitoModeForced);
48 FRIEND_TEST_ALL_PREFIXES(
49 LauncherContextMenuTest,
50 AutoHideOptionInMaximizedMode);
51
52 enum MenuItem { 39 enum MenuItem {
53 MENU_OPEN_NEW, 40 MENU_OPEN_NEW,
54 MENU_CLOSE, 41 MENU_CLOSE,
55 MENU_PIN, 42 MENU_PIN,
56 LAUNCH_TYPE_PINNED_TAB, 43 LAUNCH_TYPE_PINNED_TAB,
57 LAUNCH_TYPE_REGULAR_TAB, 44 LAUNCH_TYPE_REGULAR_TAB,
58 LAUNCH_TYPE_FULLSCREEN, 45 LAUNCH_TYPE_FULLSCREEN,
59 LAUNCH_TYPE_WINDOW, 46 LAUNCH_TYPE_WINDOW,
60 MENU_AUTO_HIDE, 47 MENU_AUTO_HIDE,
61 MENU_NEW_WINDOW, 48 MENU_NEW_WINDOW,
62 MENU_NEW_INCOGNITO_WINDOW, 49 MENU_NEW_INCOGNITO_WINDOW,
63 MENU_ALIGNMENT_MENU, 50 MENU_ALIGNMENT_MENU,
64 MENU_CHANGE_WALLPAPER, 51 MENU_CHANGE_WALLPAPER,
65 MENU_ITEM_COUNT 52 MENU_ITEM_COUNT
66 }; 53 };
67 54
55 LauncherContextMenu(ChromeLauncherController* controller,
56 const ash::ShelfItem* item,
57 ash::Shelf* shelf);
58 ChromeLauncherController* controller() const { return controller_; }
59
60 const ash::ShelfItem& item() const { return item_; }
61
62 ash::Shelf* shelf() const { return shelf_; }
63
64 // Add menu item for pin/unpin.
65 void AddPinMenu();
66
67 // Add menu items for autohide mode, alignment and setting wallpaper.
68 void AddAutohideAlignmentWallpaperMenu();
69
70 // Helper method to determine whether a command_id should be handled
71 // by base class.
72 bool IsCommonCommandId(int command_id) const;
73
74 private:
75 FRIEND_TEST_ALL_PREFIXES(
76 LauncherContextMenuTest,
77 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff);
78 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
79 NewWindowMenuIsDisabledWhenIncognitoModeForced);
80 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
81 AutoHideOptionInMaximizedMode);
82 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
83 DesktopShellLauncherContextMenuItemCheck);
84 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
85 ArcLauncherContextMenuItemCheck);
86
68 ChromeLauncherController* controller_; 87 ChromeLauncherController* controller_;
69 88
70 ash::ShelfItem item_; 89 ash::ShelfItem item_;
71 90
72 ash::ShelfAlignmentMenu shelf_alignment_menu_; 91 ash::ShelfAlignmentMenu shelf_alignment_menu_;
73 92
74 scoped_ptr<extensions::ContextMenuMatcher> extension_items_;
75
76 ash::Shelf* shelf_; 93 ash::Shelf* shelf_;
77 94
78 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); 95 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu);
79 }; 96 };
80 97
81 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ 98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698