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

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

Issue 2140843002: Allow arc app to lock screen orientation in TouchView/Tablet mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Mark POWER key as system key so that it won't be passed to regular apps. 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 208047c179226047e72a91773568cdc86d3ef05b..110398cfffaee0d4a0b96074a9140c44b2baf478 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
@@ -5,6 +5,7 @@
#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));
}
« no previous file with comments | « ash/accelerators/accelerator_delegate.cc ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698