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_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ | 5 #ifndef ASH_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ |
| 6 #define ASH_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ | 6 #define ASH_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/public/cpp/shelf_application_menu_item.h" | |
| 12 #include "ash/public/cpp/shelf_types.h" | 11 #include "ash/public/cpp/shelf_types.h" |
| 12 #include "ash/public/interfaces/shelf.mojom.h" | |
| 13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 // Delegate for the ShelfItem. | 17 // An abstract delegate for shelf items; see the mojo interface definition. |
| 18 class ASH_EXPORT ShelfItemDelegate { | 18 class ASH_EXPORT ShelfItemDelegate : public mojom::ShelfItemDelegate { |
| 19 public: | 19 public: |
| 20 using MenuItemList = std::vector<mojom::MenuItemPtr>; | |
| 21 | |
| 20 ShelfItemDelegate(); | 22 ShelfItemDelegate(); |
| 21 virtual ~ShelfItemDelegate(); | 23 ~ShelfItemDelegate() override; |
| 22 | 24 |
| 23 // Called when the user selects a shelf item. The event type and flags, the | 25 // Calls ItemSelected with |source|, default arguments, and no callback. |
| 24 // relevant display id, and the source of the selection should be provided if | 26 void ItemSelectedBySource(ShelfLaunchSource source); |
|
James Cook
2017/03/09 01:09:46
Does this class exist just to provide this method?
msw
2017/03/10 06:17:56
Done.
| |
| 25 // they are known to the caller; as some subclasses use these arguments. | |
| 26 // Defaults: (ET_UNKNOWN, EF_NONE, kInvalidDisplayId, LAUNCH_FROM_UNKNOWN) | |
| 27 // Returns the action performed by selecting the item. | |
| 28 virtual ShelfAction ItemSelected(ui::EventType event_type, | |
| 29 int event_flags, | |
| 30 int64_t display_id, | |
| 31 ShelfLaunchSource source) = 0; | |
| 32 | |
| 33 // A helper to call ItemSelected with a source and default arguments. | |
| 34 ShelfAction ItemSelectedBySource(ShelfLaunchSource source); | |
| 35 | |
| 36 // Returns any application menu items that should appear for this shelf item. | |
| 37 // |event_flags| specifies the flags of the event which triggered this menu. | |
| 38 virtual ShelfAppMenuItemList GetAppMenuItems(int event_flags) = 0; | |
| 39 | |
| 40 // Called on invocation of a shelf item's application menu command. | |
| 41 virtual void ExecuteCommand(uint32_t command_id, int event_flags) = 0; | |
| 42 | |
| 43 // Closes all windows associated with this item. | |
| 44 virtual void Close() = 0; | |
| 45 | 27 |
| 46 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegate); | 28 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegate); |
| 47 }; | 29 }; |
| 48 | 30 |
| 49 } // namespace ash | 31 } // namespace ash |
| 50 | 32 |
| 51 #endif // ASH_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ | 33 #endif // ASH_COMMON_SHELF_SHELF_ITEM_DELEGATE_H_ |
| OLD | NEW |