diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 20:40:56 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 20:40:56 +0000 |
commit | 9628e0afd55f6f621ad6715fd3c394e4d435163b (patch) | |
tree | ac34b3fd7c82c17e70e7ae4ad139784e60b460b6 | |
parent | 0c1fb48686d1cf0dd91d6f121db2e4c6446c9336 (diff) | |
download | chromium_src-9628e0afd55f6f621ad6715fd3c394e4d435163b.zip chromium_src-9628e0afd55f6f621ad6715fd3c394e4d435163b.tar.gz chromium_src-9628e0afd55f6f621ad6715fd3c394e4d435163b.tar.bz2 |
Implements new semantics for launcher context menu. Gone are the three
items, and instead they're repalced with a single item. The behavior of
the item changes depending upon whether in maximized mode or not. I've
put the core functionality into ash so that ash_shell now gets the
context menu too.
BUG=120947
TEST=see bug, also covered by tests.
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10069023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132048 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/ash.gyp | 3 | ||||
-rw-r--r-- | ash/ash_strings.grd | 6 | ||||
-rw-r--r-- | ash/launcher/launcher_context_menu.cc | 84 | ||||
-rw-r--r-- | ash/launcher/launcher_context_menu.h | 49 | ||||
-rw-r--r-- | ash/launcher/launcher_context_menu_unittest.cc | 53 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 3 | ||||
-rw-r--r-- | ash/shell/launcher_delegate_impl.cc | 3 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.cc | 21 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.h | 10 | ||||
-rw-r--r-- | ash/wm/workspace_controller.cc | 4 | ||||
-rw-r--r-- | ash/wm/workspace_controller.h | 2 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 12 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/launcher_context_menu.h | 11 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc | 67 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h | 43 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
18 files changed, 220 insertions, 171 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index ad6445b..c88621a 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -88,6 +88,8 @@ 'launcher/launcher.h', 'launcher/launcher_button.cc', 'launcher/launcher_button.h', + 'launcher/launcher_context_menu.cc', + 'launcher/launcher_context_menu.h', 'launcher/launcher_delegate.h', 'launcher/launcher_model.cc', 'launcher/launcher_model.h', @@ -335,6 +337,7 @@ 'drag_drop/drag_drop_controller_unittest.cc', 'focus_cycler_unittest.cc', 'ime/input_method_event_filter_unittest.cc', + 'launcher/launcher_context_menu_unittest.cc', 'launcher/launcher_model_unittest.cc', 'launcher/launcher_unittest.cc', 'monitor/multi_monitor_manager_unittest.cc', diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 7ba89c5..7150e9a 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -173,6 +173,12 @@ This file contains the strings for ash. <message name="IDS_AURA_LAUNCHER_OVERFLOW_NAME" desc="The title used for the Aura overflow button in the launcher"> Overflow Button </message> + <message name="IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED" desc="Title of the menu item in the context menu for auto-hiding the launcher when the current window is maximized"> + Autohide launcher when maximized + </message> + <message name="IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED" desc="Title of the menu item in the context menu for auto-hiding the launcher when the current window is not maximized"> + Autohide launcher + </message> <message name="IDS_AURA_SET_DESKTOP_WALLPAPER" desc="The label used for change wallpaper in context menu"> Set Wallpaper... diff --git a/ash/launcher/launcher_context_menu.cc b/ash/launcher/launcher_context_menu.cc new file mode 100644 index 0000000..3872ade --- /dev/null +++ b/ash/launcher/launcher_context_menu.cc @@ -0,0 +1,84 @@ +// 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 "ash/launcher/launcher_context_menu.h" + +#include "ash/shell.h" +#include "grit/ash_strings.h" +#include "ui/base/l10n/l10n_util.h" + +namespace ash { + +LauncherContextMenu::LauncherContextMenu() : ui::SimpleMenuModel(NULL) { + set_delegate(this); + AddCheckItemWithStringId(MENU_AUTO_HIDE, GetAutoHideResourceStringId()); +} + +LauncherContextMenu::~LauncherContextMenu() { +} + +// static +bool LauncherContextMenu::IsAutoHideMenuHideChecked() { + ash::Shell* shell = ash::Shell::GetInstance(); + ash::ShelfAutoHideBehavior auto_hide_behavior = + shell->GetShelfAutoHideBehavior(); + return (shell->IsInMaximizedMode() && + (auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || + auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)) || + (!shell->IsInMaximizedMode() && + auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); +} + +// static +void LauncherContextMenu::ToggleAutoHideMenu() { + ash::Shell* shell = ash::Shell::GetInstance(); + ash::ShelfAutoHideBehavior auto_hide_behavior; + if (shell->IsInMaximizedMode()) { + if (IsAutoHideMenuHideChecked()) + auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER; + else + auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT; + } else if (IsAutoHideMenuHideChecked()) { + auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT; + } else { + auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; + } + shell->SetShelfAutoHideBehavior(auto_hide_behavior); +} + +// static +int LauncherContextMenu::GetAutoHideResourceStringId() { + return ash::Shell::GetInstance()->IsInMaximizedMode() ? + IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED : + IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED; +} + +bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { + switch (command_id) { + case MENU_AUTO_HIDE: + return IsAutoHideMenuHideChecked(); + default: + return false; + } +} + +bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { + return true; +} + +bool LauncherContextMenu::GetAcceleratorForCommandId( + int command_id, + ui::Accelerator* accelerator) { + return false; +} + +void LauncherContextMenu::ExecuteCommand(int command_id) { + switch (static_cast<MenuItem>(command_id)) { + case MENU_AUTO_HIDE: + ToggleAutoHideMenu(); + break; + } +} + +} // namespace ash diff --git a/ash/launcher/launcher_context_menu.h b/ash/launcher/launcher_context_menu.h new file mode 100644 index 0000000..a7f638f --- /dev/null +++ b/ash/launcher/launcher_context_menu.h @@ -0,0 +1,49 @@ +// 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_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ +#define ASH_WM_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ +#pragma once + +#include "ash/ash_export.h" +#include "base/basictypes.h" +#include "ui/base/models/simple_menu_model.h" + +namespace ash { + +// Context menu for the launcher. +class ASH_EXPORT LauncherContextMenu : public ui::SimpleMenuModel, + public ui::SimpleMenuModel::Delegate { + public: + LauncherContextMenu(); + virtual ~LauncherContextMenu(); + + // 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 resource id for the auto-hide menu. + static int GetAutoHideResourceStringId(); + + // 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, + }; + + DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); +}; + +} // namespace ash + +#endif // ASH_WM_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_ diff --git a/ash/launcher/launcher_context_menu_unittest.cc b/ash/launcher/launcher_context_menu_unittest.cc new file mode 100644 index 0000000..5143d69 --- /dev/null +++ b/ash/launcher/launcher_context_menu_unittest.cc @@ -0,0 +1,53 @@ +// 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 "ash/launcher/launcher_context_menu.h" + +#include "ash/shell.h" +#include "ash/test/ash_test_base.h" +#include "ash/wm/property_util.h" +#include "ash/wm/window_util.h" +#include "ui/aura/client/aura_constants.h" +#include "ui/aura/window.h" +#include "ui/base/ui_base_types.h" +#include "ui/gfx/compositor/layer.h" + +namespace ash { + +typedef test::AshTestBase LauncherContextMenuTest; + +// Various assertions around IsAutoHideMenuHideChecked() and +// ToggleAutoHideMenu(). +TEST_F(LauncherContextMenuTest, ToggleAutoHide) { + scoped_ptr<aura::Window> window(new aura::Window(NULL)); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetType(aura::client::WINDOW_TYPE_NORMAL); + window->Init(ui::LAYER_TEXTURED); + window->SetParent(NULL); + window->Show(); + + Shell* shell = Shell::GetInstance(); + // If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make + // sense. + EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, + shell->GetShelfAutoHideBehavior()); + EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked()); + LauncherContextMenu::ToggleAutoHideMenu(); + EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, + shell->GetShelfAutoHideBehavior()); + LauncherContextMenu::ToggleAutoHideMenu(); + 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(); + EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, + shell->GetShelfAutoHideBehavior()); + LauncherContextMenu::ToggleAutoHideMenu(); + EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, + shell->GetShelfAutoHideBehavior()); +} + +} // namespace ash diff --git a/ash/shell.cc b/ash/shell.cc index 8fc842c..d273752 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -894,6 +894,10 @@ int Shell::GetGridSize() const { return workspace_controller_->workspace_manager()->grid_size(); } +bool Shell::IsInMaximizedMode() const { + return workspace_controller_->workspace_manager()->IsInMaximizedMode(); +} + //////////////////////////////////////////////////////////////////////////////// // Shell, private: diff --git a/ash/shell.h b/ash/shell.h index f7fda36..35632a5 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -235,6 +235,9 @@ class ASH_EXPORT Shell { // Returns the size of the grid. int GetGridSize() const; + // Returns true if in maximized or fullscreen mode. + bool IsInMaximizedMode() const; + static void set_initially_hide_cursor(bool hide) { initially_hide_cursor_ = hide; } diff --git a/ash/shell/launcher_delegate_impl.cc b/ash/shell/launcher_delegate_impl.cc index 9d7fe27..ddf4add 100644 --- a/ash/shell/launcher_delegate_impl.cc +++ b/ash/shell/launcher_delegate_impl.cc @@ -4,6 +4,7 @@ #include "ash/shell/launcher_delegate_impl.h" +#include "ash/launcher/launcher_context_menu.h" #include "ash/shell/toplevel_window.h" #include "ash/shell/window_watcher.h" #include "ash/wm/window_util.h" @@ -52,7 +53,7 @@ ui::MenuModel* LauncherDelegateImpl::CreateContextMenu( } ui::MenuModel* LauncherDelegateImpl::CreateContextMenuForLauncher() { - return NULL; + return new LauncherContextMenu; } ash::LauncherID LauncherDelegateImpl::GetIDByWindow(aura::Window* window) { diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index e461d9e..05ab750 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -33,13 +33,6 @@ namespace { -// The horizontal margein between workspaces in pixels. -const int kWorkspaceHorizontalMargin = 50; - -// Minimum/maximum scale for overview mode. -const float kMaxOverviewScale = 0.9f; -const float kMinOverviewScale = 0.3f; - // Returns a list of all the windows with layers in |result|. void BuildWindowList(const std::vector<aura::Window*>& windows, std::vector<aura::Window*>* result) { @@ -70,7 +63,6 @@ namespace internal { WorkspaceManager::WorkspaceManager(aura::Window* contents_view) : contents_view_(contents_view), active_workspace_(NULL), - is_overview_(false), ignored_window_(NULL), grid_size_(0), shelf_(NULL) { @@ -92,6 +84,11 @@ bool WorkspaceManager::IsManagingWindow(aura::Window* window) const { return FindBy(window) != NULL; } +bool WorkspaceManager::IsInMaximizedMode() const { + return active_workspace_ && + active_workspace_->type() == Workspace::TYPE_MAXIMIZED; +} + void WorkspaceManager::AddWindow(aura::Window* window) { DCHECK(IsManagedWindow(window)); @@ -146,12 +143,6 @@ void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) { workspace->Activate(); } -void WorkspaceManager::SetOverview(bool overview) { - if (is_overview_ == overview) - return; - NOTIMPLEMENTED(); -} - gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { if (grid_size_ <= 1) return bounds; @@ -296,8 +287,6 @@ void WorkspaceManager::SetActiveWorkspace(Workspace* workspace) { last_active ? ANIMATE : DONT_ANIMATE, true); UpdateShelfVisibility(); } - - is_overview_ = false; } // Returns the index of the workspace that contains the |window|. diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h index 9912f8d..6da00e7 100644 --- a/ash/wm/workspace/workspace_manager.h +++ b/ash/wm/workspace/workspace_manager.h @@ -55,6 +55,9 @@ class ASH_EXPORT WorkspaceManager { // Returns true if the |window| is managed by the WorkspaceManager. bool IsManagingWindow(aura::Window* window) const; + // Returns true if in maximized or fullscreen mode. + bool IsInMaximizedMode() const; + // Adds/removes a window creating/destroying workspace as necessary. void AddWindow(aura::Window* window); void RemoveWindow(aura::Window* window); @@ -73,10 +76,6 @@ class ASH_EXPORT WorkspaceManager { // Returns the bounds in which a window can be moved/resized. gfx::Rect GetDragAreaBounds(); - // Turn on/off overview mode. - void SetOverview(bool overview); - bool is_overview() const { return is_overview_; } - // Returns the window the layout manager should allow the size to be set for. // TODO: maybe this should be set on WorkspaceLayoutManager. aura::Window* ignored_window() { return ignored_window_; } @@ -166,9 +165,6 @@ class ASH_EXPORT WorkspaceManager { std::vector<Workspace*> workspaces_; - // True if the workspace manager is in overview mode. - bool is_overview_; - // The window that WorkspaceManager does not set the bounds on. aura::Window* ignored_window_; diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index ba652c2..07674df 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -45,10 +45,6 @@ WorkspaceController::~WorkspaceController() { viewport_->SetLayoutManager(NULL); } -void WorkspaceController::ToggleOverview() { - workspace_manager_->SetOverview(!workspace_manager_->is_overview()); -} - void WorkspaceController::SetGridSize(int grid_size) { workspace_manager_->set_grid_size(grid_size); event_filter_->set_grid_size(grid_size); diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h index b95ca21..fba7ac2 100644 --- a/ash/wm/workspace_controller.h +++ b/ash/wm/workspace_controller.h @@ -32,8 +32,6 @@ class ASH_EXPORT WorkspaceController : explicit WorkspaceController(aura::Window* viewport); virtual ~WorkspaceController(); - void ToggleOverview(); - // Returns the workspace manager that this controller owns. WorkspaceManager* workspace_manager() { return workspace_manager_.get(); diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d48b650..ad69848 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -15787,18 +15787,6 @@ Battery full <message name="IDS_APP_LIST_CONTEXT_MENU_UNPIN" desc="Title text for the 'unpin' context menu item of an app list item."> Unpin from Launcher </message> - <message name="IDS_LAUNCHER_CONTEXT_MENU_LAUNCHER_VISIBILITY" desc="Title of the menu in the launcher context menu for choosing launcher visibility"> - Launcher visibility - </message> - <message name="IDS_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_SHELF" desc="Title of the menu item in the context menu for always auto-hiding the shelf"> - 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 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 - </message> <message name="IDS_LAUNCHER_CONTEXT_MENU_CLOSE" desc="Title text for the 'close' context menu item of the launcher"> Close </message> 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 7809aea..5a563d0 100644 --- a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc +++ b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h" +#include "ash/launcher/launcher_context_menu.h" +#include "ash/shell.h" #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -12,8 +14,7 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate, const ash::LauncherItem* item) : ui::SimpleMenuModel(NULL), delegate_(delegate), - item_(item ? *item : ash::LauncherItem()), - shelf_menu_(delegate) { + item_(item ? *item : ash::LauncherItem()) { set_delegate(this); if (is_valid_item()) { @@ -37,9 +38,8 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate, } AddSeparator(); } - AddSubMenuWithStringId(MENU_AUTO_HIDE, - IDS_LAUNCHER_CONTEXT_MENU_LAUNCHER_VISIBILITY, - &shelf_menu_); + AddCheckItemWithStringId( + MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId()); } LauncherContextMenu::~LauncherContextMenu() { @@ -53,6 +53,8 @@ bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { case LAUNCH_TYPE_WINDOW: return delegate_->GetAppType(item_.id) == ChromeLauncherDelegate::APP_TYPE_WINDOW; + case MENU_AUTO_HIDE: + return ash::LauncherContextMenu::IsAutoHideMenuHideChecked(); default: return false; } @@ -86,6 +88,6 @@ void LauncherContextMenu::ExecuteCommand(int command_id) { delegate_->SetAppType(item_.id, ChromeLauncherDelegate::APP_TYPE_WINDOW); break; case MENU_AUTO_HIDE: - break; + return ash::LauncherContextMenu::ToggleAutoHideMenu(); } } 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 40840ab..6e841f1 100644 --- a/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h +++ b/chrome/browser/ui/views/ash/launcher/launcher_context_menu.h @@ -8,18 +8,8 @@ #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 { -class Point; -} - -namespace views { -class MenuRunner; -class View; -} - class ChromeLauncherDelegate; // Context menu shown for a launcher item. @@ -59,7 +49,6 @@ 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 deleted file mode 100644 index 445fe68..0000000 --- a/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.cc +++ /dev/null @@ -1,67 +0,0 @@ -// 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 deleted file mode 100644 index 6ae709270..0000000 --- a/chrome/browser/ui/views/ash/launcher/shelf_auto_hide_menu.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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: - // Menu command id needs to be unique. So starting at 1000 to avoid command - // id conflicts with parent LauncherContextMenu. - enum MenuItem { - MENU_AUTO_HIDE_DEFAULT = 1000, - 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 bf35479..15ac32c 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3229,8 +3229,6 @@ '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', |