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

Unified Diff: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc

Issue 2139893002: Add CURRENT lock orientation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CURRENT lock orientation. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
index ecdc85634bae89d0f0ff418bdb6756deec5b69ba..cf5a14a7efcd5c2e9d2a64a35bf53d25462408ff 100644
--- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
@@ -6,6 +6,7 @@
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_shell.h"
+#include "ash/display/display_manager.h"
#include "ash/display/screen_orientation_controller_chromeos.h"
#include "ash/shelf/shelf_delegate.h"
#include "ash/shelf/shelf_util.h"
@@ -28,6 +29,7 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/base/base_window.h"
+#include "ui/display/display.h"
#include "ui/views/widget/widget.h"
namespace {
@@ -38,8 +40,29 @@ enum class FullScreenMode {
NON_ACTIVE, // Fullscreen was not activated for an app.
};
+arc::mojom::OrientationLock GetCurrentOrientation() {
+ if (!display::Display::HasInternalDisplay())
+ return arc::mojom::OrientationLock::NONE;
+ display::Display internal_display =
+ ash::Shell::GetInstance()->display_manager()->GetDisplayForId(
+ display::Display::InternalDisplayId());
+
+ // ChromeOS currently assumes that the internal panel is always
+ // landscape (ROTATE_0 == landscape).
+ switch (internal_display.rotation()) {
+ case display::Display::ROTATE_0:
+ case display::Display::ROTATE_180:
+ return arc::mojom::OrientationLock::LANDSCAPE;
+ case display::Display::ROTATE_90:
+ case display::Display::ROTATE_270:
+ return arc::mojom::OrientationLock::PORTRAIT;
+ }
+ return arc::mojom::OrientationLock::NONE;
+}
+
blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom(
arc::mojom::OrientationLock orientation_lock) {
+ DCHECK_NE(arc::mojom::OrientationLock::CURRENT, orientation_lock);
if (orientation_lock == arc::mojom::OrientationLock::PORTRAIT) {
return blink::WebScreenOrientationLockPortrait;
} else if (orientation_lock == arc::mojom::OrientationLock::LANDSCAPE) {
@@ -572,6 +595,13 @@ void ArcAppWindowLauncherController::SetOrientationLockForAppWindow(
return;
orientation_lock = app_info->orientation_lock;
}
+
+ if (orientation_lock == arc::mojom::OrientationLock::CURRENT) {
+ // Resolve the orientation when it first resolved.
+ orientation_lock = GetCurrentOrientation();
+ app_window->set_requested_orientation_lock(orientation_lock);
+ }
+
shell->screen_orientation_controller()->LockOrientationForWindow(
window, BlinkOrientationLockFromMojom(orientation_lock));
}

Powered by Google App Engine
This is Rietveld 408576698