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 "views/controls/menu/menu_item_view.h" | 5 #include "views/controls/menu/menu_item_view.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "grit/app_strings.h" | 10 #include "grit/app_strings.h" |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 parent_menu_item_ = parent; | 555 parent_menu_item_ = parent; |
556 type_ = type; | 556 type_ = type; |
557 selected_ = false; | 557 selected_ = false; |
558 command_ = command; | 558 command_ = command; |
559 submenu_ = NULL; | 559 submenu_ = NULL; |
560 show_mnemonics_ = false; | 560 show_mnemonics_ = false; |
561 // Assign our ID, this allows SubmenuItemView to find MenuItemViews. | 561 // Assign our ID, this allows SubmenuItemView to find MenuItemViews. |
562 SetID(kMenuItemViewID); | 562 SetID(kMenuItemViewID); |
563 has_icons_ = false; | 563 has_icons_ = false; |
564 | 564 |
| 565 // Don't request enabled status from the root menu item as it is just |
| 566 // a container for real items. |
565 MenuDelegate* root_delegate = GetDelegate(); | 567 MenuDelegate* root_delegate = GetDelegate(); |
566 if (root_delegate) | 568 if (parent && root_delegate) |
567 SetEnabled(root_delegate->IsCommandEnabled(command)); | 569 SetEnabled(root_delegate->IsCommandEnabled(command)); |
568 } | 570 } |
569 | 571 |
570 void MenuItemView::DropMenuClosed(bool notify_delegate) { | 572 void MenuItemView::DropMenuClosed(bool notify_delegate) { |
571 DCHECK(controller_); | 573 DCHECK(controller_); |
572 DCHECK(!controller_->IsBlockingRun()); | 574 DCHECK(!controller_->IsBlockingRun()); |
573 if (MenuController::GetActiveInstance() == controller_) | 575 if (MenuController::GetActiveInstance() == controller_) |
574 MenuController::SetActiveInstance(NULL); | 576 MenuController::SetActiveInstance(NULL); |
575 delete controller_; | 577 delete controller_; |
576 controller_ = NULL; | 578 controller_ = NULL; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 740 } |
739 | 741 |
740 string16 MenuItemView::GetAcceleratorText() { | 742 string16 MenuItemView::GetAcceleratorText() { |
741 Accelerator accelerator; | 743 Accelerator accelerator; |
742 return (GetDelegate() && | 744 return (GetDelegate() && |
743 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? | 745 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? |
744 accelerator.GetShortcutText() : string16(); | 746 accelerator.GetShortcutText() : string16(); |
745 } | 747 } |
746 | 748 |
747 } // namespace views | 749 } // namespace views |
OLD | NEW |