Chromium Code Reviews| 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; |
| } |
| } |