Index: content/public/common/screen_orientation_struct_traits.h |
diff --git a/content/public/common/screen_orientation_struct_traits.h b/content/public/common/screen_orientation_struct_traits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0576268b1e17431ebc322989fdde2f65a747fd24 |
--- /dev/null |
+++ b/content/public/common/screen_orientation_struct_traits.h |
@@ -0,0 +1,80 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |
+#define CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |
+ |
+#include "content/public/common/screen_orientation.mojom.h" |
+#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct EnumTraits<content::mojom::ScreenOrientationLockType, |
+ blink::WebScreenOrientationLockType> { |
+ static content::mojom::ScreenOrientationLockType ToMojom( |
+ blink::WebScreenOrientationLockType lock_type) { |
+ switch (lock_type) { |
+ case blink::WebScreenOrientationLockDefault: |
+ return content::mojom::ScreenOrientationLockType::DEFAULT; |
+ case blink::WebScreenOrientationLockPortraitPrimary: |
+ return content::mojom::ScreenOrientationLockType::PORTRAIT_PRIMARY; |
+ case blink::WebScreenOrientationLockPortraitSecondary: |
+ return content::mojom::ScreenOrientationLockType::PORTRAIT_SECONDARY; |
+ case blink::WebScreenOrientationLockLandscapePrimary: |
+ return content::mojom::ScreenOrientationLockType::LANDSCAPE_PRIMARY; |
+ case blink::WebScreenOrientationLockLandscapeSecondary: |
+ return content::mojom::ScreenOrientationLockType::LANDSCAPE_SECONDARY; |
+ case blink::WebScreenOrientationLockAny: |
+ return content::mojom::ScreenOrientationLockType::ANY; |
+ case blink::WebScreenOrientationLockLandscape: |
+ return content::mojom::ScreenOrientationLockType::LANDSCAPE; |
+ case blink::WebScreenOrientationLockPortrait: |
+ return content::mojom::ScreenOrientationLockType::PORTRAIT; |
+ case blink::WebScreenOrientationLockNatural: |
+ return content::mojom::ScreenOrientationLockType::NATURAL; |
+ } |
+ NOTREACHED(); |
+ return content::mojom::ScreenOrientationLockType::DEFAULT; |
+ } |
+ |
+ static bool FromMojom(content::mojom::ScreenOrientationLockType input, |
+ blink::WebScreenOrientationLockType* out) { |
+ switch (input) { |
+ case content::mojom::ScreenOrientationLockType::DEFAULT: |
+ *out = blink::WebScreenOrientationLockDefault; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::PORTRAIT_PRIMARY: |
+ *out = blink::WebScreenOrientationLockPortraitPrimary; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::PORTRAIT_SECONDARY: |
+ *out = blink::WebScreenOrientationLockPortraitSecondary; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::LANDSCAPE_PRIMARY: |
+ *out = blink::WebScreenOrientationLockLandscapePrimary; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::LANDSCAPE_SECONDARY: |
+ *out = blink::WebScreenOrientationLockLandscapeSecondary; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::ANY: |
+ *out = blink::WebScreenOrientationLockAny; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::LANDSCAPE: |
+ *out = blink::WebScreenOrientationLockLandscape; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::PORTRAIT: |
+ *out = blink::WebScreenOrientationLockPortrait; |
+ return true; |
+ case content::mojom::ScreenOrientationLockType::NATURAL: |
+ *out = blink::WebScreenOrientationLockNatural; |
+ return true; |
+ } |
+ NOTREACHED(); |
+ return false; |
+ } |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_STRUCT_TRAITS_H_ |