OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | |
6 #define ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | |
7 | |
8 #include "ash/public/cpp/shelf_types.h" | |
9 #include "ash/public/interfaces/shelf.mojom.h" | |
10 | |
11 namespace mojo { | |
12 | |
13 template <> | |
14 struct EnumTraits<ash::mojom::ShelfAction, ash::ShelfAction> { | |
15 static ash::mojom::ShelfAction ToMojom(ash::ShelfAction input) { | |
16 switch (input) { | |
17 case ash::SHELF_ACTION_NONE: | |
18 return ash::mojom::ShelfAction::NONE; | |
19 case ash::SHELF_ACTION_NEW_WINDOW_CREATED: | |
20 return ash::mojom::ShelfAction::WINDOW_CREATED; | |
21 case ash::SHELF_ACTION_WINDOW_ACTIVATED: | |
22 return ash::mojom::ShelfAction::WINDOW_ACTIVATED; | |
23 case ash::SHELF_ACTION_WINDOW_MINIMIZED: | |
24 return ash::mojom::ShelfAction::WINDOW_MINIMIZED; | |
25 case ash::SHELF_ACTION_APP_LIST_SHOWN: | |
26 return ash::mojom::ShelfAction::APP_LIST_SHOWN; | |
27 } | |
28 NOTREACHED(); | |
29 return ash::mojom::ShelfAction::NONE; | |
30 } | |
31 | |
32 static bool FromMojom(ash::mojom::ShelfAction input, ash::ShelfAction* out) { | |
33 switch (input) { | |
34 case ash::mojom::ShelfAction::NONE: | |
35 *out = ash::SHELF_ACTION_NONE; | |
36 return true; | |
37 case ash::mojom::ShelfAction::WINDOW_CREATED: | |
38 *out = ash::SHELF_ACTION_NEW_WINDOW_CREATED; | |
39 return true; | |
40 case ash::mojom::ShelfAction::WINDOW_ACTIVATED: | |
41 *out = ash::SHELF_ACTION_WINDOW_ACTIVATED; | |
42 return true; | |
43 case ash::mojom::ShelfAction::WINDOW_MINIMIZED: | |
44 *out = ash::SHELF_ACTION_WINDOW_MINIMIZED; | |
45 return true; | |
46 case ash::mojom::ShelfAction::APP_LIST_SHOWN: | |
47 *out = ash::SHELF_ACTION_APP_LIST_SHOWN; | |
48 return true; | |
49 } | |
50 NOTREACHED(); | |
51 return false; | |
52 } | |
53 }; | |
54 | |
55 template <> | |
56 struct EnumTraits<ash::mojom::ShelfAlignment, ash::ShelfAlignment> { | |
57 static ash::mojom::ShelfAlignment ToMojom(ash::ShelfAlignment input) { | |
58 switch (input) { | |
59 case ash::SHELF_ALIGNMENT_BOTTOM: | |
60 return ash::mojom::ShelfAlignment::BOTTOM; | |
61 case ash::SHELF_ALIGNMENT_LEFT: | |
62 return ash::mojom::ShelfAlignment::LEFT; | |
63 case ash::SHELF_ALIGNMENT_RIGHT: | |
64 return ash::mojom::ShelfAlignment::RIGHT; | |
65 case ash::SHELF_ALIGNMENT_BOTTOM_LOCKED: | |
66 return ash::mojom::ShelfAlignment::BOTTOM_LOCKED; | |
67 } | |
68 NOTREACHED(); | |
69 return ash::mojom::ShelfAlignment::BOTTOM; | |
70 } | |
71 | |
72 static bool FromMojom(ash::mojom::ShelfAlignment input, | |
73 ash::ShelfAlignment* out) { | |
74 switch (input) { | |
75 case ash::mojom::ShelfAlignment::BOTTOM: | |
76 *out = ash::SHELF_ALIGNMENT_BOTTOM; | |
77 return true; | |
78 case ash::mojom::ShelfAlignment::LEFT: | |
79 *out = ash::SHELF_ALIGNMENT_LEFT; | |
80 return true; | |
81 case ash::mojom::ShelfAlignment::RIGHT: | |
82 *out = ash::SHELF_ALIGNMENT_RIGHT; | |
83 return true; | |
84 case ash::mojom::ShelfAlignment::BOTTOM_LOCKED: | |
85 *out = ash::SHELF_ALIGNMENT_BOTTOM_LOCKED; | |
86 return true; | |
87 } | |
88 NOTREACHED(); | |
89 return false; | |
90 } | |
91 }; | |
92 | |
93 template <> | |
94 struct EnumTraits<ash::mojom::ShelfAutoHideBehavior, | |
95 ash::ShelfAutoHideBehavior> { | |
96 static ash::mojom::ShelfAutoHideBehavior ToMojom( | |
97 ash::ShelfAutoHideBehavior input) { | |
98 switch (input) { | |
99 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | |
100 return ash::mojom::ShelfAutoHideBehavior::ALWAYS; | |
101 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | |
102 return ash::mojom::ShelfAutoHideBehavior::NEVER; | |
103 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | |
104 return ash::mojom::ShelfAutoHideBehavior::HIDDEN; | |
105 } | |
106 NOTREACHED(); | |
107 return ash::mojom::ShelfAutoHideBehavior::NEVER; | |
108 } | |
109 | |
110 static bool FromMojom(ash::mojom::ShelfAutoHideBehavior input, | |
111 ash::ShelfAutoHideBehavior* out) { | |
112 switch (input) { | |
113 case ash::mojom::ShelfAutoHideBehavior::ALWAYS: | |
114 *out = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | |
115 return true; | |
116 case ash::mojom::ShelfAutoHideBehavior::NEVER: | |
117 *out = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER; | |
118 return true; | |
119 case ash::mojom::ShelfAutoHideBehavior::HIDDEN: | |
120 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; | |
121 return true; | |
122 } | |
123 NOTREACHED(); | |
124 return false; | |
125 } | |
126 }; | |
127 | |
128 template <> | |
129 struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { | |
130 static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) { | |
131 switch (input) { | |
132 case ash::LAUNCH_FROM_UNKNOWN: | |
133 return ash::mojom::ShelfLaunchSource::UNKNOWN; | |
134 case ash::LAUNCH_FROM_APP_LIST: | |
135 return ash::mojom::ShelfLaunchSource::APP_LIST; | |
136 case ash::LAUNCH_FROM_APP_LIST_SEARCH: | |
137 return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH; | |
138 } | |
139 NOTREACHED(); | |
140 return ash::mojom::ShelfLaunchSource::UNKNOWN; | |
141 } | |
142 | |
143 static bool FromMojom(ash::mojom::ShelfLaunchSource input, | |
144 ash::ShelfLaunchSource* out) { | |
145 switch (input) { | |
146 case ash::mojom::ShelfLaunchSource::UNKNOWN: | |
147 *out = ash::LAUNCH_FROM_UNKNOWN; | |
148 return true; | |
149 case ash::mojom::ShelfLaunchSource::APP_LIST: | |
150 *out = ash::LAUNCH_FROM_APP_LIST; | |
151 return true; | |
152 case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH: | |
153 *out = ash::LAUNCH_FROM_APP_LIST_SEARCH; | |
154 return true; | |
155 } | |
156 NOTREACHED(); | |
157 return false; | |
158 } | |
159 }; | |
160 | |
161 } // namespace mojo | |
162 | |
163 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | |
OLD | NEW |