diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 23:37:16 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 23:37:16 +0000 |
commit | 2ee2f5db813d4f9ac9c129c67c3fb2b3c01ae999 (patch) | |
tree | a11e262fa33def6946ebc1cf0169b1668da65e74 /ash | |
parent | 8521c5c456550b9e46f85726d52ff51715cbfa36 (diff) | |
download | chromium_src-2ee2f5db813d4f9ac9c129c67c3fb2b3c01ae999.zip chromium_src-2ee2f5db813d4f9ac9c129c67c3fb2b3c01ae999.tar.gz chromium_src-2ee2f5db813d4f9ac9c129c67c3fb2b3c01ae999.tar.bz2 |
ash/immersive mode: Hide the launcher when entering immersive mode
* Set shelf to auto-hide when enabling immersive mode
* Directly access ash::Shell for auto-hide so we don't overwrite
the user's preferences
BUG=168592
TEST=added to browser_tests ImmersiveModeController
Review URL: https://chromiumcodereview.appspot.com/11830008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176206 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/root_window_controller.cc | 10 | ||||
-rw-r--r-- | ash/root_window_controller.h | 4 | ||||
-rw-r--r-- | ash/root_window_controller_unittest.cc | 31 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 5 | ||||
-rw-r--r-- | ash/wm/window_properties.cc | 1 | ||||
-rw-r--r-- | ash/wm/window_properties.h | 3 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.cc | 4 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.h | 3 | ||||
-rw-r--r-- | ash/wm/workspace_controller.cc | 5 | ||||
-rw-r--r-- | ash/wm/workspace_controller.h | 5 |
10 files changed, 69 insertions, 2 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index 1993e418..5ea37bb 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -512,6 +512,16 @@ ShelfAlignment RootWindowController::GetShelfAlignment() { return shelf_->GetAlignment(); } +bool RootWindowController::IsImmersiveMode() const { + aura::Window* container = workspace_controller_->GetActiveWorkspaceWindow(); + for (size_t i = 0; i < container->children().size(); ++i) { + aura::Window* child = container->children()[i]; + if (child->IsVisible() && child->GetProperty(kImmersiveModeKey)) + return true; + } + return false; +} + //////////////////////////////////////////////////////////////////////////////// // RootWindowController, private: diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 92185a6..e5e85ef1 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -164,6 +164,10 @@ class ASH_EXPORT RootWindowController { bool SetShelfAlignment(ShelfAlignment alignment); ShelfAlignment GetShelfAlignment(); + // Returns true if the active workspace is in immersive mode. Exposed here + // so clients of Ash don't need to know the details of workspace management. + bool IsImmersiveMode() const; + private: // Creates each of the special window containers that holds windows of various // types in the shell UI. diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index 8dac9d3..54aa82d 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -11,6 +11,7 @@ #include "ash/system/tray/system_tray_delegate.h" #include "ash/test/ash_test_base.h" #include "ash/wm/system_modal_container_layout_manager.h" +#include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" #include "ui/aura/client/focus_change_observer.h" #include "ui/aura/client/focus_client.h" @@ -25,6 +26,9 @@ #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" +using aura::Window; +using views::Widget; + namespace ash { namespace { @@ -319,5 +323,32 @@ TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { session_modal_widget->GetNativeView())); } +// Ensure a workspace with two windows reports immersive mode even if only +// one has the property set. +TEST_F(RootWindowControllerTest, ImmersiveMode) { + UpdateDisplay("600x600"); + internal::RootWindowController* controller = + Shell::GetInstance()->GetPrimaryRootWindowController(); + + // Open a maximized window. + Widget* w1 = CreateTestWidget(gfx::Rect(0, 1, 250, 251)); + w1->Maximize(); + + // Immersive mode off by default. + EXPECT_FALSE(controller->IsImmersiveMode()); + + // Enter immersive mode. + w1->GetNativeWindow()->SetProperty(ash::internal::kImmersiveModeKey, true); + EXPECT_TRUE(controller->IsImmersiveMode()); + + // Add a child, like a print window. Still in immersive mode. + Widget* w2 = + Widget::CreateWindowWithParentAndBounds(NULL, + w1->GetNativeWindow(), + gfx::Rect(0, 1, 150, 151)); + w2->Show(); + EXPECT_TRUE(controller->IsImmersiveMode()); +} + } // namespace test } // namespace ash diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index a04a05f..85130c2 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -15,6 +15,7 @@ #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/system/status_area_widget.h" +#include "ash/wm/property_util.h" #include "ash/wm/workspace_controller.h" #include "ash/wm/workspace/workspace_animations.h" #include "base/auto_reset.h" @@ -257,6 +258,10 @@ void ShelfLayoutManager::UpdateVisibilityState() { SetState(SHELF_VISIBLE); } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { SetState(SHELF_AUTO_HIDE); + } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { + // The user choosing immersive mode indicates he or she wants to maximize + // screen real-estate for content, so always auto-hide the shelf. + SetState(SHELF_AUTO_HIDE); } else { WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); switch (window_state) { diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc index 874f030..a9bc168 100644 --- a/ash/wm/window_properties.cc +++ b/ash/wm/window_properties.cc @@ -24,6 +24,7 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::internal::AlwaysOnTopController, NULL); DEFINE_WINDOW_PROPERTY_KEY(bool, kIgnoreSoloWindowFramePainterPolicy, false); DEFINE_WINDOW_PROPERTY_KEY(bool, kIgnoredByShelfKey, false); +DEFINE_WINDOW_PROPERTY_KEY(bool, kImmersiveModeKey, false); DEFINE_WINDOW_PROPERTY_KEY( ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT); DEFINE_WINDOW_PROPERTY_KEY(RootWindowController*, diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h index 0136f86..026c72d 100644 --- a/ash/wm/window_properties.h +++ b/ash/wm/window_properties.h @@ -43,6 +43,9 @@ ASH_EXPORT extern const aura::WindowProperty<bool>* const extern const aura::WindowProperty<bool>* const kIgnoredByShelfKey; +// True if this is a browser window in immersive mode. +ASH_EXPORT extern const aura::WindowProperty<bool>* const kImmersiveModeKey; + // Used to remember the show state before the window was minimized. extern const aura::WindowProperty<ui::WindowShowState>* const kRestoreShowStateKey; diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index 0426d78..95c63f1 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -236,6 +236,10 @@ void WorkspaceManager::SetActiveWorkspaceByWindow(Window* window) { } } +Window* WorkspaceManager::GetActiveWorkspaceWindow() { + return active_workspace_->window(); +} + Window* WorkspaceManager::GetParentForNewWindow(Window* window) { // Try to put windows with transient parents in the same workspace as their // transient parent. diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h index 79bf0ac..08a50bbe 100644 --- a/ash/wm/workspace/workspace_manager.h +++ b/ash/wm/workspace/workspace_manager.h @@ -79,6 +79,9 @@ class ASH_EXPORT WorkspaceManager : public ash::ShellObserver { // NULL or not contained in a workspace. void SetActiveWorkspaceByWindow(aura::Window* window); + // Returns the container window for the active workspace, never NULL. + aura::Window* GetActiveWorkspaceWindow(); + // Returns the parent for |window|. This is invoked from StackingController // when a new Window is being added. aura::Window* GetParentForNewWindow(aura::Window* window); diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index 3ca70d6..93099f9 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -46,11 +46,14 @@ void WorkspaceController::SetActiveWorkspaceByWindow(aura::Window* window) { return workspace_manager_->SetActiveWorkspaceByWindow(window); } +aura::Window* WorkspaceController::GetActiveWorkspaceWindow() { + return workspace_manager_->GetActiveWorkspaceWindow(); +} + aura::Window* WorkspaceController::GetParentForNewWindow(aura::Window* window) { return workspace_manager_->GetParentForNewWindow(window); } - void WorkspaceController::DoInitialAnimation() { workspace_manager_->DoInitialAnimation(); } diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h index a77863a..ba82e09 100644 --- a/ash/wm/workspace_controller.h +++ b/ash/wm/workspace_controller.h @@ -40,7 +40,10 @@ class ASH_EXPORT WorkspaceController // Sets the active workspace based on |window|. void SetActiveWorkspaceByWindow(aura::Window* window); - // See description in BaseWorkspaceManager::GetParentForNewWindow(). + // Returns the container window for the active workspace, never NULL. + aura::Window* GetActiveWorkspaceWindow(); + + // See description in WorkspaceManager::GetParentForNewWindow(). aura::Window* GetParentForNewWindow(aura::Window* window); // Starts the animation that occurs on first login. |