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

Unified Diff: ash/shelf/shelf_alignment_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: Fix ash_shell_with_content; cleanup. 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/shelf/shelf_alignment_menu.h ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_alignment_menu.cc
diff --git a/ash/shelf/shelf_alignment_menu.cc b/ash/shelf/shelf_alignment_menu.cc
index 5b14e8fb915a5b0d8f695828de152b4ffd781486..0e8220719da236249ddc336266b4cfafd5ba1117 100644
--- a/ash/shelf/shelf_alignment_menu.cc
+++ b/ash/shelf/shelf_alignment_menu.cc
@@ -13,10 +13,9 @@
namespace ash {
-ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root)
- : ui::SimpleMenuModel(NULL),
- root_window_(root) {
- DCHECK(root_window_);
+ShelfAlignmentMenu::ShelfAlignmentMenu(Shelf* shelf)
+ : ui::SimpleMenuModel(nullptr), shelf_(shelf) {
+ DCHECK(shelf_);
int align_group_id = 1;
set_delegate(this);
AddRadioItemWithStringId(MENU_ALIGN_LEFT,
@@ -33,10 +32,9 @@ ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root)
ShelfAlignmentMenu::~ShelfAlignmentMenu() {}
bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const {
- return Shelf::ForWindow(root_window_)
- ->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id,
- MENU_ALIGN_LEFT == command_id,
- MENU_ALIGN_RIGHT == command_id, false);
+ return shelf_->SelectValueForShelfAlignment(
+ MENU_ALIGN_BOTTOM == command_id, MENU_ALIGN_LEFT == command_id,
+ MENU_ALIGN_RIGHT == command_id, false);
}
bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const {
@@ -50,24 +48,21 @@ bool ShelfAlignmentMenu::GetAcceleratorForCommandId(
}
void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) {
+ aura::Window* root_window =
+ shelf_->shelf_widget()->GetNativeWindow()->GetRootWindow();
+ Shell* shell = Shell::GetInstance();
switch (static_cast<MenuItem>(command_id)) {
case MENU_ALIGN_LEFT:
- Shell::GetInstance()->metrics()->
- RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT);
- Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT,
- root_window_);
+ shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT);
+ shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, root_window);
msw 2016/03/17 19:04:37 Shell::SetShelfAlignment triggers ShellObserver::O
break;
case MENU_ALIGN_BOTTOM:
- Shell::GetInstance()->metrics()->
- RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM);
- Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM,
- root_window_);
+ shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM);
+ shell->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM, root_window);
break;
case MENU_ALIGN_RIGHT:
- Shell::GetInstance()->metrics()->
- RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT);
- Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT,
- root_window_);
+ shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT);
+ shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, root_window);
break;
}
}
« no previous file with comments | « ash/shelf/shelf_alignment_menu.h ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698