Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Unified Diff: ash/shell/context_menu.cc

Issue 1812013003: Pass shelf instances, not root windows, for ash context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call OnShelfAlignmentChanged after LayoutShelf. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shell/context_menu.h ('k') | ash/shell/shell_delegate_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shell/context_menu.cc
diff --git a/ash/shell/context_menu.cc b/ash/shell/context_menu.cc
index 91f5abd344b4e6885fbcbc34c0acdb1fb34b27c2..c07c547e4ce26b1255f978eee4784a011094df2f 100644
--- a/ash/shell/context_menu.cc
+++ b/ash/shell/context_menu.cc
@@ -4,20 +4,16 @@
#include "ash/shell/context_menu.h"
-#include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_types.h"
-#include "ash/shell.h"
#include "grit/ash_strings.h"
namespace ash {
namespace shell {
-ContextMenu::ContextMenu(aura::Window* root)
- : ui::SimpleMenuModel(NULL),
- root_window_(root),
- alignment_menu_(root) {
- DCHECK(root_window_);
+ContextMenu::ContextMenu(ash::Shelf* shelf)
+ : ui::SimpleMenuModel(nullptr), shelf_(shelf), alignment_menu_(shelf) {
+ DCHECK(shelf_);
set_delegate(this);
AddCheckItemWithStringId(MENU_AUTO_HIDE,
IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
@@ -30,38 +26,26 @@ ContextMenu::~ContextMenu() {
}
bool ContextMenu::IsCommandIdChecked(int command_id) const {
- switch (command_id) {
- case MENU_AUTO_HIDE:
- return Shell::GetInstance()->GetShelfAutoHideBehavior(root_window_) ==
- ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
- default:
- return false;
- }
+ if (command_id == MENU_AUTO_HIDE)
+ return shelf_->GetAutoHideBehavior() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ return false;
}
bool ContextMenu::IsCommandIdEnabled(int command_id) const {
return true;
}
-bool ContextMenu::GetAcceleratorForCommandId(
- int command_id,
- ui::Accelerator* accelerator) {
+bool ContextMenu::GetAcceleratorForCommandId(int command_id,
+ ui::Accelerator* accelerator) {
return false;
}
void ContextMenu::ExecuteCommand(int command_id, int event_flags) {
- Shell* shell = Shell::GetInstance();
- switch (static_cast<MenuItem>(command_id)) {
- case MENU_AUTO_HIDE:
- shell->SetShelfAutoHideBehavior(
- shell->GetShelfAutoHideBehavior(root_window_) ==
- SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
- SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
- SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
- root_window_);
- break;
- case MENU_ALIGNMENT_MENU:
- break;
+ if (command_id == MENU_AUTO_HIDE) {
+ shelf_->SetAutoHideBehavior(shelf_->GetAutoHideBehavior() ==
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS
+ ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER
+ : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
}
}
« no previous file with comments | « ash/shell/context_menu.h ('k') | ash/shell/shell_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698