summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 23:26:56 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 23:26:56 +0000
commit09f3fc8feccea26a7544a73d7beb485a13949a13 (patch)
treebdfddf4e4389f78c398965f74a78504af5e39667
parent3af863ac1a4a40cf7885858873cc549fac9e4f8a (diff)
downloadchromium_src-09f3fc8feccea26a7544a73d7beb485a13949a13.zip
chromium_src-09f3fc8feccea26a7544a73d7beb485a13949a13.tar.gz
chromium_src-09f3fc8feccea26a7544a73d7beb485a13949a13.tar.bz2
Adds option to always hide launcher.
BUG=119803 TEST=see bug R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/9863007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129045 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/shell.cc8
-rw-r--r--ash/shell.h7
-rw-r--r--ash/wm/shelf_auto_hide_behavior.h24
-rw-r--r--ash/wm/shelf_layout_manager.cc23
-rw-r--r--ash/wm/shelf_layout_manager.h11
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc24
-rw-r--r--chrome/app/generated_resources.grd2
-rw-r--r--chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc39
-rw-r--r--chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h3
-rw-r--r--chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc19
-rw-r--r--chrome/browser/ui/views/ash/launcher/launcher_context_menu.h2
-rw-r--r--chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc67
-rw-r--r--chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h41
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/pref_names.cc7
-rw-r--r--chrome/common/pref_names.h5
17 files changed, 238 insertions, 47 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 3bccd1a..615ddd2 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -202,6 +202,7 @@
'wm/partial_screenshot_event_filter.h',
'wm/partial_screenshot_view.cc',
'wm/partial_screenshot_view.h',
+ 'wm/shelf_auto_hide_behavior.h',
'wm/system_modal_container_layout_manager.cc',
'wm/system_modal_container_layout_manager.h',
'wm/system_modal_container_event_filter.cc',
diff --git a/ash/shell.cc b/ash/shell.cc
index 4c3282b..87021be 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -854,12 +854,12 @@ void Shell::UpdateShelfVisibility() {
shelf_->UpdateVisibilityState();
}
-void Shell::SetShelfAlwaysAutoHide(bool value) {
- shelf_->SetAlwaysAutoHide(value);
+void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
+ shelf_->SetAutoHideBehavior(behavior);
}
-bool Shell::GetShelfAlwaysAutoHide() const {
- return shelf_->always_auto_hide();
+ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
+ return shelf_->auto_hide_behavior();
}
int Shell::GetGridSize() const {
diff --git a/ash/shell.h b/ash/shell.h
index 5aac16a..10f972a 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -10,6 +10,7 @@
#include <vector>
#include "ash/ash_export.h"
+#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
@@ -209,9 +210,9 @@ class ASH_EXPORT Shell {
// Force the shelf to query for it's current visibility state.
void UpdateShelfVisibility();
- // Sets/gets whether the shelf always auto-hides.
- void SetShelfAlwaysAutoHide(bool value);
- bool GetShelfAlwaysAutoHide() const;
+ // Sets/gets the shelf auto-hide behavior.
+ void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
+ ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
// TODO(sky): don't expose this!
internal::ShelfLayoutManager* shelf() const { return shelf_; }
diff --git a/ash/wm/shelf_auto_hide_behavior.h b/ash/wm/shelf_auto_hide_behavior.h
new file mode 100644
index 0000000..29c35da
--- /dev/null
+++ b/ash/wm/shelf_auto_hide_behavior.h
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_
+#define ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_
+#pragma once
+
+namespace ash {
+
+enum ShelfAutoHideBehavior {
+ // The default; maximized windows trigger an auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
+
+ // Always auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
+
+ // Never auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
+};
+
+} // namespace ash
+
+#endif // ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 951fa73..6fd6e1b 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -106,7 +106,7 @@ ShelfLayoutManager::AutoHideEventFilter::PreHandleGestureEvent(
ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
: in_layout_(false),
- always_auto_hide_(false),
+ auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT),
shelf_height_(status->GetWindowScreenBounds().height()),
launcher_(NULL),
status_(status),
@@ -117,10 +117,10 @@ ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
ShelfLayoutManager::~ShelfLayoutManager() {
}
-void ShelfLayoutManager::SetAlwaysAutoHide(bool value) {
- if (always_auto_hide_ == value)
+void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
+ if (auto_hide_behavior_ == behavior)
return;
- always_auto_hide_ = value;
+ auto_hide_behavior_ = behavior;
UpdateVisibilityState();
}
@@ -128,8 +128,13 @@ gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds(
aura::Window* window) const {
// TODO: needs to be multi-mon aware.
gfx::Rect bounds(gfx::Screen::GetMonitorAreaNearestWindow(window));
- bounds.set_height(bounds.height() - kAutoHideHeight);
- return bounds;
+ if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT ||
+ auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
+ bounds.set_height(bounds.height() - kAutoHideHeight);
+ return bounds;
+ }
+ // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller.
+ return GetUnmaximizedWorkAreaBounds(window);
}
gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds(
@@ -183,12 +188,14 @@ void ShelfLayoutManager::UpdateVisibilityState() {
break;
case WorkspaceManager::WINDOW_STATE_MAXIMIZED:
- SetState(AUTO_HIDE);
+ SetState(auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER ?
+ AUTO_HIDE : VISIBLE);
break;
case WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
case WorkspaceManager::WINDOW_STATE_DEFAULT:
- SetState(always_auto_hide_ ? AUTO_HIDE : VISIBLE);
+ SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
+ AUTO_HIDE : VISIBLE);
SetWindowOverlapsShelf(window_state ==
WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
}
diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h
index 05e3e7a..850aa80 100644
--- a/ash/wm/shelf_layout_manager.h
+++ b/ash/wm/shelf_layout_manager.h
@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/launcher/launcher.h"
+#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/timer.h"
@@ -63,9 +64,11 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager {
explicit ShelfLayoutManager(views::Widget* status);
virtual ~ShelfLayoutManager();
- // Sets whether the shelf always auto-hides. Default is false.
- void SetAlwaysAutoHide(bool value);
- bool always_auto_hide() const { return always_auto_hide_; }
+ // Sets the ShelfAutoHideBehavior. See enum description for details.
+ void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
+ ShelfAutoHideBehavior auto_hide_behavior() const {
+ return auto_hide_behavior_;
+ }
void set_workspace_manager(WorkspaceManager* manager) {
workspace_manager_ = manager;
@@ -174,7 +177,7 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager {
bool in_layout_;
// See description above setter.
- bool always_auto_hide_;
+ ShelfAutoHideBehavior auto_hide_behavior_;
// Current state.
State state_;
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index f33605e..cd30b3d 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -263,8 +263,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
}
-// Assertions around SetAlwaysAutoHide.
-TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) {
+// Assertions around SetAutoHideBehavior.
+TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
@@ -272,12 +272,28 @@ TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) {
// Widget is now owned by the parent window.
widget->Init(params);
widget->Show();
+ aura::Window* window = widget->GetNativeWindow();
+ gfx::Rect monitor_bounds(gfx::Screen::GetMonitorAreaNearestWindow(window));
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
- shelf->SetAlwaysAutoHide(true);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
- shelf->SetAlwaysAutoHide(FALSE);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
+ EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
+
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
+ EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
+
+ widget->Maximize();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
}
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 8cf31d1..3c4cded 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -15713,7 +15713,7 @@ Battery full
Auto-hide
</message>
<message name="IDS_LAUNCHER_CONTEXT_MENU_NEVER_AUTO_HIDE" desc="Title of the menu item in the context menu for never auto-hiding">
- Always visibile
+ Always visible
</message>
<message name="IDS_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_WHEN_MAXIMIZED" desc="Title of the menu item in the context menu for auto-hiding when window is maximized">
Hide when window is maximized
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
index 7559108..a673a49 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
@@ -47,6 +47,11 @@ const char kAppTypePath[] = "type";
const char kAppTypeTab[] = "tab";
const char kAppTypeWindow[] = "window";
+// Values used for prefs::kShelfAutoHideBehavior.
+const char kShelfAutoHideBehaviorAlways[] = "Always";
+const char kShelfAutoHideBehaviorDefault[] = "Default";
+const char kShelfAutoHideBehaviorNever[] = "Never";
+
} // namespace
// ChromeLauncherDelegate::Item ------------------------------------------------
@@ -115,8 +120,15 @@ void ChromeLauncherDelegate::Init() {
}
// TODO(sky): update unit test so that this test isn't necessary.
if (ash::Shell::HasInstance()) {
- ash::Shell::GetInstance()->SetShelfAlwaysAutoHide(
- profile_->GetPrefs()->GetBoolean(prefs::kAlwaysAutoHideShelf));
+ std::string behavior_value(
+ profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior));
+ ash::ShelfAutoHideBehavior behavior =
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
+ if (behavior_value == kShelfAutoHideBehaviorNever)
+ behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
+ else if (behavior_value == kShelfAutoHideBehaviorAlways)
+ behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
}
}
@@ -126,8 +138,9 @@ void ChromeLauncherDelegate::RegisterUserPrefs(PrefService* user_prefs) {
// pushed to local state and we'll need to track profile per item.
user_prefs->RegisterListPref(prefs::kPinnedLauncherApps,
PrefService::SYNCABLE_PREF);
- user_prefs->RegisterBooleanPref(prefs::kAlwaysAutoHideShelf,
- false, PrefService::SYNCABLE_PREF);
+ user_prefs->RegisterStringPref(prefs::kShelfAutoHideBehavior,
+ kShelfAutoHideBehaviorDefault,
+ PrefService::SYNCABLE_PREF);
}
ash::LauncherID ChromeLauncherDelegate::CreateTabbedLauncherItem(
@@ -344,6 +357,24 @@ void ChromeLauncherDelegate::UnpinAppsWithID(const std::string& app_id) {
}
}
+void ChromeLauncherDelegate::SetAutoHideBehavior(
+ ash::ShelfAutoHideBehavior behavior) {
+ ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
+ const char* value = NULL;
+ switch (behavior) {
+ case ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT:
+ value = kShelfAutoHideBehaviorDefault;
+ break;
+ case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
+ value = kShelfAutoHideBehaviorAlways;
+ break;
+ case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
+ value = kShelfAutoHideBehaviorNever;
+ break;
+ }
+ profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value);
+}
+
void ChromeLauncherDelegate::CreateNewTab() {
Browser *last_browser = BrowserList::FindTabbedBrowser(
GetProfileForNewWindows(), true);
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h
index 4994db6..34a6616 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h
@@ -12,6 +12,7 @@
#include "ash/launcher/launcher_delegate.h"
#include "ash/launcher/launcher_model_observer.h"
#include "ash/launcher/launcher_types.h"
+#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -149,6 +150,8 @@ class ChromeLauncherDelegate : public ash::LauncherDelegate,
Profile* profile() { return profile_; }
+ void SetAutoHideBehavior(ash::ShelfAutoHideBehavior behavior);
+
// ash::LauncherDelegate overrides:
virtual void CreateNewTab() OVERRIDE;
virtual void CreateNewWindow() OVERRIDE;
diff --git a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc
index 3bbe995..64d3d8a 100644
--- a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc
+++ b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc
@@ -4,11 +4,7 @@
#include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h"
-#include "ash/shell.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h"
-#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -16,7 +12,8 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate,
const ash::LauncherItem* item)
: ui::SimpleMenuModel(NULL),
delegate_(delegate),
- item_(item ? *item : ash::LauncherItem()) {
+ item_(item ? *item : ash::LauncherItem()),
+ shelf_menu_(delegate) {
set_delegate(this);
if (is_valid_item()) {
@@ -40,8 +37,9 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate,
}
AddSeparator();
}
- AddCheckItemWithStringId(MENU_AUTO_HIDE,
- IDS_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_SHELF);
+ AddSubMenuWithStringId(MENU_AUTO_HIDE,
+ IDS_LAUNCHER_CONTEXT_MENU_SHELF_VISIBILITY,
+ &shelf_menu_);
}
LauncherContextMenu::~LauncherContextMenu() {
@@ -49,8 +47,6 @@ LauncherContextMenu::~LauncherContextMenu() {
bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
switch (command_id) {
- case MENU_AUTO_HIDE:
- return ash::Shell::GetInstance()->GetShelfAlwaysAutoHide();
case LAUNCH_TYPE_REGULAR_TAB:
return delegate_->GetAppType(item_.id) ==
ChromeLauncherDelegate::APP_TYPE_TAB;
@@ -90,11 +86,6 @@ void LauncherContextMenu::ExecuteCommand(int command_id) {
delegate_->SetAppType(item_.id, ChromeLauncherDelegate::APP_TYPE_WINDOW);
break;
case MENU_AUTO_HIDE:
- ash::Shell::GetInstance()->SetShelfAlwaysAutoHide(
- !ash::Shell::GetInstance()->GetShelfAlwaysAutoHide());
- delegate_->profile()->GetPrefs()->SetBoolean(
- prefs::kAlwaysAutoHideShelf,
- ash::Shell::GetInstance()->GetShelfAlwaysAutoHide());
break;
}
}
diff --git a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h
index 18df487..40840ab 100644
--- a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h
+++ b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h
@@ -8,6 +8,7 @@
#include "ash/launcher/launcher_types.h"
#include "base/basictypes.h"
+#include "chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h"
#include "ui/base/models/simple_menu_model.h"
namespace gfx {
@@ -58,6 +59,7 @@ class LauncherContextMenu : public ui::SimpleMenuModel,
ChromeLauncherDelegate* delegate_;
ash::LauncherItem item_;
+ ShelfAutoHideMenu shelf_menu_;
DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu);
};
diff --git a/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc b/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc
new file mode 100644
index 0000000..445fe68
--- /dev/null
+++ b/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h"
+
+#include "ash/shell.h"
+#include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h"
+#include "grit/generated_resources.h"
+
+ShelfAutoHideMenu::ShelfAutoHideMenu(ChromeLauncherDelegate* delegate)
+ : ui::SimpleMenuModel(NULL),
+ delegate_(delegate) {
+ set_delegate(this);
+
+ AddRadioItemWithStringId(MENU_AUTO_HIDE_DEFAULT,
+ IDS_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_WHEN_MAXIMIZED,
+ 1);
+ AddRadioItemWithStringId(MENU_AUTO_HIDE_ALWAYS,
+ IDS_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_SHELF,
+ 1);
+ AddRadioItemWithStringId(MENU_AUTO_HIDE_NEVER,
+ IDS_LAUNCHER_CONTEXT_MENU_NEVER_AUTO_HIDE,
+ 1);
+}
+
+ShelfAutoHideMenu::~ShelfAutoHideMenu() {
+}
+
+bool ShelfAutoHideMenu::IsCommandIdChecked(int command_id) const {
+ ash::ShelfAutoHideBehavior behavior =
+ ash::Shell::GetInstance()->GetShelfAutoHideBehavior();
+ switch (command_id) {
+ case MENU_AUTO_HIDE_DEFAULT:
+ return behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
+ case MENU_AUTO_HIDE_ALWAYS:
+ return behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ case MENU_AUTO_HIDE_NEVER:
+ return behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
+ default:
+ return false;
+ }
+}
+
+bool ShelfAutoHideMenu::IsCommandIdEnabled(int command_id) const {
+ return true;
+}
+
+bool ShelfAutoHideMenu::GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) {
+ return false;
+}
+
+void ShelfAutoHideMenu::ExecuteCommand(int command_id) {
+ switch (static_cast<MenuItem>(command_id)) {
+ case MENU_AUTO_HIDE_DEFAULT:
+ delegate_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
+ break;
+ case MENU_AUTO_HIDE_ALWAYS:
+ delegate_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ break;
+ case MENU_AUTO_HIDE_NEVER:
+ delegate_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ break;
+ }
+}
diff --git a/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h b/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h
new file mode 100644
index 0000000..9caa1ca
--- /dev/null
+++ b/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_SHELF_AUTO_HIDE_MENU_H_
+#define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_SHELF_AUTO_HIDE_MENU_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "ui/base/models/simple_menu_model.h"
+
+class ChromeLauncherDelegate;
+
+// Submenu of LauncherContextMenu for choosing the visibility of the shelf.
+class ShelfAutoHideMenu : public ui::SimpleMenuModel,
+ public ui::SimpleMenuModel::Delegate {
+ public:
+ explicit ShelfAutoHideMenu(ChromeLauncherDelegate* delegate);
+ virtual ~ShelfAutoHideMenu();
+
+ // ui::SimpleMenuModel::Delegate overrides:
+ virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) OVERRIDE;
+ virtual void ExecuteCommand(int command_id) OVERRIDE;
+
+ private:
+ enum MenuItem {
+ MENU_AUTO_HIDE_DEFAULT,
+ MENU_AUTO_HIDE_ALWAYS,
+ MENU_AUTO_HIDE_NEVER,
+ };
+
+ ChromeLauncherDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShelfAutoHideMenu);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_SHELF_AUTO_HIDE_MENU_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a95ba51..46bcafe 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3241,6 +3241,8 @@
'browser/ui/views/ash/launcher/launcher_favicon_loader.h',
'browser/ui/views/ash/launcher/launcher_updater.cc',
'browser/ui/views/ash/launcher/launcher_updater.h',
+ 'browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc',
+ 'browser/ui/views/ash/launcher/shelf_auto_hide_menu.h',
'browser/ui/views/ash/panel_view_aura.cc',
'browser/ui/views/ash/panel_view_aura.h',
'browser/ui/views/ash/screen_orientation_listener.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 8f60a3b8..489a573 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1788,9 +1788,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";
-
const char kPinnedLauncherApps[] = "pinned_launcher_apps";
const char kMaximumSecondsBetweenDoubleClick[] =
@@ -1803,6 +1800,10 @@ const char kMinFlickSpeedSquared[] =
"gesture.min_flick_speed_squared";
const char kMinimumTouchDownDurationInSecondsForClick[] =
"gesture.minimum_touch_down_duration_in_seconds_for_click";
+
+// String value corresponding to ash::Shell::ShelfAutoHideBehavior.
+const char kShelfAutoHideBehavior[] = "auto_hide_behavior";
+
#endif
// Indicates whether the browser is in managed mode.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index baec892..51e8e6b 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -670,8 +670,6 @@ extern const char kRestoreSessionStateDialogShown[];
extern const char kWebIntentsEnabled[];
#if defined(USE_AURA)
-extern const char kAlwaysAutoHideShelf[];
-
extern const char kPinnedLauncherApps[];
extern const char kMaximumSecondsBetweenDoubleClick[];
@@ -679,6 +677,9 @@ extern const char kMaximumTouchDownDurationInSecondsForClick[];
extern const char kMaximumTouchMoveInPixelsForClick[];
extern const char kMinFlickSpeedSquared[];
extern const char kMinimumTouchDownDurationInSecondsForClick[];
+
+extern const char kShelfAutoHideBehavior[];
+
#endif
extern const char kInManagedMode[];