summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/wm/custom_frame_view_ash.cc96
-rw-r--r--ash/wm/window_state.cc4
-rw-r--r--ash/wm/window_state.h1
-rw-r--r--chrome/browser/ui/ash/accelerator_commands_browsertest.cc372
-rw-r--r--chrome/browser/ui/views/apps/native_app_window_views.cc14
-rw-r--r--chrome/chrome_tests.gypi1
6 files changed, 416 insertions, 72 deletions
diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc
index 47a88bc..c4b58d5 100644
--- a/ash/wm/custom_frame_view_ash.cc
+++ b/ash/wm/custom_frame_view_ash.cc
@@ -4,13 +4,20 @@
#include "ash/wm/custom_frame_view_ash.h"
+#include "ash/ash_switches.h"
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
#include "ash/wm/caption_buttons/frame_maximize_button.h"
#include "ash/wm/caption_buttons/frame_maximize_button_observer.h"
#include "ash/wm/frame_border_hit_test_controller.h"
#include "ash/wm/header_painter.h"
#include "ash/wm/immersive_fullscreen_controller.h"
+#include "ash/wm/window_state.h"
+#include "ash/wm/window_state_delegate.h"
+#include "base/command_line.h"
#include "grit/ash_resources.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_observer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
@@ -30,6 +37,86 @@ const gfx::Font& GetTitleFont() {
return *title_font;
}
+///////////////////////////////////////////////////////////////////////////////
+// CustomFrameViewAshWindowStateDelegate
+
+// Handles a user's fullscreen request (Shift+F4/F4). Puts the window into
+// immersive fullscreen if the kAshEnableImmersiveFullscreenForAllWindows
+// flag is set.
+class CustomFrameViewAshWindowStateDelegate
+ : public ash::wm::WindowStateDelegate,
+ public ash::wm::WindowStateObserver,
+ public aura::WindowObserver {
+ public:
+ CustomFrameViewAshWindowStateDelegate(
+ ash::wm::WindowState* window_state,
+ ash::CustomFrameViewAsh* custom_frame_view)
+ : window_state_(window_state) {
+#if defined(OS_CHROMEOS)
+ // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for
+ // Windows Ash.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshEnableImmersiveFullscreenForAllWindows)) {
+ immersive_fullscreen_controller_.reset(
+ new ash::ImmersiveFullscreenController);
+ custom_frame_view->InitImmersiveFullscreenControllerForView(
+ immersive_fullscreen_controller_.get());
+
+ // Add a window state observer to exit fullscreen properly in case
+ // fullscreen is exited without going through
+ // WindowState::ToggleFullscreen(). This is the case when exiting
+ // immersive fullscreen via the "Restore" window control.
+ // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048
+ window_state->AddObserver(this);
+ window_state->window()->AddObserver(this);
+ }
+#endif
+ }
+ virtual ~CustomFrameViewAshWindowStateDelegate() {
+ if (window_state_) {
+ window_state_->RemoveObserver(this);
+ window_state_->window()->RemoveObserver(this);
+ }
+ }
+ private:
+ // Overridden from ash::wm::WindowStateDelegate:
+ virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE {
+ bool enter_fullscreen = !window_state->IsFullscreen();
+ if (enter_fullscreen) {
+ window_state->window()->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_FULLSCREEN);
+ } else {
+ window_state->Restore();
+ }
+ if (immersive_fullscreen_controller_)
+ immersive_fullscreen_controller_->SetEnabled(enter_fullscreen);
+ return true;
+ }
+ // Overridden from aura::WindowObserver:
+ virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
+ window_state_->RemoveObserver(this);
+ window_state_->window()->RemoveObserver(this);
+ window_state_ = NULL;
+ }
+ // Overridden from ash::wm::WindowStateObserver:
+ virtual void OnWindowShowTypeChanged(
+ ash::wm::WindowState* window_state,
+ ash::wm::WindowShowType old_type) OVERRIDE {
+ if (!window_state->IsFullscreen() &&
+ !window_state->IsMinimized() &&
+ immersive_fullscreen_controller_.get() &&
+ immersive_fullscreen_controller_->IsEnabled()) {
+ immersive_fullscreen_controller_->SetEnabled(false);
+ }
+ }
+
+ ash::wm::WindowState* window_state_;
+ scoped_ptr<ash::ImmersiveFullscreenController>
+ immersive_fullscreen_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshWindowStateDelegate);
+};
+
} // namespace
namespace ash {
@@ -302,6 +389,15 @@ CustomFrameViewAsh::CustomFrameViewAsh(views::Widget* frame)
// |header_view_| is set as the non client view's overlay view so that it can
// overlay the web contents in immersive fullscreen.
frame->non_client_view()->SetOverlayView(new OverlayView(header_view_));
+
+ // A delegate for a more complex way of fullscreening the window may already
+ // be set. This is the case for packaged apps.
+ wm::WindowState* window_state = wm::GetWindowState(frame->GetNativeWindow());
+ if (!window_state->HasDelegate()) {
+ window_state->SetDelegate(scoped_ptr<wm::WindowStateDelegate>(
+ new CustomFrameViewAshWindowStateDelegate(
+ window_state, this)).Pass());
+ }
}
CustomFrameViewAsh::~CustomFrameViewAsh() {
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc
index 0a47384..99598b4 100644
--- a/ash/wm/window_state.cc
+++ b/ash/wm/window_state.cc
@@ -61,6 +61,10 @@ WindowState::WindowState(aura::Window* window)
WindowState::~WindowState() {
}
+bool WindowState::HasDelegate() const {
+ return delegate_;
+}
+
void WindowState::SetDelegate(scoped_ptr<WindowStateDelegate> delegate) {
DCHECK(!delegate_.get());
delegate_ = delegate.Pass();
diff --git a/ash/wm/window_state.h b/ash/wm/window_state.h
index d67c1e5..92069a3 100644
--- a/ash/wm/window_state.h
+++ b/ash/wm/window_state.h
@@ -49,6 +49,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
aura::Window* window() { return window_; }
const aura::Window* window() const { return window_; }
+ bool HasDelegate() const;
void SetDelegate(scoped_ptr<WindowStateDelegate> delegate);
// Returns the window's current show state.
diff --git a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
index 704fc2f..fe22400 100644
--- a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
+++ b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
@@ -6,6 +6,7 @@
#include "apps/shell_window.h"
#include "apps/ui/native_app_window.h"
+#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/wm/window_state.h"
#include "base/command_line.h"
@@ -14,19 +15,41 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/test_switches.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+using testing::Combine;
+using testing::Values;
+using testing::WithParamInterface;
namespace {
-// Returns true if |window| is in immersive fullscreen. Infer whether |window|
-// is in immersive fullscreen based on whether the shelf is hidden when
-// |window| is fullscreen because DEPS does not allow the test to use
-// BrowserView. (This is not quite right because the shelf is hidden if a window
-// is in both immersive fullscreen and tab fullscreen.)
-bool IsInImmersiveFullscreen(BrowserWindow* browser_window) {
- ash::wm::WindowState* window_state = ash::wm::GetWindowState(
- browser_window->GetNativeWindow());
+// WidgetDelegateView which allows the widget to be maximized.
+class MaximizableWidgetDelegate : public views::WidgetDelegateView {
+ public:
+ MaximizableWidgetDelegate() {
+ }
+ virtual ~MaximizableWidgetDelegate() {
+ }
+
+ virtual bool CanMaximize() const OVERRIDE {
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaximizableWidgetDelegate);
+};
+
+// Returns true if |window_state|'s window is in immersive fullscreen. Infer
+// whether the window is in immersive fullscreen based on whether the shelf is
+// hidden when the window is fullscreen. (This is not quite right because the
+// shelf is hidden if a window is in both immersive fullscreen and tab
+// fullscreen.)
+bool IsInImmersiveFullscreen(ash::wm::WindowState* window_state) {
return window_state->IsFullscreen() &&
!window_state->hide_shelf_when_fullscreen();
}
@@ -37,6 +60,12 @@ typedef InProcessBrowserTest AcceleratorCommandsBrowserTest;
// Confirm that toggling window miximized works properly
IN_PROC_BROWSER_TEST_F(AcceleratorCommandsBrowserTest, ToggleMaximized) {
+#if defined(OS_WIN)
+ // Run the test on Win Ash only.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
+ return;
+#endif
+
ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance";
ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState();
ASSERT_TRUE(window_state);
@@ -62,98 +91,315 @@ IN_PROC_BROWSER_TEST_F(AcceleratorCommandsBrowserTest, ToggleMaximized) {
EXPECT_TRUE(window_state->IsMaximized());
}
-// Confirm that toggling window fullscren works properly.
-IN_PROC_BROWSER_TEST_F(AcceleratorCommandsBrowserTest, ToggleFullscreen) {
+class AcceleratorCommandsFullscreenBrowserTest
+ : public WithParamInterface<std::tr1::tuple<bool, ui::WindowShowState> >,
+ public InProcessBrowserTest {
+ public:
+ AcceleratorCommandsFullscreenBrowserTest()
+#if defined(OS_CHROMEOS)
+ : put_browser_in_immersive_(true),
+ put_all_windows_in_immersive_(std::tr1::get<0>(GetParam())),
+#else
+ : put_browser_in_immersive_(false),
+ put_all_windows_in_immersive_(false),
+#endif
+ initial_show_state_(std::tr1::get<1>(GetParam())) {
+ }
+ virtual ~AcceleratorCommandsFullscreenBrowserTest() {
+ }
+
+ // BrowserTestBase override:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ InProcessBrowserTest::SetUpCommandLine(command_line);
+ if (put_all_windows_in_immersive_) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ ash::switches::kAshEnableImmersiveFullscreenForAllWindows);
+ }
+ }
+
+ // Sets |window_state|'s show state to |initial_show_state_|.
+ void SetToInitialShowState(ash::wm::WindowState* window_state) {
+ if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED)
+ window_state->Maximize();
+ else
+ window_state->Restore();
+ }
+
+ // Returns true if |window_state|'s show state is |initial_show_state_|.
+ bool IsInitialShowState(const ash::wm::WindowState* window_state) const {
+ return window_state->GetShowState() == initial_show_state_;
+ }
+
+ bool put_browser_in_immersive() const {
+ return put_browser_in_immersive_;
+ }
+
+ bool put_all_windows_in_immersive() const {
+ return put_all_windows_in_immersive_;
+ }
+
+ private:
+ bool put_browser_in_immersive_;
+ bool put_all_windows_in_immersive_;
+ ui::WindowShowState initial_show_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorCommandsFullscreenBrowserTest);
+};
+
+// Test that toggling window fullscreen works properly.
+IN_PROC_BROWSER_TEST_P(AcceleratorCommandsFullscreenBrowserTest,
+ ToggleFullscreen) {
+#if defined(OS_WIN)
+ // Run the test on Win Ash only.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
+ return;
+#endif
+
ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance";
- // 1) ToggleFullscreen() should toggle whether a tabbed browser window is in
- // immersive fullscreen.
+
+ // 1) Browser windows.
ASSERT_TRUE(browser()->is_type_tabbed());
- BrowserWindow* browser_window = browser()->window();
- ASSERT_TRUE(browser_window->IsActive());
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ ash::wm::WindowState* window_state =
+ ash::wm::GetWindowState(browser()->window()->GetNativeWindow());
+ ASSERT_TRUE(window_state->IsActive());
+ SetToInitialShowState(window_state);
+ EXPECT_TRUE(IsInitialShowState(window_state));
ash::accelerators::ToggleFullscreen();
- EXPECT_TRUE(browser_window->IsFullscreen());
- EXPECT_TRUE(IsInImmersiveFullscreen(browser_window));
+ EXPECT_TRUE(window_state->IsFullscreen());
+ EXPECT_EQ(put_browser_in_immersive(), IsInImmersiveFullscreen(window_state));
ash::accelerators::ToggleFullscreen();
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ EXPECT_TRUE(IsInitialShowState(window_state));
// 2) ToggleFullscreen() should have no effect on windows which cannot be
// maximized.
- browser_window->GetNativeWindow()->SetProperty(aura::client::kCanMaximizeKey,
- false);
+ window_state->window()->SetProperty(aura::client::kCanMaximizeKey, false);
ash::accelerators::ToggleFullscreen();
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ EXPECT_TRUE(IsInitialShowState(window_state));
- // 3) ToggleFullscreen() should put v1 apps into non-immersive fullscreen.
+ // 3) Hosted apps.
Browser::CreateParams browser_create_params(Browser::TYPE_POPUP,
- browser()->profile(), chrome::HOST_DESKTOP_TYPE_NATIVE);
-#if defined(OS_WIN)
- browser_create_params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH;
-#endif // OS_WIN
+ browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH);
browser_create_params.app_name = "Test";
Browser* app_host_browser = new Browser(browser_create_params);
ASSERT_TRUE(app_host_browser->is_app());
AddBlankTabAndShow(app_host_browser);
- browser_window = app_host_browser->window();
- ASSERT_TRUE(browser_window->IsActive());
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ window_state =
+ ash::wm::GetWindowState(app_host_browser->window()->GetNativeWindow());
+ ASSERT_TRUE(window_state->IsActive());
+ SetToInitialShowState(window_state);
+ EXPECT_TRUE(IsInitialShowState(window_state));
ash::accelerators::ToggleFullscreen();
- EXPECT_TRUE(browser_window->IsFullscreen());
- EXPECT_FALSE(IsInImmersiveFullscreen(browser_window));
+ EXPECT_TRUE(window_state->IsFullscreen());
+ EXPECT_EQ(put_all_windows_in_immersive(),
+ IsInImmersiveFullscreen(window_state));
ash::accelerators::ToggleFullscreen();
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ EXPECT_TRUE(IsInitialShowState(window_state));
- // 4) ToggleFullscreen() should put popup browser windows into non-immersive
- // fullscreen.
+ // 4) Popup browser windows.
browser_create_params.app_name = "";
Browser* popup_browser = new Browser(browser_create_params);
ASSERT_TRUE(popup_browser->is_type_popup());
ASSERT_FALSE(popup_browser->is_app());
AddBlankTabAndShow(popup_browser);
- browser_window = popup_browser->window();
- ASSERT_TRUE(browser_window->IsActive());
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ window_state =
+ ash::wm::GetWindowState(popup_browser->window()->GetNativeWindow());
+ ASSERT_TRUE(window_state->IsActive());
+ SetToInitialShowState(window_state);
+ EXPECT_TRUE(IsInitialShowState(window_state));
+
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(window_state->IsFullscreen());
+ EXPECT_EQ(put_all_windows_in_immersive(),
+ IsInImmersiveFullscreen(window_state));
ash::accelerators::ToggleFullscreen();
- EXPECT_TRUE(browser_window->IsFullscreen());
- EXPECT_FALSE(IsInImmersiveFullscreen(browser_window));
+ EXPECT_TRUE(IsInitialShowState(window_state));
+ // 5) Miscellaneous windows (e.g. task manager).
+ views::Widget::InitParams params;
+ params.delegate = new MaximizableWidgetDelegate();
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ scoped_ptr<views::Widget> widget(new views::Widget);
+ widget->Init(params);
+ widget->Show();
+
+ window_state = ash::wm::GetWindowState(widget->GetNativeWindow());
+ ASSERT_TRUE(window_state->IsActive());
+ SetToInitialShowState(window_state);
+ EXPECT_TRUE(IsInitialShowState(window_state));
+
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(window_state->IsFullscreen());
+ EXPECT_EQ(put_all_windows_in_immersive(),
+ IsInImmersiveFullscreen(window_state));
+
+ // TODO(pkotwicz|oshima): Make toggling fullscreen restore the window to its
+ // show state prior to entering fullscreen.
ash::accelerators::ToggleFullscreen();
- EXPECT_FALSE(browser_window->IsMaximized());
- EXPECT_FALSE(browser_window->IsFullscreen());
+ EXPECT_FALSE(window_state->IsFullscreen());
}
-typedef extensions::PlatformAppBrowserTest
- AcceleratorCommandsPlatformAppBrowserTest;
+#if defined(OS_CHROMEOS)
+INSTANTIATE_TEST_CASE_P(InitiallyRestored,
+ AcceleratorCommandsFullscreenBrowserTest,
+ Combine(Values(false, true),
+ Values(ui::SHOW_STATE_NORMAL)));
+INSTANTIATE_TEST_CASE_P(InitiallyMaximized,
+ AcceleratorCommandsFullscreenBrowserTest,
+ Combine(Values(false, true),
+ Values(ui::SHOW_STATE_MAXIMIZED)));
+#else
+// The kAshEnableImmersiveFullscreenForAllWindows flag should have no effect on
+// Windows. Do not run the tests with and without the flag to spare some
+// cycles.
+INSTANTIATE_TEST_CASE_P(InitiallyRestored,
+ AcceleratorCommandsFullscreenBrowserTest,
+ Combine(Values(false),
+ Values(ui::SHOW_STATE_NORMAL)));
+INSTANTIATE_TEST_CASE_P(InitiallyMaximized,
+ AcceleratorCommandsFullscreenBrowserTest,
+ Combine(Values(false),
+ Values(ui::SHOW_STATE_MAXIMIZED)));
+#endif
+
+class AcceleratorCommandsPlatformAppFullscreenBrowserTest
+ : public WithParamInterface<std::tr1::tuple<bool, ui::WindowShowState> >,
+ public extensions::PlatformAppBrowserTest {
+ public:
+ AcceleratorCommandsPlatformAppFullscreenBrowserTest()
+#if defined(OS_CHROMEOS)
+ : put_all_windows_in_immersive_(std::tr1::get<0>(GetParam())),
+#else
+ : put_all_windows_in_immersive_(false),
+#endif
+ initial_show_state_(std::tr1::get<1>(GetParam())) {
+ }
+ virtual ~AcceleratorCommandsPlatformAppFullscreenBrowserTest() {
+ }
+
+ // Sets |shell_window|'s show state to |initial_show_state_|.
+ void SetToInitialShowState(apps::ShellWindow* shell_window) {
+ if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED)
+ shell_window->Maximize();
+ else
+ shell_window->Restore();
+ }
+
+ // Returns true if |shell_window|'s show state is |initial_show_state_|.
+ bool IsInitialShowState(apps::ShellWindow* shell_window) const {
+ if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED)
+ return shell_window->GetBaseWindow()->IsMaximized();
+ else
+ return ui::BaseWindow::IsRestored(*shell_window->GetBaseWindow());
+ }
+
+ // content::BrowserTestBase override:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ if (put_all_windows_in_immersive_) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ ash::switches::kAshEnableImmersiveFullscreenForAllWindows);
+ }
+ extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
+ }
+
+ bool put_all_windows_in_immersive() const {
+ return put_all_windows_in_immersive_;
+ }
+
+ private:
+ bool put_all_windows_in_immersive_;
+ ui::WindowShowState initial_show_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorCommandsPlatformAppFullscreenBrowserTest);
+};
+
+// Test the behavior of platform apps when ToggleFullscreen() is called.
+IN_PROC_BROWSER_TEST_P(AcceleratorCommandsPlatformAppFullscreenBrowserTest,
+ ToggleFullscreen) {
+#if defined(OS_WIN)
+ // Run the test on Win Ash only.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
+ return;
+#endif
-// Test that ToggleFullscreen() toggles the platform app's fullscreen state.
-IN_PROC_BROWSER_TEST_F(AcceleratorCommandsPlatformAppBrowserTest,
- ToggleFullscreenPlatformApp) {
ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance";
const extensions::Extension* extension = LoadAndLaunchPlatformApp("minimal");
- apps::ShellWindow* shell_window = CreateShellWindow(extension);
- apps::NativeAppWindow* app_window = shell_window->GetBaseWindow();
- ASSERT_TRUE(shell_window->GetBaseWindow()->IsActive());
- EXPECT_FALSE(app_window->IsMaximized());
- EXPECT_FALSE(app_window->IsFullscreen());
- ash::accelerators::ToggleFullscreen();
- EXPECT_TRUE(app_window->IsFullscreen());
+ {
+ // Test that ToggleFullscreen() toggles a platform's app's fullscreen
+ // state and that it additionally puts the app into immersive fullscreen
+ // if put_all_windows_in_immersive() returns true.
+ apps::ShellWindow::CreateParams params;
+ params.frame = apps::ShellWindow::FRAME_CHROME;
+ apps::ShellWindow* shell_window = CreateShellWindowFromParams(
+ extension, params);
+ apps::NativeAppWindow* app_window = shell_window->GetBaseWindow();
+ SetToInitialShowState(shell_window);
+ ASSERT_TRUE(shell_window->GetBaseWindow()->IsActive());
+ EXPECT_TRUE(IsInitialShowState(shell_window));
- ash::accelerators::ToggleFullscreen();
- EXPECT_FALSE(app_window->IsMaximized());
- EXPECT_FALSE(app_window->IsFullscreen());
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(app_window->IsFullscreen());
+ ash::wm::WindowState* window_state =
+ ash::wm::GetWindowState(app_window->GetNativeWindow());
+ EXPECT_EQ(put_all_windows_in_immersive(),
+ IsInImmersiveFullscreen(window_state));
+
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(IsInitialShowState(shell_window));
- CloseShellWindow(shell_window);
+ CloseShellWindow(shell_window);
+ }
+
+ {
+ // Repeat the test, but make sure that frameless platform apps are never put
+ // into immersive fullscreen.
+ apps::ShellWindow::CreateParams params;
+ params.frame = apps::ShellWindow::FRAME_NONE;
+ apps::ShellWindow* shell_window = CreateShellWindowFromParams(
+ extension, params);
+ apps::NativeAppWindow* app_window = shell_window->GetBaseWindow();
+ ASSERT_TRUE(shell_window->GetBaseWindow()->IsActive());
+ SetToInitialShowState(shell_window);
+ EXPECT_TRUE(IsInitialShowState(shell_window));
+
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(app_window->IsFullscreen());
+ ash::wm::WindowState* window_state =
+ ash::wm::GetWindowState(app_window->GetNativeWindow());
+ EXPECT_FALSE(IsInImmersiveFullscreen(window_state));
+
+ ash::accelerators::ToggleFullscreen();
+ EXPECT_TRUE(IsInitialShowState(shell_window));
+
+ CloseShellWindow(shell_window);
+ }
}
+
+#if defined(OS_CHROMEOS)
+INSTANTIATE_TEST_CASE_P(InitiallyRestored,
+ AcceleratorCommandsPlatformAppFullscreenBrowserTest,
+ Combine(Values(false, true),
+ Values(ui::SHOW_STATE_NORMAL)));
+INSTANTIATE_TEST_CASE_P(InitiallyMaximized,
+ AcceleratorCommandsPlatformAppFullscreenBrowserTest,
+ Combine(Values(false, true),
+ Values(ui::SHOW_STATE_MAXIMIZED)));
+#else
+// The kAshEnableImmersiveFullscreenForAllWindows flag should have no effect on
+// Windows. Do not run the tests with and without the flag to spare some
+// cycles.
+INSTANTIATE_TEST_CASE_P(InitiallyRestored,
+ AcceleratorCommandsPlatformAppFullscreenBrowserTest,
+ Combine(Values(false),
+ Values(ui::SHOW_STATE_NORMAL)));
+INSTANTIATE_TEST_CASE_P(InitiallyMaximized,
+ AcceleratorCommandsPlatformAppFullscreenBrowserTest,
+ Combine(Values(false),
+ Values(ui::SHOW_STATE_MAXIMIZED)));
+#endif
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc
index dce6d3f..c5a8b95 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc
@@ -235,14 +235,6 @@ NativeAppWindowViews::NativeAppWindowViews(
OnViewWasResized();
window_->AddObserver(this);
-#if defined(USE_ASH)
- if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) ==
- chrome::HOST_DESKTOP_TYPE_ASH) {
- ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
- scoped_ptr<ash::wm::WindowStateDelegate>(
- new NativeAppWindowStateDelegate(shell_window, this)).Pass());
- }
-#endif
}
NativeAppWindowViews::~NativeAppWindowViews() {
@@ -756,6 +748,12 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
views::Widget* widget) {
#if defined(USE_ASH)
if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
+ // Set the delegate now because CustomFrameViewAsh sets the
+ // WindowStateDelegate if one is not already set.
+ ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
+ scoped_ptr<ash::wm::WindowStateDelegate>(
+ new NativeAppWindowStateDelegate(shell_window_, this)).Pass());
+
if (shell_window_->window_type_is_panel()) {
ash::PanelFrameView::FrameType frame_type = frameless_ ?
ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 10387df..b970cd7 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1854,7 +1854,6 @@
# for win aura builds.
# TODO: enable these for win_ash browser tests.
'browser/chromeos/system/tray_accessibility_browsertest.cc',
- 'browser/ui/ash/accelerator_commands_browsertest.cc',
'browser/ui/ash/caps_lock_delegate_chromeos_browsertest.cc',
'browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc',
'browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc',