blob: 6dd0d6835277593034cb6c5b38e076609f24cf1c [file] [log] [blame]
benf6de9852015-10-06 21:29:281// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/content/screen_orientation_delegate_chromeos.h"
6
Mitsuru Oshimaddfde3552018-03-22 09:12:137#include "ash/display/screen_orientation_controller.h"
benf6de9852015-10-06 21:29:288#include "ash/shell.h"
benf6de9852015-10-06 21:29:289#include "content/public/browser/web_contents.h"
10
11namespace ash {
Mitsuru Oshimac6b51112018-03-19 21:05:2912namespace {
13
14OrientationLockType ToAshOrientationLockType(
15 blink::WebScreenOrientationLockType blink_orientation_lock) {
16 switch (blink_orientation_lock) {
17 case blink::kWebScreenOrientationLockDefault:
18 case blink::kWebScreenOrientationLockAny:
19 return OrientationLockType::kAny;
20 case blink::kWebScreenOrientationLockPortrait:
21 return OrientationLockType::kPortrait;
22 case blink::kWebScreenOrientationLockPortraitPrimary:
23 return OrientationLockType::kPortraitPrimary;
24 case blink::kWebScreenOrientationLockPortraitSecondary:
25 return OrientationLockType::kPortraitSecondary;
26 case blink::kWebScreenOrientationLockLandscape:
27 return OrientationLockType::kLandscape;
28 case blink::kWebScreenOrientationLockLandscapePrimary:
29 return OrientationLockType::kLandscapePrimary;
30 case blink::kWebScreenOrientationLockLandscapeSecondary:
31 return OrientationLockType::kLandscapeSecondary;
32 case blink::kWebScreenOrientationLockNatural:
33 return OrientationLockType::kNatural;
34 }
35 return OrientationLockType::kAny;
36}
37
38} // namespace
benf6de9852015-10-06 21:29:2839
40ScreenOrientationDelegateChromeos::ScreenOrientationDelegateChromeos() {
leon.han552e9de2017-02-09 14:37:3041 content::WebContents::SetScreenOrientationDelegate(this);
benf6de9852015-10-06 21:29:2842}
mswa8c8a552016-07-13 02:22:2043
benf6de9852015-10-06 21:29:2844ScreenOrientationDelegateChromeos::~ScreenOrientationDelegateChromeos() {
leon.han552e9de2017-02-09 14:37:3045 content::WebContents::SetScreenOrientationDelegate(nullptr);
benf6de9852015-10-06 21:29:2846}
47
48bool ScreenOrientationDelegateChromeos::FullScreenRequired(
49 content::WebContents* web_contents) {
50 return true;
51}
52
53void ScreenOrientationDelegateChromeos::Lock(
54 content::WebContents* web_contents,
Mitsuru Oshimac6b51112018-03-19 21:05:2955 blink::WebScreenOrientationLockType orientation_lock) {
skycb4be5b2017-04-06 17:52:4556 Shell::Get()->screen_orientation_controller()->LockOrientationForWindow(
Mitsuru Oshima850d9722018-03-21 21:24:2057 web_contents->GetNativeView(),
58 ToAshOrientationLockType(orientation_lock));
benf6de9852015-10-06 21:29:2859}
60
61bool ScreenOrientationDelegateChromeos::ScreenOrientationProviderSupported() {
skycb4be5b2017-04-06 17:52:4562 return Shell::Get()
benf6de9852015-10-06 21:29:2863 ->screen_orientation_controller()
64 ->ScreenOrientationProviderSupported();
65}
mswa8c8a552016-07-13 02:22:2066
benf6de9852015-10-06 21:29:2867void ScreenOrientationDelegateChromeos::Unlock(
68 content::WebContents* web_contents) {
skycb4be5b2017-04-06 17:52:4569 Shell::Get()->screen_orientation_controller()->UnlockOrientationForWindow(
varkha843aa522017-05-24 16:05:5970 web_contents->GetNativeView());
benf6de9852015-10-06 21:29:2871}
72
73} // namespace ash