Commit c0ff6975 authored by hidehiko's avatar hidehiko Committed by Commit bot

Prevent maximize/minimize/fullscreen-ize window in trusted pinned mode.

If the window is in the trusted pinned mode,
we do not expect that can enter into another mode, e.g.
maximized/minimized/fulscreen mode, without explicit
unpin action by client.

BUG=665943
TEST=Ran trybots. Tested in ARC kiosk mode, and the apps can continue
     to run on a pinnded window.

Review-Url: https://codereview.chromium.org/2590123002
Cr-Commit-Position: refs/heads/master@{#441872}
parent 7254e350
...@@ -167,6 +167,10 @@ void DefaultState::OnWMEvent(WindowState* window_state, const WMEvent* event) { ...@@ -167,6 +167,10 @@ void DefaultState::OnWMEvent(WindowState* window_state, const WMEvent* event) {
if (ProcessWorkspaceEvents(window_state, event)) if (ProcessWorkspaceEvents(window_state, event))
return; return;
// Do not change the PINNED window state if this is not unpin event.
if (window_state->IsTrustedPinned() && event->type() != WM_EVENT_NORMAL)
return;
if (ProcessCompoundEvents(window_state, event)) if (ProcessCompoundEvents(window_state, event))
return; return;
......
...@@ -87,6 +87,10 @@ bool WindowState::IsPinned() const { ...@@ -87,6 +87,10 @@ bool WindowState::IsPinned() const {
GetStateType() == WINDOW_STATE_TYPE_TRUSTED_PINNED; GetStateType() == WINDOW_STATE_TYPE_TRUSTED_PINNED;
} }
bool WindowState::IsTrustedPinned() const {
return GetStateType() == WINDOW_STATE_TYPE_TRUSTED_PINNED;
}
bool WindowState::IsNormalStateType() const { bool WindowState::IsNormalStateType() const {
return GetStateType() == WINDOW_STATE_TYPE_NORMAL || return GetStateType() == WINDOW_STATE_TYPE_NORMAL ||
GetStateType() == WINDOW_STATE_TYPE_DEFAULT; GetStateType() == WINDOW_STATE_TYPE_DEFAULT;
......
...@@ -97,6 +97,7 @@ class ASH_EXPORT WindowState { ...@@ -97,6 +97,7 @@ class ASH_EXPORT WindowState {
bool IsFullscreen() const; bool IsFullscreen() const;
bool IsSnapped() const; bool IsSnapped() const;
bool IsPinned() const; bool IsPinned() const;
bool IsTrustedPinned() const;
// True if the window's state type is WINDOW_STATE_TYPE_MAXIMIZED, // True if the window's state type is WINDOW_STATE_TYPE_MAXIMIZED,
// WINDOW_STATE_TYPE_FULLSCREEN or WINDOW_STATE_TYPE_PINNED. // WINDOW_STATE_TYPE_FULLSCREEN or WINDOW_STATE_TYPE_PINNED.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/common/wm/wm_event.h" #include "ash/common/wm/wm_event.h"
#include "ash/test/ash_md_test_base.h" #include "ash/test/ash_md_test_base.h"
#include "ash/wm/window_state_aura.h" #include "ash/wm/window_state_aura.h"
#include "ash/wm/window_util.h"
#include "services/ui/public/interfaces/window_manager_constants.mojom.h" #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
...@@ -360,6 +361,33 @@ TEST_P(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) { ...@@ -360,6 +361,33 @@ TEST_P(WindowStateTest, DoNotResizeMaximizedWindowInFullscreen) {
maximized->GetBoundsInScreen().ToString()); maximized->GetBoundsInScreen().ToString());
} }
TEST_P(WindowStateTest, TrustedPinned) {
std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
WindowState* window_state = GetWindowState(window.get());
EXPECT_FALSE(window_state->IsTrustedPinned());
wm::PinWindow(window.get(), true /* trusted */);
EXPECT_TRUE(window_state->IsTrustedPinned());
gfx::Rect work_area =
display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
EXPECT_EQ(work_area.ToString(), window->bounds().ToString());
// Sending non-unpin/non-workspace related event should be ignored.
{
const WMEvent fullscreen_event(WM_EVENT_FULLSCREEN);
window_state->OnWMEvent(&fullscreen_event);
}
EXPECT_TRUE(window_state->IsTrustedPinned());
// Update display triggers workspace event.
UpdateDisplay("300x200");
EXPECT_EQ("0,0 300x200", window->GetBoundsInScreen().ToString());
// Unpin should work.
window_state->Restore();
EXPECT_FALSE(window_state->IsTrustedPinned());
}
TEST_P(WindowStateTest, AllowSetBoundsInMaximized) { TEST_P(WindowStateTest, AllowSetBoundsInMaximized) {
std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
WindowState* window_state = GetWindowState(window.get()); WindowState* window_state = GetWindowState(window.get());
......
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