Chromium Code Reviews| 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 cd1890316ac330b1a8592cd9d02972d9bef9de5b..64b34f57a7acc05ed41b59839cc0bbbe5342597b 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 |
| @@ -44,28 +44,6 @@ 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: |
| - return arc::mojom::OrientationLock::LANDSCAPE_PRIMARY; |
| - case display::Display::ROTATE_90: |
| - return arc::mojom::OrientationLock::PORTRAIT_PRIMARY; |
| - case display::Display::ROTATE_180: |
| - return arc::mojom::OrientationLock::LANDSCAPE_SECONDARY; |
| - case display::Display::ROTATE_270: |
| - return arc::mojom::OrientationLock::PORTRAIT_SECONDARY; |
| - } |
| - return arc::mojom::OrientationLock::NONE; |
| -} |
| - |
| blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom( |
| arc::mojom::OrientationLock orientation_lock) { |
| DCHECK_NE(arc::mojom::OrientationLock::CURRENT, orientation_lock); |
| @@ -112,6 +90,10 @@ class ArcAppWindowLauncherController::AppWindowInfo { |
| return requested_orientation_lock_; |
| } |
| + void set_lock_to_current(bool lock) { lock_to_current_ = lock; } |
| + |
| + bool lock_to_current() const { return lock_to_current_; } |
| + |
| void set_app_window(std::unique_ptr<AppWindow> window) { |
| app_window_ = std::move(window); |
| } |
| @@ -121,6 +103,12 @@ class ArcAppWindowLauncherController::AppWindowInfo { |
| private: |
| const arc::ArcAppShelfId app_shelf_id_; |
| bool has_requested_orientation_lock_ = false; |
| + |
| + // If true, the orientation should be locked to the specific |
| + // orientation after the requested_orientation_lock is applied. |
| + // This is meaningful only if the orientation is one of ::NONE, |
| + // ::PORTRAIT or ::LANDSCAPE. |
| + bool lock_to_current_ = false; |
| arc::mojom::OrientationLock requested_orientation_lock_ = |
| arc::mojom::OrientationLock::NONE; |
| std::unique_ptr<AppWindow> app_window_; |
| @@ -552,7 +540,16 @@ void ArcAppWindowLauncherController::OnTaskOrientationLockRequested( |
| DCHECK(info); |
| if (!info) |
| return; |
| - info->set_requested_orientation_lock(orientation_lock); |
| + |
| + if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { |
| + info->set_lock_to_current(true); |
| + if (!info->has_requested_orientation_lock()) { |
| + info->set_requested_orientation_lock(arc::mojom::OrientationLock::NONE); |
| + } |
| + } else { |
| + info->set_requested_orientation_lock(orientation_lock); |
| + info->set_lock_to_current(false); |
| + } |
| if (ash::Shell::Get() |
| ->maximize_mode_controller() |
| @@ -695,8 +692,10 @@ void ArcAppWindowLauncherController::SetOrientationLockForAppWindow( |
| AppWindowInfo* info = GetAppWindowInfoForTask(app_window->task_id()); |
| arc::mojom::OrientationLock orientation_lock; |
| + bool lock_to_current_orientation = false; |
| if (info->has_requested_orientation_lock()) { |
| orientation_lock = info->requested_orientation_lock(); |
| + lock_to_current_orientation = info->lock_to_current(); |
|
jonross
2017/04/04 21:51:32
for Portrait/Landscape + lock_to_current, those re
|
| } else { |
| ArcAppListPrefs* prefs = ArcAppListPrefs::Get(observed_profile_); |
| std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| @@ -704,16 +703,15 @@ void ArcAppWindowLauncherController::SetOrientationLockForAppWindow( |
| if (!app_info) |
| return; |
| orientation_lock = app_info->orientation_lock; |
| - } |
| - |
| - if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { |
| - // Resolve the orientation when it first resolved. |
| - orientation_lock = GetCurrentOrientation(); |
| - info->set_requested_orientation_lock(orientation_lock); |
| + if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { |
| + orientation_lock = arc::mojom::OrientationLock::NONE; |
| + lock_to_current_orientation = true; |
| + } |
| } |
| ash::Shell* shell = ash::Shell::GetInstance(); |
| shell->screen_orientation_controller()->LockOrientationForWindow( |
| - window, BlinkOrientationLockFromMojom(orientation_lock)); |
| + window, BlinkOrientationLockFromMojom(orientation_lock), |
| + lock_to_current_orientation); |
| } |
| // static |