Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ash/public/interfaces/shelf_struct_traits.h

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ 5 #ifndef ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
6 #define ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ 6 #define ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
7 7
8 #include "ash/public/cpp/shelf_types.h" 8 #include "ash/public/cpp/shelf_types.h"
9 #include "ash/public/interfaces/shelf.mojom.h" 9 #include "ash/public/interfaces/shelf.mojom.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 template <> 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 <>
14 struct EnumTraits<ash::mojom::ShelfAlignment, ash::ShelfAlignment> { 56 struct EnumTraits<ash::mojom::ShelfAlignment, ash::ShelfAlignment> {
15 static ash::mojom::ShelfAlignment ToMojom(ash::ShelfAlignment input) { 57 static ash::mojom::ShelfAlignment ToMojom(ash::ShelfAlignment input) {
16 switch (input) { 58 switch (input) {
17 case ash::SHELF_ALIGNMENT_BOTTOM: 59 case ash::SHELF_ALIGNMENT_BOTTOM:
18 return ash::mojom::ShelfAlignment::BOTTOM; 60 return ash::mojom::ShelfAlignment::BOTTOM;
19 case ash::SHELF_ALIGNMENT_LEFT: 61 case ash::SHELF_ALIGNMENT_LEFT:
20 return ash::mojom::ShelfAlignment::LEFT; 62 return ash::mojom::ShelfAlignment::LEFT;
21 case ash::SHELF_ALIGNMENT_RIGHT: 63 case ash::SHELF_ALIGNMENT_RIGHT:
22 return ash::mojom::ShelfAlignment::RIGHT; 64 return ash::mojom::ShelfAlignment::RIGHT;
23 case ash::SHELF_ALIGNMENT_BOTTOM_LOCKED: 65 case ash::SHELF_ALIGNMENT_BOTTOM_LOCKED:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return true; 118 return true;
77 case ash::mojom::ShelfAutoHideBehavior::HIDDEN: 119 case ash::mojom::ShelfAutoHideBehavior::HIDDEN:
78 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; 120 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
79 return true; 121 return true;
80 } 122 }
81 NOTREACHED(); 123 NOTREACHED();
82 return false; 124 return false;
83 } 125 }
84 }; 126 };
85 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
86 } // namespace mojo 161 } // namespace mojo
87 162
88 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ 163 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698