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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
5 5
6 #include "ash/common/wm/window_state.h" 6 #include "ash/common/wm/window_state.h"
7 #include "ash/common/wm_shell.h" 7 #include "ash/common/wm_shell.h"
8 #include "ash/display/display_manager.h"
8 #include "ash/display/screen_orientation_controller_chromeos.h" 9 #include "ash/display/screen_orientation_controller_chromeos.h"
9 #include "ash/shelf/shelf_delegate.h" 10 #include "ash/shelf/shelf_delegate.h"
10 #include "ash/shelf/shelf_util.h" 11 #include "ash/shelf/shelf_util.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/wm/window_state_aura.h" 14 #include "ash/wm/window_state_aura.h"
14 #include "ash/wm/window_util.h" 15 #include "ash/wm/window_util.h"
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 17 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
17 #include "chrome/browser/chromeos/arc/arc_support_host.h" 18 #include "chrome/browser/chromeos/arc/arc_support_host.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 20 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
20 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h" 21 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h"
21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
22 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 23 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
23 #include "components/arc/arc_bridge_service.h" 24 #include "components/arc/arc_bridge_service.h"
24 #include "components/exo/shell_surface.h" 25 #include "components/exo/shell_surface.h"
25 #include "components/signin/core/account_id/account_id.h" 26 #include "components/signin/core/account_id/account_id.h"
26 #include "components/user_manager/user_manager.h" 27 #include "components/user_manager/user_manager.h"
27 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 28 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
28 #include "ui/aura/client/aura_constants.h" 29 #include "ui/aura/client/aura_constants.h"
29 #include "ui/aura/env.h" 30 #include "ui/aura/env.h"
30 #include "ui/base/base_window.h" 31 #include "ui/base/base_window.h"
32 #include "ui/display/display.h"
31 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
32 34
33 namespace { 35 namespace {
34 36
35 enum class FullScreenMode { 37 enum class FullScreenMode {
36 NOT_DEFINED, // Fullscreen mode was not defined. 38 NOT_DEFINED, // Fullscreen mode was not defined.
37 ACTIVE, // Fullscreen is activated for an app. 39 ACTIVE, // Fullscreen is activated for an app.
38 NON_ACTIVE, // Fullscreen was not activated for an app. 40 NON_ACTIVE, // Fullscreen was not activated for an app.
39 }; 41 };
40 42
43 arc::mojom::OrientationLock GetCurrentOrientation() {
44 if (!display::Display::HasInternalDisplay())
45 return arc::mojom::OrientationLock::NONE;
46 display::Display internal_display =
47 ash::Shell::GetInstance()->display_manager()->GetDisplayForId(
48 display::Display::InternalDisplayId());
49
50 // ChromeOS currently assumes that the internal panel is always
51 // landscape (ROTATE_0 == landscape).
52 switch (internal_display.rotation()) {
53 case display::Display::ROTATE_0:
54 case display::Display::ROTATE_180:
55 return arc::mojom::OrientationLock::LANDSCAPE;
56 case display::Display::ROTATE_90:
57 case display::Display::ROTATE_270:
58 return arc::mojom::OrientationLock::PORTRAIT;
59 }
60 return arc::mojom::OrientationLock::NONE;
61 }
62
41 blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom( 63 blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom(
42 arc::mojom::OrientationLock orientation_lock) { 64 arc::mojom::OrientationLock orientation_lock) {
65 DCHECK_NE(arc::mojom::OrientationLock::CURRENT, orientation_lock);
43 if (orientation_lock == arc::mojom::OrientationLock::PORTRAIT) { 66 if (orientation_lock == arc::mojom::OrientationLock::PORTRAIT) {
44 return blink::WebScreenOrientationLockPortrait; 67 return blink::WebScreenOrientationLockPortrait;
45 } else if (orientation_lock == arc::mojom::OrientationLock::LANDSCAPE) { 68 } else if (orientation_lock == arc::mojom::OrientationLock::LANDSCAPE) {
46 return blink::WebScreenOrientationLockLandscape; 69 return blink::WebScreenOrientationLockLandscape;
47 } else { 70 } else {
48 return blink::WebScreenOrientationLockAny; 71 return blink::WebScreenOrientationLockAny;
49 } 72 }
50 } 73 }
51 74
52 } // namespace 75 } // namespace
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (app_window->has_requested_orientation_lock()) { 588 if (app_window->has_requested_orientation_lock()) {
566 orientation_lock = app_window->requested_orientation_lock(); 589 orientation_lock = app_window->requested_orientation_lock();
567 } else { 590 } else {
568 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(observed_profile_); 591 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(observed_profile_);
569 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 592 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
570 prefs->GetApp(app_window->app_id()); 593 prefs->GetApp(app_window->app_id());
571 if (!app_info) 594 if (!app_info)
572 return; 595 return;
573 orientation_lock = app_info->orientation_lock; 596 orientation_lock = app_info->orientation_lock;
574 } 597 }
598
599 if (orientation_lock == arc::mojom::OrientationLock::CURRENT) {
600 // Resolve the orientation when it first resolved.
601 orientation_lock = GetCurrentOrientation();
602 app_window->set_requested_orientation_lock(orientation_lock);
603 }
604
575 shell->screen_orientation_controller()->LockOrientationForWindow( 605 shell->screen_orientation_controller()->LockOrientationForWindow(
576 window, BlinkOrientationLockFromMojom(orientation_lock)); 606 window, BlinkOrientationLockFromMojom(orientation_lock));
577 } 607 }
OLDNEW
« 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