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 #ifndef ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | 5 #ifndef ASH_PUBLIC_CPP_SHELF_STRUCT_TRAITS_H_ |
6 #define ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | 6 #define ASH_PUBLIC_CPP_SHELF_STRUCT_TRAITS_H_ |
7 | 7 |
| 8 #include "ash/public/cpp/ash_public_export.h" |
| 9 #include "ash/public/cpp/shelf_item.h" |
8 #include "ash/public/cpp/shelf_types.h" | 10 #include "ash/public/cpp/shelf_types.h" |
9 #include "ash/public/interfaces/shelf.mojom.h" | 11 #include "ash/public/interfaces/shelf.mojom-shared.h" |
| 12 |
| 13 using ash::ShelfItem; |
10 | 14 |
11 namespace mojo { | 15 namespace mojo { |
12 | 16 |
13 template <> | 17 template <> |
14 struct EnumTraits<ash::mojom::ShelfAction, ash::ShelfAction> { | 18 struct EnumTraits<ash::mojom::ShelfAction, ash::ShelfAction> { |
15 static ash::mojom::ShelfAction ToMojom(ash::ShelfAction input) { | 19 static ash::mojom::ShelfAction ToMojom(ash::ShelfAction input) { |
16 switch (input) { | 20 switch (input) { |
17 case ash::SHELF_ACTION_NONE: | 21 case ash::SHELF_ACTION_NONE: |
18 return ash::mojom::ShelfAction::NONE; | 22 return ash::mojom::ShelfAction::NONE; |
19 case ash::SHELF_ACTION_NEW_WINDOW_CREATED: | 23 case ash::SHELF_ACTION_NEW_WINDOW_CREATED: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 case ash::mojom::ShelfAutoHideBehavior::HIDDEN: | 123 case ash::mojom::ShelfAutoHideBehavior::HIDDEN: |
120 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; | 124 *out = ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; |
121 return true; | 125 return true; |
122 } | 126 } |
123 NOTREACHED(); | 127 NOTREACHED(); |
124 return false; | 128 return false; |
125 } | 129 } |
126 }; | 130 }; |
127 | 131 |
128 template <> | 132 template <> |
| 133 struct EnumTraits<ash::mojom::ShelfItemStatus, ash::ShelfItemStatus> { |
| 134 static ash::mojom::ShelfItemStatus ToMojom(ash::ShelfItemStatus input) { |
| 135 switch (input) { |
| 136 case ash::STATUS_CLOSED: |
| 137 return ash::mojom::ShelfItemStatus::CLOSED; |
| 138 case ash::STATUS_RUNNING: |
| 139 return ash::mojom::ShelfItemStatus::RUNNING; |
| 140 case ash::STATUS_ACTIVE: |
| 141 return ash::mojom::ShelfItemStatus::ACTIVE; |
| 142 case ash::STATUS_ATTENTION: |
| 143 return ash::mojom::ShelfItemStatus::ATTENTION; |
| 144 } |
| 145 NOTREACHED(); |
| 146 return ash::mojom::ShelfItemStatus::CLOSED; |
| 147 } |
| 148 |
| 149 static bool FromMojom(ash::mojom::ShelfItemStatus input, |
| 150 ash::ShelfItemStatus* out) { |
| 151 switch (input) { |
| 152 case ash::mojom::ShelfItemStatus::CLOSED: |
| 153 *out = ash::STATUS_CLOSED; |
| 154 return true; |
| 155 case ash::mojom::ShelfItemStatus::RUNNING: |
| 156 *out = ash::STATUS_RUNNING; |
| 157 return true; |
| 158 case ash::mojom::ShelfItemStatus::ACTIVE: |
| 159 *out = ash::STATUS_ACTIVE; |
| 160 return true; |
| 161 case ash::mojom::ShelfItemStatus::ATTENTION: |
| 162 *out = ash::STATUS_ATTENTION; |
| 163 return true; |
| 164 } |
| 165 NOTREACHED(); |
| 166 return false; |
| 167 } |
| 168 }; |
| 169 |
| 170 template <> |
| 171 struct EnumTraits<ash::mojom::ShelfItemType, ash::ShelfItemType> { |
| 172 static ash::mojom::ShelfItemType ToMojom(ash::ShelfItemType input) { |
| 173 switch (input) { |
| 174 case ash::TYPE_APP_PANEL: |
| 175 return ash::mojom::ShelfItemType::PANEL; |
| 176 case ash::TYPE_PINNED_APP: |
| 177 return ash::mojom::ShelfItemType::PINNED_APP; |
| 178 case ash::TYPE_APP_LIST: |
| 179 return ash::mojom::ShelfItemType::APP_LIST; |
| 180 case ash::TYPE_BROWSER_SHORTCUT: |
| 181 return ash::mojom::ShelfItemType::BROWSER; |
| 182 case ash::TYPE_APP: |
| 183 return ash::mojom::ShelfItemType::APP; |
| 184 case ash::TYPE_DIALOG: |
| 185 return ash::mojom::ShelfItemType::DIALOG; |
| 186 case ash::TYPE_UNDEFINED: |
| 187 return ash::mojom::ShelfItemType::UNDEFINED; |
| 188 } |
| 189 NOTREACHED(); |
| 190 return ash::mojom::ShelfItemType::UNDEFINED; |
| 191 } |
| 192 |
| 193 static bool FromMojom(ash::mojom::ShelfItemType input, |
| 194 ash::ShelfItemType* out) { |
| 195 switch (input) { |
| 196 case ash::mojom::ShelfItemType::PANEL: |
| 197 *out = ash::TYPE_APP_PANEL; |
| 198 return true; |
| 199 case ash::mojom::ShelfItemType::PINNED_APP: |
| 200 *out = ash::TYPE_PINNED_APP; |
| 201 return true; |
| 202 case ash::mojom::ShelfItemType::APP_LIST: |
| 203 *out = ash::TYPE_APP_LIST; |
| 204 return true; |
| 205 case ash::mojom::ShelfItemType::BROWSER: |
| 206 *out = ash::TYPE_BROWSER_SHORTCUT; |
| 207 return true; |
| 208 case ash::mojom::ShelfItemType::APP: |
| 209 *out = ash::TYPE_APP; |
| 210 return true; |
| 211 case ash::mojom::ShelfItemType::DIALOG: |
| 212 *out = ash::TYPE_DIALOG; |
| 213 return true; |
| 214 case ash::mojom::ShelfItemType::UNDEFINED: |
| 215 *out = ash::TYPE_UNDEFINED; |
| 216 return true; |
| 217 } |
| 218 NOTREACHED(); |
| 219 return false; |
| 220 } |
| 221 }; |
| 222 |
| 223 template <> |
129 struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { | 224 struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { |
130 static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) { | 225 static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) { |
131 switch (input) { | 226 switch (input) { |
132 case ash::LAUNCH_FROM_UNKNOWN: | 227 case ash::LAUNCH_FROM_UNKNOWN: |
133 return ash::mojom::ShelfLaunchSource::UNKNOWN; | 228 return ash::mojom::ShelfLaunchSource::UNKNOWN; |
134 case ash::LAUNCH_FROM_APP_LIST: | 229 case ash::LAUNCH_FROM_APP_LIST: |
135 return ash::mojom::ShelfLaunchSource::APP_LIST; | 230 return ash::mojom::ShelfLaunchSource::APP_LIST; |
136 case ash::LAUNCH_FROM_APP_LIST_SEARCH: | 231 case ash::LAUNCH_FROM_APP_LIST_SEARCH: |
137 return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH; | 232 return ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH; |
138 } | 233 } |
(...skipping 12 matching lines...) Expand all Loading... |
151 return true; | 246 return true; |
152 case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH: | 247 case ash::mojom::ShelfLaunchSource::APP_LIST_SEARCH: |
153 *out = ash::LAUNCH_FROM_APP_LIST_SEARCH; | 248 *out = ash::LAUNCH_FROM_APP_LIST_SEARCH; |
154 return true; | 249 return true; |
155 } | 250 } |
156 NOTREACHED(); | 251 NOTREACHED(); |
157 return false; | 252 return false; |
158 } | 253 } |
159 }; | 254 }; |
160 | 255 |
| 256 template <> |
| 257 struct ASH_PUBLIC_EXPORT |
| 258 StructTraits<ash::mojom::ShelfItemDataView, ShelfItem> { |
| 259 static ash::ShelfItemType type(const ShelfItem& i) { return i.type; } |
| 260 static const SkBitmap& image(const ShelfItem& i); |
| 261 static ash::ShelfID shelf_id(const ShelfItem& i) { return i.id; } |
| 262 static ash::ShelfItemStatus status(const ShelfItem& i) { return i.status; } |
| 263 static const std::string& app_id(const ShelfItem& i) { return i.app_id; } |
| 264 static const base::string16& title(const ShelfItem& i) { return i.title; } |
| 265 static bool shows_tooltip(const ShelfItem& i) { return i.shows_tooltip; } |
| 266 static bool pinned_by_policy(const ShelfItem& i) { |
| 267 return i.pinned_by_policy; |
| 268 } |
| 269 |
| 270 static bool Read(ash::mojom::ShelfItemDataView data, ShelfItem* out); |
| 271 }; |
| 272 |
161 } // namespace mojo | 273 } // namespace mojo |
162 | 274 |
163 #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ | 275 #endif // ASH_PUBLIC_CPP_SHELF_STRUCT_TRAITS_H_ |
OLD | NEW |