OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 }; | 250 }; |
251 | 251 |
252 string16 GetAccessibleNameForWrenchMenuItem( | 252 string16 GetAccessibleNameForWrenchMenuItem( |
253 MenuModel* model, int item_index, int accessible_string_id) { | 253 MenuModel* model, int item_index, int accessible_string_id) { |
254 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id); | 254 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id); |
255 string16 accelerator_text; | 255 string16 accelerator_text; |
256 | 256 |
257 ui::Accelerator menu_accelerator; | 257 ui::Accelerator menu_accelerator; |
258 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) { | 258 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) { |
259 accelerator_text = | 259 accelerator_text = |
260 views::Accelerator(menu_accelerator.key_code(), | 260 ui::Accelerator(menu_accelerator.key_code(), |
261 menu_accelerator.modifiers()).GetShortcutText(); | 261 menu_accelerator.modifiers()).GetShortcutText(); |
262 } | 262 } |
263 | 263 |
264 return MenuItemView::GetAccessibleNameForMenuItem( | 264 return MenuItemView::GetAccessibleNameForMenuItem( |
265 accessible_name, accelerator_text); | 265 accessible_name, accelerator_text); |
266 } | 266 } |
267 | 267 |
268 // WrenchMenuView is a view that can contain text buttons. | 268 // WrenchMenuView is a view that can contain text buttons. |
269 class WrenchMenuView : public ScheduleAllView, public views::ButtonListener { | 269 class WrenchMenuView : public ScheduleAllView, public views::ButtonListener { |
270 public: | 270 public: |
271 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model) | 271 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model) |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { | 740 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { |
741 // These items are represented by child views. If ExecuteCommand is invoked | 741 // These items are represented by child views. If ExecuteCommand is invoked |
742 // it means the user clicked on the area around the buttons and we should | 742 // it means the user clicked on the area around the buttons and we should |
743 // not do anyting. | 743 // not do anyting. |
744 return; | 744 return; |
745 } | 745 } |
746 | 746 |
747 return entry.first->ActivatedAt(entry.second); | 747 return entry.first->ActivatedAt(entry.second); |
748 } | 748 } |
749 | 749 |
750 bool WrenchMenu::GetAccelerator(int id, views::Accelerator* accelerator) { | 750 bool WrenchMenu::GetAccelerator(int id, ui::Accelerator* accelerator) { |
751 if (is_bookmark_command(id)) | 751 if (is_bookmark_command(id)) |
752 return false; | 752 return false; |
753 | 753 |
754 const Entry& entry = id_to_entry_.find(id)->second; | 754 const Entry& entry = id_to_entry_.find(id)->second; |
755 int command_id = entry.first->GetCommandIdAt(entry.second); | 755 int command_id = entry.first->GetCommandIdAt(entry.second); |
756 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { | 756 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { |
757 // These have special child views; don't show the accelerator for them. | 757 // These have special child views; don't show the accelerator for them. |
758 return false; | 758 return false; |
759 } | 759 } |
760 | 760 |
761 ui::Accelerator menu_accelerator; | 761 ui::Accelerator menu_accelerator; |
762 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator)) | 762 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator)) |
763 return false; | 763 return false; |
764 | 764 |
765 *accelerator = views::Accelerator(menu_accelerator.key_code(), | 765 *accelerator = ui::Accelerator(menu_accelerator.key_code(), |
766 menu_accelerator.modifiers()); | 766 menu_accelerator.modifiers()); |
767 return true; | 767 return true; |
768 } | 768 } |
769 | 769 |
770 void WrenchMenu::WillShowMenu(MenuItemView* menu) { | 770 void WrenchMenu::WillShowMenu(MenuItemView* menu) { |
771 if (menu == bookmark_menu_) | 771 if (menu == bookmark_menu_) |
772 CreateBookmarkMenu(); | 772 CreateBookmarkMenu(); |
773 } | 773 } |
774 | 774 |
775 void WrenchMenu::BookmarkModelChanged() { | 775 void WrenchMenu::BookmarkModelChanged() { |
776 DCHECK(bookmark_menu_delegate_.get()); | 776 DCHECK(bookmark_menu_delegate_.get()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 bookmark_menu_delegate_.reset( | 885 bookmark_menu_delegate_.reset( |
886 new BookmarkMenuDelegate(browser_->profile(), | 886 new BookmarkMenuDelegate(browser_->profile(), |
887 NULL, | 887 NULL, |
888 parent, | 888 parent, |
889 first_bookmark_command_id_)); | 889 first_bookmark_command_id_)); |
890 bookmark_menu_delegate_->Init( | 890 bookmark_menu_delegate_->Init( |
891 this, bookmark_menu_, model->bookmark_bar_node(), 0, | 891 this, bookmark_menu_, model->bookmark_bar_node(), 0, |
892 BookmarkMenuDelegate::SHOW_OTHER_FOLDER, | 892 BookmarkMenuDelegate::SHOW_OTHER_FOLDER, |
893 bookmark_utils::LAUNCH_WRENCH_MENU); | 893 bookmark_utils::LAUNCH_WRENCH_MENU); |
894 } | 894 } |
OLD | NEW |