Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ | 5 #ifndef ASH_SHELF_SHELF_ITEM_DELEGATE_H_ |
| 6 #define ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ | 6 #define ASH_SHELF_SHELF_ITEM_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/launcher/launcher_types.h" | |
| 10 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 11 #include "ui/base/models/simple_menu_model.h" | 10 #include "ui/base/models/simple_menu_model.h" |
| 12 | 11 |
| 13 namespace aura { | |
| 14 class RootWindow; | |
| 15 } | |
| 16 | |
| 17 namespace ui { | 12 namespace ui { |
| 18 class Event; | 13 class Event; |
| 19 } | 14 } |
| 20 | 15 |
| 21 namespace ash { | 16 namespace ash { |
| 22 | 17 |
| 23 // A special menu model which keeps track of an "active" menu item. | 18 // A special menu model which keeps track of an "active" menu item. |
| 24 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel { | 19 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel { |
|
tfarina
2013/12/02 18:41:32
Glad you noticed it. I'm two mind, but I think I c
| |
| 25 public: | 20 public: |
| 26 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate) | 21 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate) |
| 27 : ui::SimpleMenuModel(delegate) {} | 22 : ui::SimpleMenuModel(delegate) {} |
| 28 | 23 |
| 29 // Returns |true| when the given |command_id| is active and needs to be drawn | 24 // Returns |true| when the given |command_id| is active and needs to be drawn |
| 30 // in a special state. | 25 // in a special state. |
| 31 virtual bool IsCommandActive(int command_id) const = 0; | 26 virtual bool IsCommandActive(int command_id) const = 0; |
| 32 | 27 |
| 33 private: | 28 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel); | 29 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel); |
| 35 }; | 30 }; |
| 36 | 31 |
| 37 // Delegate for the LauncherItem. | 32 // Delegate for the LauncherItem. |
| 38 class ASH_EXPORT LauncherItemDelegate { | 33 class ASH_EXPORT ShelfItemDelegate { |
| 39 public: | 34 public: |
| 40 virtual ~LauncherItemDelegate() {} | 35 virtual ~ShelfItemDelegate() {} |
| 41 | 36 |
| 42 // Invoked when the user clicks on a window entry in the launcher. | 37 // Invoked when the user clicks on a window entry in the launcher. |
| 43 // |event| is the click event. The |event| is dispatched by a view | 38 // |event| is the click event. The |event| is dispatched by a view |
| 44 // and has an instance of |views::View| as the event target | 39 // and has an instance of |views::View| as the event target |
| 45 // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed | 40 // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed |
| 46 // that this was triggered by keyboard action (Alt+<number>) and special | 41 // that this was triggered by keyboard action (Alt+<number>) and special |
| 47 // handling might happen. | 42 // handling might happen. |
| 48 // Returns true if a new item was created. | 43 // Returns true if a new item was created. |
| 49 virtual bool ItemSelected(const ui::Event& event) = 0; | 44 virtual bool ItemSelected(const ui::Event& event) = 0; |
| 50 | 45 |
| 51 // Returns the title to display. | 46 // Returns the title to display. |
| 52 virtual base::string16 GetTitle() = 0; | 47 virtual base::string16 GetTitle() = 0; |
| 53 | 48 |
| 54 // Returns the context menumodel for the specified item on | 49 // Returns the context menumodel for the specified item on |
| 55 // |root_window|. Return NULL if there should be no context | 50 // |root_window|. Return NULL if there should be no context |
| 56 // menu. The caller takes ownership of the returned model. | 51 // menu. The caller takes ownership of the returned model. |
| 57 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0; | 52 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0; |
| 58 | 53 |
| 59 // Returns the application menu model for the specified item. There are three | 54 // Returns the application menu model for the specified item. There are three |
| 60 // possible return values: | 55 // possible return values: |
| 61 // - A return of NULL indicates that no menu is wanted for this item. | 56 // - A return of NULL indicates that no menu is wanted for this item. |
| 62 // - A return of a menu with one item means that only the name of the | 57 // - A return of a menu with one item means that only the name of the |
| 63 // application/item was added and there are no active applications. | 58 // application/item was added and there are no active applications. |
| 64 // Note: This is useful for hover menus which also show context help. | 59 // Note: This is useful for hover menus which also show context help. |
| 65 // - A list containing the title and the active list of items. | 60 // - A list containing the title and the active list of items. |
| 66 // The caller takes ownership of the returned model. | 61 // The caller takes ownership of the returned model. |
| 67 // |event_flags| specifies the flags of the event which triggered this menu. | 62 // |event_flags| specifies the flags of the event which triggered this menu. |
| 68 virtual ash::LauncherMenuModel* CreateApplicationMenu(int event_flags) = 0; | 63 virtual LauncherMenuModel* CreateApplicationMenu(int event_flags) = 0; |
| 69 | 64 |
| 70 // Whether the launcher item is draggable. | 65 // Whether the launcher item is draggable. |
| 71 virtual bool IsDraggable() = 0; | 66 virtual bool IsDraggable() = 0; |
| 72 | 67 |
| 73 // Returns true if a tooltip should be shown. | 68 // Returns true if a tooltip should be shown. |
| 74 virtual bool ShouldShowTooltip() = 0; | 69 virtual bool ShouldShowTooltip() = 0; |
| 75 }; | 70 }; |
| 76 | 71 |
| 77 } // namespace ash | 72 } // namespace ash |
| 78 | 73 |
| 79 #endif // ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ | 74 #endif // ASH_SHELF_SHELF_ITEM_DELEGATE_H_ |
| OLD | NEW |