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 CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "content/public/common/screen_orientation.mojom.h" |
| 9 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 template <> |
| 14 struct EnumTraits<content::mojom::ScreenOrientationLockType, |
| 15 blink::WebScreenOrientationLockType> { |
| 16 static content::mojom::ScreenOrientationLockType ToMojom( |
| 17 blink::WebScreenOrientationLockType lock_type) { |
| 18 switch (lock_type) { |
| 19 case blink::WebScreenOrientationLockDefault: |
| 20 return content::mojom::ScreenOrientationLockType::DEFAULT; |
| 21 case blink::WebScreenOrientationLockPortraitPrimary: |
| 22 return content::mojom::ScreenOrientationLockType::PORTRAIT_PRIMARY; |
| 23 case blink::WebScreenOrientationLockPortraitSecondary: |
| 24 return content::mojom::ScreenOrientationLockType::PORTRAIT_SECONDARY; |
| 25 case blink::WebScreenOrientationLockLandscapePrimary: |
| 26 return content::mojom::ScreenOrientationLockType::LANDSCAPE_PRIMARY; |
| 27 case blink::WebScreenOrientationLockLandscapeSecondary: |
| 28 return content::mojom::ScreenOrientationLockType::LANDSCAPE_SECONDARY; |
| 29 case blink::WebScreenOrientationLockAny: |
| 30 return content::mojom::ScreenOrientationLockType::ANY; |
| 31 case blink::WebScreenOrientationLockLandscape: |
| 32 return content::mojom::ScreenOrientationLockType::LANDSCAPE; |
| 33 case blink::WebScreenOrientationLockPortrait: |
| 34 return content::mojom::ScreenOrientationLockType::PORTRAIT; |
| 35 case blink::WebScreenOrientationLockNatural: |
| 36 return content::mojom::ScreenOrientationLockType::NATURAL; |
| 37 } |
| 38 NOTREACHED(); |
| 39 return content::mojom::ScreenOrientationLockType::DEFAULT; |
| 40 } |
| 41 |
| 42 static bool FromMojom(content::mojom::ScreenOrientationLockType input, |
| 43 blink::WebScreenOrientationLockType* out) { |
| 44 switch (input) { |
| 45 case content::mojom::ScreenOrientationLockType::DEFAULT: |
| 46 *out = blink::WebScreenOrientationLockDefault; |
| 47 return true; |
| 48 case content::mojom::ScreenOrientationLockType::PORTRAIT_PRIMARY: |
| 49 *out = blink::WebScreenOrientationLockPortraitPrimary; |
| 50 return true; |
| 51 case content::mojom::ScreenOrientationLockType::PORTRAIT_SECONDARY: |
| 52 *out = blink::WebScreenOrientationLockPortraitSecondary; |
| 53 return true; |
| 54 case content::mojom::ScreenOrientationLockType::LANDSCAPE_PRIMARY: |
| 55 *out = blink::WebScreenOrientationLockLandscapePrimary; |
| 56 return true; |
| 57 case content::mojom::ScreenOrientationLockType::LANDSCAPE_SECONDARY: |
| 58 *out = blink::WebScreenOrientationLockLandscapeSecondary; |
| 59 return true; |
| 60 case content::mojom::ScreenOrientationLockType::ANY: |
| 61 *out = blink::WebScreenOrientationLockAny; |
| 62 return true; |
| 63 case content::mojom::ScreenOrientationLockType::LANDSCAPE: |
| 64 *out = blink::WebScreenOrientationLockLandscape; |
| 65 return true; |
| 66 case content::mojom::ScreenOrientationLockType::PORTRAIT: |
| 67 *out = blink::WebScreenOrientationLockPortrait; |
| 68 return true; |
| 69 case content::mojom::ScreenOrientationLockType::NATURAL: |
| 70 *out = blink::WebScreenOrientationLockNatural; |
| 71 return true; |
| 72 } |
| 73 NOTREACHED(); |
| 74 return false; |
| 75 } |
| 76 }; |
| 77 |
| 78 } // namespace content |
| 79 |
| 80 #endif // CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |
OLD | NEW |