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

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

Issue 2750463009: mash: Fix ShelfItem mojo struct; add enums and traits. (Closed)
Patch Set: Sync and rebase. 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
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 case ash::mojom::ShelfAutoHideBehavior::HIDDEN: 119 case ash::mojom::ShelfAutoHideBehavior::HIDDEN:
120 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; 120 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
121 return true; 121 return true;
122 } 122 }
123 NOTREACHED(); 123 NOTREACHED();
124 return false; 124 return false;
125 } 125 }
126 }; 126 };
127 127
128 template <> 128 template <>
129 struct EnumTraits<ash::mojom::ShelfItemStatus, ash::ShelfItemStatus> {
130 static ash::mojom::ShelfItemStatus ToMojom(ash::ShelfItemStatus input) {
131 switch (input) {
132 case ash::STATUS_CLOSED:
133 return ash::mojom::ShelfItemStatus::CLOSED;
134 case ash::STATUS_RUNNING:
135 return ash::mojom::ShelfItemStatus::RUNNING;
136 case ash::STATUS_ACTIVE:
137 return ash::mojom::ShelfItemStatus::ACTIVE;
138 case ash::STATUS_ATTENTION:
139 return ash::mojom::ShelfItemStatus::ATTENTION;
140 }
141 NOTREACHED();
142 return ash::mojom::ShelfItemStatus::CLOSED;
143 }
144
145 static bool FromMojom(ash::mojom::ShelfItemStatus input,
146 ash::ShelfItemStatus* out) {
147 switch (input) {
148 case ash::mojom::ShelfItemStatus::CLOSED:
149 *out = ash::STATUS_CLOSED;
150 return true;
151 case ash::mojom::ShelfItemStatus::RUNNING:
152 *out = ash::STATUS_RUNNING;
153 return true;
154 case ash::mojom::ShelfItemStatus::ACTIVE:
155 *out = ash::STATUS_ACTIVE;
156 return true;
157 case ash::mojom::ShelfItemStatus::ATTENTION:
158 *out = ash::STATUS_ATTENTION;
159 return true;
160 }
161 NOTREACHED();
162 return false;
163 }
164 };
165
166 template <>
167 struct EnumTraits<ash::mojom::ShelfItemType, ash::ShelfItemType> {
168 static ash::mojom::ShelfItemType ToMojom(ash::ShelfItemType input) {
169 switch (input) {
170 case ash::TYPE_APP_PANEL:
171 return ash::mojom::ShelfItemType::PANEL;
172 case ash::TYPE_PINNED_APP:
173 return ash::mojom::ShelfItemType::PINNED_APP;
174 case ash::TYPE_APP_LIST:
175 return ash::mojom::ShelfItemType::APP_LIST;
176 case ash::TYPE_BROWSER_SHORTCUT:
177 return ash::mojom::ShelfItemType::BROWSER;
178 case ash::TYPE_APP:
179 return ash::mojom::ShelfItemType::APP;
180 case ash::TYPE_DIALOG:
181 return ash::mojom::ShelfItemType::DIALOG;
182 case ash::TYPE_UNDEFINED:
183 return ash::mojom::ShelfItemType::UNDEFINED;
184 }
185 NOTREACHED();
186 return ash::mojom::ShelfItemType::UNDEFINED;
187 }
188
189 static bool FromMojom(ash::mojom::ShelfItemType input,
190 ash::ShelfItemType* out) {
191 switch (input) {
192 case ash::mojom::ShelfItemType::PANEL:
193 *out = ash::TYPE_APP_PANEL;
194 return true;
195 case ash::mojom::ShelfItemType::PINNED_APP:
196 *out = ash::TYPE_PINNED_APP;
197 return true;
198 case ash::mojom::ShelfItemType::APP_LIST:
199 *out = ash::TYPE_APP_LIST;
200 return true;
201 case ash::mojom::ShelfItemType::BROWSER:
202 *out = ash::TYPE_BROWSER_SHORTCUT;
203 return true;
204 case ash::mojom::ShelfItemType::APP:
205 *out = ash::TYPE_APP;
206 return true;
207 case ash::mojom::ShelfItemType::DIALOG:
208 *out = ash::TYPE_DIALOG;
209 return true;
210 case ash::mojom::ShelfItemType::UNDEFINED:
211 *out = ash::TYPE_UNDEFINED;
212 return true;
213 }
214 NOTREACHED();
215 return false;
216 }
217 };
218
219 template <>
129 struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { 220 struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> {
130 static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) { 221 static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) {
131 switch (input) { 222 switch (input) {
132 case ash::LAUNCH_FROM_UNKNOWN: 223 case ash::LAUNCH_FROM_UNKNOWN:
133 return ash::mojom::ShelfLaunchSource::UNKNOWN; 224 return ash::mojom::ShelfLaunchSource::UNKNOWN;
134 case ash::LAUNCH_FROM_APP_LIST: 225 case ash::LAUNCH_FROM_APP_LIST:
135 return ash::mojom::ShelfLaunchSource::APP_LIST; 226 return ash::mojom::ShelfLaunchSource::APP_LIST;
136 case ash::LAUNCH_FROM_APP_LIST_SEARCH: 227 case ash::LAUNCH_FROM_APP_LIST_SEARCH:
137 return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH; 228 return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH;
138 } 229 }
(...skipping 12 matching lines...) Expand all
151 return true; 242 return true;
152 case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH: 243 case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH:
153 *out = ash::LAUNCH_FROM_APP_LIST_SEARCH; 244 *out = ash::LAUNCH_FROM_APP_LIST_SEARCH;
154 return true; 245 return true;
155 } 246 }
156 NOTREACHED(); 247 NOTREACHED();
157 return false; 248 return false;
158 } 249 }
159 }; 250 };
160 251
252 template <>
253 struct StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem> {
254 static ash::ShelfItemType type(const ash::ShelfItem& i);
255 static const SkBitmap& image(const ash::ShelfItem& i);
256 static int64_t shelf_id(const ash::ShelfItem& i);
257 static ash::ShelfItemStatus status(const ash::ShelfItem& i);
258 static const std::string& app_id(const ash::ShelfItem& i);
259 static const base::string16& title(const ash::ShelfItem& i);
260 static bool shows_tooltip(const ash::ShelfItem& i);
261 static bool pinned_by_policy(const ash::ShelfItem& i);
262 static bool Read(ash::mojom::ShelfItemDataView data, ash::ShelfItem* out);
James Cook 2017/03/16 16:48:51 optional super nit: blank line above?
msw 2017/03/16 23:15:50 Done.
263 };
264
161 } // namespace mojo 265 } // namespace mojo
162 266
163 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ 267 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698