Index: ash/display/screen_orientation_controller_chromeos.cc |
diff --git a/ash/display/screen_orientation_controller_chromeos.cc b/ash/display/screen_orientation_controller_chromeos.cc |
index 43663a511df5d730862a028d5aa661bddf537ebe..14a4f0b9eaf21b60bc78196d86aea3c7ab6e9ac9 100644 |
--- a/ash/display/screen_orientation_controller_chromeos.cc |
+++ b/ash/display/screen_orientation_controller_chromeos.cc |
@@ -62,36 +62,6 @@ blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() { |
return blink::WebScreenOrientationLockLandscape; |
} |
-blink::WebScreenOrientationLockType RotationToOrientation( |
- display::Display::Rotation rotation) { |
- blink::WebScreenOrientationLockType natural = GetDisplayNaturalOrientation(); |
- if (natural == blink::WebScreenOrientationLockLandscape) { |
- switch (rotation) { |
- case display::Display::ROTATE_0: |
- return blink::WebScreenOrientationLockLandscapePrimary; |
- case display::Display::ROTATE_90: |
- return blink::WebScreenOrientationLockPortraitPrimary; |
- case display::Display::ROTATE_180: |
- return blink::WebScreenOrientationLockLandscapeSecondary; |
- case display::Display::ROTATE_270: |
- return blink::WebScreenOrientationLockPortraitSecondary; |
- } |
- } else { // Natural portrait |
- switch (rotation) { |
- case display::Display::ROTATE_0: |
- return blink::WebScreenOrientationLockPortraitPrimary; |
- case display::Display::ROTATE_90: |
- return blink::WebScreenOrientationLockLandscapePrimary; |
- case display::Display::ROTATE_180: |
- return blink::WebScreenOrientationLockPortraitSecondary; |
- case display::Display::ROTATE_270: |
- return blink::WebScreenOrientationLockLandscapeSecondary; |
- } |
- } |
- NOTREACHED(); |
- return blink::WebScreenOrientationLockAny; |
-} |
- |
// Returns the rotation that matches the orientation type. |
// Returns ROTATE_0 if the given orientation is ANY, which is used |
// to indicate that user didn't lock orientation. |
@@ -153,6 +123,38 @@ blink::WebScreenOrientationLockType ResolveOrientationLock( |
} // namespace |
+// static |
+blink::WebScreenOrientationLockType |
+ScreenOrientationController::RotationToOrientation( |
+ display::Display::Rotation rotation) { |
+ blink::WebScreenOrientationLockType natural = GetDisplayNaturalOrientation(); |
+ if (natural == blink::WebScreenOrientationLockLandscape) { |
+ switch (rotation) { |
+ case display::Display::ROTATE_0: |
+ return blink::WebScreenOrientationLockLandscapePrimary; |
+ case display::Display::ROTATE_90: |
+ return blink::WebScreenOrientationLockPortraitPrimary; |
+ case display::Display::ROTATE_180: |
+ return blink::WebScreenOrientationLockLandscapeSecondary; |
+ case display::Display::ROTATE_270: |
+ return blink::WebScreenOrientationLockPortraitSecondary; |
+ } |
+ } else { // Natural portrait |
+ switch (rotation) { |
+ case display::Display::ROTATE_0: |
+ return blink::WebScreenOrientationLockPortraitPrimary; |
+ case display::Display::ROTATE_90: |
+ return blink::WebScreenOrientationLockLandscapePrimary; |
+ case display::Display::ROTATE_180: |
+ return blink::WebScreenOrientationLockPortraitSecondary; |
+ case display::Display::ROTATE_270: |
+ return blink::WebScreenOrientationLockLandscapeSecondary; |
+ } |
+ } |
+ NOTREACHED(); |
+ return blink::WebScreenOrientationLockAny; |
+} |
+ |
ScreenOrientationController::ScreenOrientationController() |
: natural_orientation_(GetDisplayNaturalOrientation()), |
ignore_display_configuration_updates_(false), |
@@ -232,6 +234,13 @@ void ScreenOrientationController::ToggleUserRotationLock() { |
.GetActiveRotation(); |
user_locked_orientation_ = RotationToOrientation(current_rotation); |
} |
+ SetLockToOrientation(user_locked_orientation_); |
+} |
+ |
+void ScreenOrientationController::SetLockToOrientation( |
+ blink::WebScreenOrientationLockType orientation) { |
+ DCHECK(display::Display::HasInternalDisplay()); |
oshima
2017/03/30 00:44:37
move SetLockToOrientation to private, and add
SetL
Qiang(Joe) Xu
2017/03/30 01:15:14
Done.
|
+ user_locked_orientation_ = orientation; |
base::AutoReset<bool> auto_ignore_display_configuration_updates( |
&ignore_display_configuration_updates_, true); |
Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties( |