summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 17:04:27 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 17:04:27 +0000
commitc0bb1a2067f33ae8dc9450aea1dc09d407c3d034 (patch)
tree389c8cbed38b046d29a84afc5a1c9d12714b4c70
parentd925280a75c8394c2fa7d121b5e4e1e0d9d86714 (diff)
downloadchromium_src-c0bb1a2067f33ae8dc9450aea1dc09d407c3d034.zip
chromium_src-c0bb1a2067f33ae8dc9450aea1dc09d407c3d034.tar.gz
chromium_src-c0bb1a2067f33ae8dc9450aea1dc09d407c3d034.tar.bz2
Turning off auto hide modes for the shelf while the maximize mode is up and running
BUG=353145 TEST=unittest, ash tests and visual Review URL: https://codereview.chromium.org/205603003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258612 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/shelf/shelf_layout_manager.cc32
-rw-r--r--ash/shelf/shelf_layout_manager.h6
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc88
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc5
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu.cc4
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu.h3
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc26
7 files changed, 159 insertions, 5 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 9cc67d6..18c3f25 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -198,6 +198,8 @@ class ShelfLayoutManager::UpdateShelfObserver
ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf)
: root_window_(shelf->GetNativeView()->GetRootWindow()),
updating_bounds_(false),
+ force_shelf_always_visibile_(
+ Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled()),
auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER),
alignment_(SHELF_ALIGNMENT_BOTTOM),
shelf_(shelf),
@@ -318,7 +320,8 @@ void ShelfLayoutManager::UpdateVisibilityState() {
if (!workspace_controller_)
return;
- if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
+ if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked() ||
+ force_shelf_always_visibile_) {
SetState(SHELF_VISIBLE);
} else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
@@ -393,6 +396,9 @@ void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) {
// ShelfLayoutManager, Gesture functions:
void ShelfLayoutManager::OnGestureEdgeSwipe(const ui::GestureEvent& gesture) {
+ if (force_shelf_always_visibile_)
+ return;
+
if (visibility_state() == SHELF_AUTO_HIDE) {
gesture_drag_auto_hide_state_ = SHELF_AUTO_HIDE_SHOWN;
gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
@@ -402,6 +408,8 @@ void ShelfLayoutManager::OnGestureEdgeSwipe(const ui::GestureEvent& gesture) {
}
void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
+ if (force_shelf_always_visibile_)
+ return;
gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
gesture_drag_amount_ = 0.f;
gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ?
@@ -411,6 +419,8 @@ void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
const ui::GestureEvent& gesture) {
+ if (force_shelf_always_visibile_)
+ return DRAG_SHELF;
bool horizontal = IsHorizontalAlignment();
gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() :
gesture.details().scroll_x();
@@ -435,6 +445,8 @@ ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
}
void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
+ if (force_shelf_always_visibile_)
+ return;
bool horizontal = IsHorizontalAlignment();
bool should_change = false;
if (gesture.type() == ui::ET_GESTURE_SCROLL_END) {
@@ -555,6 +567,21 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) {
LayoutShelf();
}
+void ShelfLayoutManager::OnMaximizeModeStarted() {
+ DCHECK(!force_shelf_always_visibile_);
+ force_shelf_always_visibile_ = true;
+ UpdateVisibilityState();
+}
+
+void ShelfLayoutManager::OnMaximizeModeEnded() {
+ DCHECK(force_shelf_always_visibile_);
+ // Note: At this time Ash::Shell::IsMaximizeModeWindowManagerEnabled() will
+ // report true, even though it is in progress of shut down. To address this
+ // |force_shelf_always_visibile_| will be read.
+ force_shelf_always_visibile_ = false;
+ UpdateVisibilityState();
+}
+
void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
UpdateAutoHideStateNow();
@@ -1003,6 +1030,9 @@ gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const {
ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
ShelfVisibilityState visibility_state) const {
+ if (force_shelf_always_visibile_)
+ return SHELF_AUTO_HIDE_SHOWN;
+
if (visibility_state != SHELF_AUTO_HIDE || !shelf_)
return SHELF_AUTO_HIDE_HIDDEN;
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index 861b25b..ef1f465 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -184,6 +184,8 @@ class ASH_EXPORT ShelfLayoutManager :
// Overridden from ash::ShellObserver:
virtual void OnLockStateChanged(bool locked) OVERRIDE;
+ virtual void OnMaximizeModeStarted() OVERRIDE;
+ virtual void OnMaximizeModeEnded() OVERRIDE;
// Overriden from aura::client::ActivationChangeObserver:
virtual void OnWindowActivated(aura::Window* gained_active,
@@ -346,6 +348,10 @@ class ASH_EXPORT ShelfLayoutManager :
// UpdateBoundsAndOpacity() again from SetChildBounds().
bool updating_bounds_;
+ // If true, the shelf gets forced (e.g. by the maximize mode) to be always
+ // visible.
+ bool force_shelf_always_visibile_;
+
// See description above setter.
ShelfAutoHideBehavior auto_hide_behavior_;
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 7b3b5d8..07b67fb 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -861,6 +861,38 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}
+// Check that swipes and mouse interactions do have no impact in Maximize mode.
+TEST_F(ShelfLayoutManagerTest, MaximizeModePreventsMouseHide) {
+ aura::Window* root = Shell::GetPrimaryRootWindow();
+ aura::test::EventGenerator generator(root, root);
+ generator.MoveMouseTo(0, 0);
+
+ ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(0, 0, 200, 200);
+ params.context = CurrentContext();
+ // Widget is now owned by the parent window.
+ widget->Init(params);
+ widget->Maximize();
+ widget->Show();
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ shelf->OnMaximizeModeStarted();
+ // LayoutShelf() forces the animation to completion.
+ shelf->LayoutShelf();
+
+ // Drag mouse to bottom of screen. In contrast to normal operation the shelf
+ // should remain visible.
+ generator.MoveMouseTo(0, 0);
+ generator.PressLeftButton();
+ generator.MoveMouseTo(0, root->bounds().bottom() - 1);
+ UpdateAutoHideStateNow();
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+}
+
// Test the behavior of the shelf when it is auto hidden and it is on the
// boundary between the primary and the secondary display.
TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
@@ -1541,6 +1573,34 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) {
EXPECT_TRUE(widget->IsFullscreen());
}
+// Check that in maximize mode gesture swipes on the shelf have no effect.
+TEST_F(ShelfLayoutManagerTest, MaximizeModeGestureEdgeSwipe) {
+ ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(0, 0, 200, 200);
+ params.context = CurrentContext();
+ widget->Init(params);
+ widget->Show();
+ widget->Maximize();
+
+ shelf->LayoutShelf();
+
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ shelf->LayoutShelf();
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ shelf->OnMaximizeModeStarted();
+ shelf->LayoutShelf();
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ generator.GestureEdgeSwipe();
+
+ EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+}
+
#if defined(OS_WIN)
// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
#define MAYBE_GestureDrag DISABLED_GestureDrag
@@ -1933,6 +1993,34 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
}
+// Verify that setting the shelf's auto hide mode in maximize mode does not
+// hide.
+TEST_F(ShelfLayoutManagerTest, DoesNotHideInMaximizeMode) {
+ EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
+
+ GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ scoped_ptr<aura::Window> w1(CreateTestWindow());
+ w1->Show();
+ ShelfLayoutManager* shelf = GetShelfLayoutManager();
+
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ GetShelfLayoutManager()->OnMaximizeModeStarted();
+ EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+
+ // Setting the state again should have no impact.
+ GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+
+ GetShelfLayoutManager()->OnMaximizeModeEnded();
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+}
+
#if defined(OS_CHROMEOS)
#define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge
#else
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index 8cba80d..7dd0411 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -905,8 +905,9 @@ ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior(
bool ChromeLauncherController::CanUserModifyShelfAutoHideBehavior(
aura::Window* root_window) const {
- return profile_->GetPrefs()->
- FindPreference(prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable();
+ return !ash::Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled() &&
+ profile_->GetPrefs()->FindPreference(
+ prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable();
}
void ChromeLauncherController::ToggleShelfAutoHideBehavior(
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
index 92cb916..4369c3d 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
@@ -171,9 +171,9 @@ void LauncherContextMenu::Init() {
// fullscreen because it is confusing when the preference appears not to
// apply.
if (!IsFullScreenMode() &&
- controller_->CanUserModifyShelfAutoHideBehavior(root_window_)) {
+ controller_->CanUserModifyShelfAutoHideBehavior(root_window_)) {
AddCheckItemWithStringId(MENU_AUTO_HIDE,
- IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
+ IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
}
if (ash::ShelfWidget::ShelfAlignmentAllowed()) {
AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.h b/chrome/browser/ui/ash/launcher/launcher_context_menu.h
index f2d29f6..429b6eb 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu.h
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.h
@@ -69,6 +69,9 @@ class LauncherContextMenu : public ui::SimpleMenuModel,
FRIEND_TEST_ALL_PREFIXES(
LauncherContextMenuTest,
NewWindowMenuIsDisabledWhenIncognitoModeForced);
+ FRIEND_TEST_ALL_PREFIXES(
+ LauncherContextMenuTest,
+ NoAutoHideOptionInMaximizedMode);
enum MenuItem {
MENU_OPEN_NEW,
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc
index 6c885e0..4250223 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc
@@ -7,6 +7,7 @@
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_item_types.h"
#include "ash/shelf/shelf_model.h"
+#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "base/prefs/pref_service.h"
#include "chrome/app/chrome_command_ids.h"
@@ -108,3 +109,28 @@ TEST_F(LauncherContextMenuTest,
menu.get(), LauncherContextMenu::MENU_NEW_WINDOW));
EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW));
}
+
+// Verifies that the "auto hide" menu items are not present in maximized mode.
+TEST_F(LauncherContextMenuTest, NoAutoHideOptionInMaximizedMode) {
+ {
+ scoped_ptr<LauncherContextMenu> menu(
+ CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
+ ASSERT_TRUE(IsItemPresentInMenu(
+ menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
+ }
+ ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
+ {
+ scoped_ptr<LauncherContextMenu> menu(
+ CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
+ ASSERT_FALSE(IsItemPresentInMenu(
+ menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
+ }
+ ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
+ {
+ scoped_ptr<LauncherContextMenu> menu(
+ CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT));
+ ASSERT_TRUE(IsItemPresentInMenu(
+ menu.get(), LauncherContextMenu::MENU_AUTO_HIDE));
+ }
+}
+