Chromium Code Reviews| Index: ash/public/interfaces/shelf_struct_traits.h |
| diff --git a/ash/public/interfaces/shelf_struct_traits.h b/ash/public/interfaces/shelf_struct_traits.h |
| index 74c0a7cdcfa6246b8c96aaaebf3a7cb55fa47753..673d11ddb7430a973c7c1341ff347574b9a6cf17 100644 |
| --- a/ash/public/interfaces/shelf_struct_traits.h |
| +++ b/ash/public/interfaces/shelf_struct_traits.h |
| @@ -126,6 +126,97 @@ struct EnumTraits<ash::mojom::ShelfAutoHideBehavior, |
| }; |
| template <> |
| +struct EnumTraits<ash::mojom::ShelfItemStatus, ash::ShelfItemStatus> { |
| + static ash::mojom::ShelfItemStatus ToMojom(ash::ShelfItemStatus input) { |
| + switch (input) { |
| + case ash::STATUS_CLOSED: |
| + return ash::mojom::ShelfItemStatus::CLOSED; |
| + case ash::STATUS_RUNNING: |
| + return ash::mojom::ShelfItemStatus::RUNNING; |
| + case ash::STATUS_ACTIVE: |
| + return ash::mojom::ShelfItemStatus::ACTIVE; |
| + case ash::STATUS_ATTENTION: |
| + return ash::mojom::ShelfItemStatus::ATTENTION; |
| + } |
| + NOTREACHED(); |
| + return ash::mojom::ShelfItemStatus::CLOSED; |
| + } |
| + |
| + static bool FromMojom(ash::mojom::ShelfItemStatus input, |
| + ash::ShelfItemStatus* out) { |
| + switch (input) { |
| + case ash::mojom::ShelfItemStatus::CLOSED: |
| + *out = ash::STATUS_CLOSED; |
| + return true; |
| + case ash::mojom::ShelfItemStatus::RUNNING: |
| + *out = ash::STATUS_RUNNING; |
| + return true; |
| + case ash::mojom::ShelfItemStatus::ACTIVE: |
| + *out = ash::STATUS_ACTIVE; |
| + return true; |
| + case ash::mojom::ShelfItemStatus::ATTENTION: |
| + *out = ash::STATUS_ATTENTION; |
| + return true; |
| + } |
| + NOTREACHED(); |
| + return false; |
| + } |
| +}; |
| + |
| +template <> |
| +struct EnumTraits<ash::mojom::ShelfItemType, ash::ShelfItemType> { |
| + static ash::mojom::ShelfItemType ToMojom(ash::ShelfItemType input) { |
| + switch (input) { |
| + case ash::TYPE_APP_PANEL: |
| + return ash::mojom::ShelfItemType::PANEL; |
| + case ash::TYPE_PINNED_APP: |
| + return ash::mojom::ShelfItemType::PINNED_APP; |
| + case ash::TYPE_APP_LIST: |
| + return ash::mojom::ShelfItemType::APP_LIST; |
| + case ash::TYPE_BROWSER_SHORTCUT: |
| + return ash::mojom::ShelfItemType::BROWSER; |
| + case ash::TYPE_APP: |
| + return ash::mojom::ShelfItemType::APP; |
| + case ash::TYPE_DIALOG: |
| + return ash::mojom::ShelfItemType::DIALOG; |
| + case ash::TYPE_UNDEFINED: |
| + return ash::mojom::ShelfItemType::UNDEFINED; |
| + } |
| + NOTREACHED(); |
| + return ash::mojom::ShelfItemType::UNDEFINED; |
| + } |
| + |
| + static bool FromMojom(ash::mojom::ShelfItemType input, |
| + ash::ShelfItemType* out) { |
| + switch (input) { |
| + case ash::mojom::ShelfItemType::PANEL: |
| + *out = ash::TYPE_APP_PANEL; |
| + return true; |
| + case ash::mojom::ShelfItemType::PINNED_APP: |
| + *out = ash::TYPE_PINNED_APP; |
| + return true; |
| + case ash::mojom::ShelfItemType::APP_LIST: |
| + *out = ash::TYPE_APP_LIST; |
| + return true; |
| + case ash::mojom::ShelfItemType::BROWSER: |
| + *out = ash::TYPE_BROWSER_SHORTCUT; |
| + return true; |
| + case ash::mojom::ShelfItemType::APP: |
| + *out = ash::TYPE_APP; |
| + return true; |
| + case ash::mojom::ShelfItemType::DIALOG: |
| + *out = ash::TYPE_DIALOG; |
| + return true; |
| + case ash::mojom::ShelfItemType::UNDEFINED: |
| + *out = ash::TYPE_UNDEFINED; |
| + return true; |
| + } |
| + NOTREACHED(); |
| + return false; |
| + } |
| +}; |
| + |
| +template <> |
| struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { |
| static ash::mojom::ShelfLaunchSource ToMojom(ash::ShelfLaunchSource input) { |
| switch (input) { |
| @@ -158,6 +249,19 @@ struct EnumTraits<ash::mojom::ShelfLaunchSource, ash::ShelfLaunchSource> { |
| } |
| }; |
| +template <> |
| +struct StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem> { |
| + static ash::ShelfItemType type(const ash::ShelfItem& i); |
| + static const SkBitmap& image(const ash::ShelfItem& i); |
| + static int64_t shelf_id(const ash::ShelfItem& i); |
| + static ash::ShelfItemStatus status(const ash::ShelfItem& i); |
| + static const std::string& app_id(const ash::ShelfItem& i); |
| + static const base::string16& title(const ash::ShelfItem& i); |
| + static bool shows_tooltip(const ash::ShelfItem& i); |
| + static bool pinned_by_policy(const ash::ShelfItem& i); |
| + 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.
|
| +}; |
| + |
| } // namespace mojo |
| #endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_ |