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_WALLPAPER_ENUM_TRAITS_H_ | |
6 #define ASH_PUBLIC_INTERFACES_WALLPAPER_ENUM_TRAITS_H_ | |
7 | |
8 #include "ash/public/interfaces/wallpaper.mojom.h" | |
9 #include "components/wallpaper/wallpaper_layout.h" | |
10 | |
11 namespace mojo { | |
12 | |
13 template <> | |
14 struct EnumTraits<ash::mojom::WallpaperLayout, wallpaper::WallpaperLayout> { | |
15 static ash::mojom::WallpaperLayout ToMojom(wallpaper::WallpaperLayout input) { | |
16 switch (input) { | |
17 case wallpaper::WALLPAPER_LAYOUT_CENTER: | |
18 return ash::mojom::WallpaperLayout::CENTER; | |
19 case wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED: | |
20 return ash::mojom::WallpaperLayout::CENTER_CROPPED; | |
21 case wallpaper::WALLPAPER_LAYOUT_STRETCH: | |
22 return ash::mojom::WallpaperLayout::STRETCH; | |
23 case wallpaper::WALLPAPER_LAYOUT_TILE: | |
24 return ash::mojom::WallpaperLayout::TILE; | |
25 case wallpaper::NUM_WALLPAPER_LAYOUT: | |
26 break; | |
27 } | |
28 NOTREACHED(); | |
29 return ash::mojom::WallpaperLayout::CENTER; | |
30 } | |
31 | |
32 static bool FromMojom(ash::mojom::WallpaperLayout input, | |
33 wallpaper::WallpaperLayout* out) { | |
34 switch (input) { | |
35 case ash::mojom::WallpaperLayout::CENTER: | |
36 *out = wallpaper::WALLPAPER_LAYOUT_CENTER; | |
37 return true; | |
38 case ash::mojom::WallpaperLayout::CENTER_CROPPED: | |
39 *out = wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; | |
40 return true; | |
41 case ash::mojom::WallpaperLayout::STRETCH: | |
42 *out = wallpaper::WALLPAPER_LAYOUT_STRETCH; | |
43 return true; | |
44 case ash::mojom::WallpaperLayout::TILE: | |
45 *out = wallpaper::WALLPAPER_LAYOUT_TILE; | |
46 return true; | |
47 } | |
48 NOTREACHED(); | |
49 return false; | |
50 } | |
51 }; | |
52 | |
53 } // namespace mojo | |
54 | |
55 #endif // ASH_PUBLIC_INTERFACES_WALLPAPER_ENUM_TRAITS_H_ | |
OLD | NEW |