Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: content/public/common/screen_orientation_struct_traits.h

Issue 2391883006: Mojo-ify implementation of screen orientation locking/unlocking. (Closed)
Patch Set: Ensure correct ordering between ViewMsg_Resize and screen orientation messages Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698