OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 module ash.mojom; | 5 module ash.mojom; |
6 | 6 |
| 7 import "mojo/common/string16.mojom"; |
7 import "skia/public/interfaces/bitmap.mojom"; | 8 import "skia/public/interfaces/bitmap.mojom"; |
| 9 import "ui/events/mojo/event.mojom"; |
| 10 |
| 11 // The actions that may be performed when a shelf item is selected. |
| 12 // These values match ash::ShelfAction. |
| 13 enum ShelfAction { |
| 14 NONE, // No action was taken. |
| 15 WINDOW_CREATED, // A new window was created. |
| 16 WINDOW_ACTIVATED, // An existing inactive window was activated. |
| 17 WINDOW_MINIMIZED, // The currently active window was minimized. |
| 18 APP_LIST_SHOWN, // The app list launcher menu was shown. |
| 19 }; |
8 | 20 |
9 // These values match ash::ShelfAlignment. | 21 // These values match ash::ShelfAlignment. |
10 enum ShelfAlignment { BOTTOM, LEFT, RIGHT, BOTTOM_LOCKED, }; | 22 enum ShelfAlignment { BOTTOM, LEFT, RIGHT, BOTTOM_LOCKED, }; |
11 | 23 |
12 // These values match ash::ShelfAutoHideBehavior. | 24 // These values match ash::ShelfAutoHideBehavior. |
13 enum ShelfAutoHideBehavior { ALWAYS, NEVER, HIDDEN, }; | 25 enum ShelfAutoHideBehavior { ALWAYS, NEVER, HIDDEN, }; |
14 | 26 |
| 27 // Source of the launch or activation request, for tracking. |
| 28 // These values match ash::ShelfLaunchSource. |
| 29 enum ShelfLaunchSource { |
| 30 UNKNOWN, // The item was launched from outside the app list. |
| 31 APP_LIST, // The item was launched from a generic app list view. |
| 32 APP_LIST_SEARCH, // The item was launched from an app list search view. |
| 33 }; |
| 34 |
15 // The Shelf controller allows clients (eg. Chrome) to control the ash shelf. | 35 // The Shelf controller allows clients (eg. Chrome) to control the ash shelf. |
16 interface ShelfController { | 36 interface ShelfController { |
17 // Observers are immediately notified of the current shelf states when added. | 37 // Observers are immediately notified of the current shelf states when added. |
18 AddObserver(associated ShelfObserver observer); | 38 AddObserver(associated ShelfObserver observer); |
19 | 39 |
20 // Set the shelf alignment and auto-hide behavior. See WmShelf for details. | 40 // Set the shelf alignment and auto-hide behavior. See WmShelf for details. |
21 SetAlignment(ShelfAlignment alignment, int64 display_id); | 41 SetAlignment(ShelfAlignment alignment, int64 display_id); |
22 SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, int64 display_id); | 42 SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, int64 display_id); |
23 | 43 |
24 // Pin and unpin items on the shelf, or update shelf item images. | 44 // Pin and unpin items on the shelf, or update shelf item images. |
25 PinItem(ShelfItem item, associated ShelfItemDelegate delegate); | 45 PinItem(ShelfItem item, associated ShelfItemDelegate delegate); |
26 UnpinItem(string app_id); | 46 UnpinItem(string app_id); |
27 SetItemImage(string app_id, skia.mojom.Bitmap image); | 47 SetItemImage(string app_id, skia.mojom.Bitmap image); |
28 }; | 48 }; |
29 | 49 |
30 // ShelfObserver is notified on shelf changes; used to persist profile settings. | 50 // ShelfObserver is notified on shelf changes; used to persist profile settings. |
31 interface ShelfObserver { | 51 interface ShelfObserver { |
32 OnShelfCreated(int64 display_id); | 52 OnShelfCreated(int64 display_id); |
33 OnAlignmentChanged(ShelfAlignment alignment, int64 display_id); | 53 OnAlignmentChanged(ShelfAlignment alignment, int64 display_id); |
34 OnAutoHideBehaviorChanged(ShelfAutoHideBehavior auto_hide, int64 display_id); | 54 OnAutoHideBehaviorChanged(ShelfAutoHideBehavior auto_hide, int64 display_id); |
35 }; | 55 }; |
36 | 56 |
37 // ShelfItemDelegate handles command execution and observes shelf item changes. | 57 // ShelfItemDelegate handles shelf item selection, menu command execution, etc. |
38 interface ShelfItemDelegate { | 58 interface ShelfItemDelegate { |
39 // Called when a pinned shelf item is invoked without an open window. | 59 // Called when the user selects a shelf item. The event, display, and source |
40 LaunchItem(); | 60 // info should be provided if known; some implementations use these arguments. |
| 61 // Defaults: (nullptr, kInvalidDisplayId, LAUNCH_FROM_UNKNOWN) |
| 62 // The callback reports the action taken and any app menu items to show. |
| 63 // |
| 64 // NOTE: This codepath is not currently used for context menu triggering. |
| 65 // TODO(msw): Remove |display_id| once panels are removed. crbug.com/691099 |
| 66 ItemSelected(ui.mojom.Event event, |
| 67 int64 display_id, |
| 68 ShelfLaunchSource source) => (ShelfAction action, |
| 69 array<MenuItem>? menu_items); |
41 | 70 |
42 // Called on invocation of a shelf item's context menu command. | 71 // Called on invocation of a shelf item's context or application menu command. |
43 ExecuteCommand(uint32 command_id, int32 event_flags); | 72 ExecuteCommand(uint32 command_id, int32 event_flags); |
44 | 73 |
45 // Called when a shelf item is pinned or unpinned. | 74 // Closes all windows associated with this shelf item. |
46 ItemPinned(); | 75 Close(); |
47 ItemUnpinned(); | |
48 | |
49 // Called when a pinned shelf item is reordered. | |
50 // |order| is the index of the item on the shelf. | |
51 ItemReordered(uint32 order); | |
52 }; | 76 }; |
53 | 77 |
54 // ContextMenuItems may be used to supplement ash shelf item context menus. | 78 // MenuItems are used to populate application menus for shelf items. |
55 struct ContextMenuItem { | 79 // Note: Some menus only support a subset of these item features (eg. no icons). |
| 80 // Note: These are not yet used for shelf item or ash shell context menus. |
| 81 struct MenuItem { |
56 enum Type { ITEM, CHECK, RADIO, SEPARATOR, SUBMENU }; | 82 enum Type { ITEM, CHECK, RADIO, SEPARATOR, SUBMENU }; |
57 | 83 |
58 Type type; | 84 Type type; // The type of the menu item. |
59 uint32 command_id; | 85 uint32 command_id; // The client's arbitrary item command id. |
60 string? label; | 86 mojo.common.mojom.String16 label; // The string label, may be empty. |
61 array<ContextMenuItem>? submenu; | 87 skia.mojom.Bitmap image; // The image icon, may be null. |
62 bool enabled; | 88 array<MenuItem>? submenu; // The optional nested submenu item list. |
63 bool checked; | 89 bool enabled; // The enabled state. |
64 uint32 radio_group_id; | 90 bool checked; // The checked state. |
| 91 uint32 radio_group_id; // The radio group id. |
65 }; | 92 }; |
66 | 93 |
67 // ShelfItem contains the basic fields needed to pin shortcut items. | 94 // ShelfItem contains the basic fields needed to pin shortcut items. |
68 struct ShelfItem { | 95 struct ShelfItem { |
69 // An app id, used to correlate windows and shortcuts (eg. 'mojo:foo'). | 96 // An app id, used to correlate windows and shortcuts (eg. 'mojo:foo'). |
70 string app_id; | 97 string app_id; |
71 | 98 |
72 // A app title, used for tooltips, etc. (eg. 'Foo Application'). | 99 // A app title, used for tooltips, etc. (eg. 'Foo Application'). |
73 string app_title; | 100 string app_title; |
74 | 101 |
75 // An icon image Bitmap, shown on the shelf. | 102 // An icon image Bitmap, shown on the shelf. |
76 skia.mojom.Bitmap image; | 103 skia.mojom.Bitmap image; |
77 | 104 |
78 // Additional context menu items (eg. 'New Incognito Window'). | 105 // Additional context menu items (eg. 'New Incognito Window'). |
79 array<ContextMenuItem>? context_menu_items; | 106 array<MenuItem>? context_menu_items; |
80 }; | 107 }; |
OLD | NEW |