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

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: Refactor and comments&inlucdes cleanup 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;
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);
28
29 virtual void Init() = 0;
khmel 2016/03/30 00:58:46 You don't use Init in this class, please remove it
lgcheng 2016/03/30 02:06:25 Done.
31 30
32 // ui::SimpleMenuModel::Delegate overrides: 31 // ui::SimpleMenuModel::Delegate overrides:
33 bool IsItemForCommandIdDynamic(int command_id) const override; 32 bool IsItemForCommandIdDynamic(int command_id) const override;
34 base::string16 GetLabelForCommandId(int command_id) const override; 33 base::string16 GetLabelForCommandId(int command_id) const override;
35 bool IsCommandIdChecked(int command_id) const override; 34 bool IsCommandIdChecked(int command_id) const override;
36 bool IsCommandIdEnabled(int command_id) const override; 35 bool IsCommandIdEnabled(int command_id) const override;
37 bool GetAcceleratorForCommandId(int command_id, 36 bool GetAcceleratorForCommandId(int command_id,
38 ui::Accelerator* accelerator) override; 37 ui::Accelerator* accelerator) override;
39 void ExecuteCommand(int command_id, int event_flags) override; 38 void ExecuteCommand(int command_id, int event_flags) override;
40 39
41 private: 40 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 { 41 enum MenuItem {
53 MENU_OPEN_NEW, 42 MENU_OPEN_NEW,
54 MENU_CLOSE, 43 MENU_CLOSE,
55 MENU_PIN, 44 MENU_PIN,
56 LAUNCH_TYPE_PINNED_TAB, 45 LAUNCH_TYPE_PINNED_TAB,
57 LAUNCH_TYPE_REGULAR_TAB, 46 LAUNCH_TYPE_REGULAR_TAB,
58 LAUNCH_TYPE_FULLSCREEN, 47 LAUNCH_TYPE_FULLSCREEN,
59 LAUNCH_TYPE_WINDOW, 48 LAUNCH_TYPE_WINDOW,
60 MENU_AUTO_HIDE, 49 MENU_AUTO_HIDE,
61 MENU_NEW_WINDOW, 50 MENU_NEW_WINDOW,
62 MENU_NEW_INCOGNITO_WINDOW, 51 MENU_NEW_INCOGNITO_WINDOW,
63 MENU_ALIGNMENT_MENU, 52 MENU_ALIGNMENT_MENU,
64 MENU_CHANGE_WALLPAPER, 53 MENU_CHANGE_WALLPAPER,
65 MENU_ITEM_COUNT 54 MENU_ITEM_COUNT
66 }; 55 };
67 56
57 LauncherContextMenu(ChromeLauncherController* controller,
58 const ash::ShelfItem* item,
59 ash::Shelf* shelf);
60 ChromeLauncherController* controller() const { return controller_; }
61
62 const ash::ShelfItem& item() const { return item_; }
63
64 ash::Shelf* shelf() const { return shelf_; }
65
66 // Add menu item for pin/unpin.
67 void AddPinMenu();
68
69 // Add menu items for autohide mode, alignment and setting wallpaper.
70 void AddAutohideAlignmentWallpaperMenu();
71
72 // Helper method to determind whether a command_id should be handled
73 // by base class.
74 bool IsCommonCommandId(int command_id) const;
75
76 private:
77 FRIEND_TEST_ALL_PREFIXES(
78 LauncherContextMenuTest,
79 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff);
80 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
81 NewWindowMenuIsDisabledWhenIncognitoModeForced);
82 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
83 AutoHideOptionInMaximizedMode);
84 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
85 DesktopShellLauncherContextMenuItemCheck);
86 FRIEND_TEST_ALL_PREFIXES(LauncherContextMenuTest,
87 ArcLauncherContextMenuItemCheck);
88
68 ChromeLauncherController* controller_; 89 ChromeLauncherController* controller_;
69 90
70 ash::ShelfItem item_; 91 ash::ShelfItem item_;
71 92
72 ash::ShelfAlignmentMenu shelf_alignment_menu_; 93 ash::ShelfAlignmentMenu shelf_alignment_menu_;
73 94
74 scoped_ptr<extensions::ContextMenuMatcher> extension_items_;
75
76 ash::Shelf* shelf_; 95 ash::Shelf* shelf_;
77 96
78 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); 97 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu);
79 }; 98 };
80 99
81 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ 100 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698