Commit f5beba8b authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Set WindowStateType::PIP for Chrome PIP window

This CL adds ash window type (WindowStateType::PIP) to Chrome PIP window
only in Chrome OS.

This window type is used for distinguish PIP windows and manages them in
Chrome OS ash shell.

Bug: b/112060145
Change-Id: I9fb51e50577b8ebe9d690b6c2d83e300951d9846
Reviewed-on: https://chromium-review.googlesource.com/c/1242726
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarEliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604494}
parent e6e678e6
......@@ -196,4 +196,5 @@ DEFINE_UI_CLASS_PROPERTY_KEY(mojom::WindowStateType,
kWindowStateTypeKey,
mojom::WindowStateType::DEFAULT);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowPipTypeKey, false);
} // namespace ash
......@@ -185,6 +185,10 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<
mojom::WindowStateType>* const kWindowStateTypeKey;
// A property key to indicate pip window state.
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
kWindowPipTypeKey;
// Alphabetical sort.
} // namespace ash
......
......@@ -72,6 +72,8 @@ mojom::WindowStateType BaseState::GetStateForTransitionEvent(
return mojom::WindowStateType::INACTIVE;
case WM_EVENT_PIN:
return mojom::WindowStateType::PINNED;
case WM_EVENT_PIP:
return mojom::WindowStateType::PIP;
case WM_EVENT_TRUSTED_PIN:
return mojom::WindowStateType::TRUSTED_PINNED;
default:
......
......@@ -37,6 +37,7 @@ void LockWindowState::OnWMEvent(wm::WindowState* window_state,
case wm::WM_EVENT_FULLSCREEN:
UpdateWindow(window_state, mojom::WindowStateType::FULLSCREEN);
break;
case wm::WM_EVENT_PIP:
case wm::WM_EVENT_PIN:
case wm::WM_EVENT_TRUSTED_PIN:
NOTREACHED();
......
......@@ -223,6 +223,12 @@ void TabletModeWindowState::OnWMEvent(wm::WindowState* window_state,
UpdateWindow(window_state, mojom::WindowStateType::PINNED,
true /* animated */);
break;
case wm::WM_EVENT_PIP:
if (!window_state->IsPip()) {
UpdateWindow(window_state, mojom::WindowStateType::PIP,
true /* animated */);
}
break;
case wm::WM_EVENT_TRUSTED_PIN:
if (!Shell::Get()->screen_pinning_controller()->IsPinned())
UpdateWindow(window_state, mojom::WindowStateType::TRUSTED_PINNED,
......
......@@ -747,6 +747,16 @@ void WindowState::OnWindowPropertyChanged(aura::Window* window,
}
return;
}
if (key == kWindowPipTypeKey) {
if (window->GetProperty(kWindowPipTypeKey)) {
WMEvent event(WM_EVENT_PIP);
OnWMEvent(&event);
} else {
// Currently "restore" is not implemented.
NOTIMPLEMENTED();
}
return;
}
if (key == kWindowStateTypeKey) {
if (!ignore_property_change_) {
// This change came from somewhere else. Revert it.
......
......@@ -76,6 +76,7 @@ bool WMEvent::IsTransitionEvent() const {
case WM_EVENT_SHOW_INACTIVE:
case WM_EVENT_PIN:
case WM_EVENT_TRUSTED_PIN:
case WM_EVENT_PIP:
return true;
default:
break;
......
......@@ -91,6 +91,9 @@ enum WMEventType {
// A user requested to pin a window.
WM_EVENT_PIN,
// A user requested to pip a window.
WM_EVENT_PIP,
// A user requested to pin a window for a trusted application. This is similar
// WM_EVENT_PIN but does not allow user to exit the mode by shortcut key.
WM_EVENT_TRUSTED_PIN,
......
......@@ -33,6 +33,11 @@
#include "ui/views/window/non_client_view.h"
#include "ui/views/window/window_resize_utils.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/window_properties.h" // nogncheck
#include "ui/aura/window.h"
#endif
// static
std::unique_ptr<content::OverlayWindow> content::OverlayWindow::Create(
content::PictureInPictureWindowController* controller) {
......@@ -183,6 +188,7 @@ OverlayWindowViews::OverlayWindowViews(
params.keep_on_top = true;
params.visible_on_all_workspaces = true;
params.remove_standard_frame = true;
params.name = "PictureInPictureWindow";
// Set WidgetDelegate for more control over |widget_|.
params.delegate = new OverlayWindowWidgetDelegate(this);
......@@ -190,6 +196,10 @@ OverlayWindowViews::OverlayWindowViews(
Init(params);
SetUpViews();
#if defined(OS_CHROMEOS)
GetNativeWindow()->SetProperty(ash::kWindowPipTypeKey, true);
#endif // defined(OS_CHROMEOS)
is_initialized_ = true;
}
......
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