Commit 72562c24 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

ash: Fix shelf auto hide behavior not persisted regression.

Change LauncherContextMenu::ToggleAutoHideMenu to just return the toggled auto
hide behavior and make the behavior change go through ChromeLauncherDelegate,
which would persist the new behavior.

Also removed no longer in use kAlwaysAutoHideShelf pref.

BUG=124083
TEST=Verify fix for issue 124083.

Review URL: https://chromiumcodereview.appspot.com/10273012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134707 0039d316-1c4b-4281-b951-d872f2087c98
parent 3a12dd7f
......@@ -31,7 +31,7 @@ bool LauncherContextMenu::IsAutoHideMenuHideChecked() {
}
// static
void LauncherContextMenu::ToggleAutoHideMenu() {
ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
ash::Shell* shell = ash::Shell::GetInstance();
ash::ShelfAutoHideBehavior auto_hide_behavior;
if (shell->IsInMaximizedMode()) {
......@@ -44,7 +44,7 @@ void LauncherContextMenu::ToggleAutoHideMenu() {
} else {
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
}
shell->SetShelfAutoHideBehavior(auto_hide_behavior);
return auto_hide_behavior;
}
// static
......@@ -76,7 +76,8 @@ bool LauncherContextMenu::GetAcceleratorForCommandId(
void LauncherContextMenu::ExecuteCommand(int command_id) {
switch (static_cast<MenuItem>(command_id)) {
case MENU_AUTO_HIDE:
ToggleAutoHideMenu();
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
GetToggledAutoHideBehavior());
break;
}
}
......
......@@ -7,6 +7,7 @@
#pragma once
#include "ash/ash_export.h"
#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "ui/base/models/simple_menu_model.h"
......@@ -22,8 +23,8 @@ class ASH_EXPORT LauncherContextMenu : public ui::SimpleMenuModel,
// Returns true if the auto-hide menu item is checked.
static bool IsAutoHideMenuHideChecked();
// Toggles the state of the auto-hide menu item.
static void ToggleAutoHideMenu();
// Returns the toggled state of the auto-hide behavior.
static ShelfAutoHideBehavior GetToggledAutoHideBehavior();
// Returns the resource id for the auto-hide menu.
static int GetAutoHideResourceStringId();
......
......@@ -33,19 +33,23 @@ TEST_F(LauncherContextMenuTest, ToggleAutoHide) {
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
shell->GetShelfAutoHideBehavior());
EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked());
LauncherContextMenu::ToggleAutoHideMenu();
shell->SetShelfAutoHideBehavior(
LauncherContextMenu::GetToggledAutoHideBehavior());
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
shell->GetShelfAutoHideBehavior());
LauncherContextMenu::ToggleAutoHideMenu();
shell->SetShelfAutoHideBehavior(
LauncherContextMenu::GetToggledAutoHideBehavior());
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
shell->GetShelfAutoHideBehavior());
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
LauncherContextMenu::ToggleAutoHideMenu();
shell->SetShelfAutoHideBehavior(
LauncherContextMenu::GetToggledAutoHideBehavior());
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
shell->GetShelfAutoHideBehavior());
LauncherContextMenu::ToggleAutoHideMenu();
shell->SetShelfAutoHideBehavior(
LauncherContextMenu::GetToggledAutoHideBehavior());
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
shell->GetShelfAutoHideBehavior());
}
......
......@@ -117,7 +117,8 @@ void LauncherContextMenu::ExecuteCommand(int command_id) {
delegate_->SetLaunchType(item_.id, ExtensionPrefs::LAUNCH_FULLSCREEN);
break;
case MENU_AUTO_HIDE:
ash::LauncherContextMenu::ToggleAutoHideMenu();
delegate_->SetAutoHideBehavior(
ash::LauncherContextMenu::GetToggledAutoHideBehavior());
break;
case MENU_NEW_WINDOW:
delegate_->CreateNewWindow();
......
......@@ -1800,9 +1800,6 @@ const char kRestoreSessionStateDialogShown[] =
const char kWebIntentsEnabled[] = "webintents.enabled";
#if defined(USE_AURA)
// Boolean value indicating whether the shelf always hides.
const char kAlwaysAutoHideShelf[] =
"auto_hide_shelf";
// String value corresponding to ash::Shell::ShelfAutoHideBehavior.
const char kShelfAutoHideBehavior[] =
"auto_hide_behavior";
......
......@@ -668,7 +668,6 @@ extern const char kRestoreSessionStateDialogShown[];
extern const char kWebIntentsEnabled[];
#if defined(USE_AURA)
extern const char kAlwaysAutoHideShelf[];
extern const char kShelfAutoHideBehavior[];
extern const char kUseDefaultPinnedApps[];
extern const char kPinnedLauncherApps[];
......
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