Commit f553d08d authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Chrome OS: restore screen orientation delegate for classic Ash.

Mash implementation is a TODO.

Test: put in tablet mode, go to [1], press Lock in Current Orienation

[1] https://whatwebcando.today/screen-orientation.html

Bug: 889981
Change-Id: I19192a92ba927eba76c63089fa57c1288b34ff1c
Reviewed-on: https://chromium-review.googlesource.com/1252525
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595526}
parent bd92eff9
......@@ -1466,8 +1466,6 @@ component("ash_with_content") {
"content/keyboard_overlay/keyboard_overlay_delegate.h",
"content/keyboard_overlay/keyboard_overlay_view.cc",
"content/keyboard_overlay/keyboard_overlay_view.h",
"content/screen_orientation_delegate_chromeos.cc",
"content/screen_orientation_delegate_chromeos.h",
]
defines = [ "ASH_WITH_CONTENT_IMPLEMENTATION" ]
......@@ -1619,7 +1617,7 @@ copy("dbus_service_files") {
# need or use content and should be placed in |ash_unittests| instead.
test("ash_content_unittests") {
sources = [
"content/display/screen_orientation_controller_chromeos_unittest.cc",
"content/display/screen_orientation_controller_unittest.cc",
"content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc",
"content/keyboard_overlay/keyboard_overlay_view_unittest.cc",
"test/ash_unittests.cc",
......
specific_include_rules = {
"screen_orientation_controller_chromeos_unittest.cc": [
"screen_orientation_controller_unittest.cc": [
"+content/public/browser/browser_context.h",
"+content/public/browser/web_contents.h",
"+third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h",
......
......@@ -1494,6 +1494,8 @@ jumbo_split_static_library("ui") {
"ash/network/network_state_notifier.h",
"ash/network/tether_notification_presenter.cc",
"ash/network/tether_notification_presenter.h",
"ash/screen_orientation_delegate_chromeos.cc",
"ash/screen_orientation_delegate_chromeos.h",
"ash/session_controller_client.cc",
"ash/session_controller_client.h",
"ash/session_util.cc",
......
......@@ -49,6 +49,10 @@ specific_include_rules = {
# https://crbug.com/665064
"+ash/shell_delegate.h",
],
"screen_orientation_delegate_chromeos.cc": [
"+ash/display/screen_orientation_controller.h",
"+ash/shell.h",
],
# For ash::Shell::GetContainer (!mash)
"system_tray_client\.cc": [
"+ash/shell.h",
......
......@@ -35,6 +35,7 @@
#include "chrome/browser/ui/ash/network/data_promo_notification.h"
#include "chrome/browser/ui/ash/network/network_connect_delegate_chromeos.h"
#include "chrome/browser/ui/ash/network/network_portal_notification_controller.h"
#include "chrome/browser/ui/ash/screen_orientation_delegate_chromeos.h"
#include "chrome/browser/ui/ash/session_controller_client.h"
#include "chrome/browser/ui/ash/system_tray_client.h"
#include "chrome/browser/ui/ash/tab_scrubber.h"
......@@ -205,6 +206,13 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
std::move(user_activity_monitor), user_activity_detector_.get());
}
// TODO(estade): implement ScreenOrientationDelegateChromeos for Mash and
// remove this condition.
if (!features::IsUsingWindowService()) {
screen_orientation_delegate_ =
std::make_unique<ScreenOrientationDelegateChromeos>();
}
app_list_client_ = std::make_unique<AppListClientImpl>();
// Must be available at login screen, so initialize before profile.
......
......@@ -44,6 +44,7 @@ class LoginScreenClient;
class MediaClient;
class NetworkConnectDelegateChromeOS;
class NightLightClient;
class ScreenOrientationDelegateChromeos;
class SessionControllerClient;
class SystemTrayClient;
class TabletModeClient;
......@@ -97,6 +98,8 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<AppListClientImpl> app_list_client_;
std::unique_ptr<ChromeNewWindowClient> chrome_new_window_client_;
std::unique_ptr<ImeControllerClient> ime_controller_client_;
std::unique_ptr<ScreenOrientationDelegateChromeos>
screen_orientation_delegate_;
std::unique_ptr<SessionControllerClient> session_controller_client_;
std::unique_ptr<SystemTrayClient> system_tray_client_;
std::unique_ptr<TabletModeClient> tablet_mode_client_;
......
......@@ -2,37 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/content/screen_orientation_delegate_chromeos.h"
#include "chrome/browser/ui/ash/screen_orientation_delegate_chromeos.h"
#include "ash/display/screen_orientation_controller.h"
#include "ash/shell.h"
#include "ash/display/screen_orientation_controller.h" // mash-ok
#include "ash/shell.h" // mash-ok
#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "content/public/browser/web_contents.h"
namespace ash {
namespace {
OrientationLockType ToAshOrientationLockType(
ash::OrientationLockType ToAshOrientationLockType(
blink::WebScreenOrientationLockType blink_orientation_lock) {
switch (blink_orientation_lock) {
case blink::kWebScreenOrientationLockDefault:
case blink::kWebScreenOrientationLockAny:
return OrientationLockType::kAny;
return ash::OrientationLockType::kAny;
case blink::kWebScreenOrientationLockPortrait:
return OrientationLockType::kPortrait;
return ash::OrientationLockType::kPortrait;
case blink::kWebScreenOrientationLockPortraitPrimary:
return OrientationLockType::kPortraitPrimary;
return ash::OrientationLockType::kPortraitPrimary;
case blink::kWebScreenOrientationLockPortraitSecondary:
return OrientationLockType::kPortraitSecondary;
return ash::OrientationLockType::kPortraitSecondary;
case blink::kWebScreenOrientationLockLandscape:
return OrientationLockType::kLandscape;
return ash::OrientationLockType::kLandscape;
case blink::kWebScreenOrientationLockLandscapePrimary:
return OrientationLockType::kLandscapePrimary;
return ash::OrientationLockType::kLandscapePrimary;
case blink::kWebScreenOrientationLockLandscapeSecondary:
return OrientationLockType::kLandscapeSecondary;
return ash::OrientationLockType::kLandscapeSecondary;
case blink::kWebScreenOrientationLockNatural:
return OrientationLockType::kNatural;
return ash::OrientationLockType::kNatural;
}
return OrientationLockType::kAny;
return ash::OrientationLockType::kAny;
}
} // namespace
......@@ -53,21 +53,19 @@ bool ScreenOrientationDelegateChromeos::FullScreenRequired(
void ScreenOrientationDelegateChromeos::Lock(
content::WebContents* web_contents,
blink::WebScreenOrientationLockType orientation_lock) {
Shell::Get()->screen_orientation_controller()->LockOrientationForWindow(
ash::Shell::Get()->screen_orientation_controller()->LockOrientationForWindow(
web_contents->GetNativeView(),
ToAshOrientationLockType(orientation_lock));
}
bool ScreenOrientationDelegateChromeos::ScreenOrientationProviderSupported() {
return Shell::Get()
->screen_orientation_controller()
->ScreenOrientationProviderSupported();
return TabletModeClient::Get() &&
TabletModeClient::Get()->tablet_mode_enabled();
}
void ScreenOrientationDelegateChromeos::Unlock(
content::WebContents* web_contents) {
Shell::Get()->screen_orientation_controller()->UnlockOrientationForWindow(
web_contents->GetNativeView());
ash::Shell::Get()
->screen_orientation_controller()
->UnlockOrientationForWindow(web_contents->GetNativeView());
}
} // namespace ash
......@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
#define ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
#ifndef CHROME_BROWSER_UI_ASH_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
#define CHROME_BROWSER_UI_ASH_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
#include "content/public/browser/screen_orientation_delegate.h"
#include "ash/content/ash_with_content_export.h"
namespace ash {
class ASH_WITH_CONTENT_EXPORT ScreenOrientationDelegateChromeos
// Chrome OS implementation for screen orientation JS api. TODO(estade):
// implement for Mash.
class ScreenOrientationDelegateChromeos
: public content::ScreenOrientationDelegate {
public:
ScreenOrientationDelegateChromeos();
......@@ -28,6 +26,4 @@ class ASH_WITH_CONTENT_EXPORT ScreenOrientationDelegateChromeos
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDelegateChromeos);
};
} // namespace ash
#endif // ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
#endif // CHROME_BROWSER_UI_ASH_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment