Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/launcher/launcher_alignment_menu.h" | 8 #include "ash/launcher/launcher_alignment_menu.h" |
| 9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 | 13 |
| 14 class ChromeLauncherController; | 14 class ChromeLauncherController; |
| 15 | 15 |
| 16 namespace aura { | 16 namespace aura { |
| 17 class RootWindow; | 17 class RootWindow; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 class ContextMenuMatcher; | 21 class ContextMenuMatcher; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // Context menu shown for a launcher item. | 24 // Context menu shown for a launcher item. |
| 25 class LauncherContextMenu : public ui::SimpleMenuModel, | 25 class LauncherContextMenu : public ui::SimpleMenuModel, |
| 26 public ui::SimpleMenuModel::Delegate { | 26 public ui::SimpleMenuModel::Delegate { |
| 27 public: | 27 public: |
| 28 enum MenuItem { | |
|
sky
2013/01/14 16:03:37
I don't like making these public just for a test,
rustema
2013/01/15 07:37:40
Done.
| |
| 29 MENU_OPEN_NEW, | |
| 30 MENU_CLOSE, | |
| 31 MENU_PIN, | |
| 32 LAUNCH_TYPE_PINNED_TAB, | |
| 33 LAUNCH_TYPE_REGULAR_TAB, | |
| 34 LAUNCH_TYPE_FULLSCREEN, | |
| 35 LAUNCH_TYPE_WINDOW, | |
| 36 MENU_AUTO_HIDE, | |
| 37 MENU_NEW_WINDOW, | |
| 38 MENU_NEW_INCOGNITO_WINDOW, | |
| 39 MENU_ALIGNMENT_MENU, | |
| 40 MENU_CHANGE_WALLPAPER, | |
| 41 }; | |
| 28 // |item| is NULL if the context menu is for the launcher (the user right | 42 // |item| is NULL if the context menu is for the launcher (the user right |
| 29 // |clicked on an area with no icons). | 43 // |clicked on an area with no icons). |
| 30 LauncherContextMenu(ChromeLauncherController* controller, | 44 LauncherContextMenu(ChromeLauncherController* controller, |
| 31 const ash::LauncherItem* item, | 45 const ash::LauncherItem* item, |
| 32 aura::RootWindow* root_window); | 46 aura::RootWindow* root_window); |
| 33 // Creates a menu used as a desktop context menu on |root_window|. | 47 // Creates a menu used as a desktop context menu on |root_window|. |
| 34 LauncherContextMenu(ChromeLauncherController* controller, | 48 LauncherContextMenu(ChromeLauncherController* controller, |
| 35 aura::RootWindow* root_window); | 49 aura::RootWindow* root_window); |
| 36 virtual ~LauncherContextMenu(); | 50 virtual ~LauncherContextMenu(); |
| 37 | 51 |
| 38 void Init(); | 52 void Init(); |
| 39 | 53 |
| 40 // ID of the item we're showing the context menu for. | 54 // ID of the item we're showing the context menu for. |
| 41 ash::LauncherID id() const { return item_.id; } | 55 ash::LauncherID id() const { return item_.id; } |
| 42 | 56 |
| 43 // ui::SimpleMenuModel::Delegate overrides: | 57 // ui::SimpleMenuModel::Delegate overrides: |
| 44 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | 58 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
| 45 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; | 59 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
| 46 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 60 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 47 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 61 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 48 virtual bool GetAcceleratorForCommandId( | 62 virtual bool GetAcceleratorForCommandId( |
| 49 int command_id, | 63 int command_id, |
| 50 ui::Accelerator* accelerator) OVERRIDE; | 64 ui::Accelerator* accelerator) OVERRIDE; |
| 51 virtual void ExecuteCommand(int command_id) OVERRIDE; | 65 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 52 | 66 |
| 53 private: | 67 private: |
| 54 enum MenuItem { | |
| 55 MENU_OPEN_NEW, | |
| 56 MENU_CLOSE, | |
| 57 MENU_PIN, | |
| 58 LAUNCH_TYPE_PINNED_TAB, | |
| 59 LAUNCH_TYPE_REGULAR_TAB, | |
| 60 LAUNCH_TYPE_FULLSCREEN, | |
| 61 LAUNCH_TYPE_WINDOW, | |
| 62 MENU_AUTO_HIDE, | |
| 63 MENU_NEW_WINDOW, | |
| 64 MENU_NEW_INCOGNITO_WINDOW, | |
| 65 MENU_ALIGNMENT_MENU, | |
| 66 MENU_CHANGE_WALLPAPER, | |
| 67 }; | |
| 68 | |
| 69 // Does |item_| represent a valid item? See description of constructor for | 68 // Does |item_| represent a valid item? See description of constructor for |
| 70 // details on why it may not be valid. | 69 // details on why it may not be valid. |
| 71 bool is_valid_item() const { return item_.id != 0; } | 70 bool is_valid_item() const { return item_.id != 0; } |
| 72 | 71 |
| 73 ChromeLauncherController* controller_; | 72 ChromeLauncherController* controller_; |
| 74 | 73 |
| 75 ash::LauncherItem item_; | 74 ash::LauncherItem item_; |
| 76 | 75 |
| 77 ash::LauncherAlignmentMenu launcher_alignment_menu_; | 76 ash::LauncherAlignmentMenu launcher_alignment_menu_; |
| 78 | 77 |
| 79 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; | 78 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; |
| 80 | 79 |
| 81 aura::RootWindow* root_window_; | 80 aura::RootWindow* root_window_; |
| 82 | 81 |
| 83 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); | 82 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ | 85 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ |
| OLD | NEW |