| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/shelf_alignment_menu.h" | 5 #include "ash/shelf/shelf_alignment_menu.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_types.h" | 9 #include "ash/shelf/shelf_types.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "grit/ash_strings.h" | 11 #include "grit/ash_strings.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root) | 16 ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root) |
| 17 : ui::SimpleMenuModel(NULL), | 17 : ui::SimpleMenuModel(NULL), |
| 18 root_window_(root) { | 18 root_window_(root) { |
| 19 DCHECK(root_window_); | 19 DCHECK(root_window_); |
| 20 int align_group_id = 1; | 20 int align_group_id = 1; |
| 21 set_delegate(this); | 21 set_delegate(this); |
| 22 AddRadioItemWithStringId(MENU_ALIGN_LEFT, | 22 AddRadioItemWithStringId(MENU_ALIGN_LEFT, |
| 23 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, | 23 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, |
| 24 align_group_id); | 24 align_group_id); |
| 25 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, | 25 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, |
| 26 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM, | 26 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM, |
| 27 align_group_id); | 27 align_group_id); |
| 28 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, | 28 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, |
| 29 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, | 29 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, |
| 30 align_group_id); | 30 align_group_id); |
| 31 } | 31 } |
| 32 | 32 |
| 33 ShelfAlignmentMenu::~ShelfAlignmentMenu() {} | 33 ShelfAlignmentMenu::~ShelfAlignmentMenu() {} |
| 34 | 34 |
| 35 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { | 35 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { |
| 36 return ShelfLayoutManager::ForShelf(root_window_) | 36 return Shelf::ForWindow(root_window_) |
| 37 ->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id, | 37 ->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id, |
| 38 MENU_ALIGN_LEFT == command_id, | 38 MENU_ALIGN_LEFT == command_id, |
| 39 MENU_ALIGN_RIGHT == command_id, | 39 MENU_ALIGN_RIGHT == command_id, false); |
| 40 false); | |
| 41 } | 40 } |
| 42 | 41 |
| 43 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { | 42 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { |
| 44 return true; | 43 return true; |
| 45 } | 44 } |
| 46 | 45 |
| 47 bool ShelfAlignmentMenu::GetAcceleratorForCommandId( | 46 bool ShelfAlignmentMenu::GetAcceleratorForCommandId( |
| 48 int command_id, | 47 int command_id, |
| 49 ui::Accelerator* accelerator) { | 48 ui::Accelerator* accelerator) { |
| 50 return false; | 49 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 case MENU_ALIGN_RIGHT: | 66 case MENU_ALIGN_RIGHT: |
| 68 Shell::GetInstance()->metrics()-> | 67 Shell::GetInstance()->metrics()-> |
| 69 RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); | 68 RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); |
| 70 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, | 69 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, |
| 71 root_window_); | 70 root_window_); |
| 72 break; | 71 break; |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 } // namespace ash | 75 } // namespace ash |
| OLD | NEW |