| 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_types.h" | |
| 9 #include "ash/shelf/shelf_alignment_menu.h" | 8 #include "ash/shelf/shelf_alignment_menu.h" |
| 9 #include "ash/shelf/shelf_item_types.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
| 14 | 14 |
| 15 class ChromeLauncherController; | 15 class ChromeLauncherController; |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 class ShelfItemDelegate; | 18 class ShelfItemDelegate; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace aura { | 21 namespace aura { |
| 22 class Window; | 22 class Window; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 class ContextMenuMatcher; | 26 class ContextMenuMatcher; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Context menu shown for a launcher item. | 29 // Context menu shown for a launcher item. |
| 30 class LauncherContextMenu : public ui::SimpleMenuModel, | 30 class LauncherContextMenu : public ui::SimpleMenuModel, |
| 31 public ui::SimpleMenuModel::Delegate { | 31 public ui::SimpleMenuModel::Delegate { |
| 32 public: | 32 public: |
| 33 // |item| is NULL if the context menu is for the launcher (the user right | 33 // |item| is NULL if the context menu is for the launcher (the user right |
| 34 // |clicked on an area with no icons). | 34 // |clicked on an area with no icons). |
| 35 LauncherContextMenu(ChromeLauncherController* controller, | 35 LauncherContextMenu(ChromeLauncherController* controller, |
| 36 const ash::LauncherItem* item, | 36 const ash::ShelfItem* item, |
| 37 aura::Window* root_window); | 37 aura::Window* root_window); |
| 38 | 38 |
| 39 // Creates a menu used by item created by ShelfWindowWatcher. | 39 // Creates a menu used by item created by ShelfWindowWatcher. |
| 40 LauncherContextMenu(ChromeLauncherController* controller, | 40 LauncherContextMenu(ChromeLauncherController* controller, |
| 41 ash::ShelfItemDelegate* item_delegate, | 41 ash::ShelfItemDelegate* item_delegate, |
| 42 ash::LauncherItem* item, | 42 ash::ShelfItem* item, |
| 43 aura::Window* root_window); | 43 aura::Window* root_window); |
| 44 | 44 |
| 45 // Creates a menu used as a desktop context menu on |root_window|. | 45 // Creates a menu used as a desktop context menu on |root_window|. |
| 46 LauncherContextMenu(ChromeLauncherController* controller, | 46 LauncherContextMenu(ChromeLauncherController* controller, |
| 47 aura::Window* root_window); | 47 aura::Window* root_window); |
| 48 virtual ~LauncherContextMenu(); | 48 virtual ~LauncherContextMenu(); |
| 49 | 49 |
| 50 void Init(); | 50 void Init(); |
| 51 | 51 |
| 52 // ID of the item we're showing the context menu for. | 52 // ID of the item we're showing the context menu for. |
| 53 ash::LauncherID id() const { return item_.id; } | 53 ash::ShelfID id() const { return item_.id; } |
| 54 | 54 |
| 55 // ui::SimpleMenuModel::Delegate overrides: | 55 // ui::SimpleMenuModel::Delegate overrides: |
| 56 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | 56 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
| 57 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE; | 57 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
| 58 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 58 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 60 virtual bool GetAcceleratorForCommandId( | 60 virtual bool GetAcceleratorForCommandId( |
| 61 int command_id, | 61 int command_id, |
| 62 ui::Accelerator* accelerator) OVERRIDE; | 62 ui::Accelerator* accelerator) OVERRIDE; |
| 63 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 63 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 MENU_CHANGE_WALLPAPER, | 86 MENU_CHANGE_WALLPAPER, |
| 87 #endif | 87 #endif |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // Does |item_| represent a valid item? See description of constructor for | 90 // Does |item_| represent a valid item? See description of constructor for |
| 91 // details on why it may not be valid. | 91 // details on why it may not be valid. |
| 92 bool is_valid_item() const { return item_.id != 0; } | 92 bool is_valid_item() const { return item_.id != 0; } |
| 93 | 93 |
| 94 ChromeLauncherController* controller_; | 94 ChromeLauncherController* controller_; |
| 95 | 95 |
| 96 ash::LauncherItem item_; | 96 ash::ShelfItem item_; |
| 97 | 97 |
| 98 ash::ShelfAlignmentMenu shelf_alignment_menu_; | 98 ash::ShelfAlignmentMenu shelf_alignment_menu_; |
| 99 | 99 |
| 100 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; | 100 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; |
| 101 | 101 |
| 102 aura::Window* root_window_; | 102 aura::Window* root_window_; |
| 103 | 103 |
| 104 // Not owned. | 104 // Not owned. |
| 105 ash::ShelfItemDelegate* item_delegate_; | 105 ash::ShelfItemDelegate* item_delegate_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); | 107 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ | 110 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ |
| OLD | NEW |