summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskuhne@google.com <skuhne@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 23:52:06 +0000
committerskuhne@google.com <skuhne@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 23:52:06 +0000
commit35eb19b660c1508814f1becf74953521c445c919 (patch)
tree1991318b79cb3f883ba3e783e04435252a56d445
parent228b78dca4699376c3e612db650d02222fc0a021 (diff)
downloadchromium_src-35eb19b660c1508814f1becf74953521c445c919.zip
chromium_src-35eb19b660c1508814f1becf74953521c445c919.tar.gz
chromium_src-35eb19b660c1508814f1becf74953521c445c919.tar.bz2
Merge 287949 "Fixing problem with the maximize mode where MultiP..."
> Fixing problem with the maximize mode where MultiProfile windows do not get properly handled > > BUG=391334 > TEST=visual > > Review URL: https://codereview.chromium.org/437213005 TBR=skuhne@chromium.org Review URL: https://codereview.chromium.org/469563002 git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@289122 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.cc5
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.h10
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.cc12
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.h6
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc8
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc42
6 files changed, 83 insertions, 0 deletions
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index a32812a..7d8485f 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -192,6 +192,11 @@ bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const {
return maximize_mode_window_manager_.get() != NULL;
}
+void MaximizeModeController::AddWindow(aura::Window* window) {
+ if (IsMaximizeModeWindowManagerEnabled())
+ maximize_mode_window_manager_->AddWindow(window);
+}
+
void MaximizeModeController::Shutdown() {
maximize_mode_window_manager_.reset();
Shell::GetInstance()->OnMaximizeModeEnded();
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.h b/ash/wm/maximize_mode/maximize_mode_controller.h
index 8445bfa..8c0f719 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.h
+++ b/ash/wm/maximize_mode/maximize_mode_controller.h
@@ -26,6 +26,9 @@ class MaximizeModeControllerTest;
class MaximizeModeEventBlocker;
class MaximizeModeWindowManager;
class MaximizeModeWindowManagerTest;
+namespace test {
+class MultiUserWindowManagerChromeOSTest;
+}
// MaximizeModeController listens to accelerometer events and automatically
// enters and exits maximize mode when the lid is opened beyond the triggering
@@ -82,6 +85,12 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
// Test if the MaximizeModeWindowManager is enabled or not.
bool IsMaximizeModeWindowManagerEnabled() const;
+ // Add a special window to the MaximizeModeWindowManager for tracking. This is
+ // only required for special windows which are handled by other window
+ // managers like the |MultiUserWindowManager|.
+ // If the maximize mode is not enabled no action will be performed.
+ void AddWindow(aura::Window* window);
+
// TODO(jonross): move this into the destructor. Currently separated as
// ShellOberver notifies of maximize mode ending, and the observers end up
// attempting to access MaximizeModeController via the Shell. If done in
@@ -108,6 +117,7 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
private:
friend class MaximizeModeControllerTest;
friend class MaximizeModeWindowManagerTest;
+ friend class test::MultiUserWindowManagerChromeOSTest;
// Detect hinge rotation from |base| and |lid| accelerometers and
// automatically start / stop maximize mode.
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
index e434cba..2e9f042 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
@@ -54,6 +54,18 @@ int MaximizeModeWindowManager::GetNumberOfManagedWindows() {
return window_state_map_.size();
}
+void MaximizeModeWindowManager::AddWindow(aura::Window* window) {
+ // Only add the window if it is a direct dependent of a container window
+ // and not yet tracked.
+ if (!ShouldHandleWindow(window) ||
+ window_state_map_.find(window) != window_state_map_.end() ||
+ !IsContainerWindow(window->parent())) {
+ return;
+ }
+
+ MaximizeAndTrackWindow(window);
+}
+
void MaximizeModeWindowManager::WindowStateDestroyed(aura::Window* window) {
// At this time ForgetWindow() should already have been called. If not,
// someone else must have replaced the "window manager's state object".
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.h b/ash/wm/maximize_mode/maximize_mode_window_manager.h
index 78e4405..0814621 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.h
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.h
@@ -42,6 +42,12 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
// Returns the number of maximized & tracked windows by this manager.
int GetNumberOfManagedWindows();
+ // Adds a window which needs to be maximized. This is used by other window
+ // managers for windows which needs to get tracked due to (upcoming) state
+ // changes.
+ // The call gets ignored if the window was already or should not be handled.
+ void AddWindow(aura::Window* window);
+
// Called from a window state object when it gets destroyed.
void WindowStateDestroyed(aura::Window* window);
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
index a382c49..126a469 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
@@ -15,6 +15,7 @@
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/window_state.h"
#include "base/auto_reset.h"
#include "base/message_loop/message_loop.h"
@@ -692,6 +693,13 @@ void MultiUserWindowManagerChromeOS::SetWindowVisible(
aura::Window* window,
bool visible,
int animation_time_in_ms) {
+ // The MaximizeModeWindowManager will not handle invisible windows since they
+ // are not user activatable. Since invisible windows are not being tracked,
+ // we tell it to maximize / track this window now before it gets shown, to
+ // reduce animation jank from multiple resizes.
+ if (visible)
+ ash::Shell::GetInstance()->maximize_mode_controller()->AddWindow(window);
+
AnimationSetter animation_setter(
window,
GetAdjustedAnimationTimeInMS(animation_time_in_ms));
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
index f425e0bb..4f3ef97 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
@@ -8,6 +8,8 @@
#include "ash/test/ash_test_base.h"
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h"
+#include "ash/wm/maximize_mode/maximize_mode_controller.h"
+#include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "base/command_line.h"
@@ -130,6 +132,19 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase {
window);
}
+ // Create a maximize mode window manager.
+ ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
+ EXPECT_FALSE(maximize_mode_window_manager());
+ Shell::GetInstance()->maximize_mode_controller()->
+ EnableMaximizeModeWindowManager(true);
+ return maximize_mode_window_manager();
+ }
+
+ ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
+ return Shell::GetInstance()->maximize_mode_controller()->
+ maximize_mode_window_manager_.get();
+ }
+
private:
// These get created for each session.
std::vector<aura::Window*> window_;
@@ -140,6 +155,9 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase {
// The session state delegate.
ash::test::TestSessionStateDelegate* session_state_delegate_;
+ // The maximized window manager (if enabled).
+ scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_;
+
DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest);
};
@@ -638,6 +656,30 @@ TEST_F(MultiUserWindowManagerChromeOSTest, PreserveInitialVisibility) {
EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus());
}
+// Test that in case of an activated maximize mode, windows from other users get
+// maximized after a user switch.
+TEST_F(MultiUserWindowManagerChromeOSTest, MaximizeModeInteraction) {
+ SetUpForThisManyWindows(2);
+
+ multi_user_window_manager()->SetWindowOwner(window(0), "A");
+ multi_user_window_manager()->SetWindowOwner(window(1), "B");
+
+ EXPECT_FALSE(wm::GetWindowState(window(0))->IsMaximized());
+ EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized());
+
+ ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
+ ASSERT_TRUE(manager);
+
+ EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized());
+ EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized());
+
+ // After we start switching to B, the windows of user B should maximize.
+ StartUserTransitionAnimation("B");
+
+ EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized());
+ EXPECT_TRUE(wm::GetWindowState(window(1))->IsMaximized());
+}
+
// Test that a system modal dialog will switch to the desktop of the owning
// user.
TEST_F(MultiUserWindowManagerChromeOSTest, SwitchUsersUponModalityChange) {