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

Side by Side Diff: ui/views/controls/menu/menu_controller.h

Issue 2659903002: Change MenuControllerDelegate to provide WeakPtr (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // If not empty, it means we're nested. When Run is invoked from within 599 // If not empty, it means we're nested. When Run is invoked from within
600 // Run, the current state (state_) is pushed onto menu_stack_. This allows 600 // Run, the current state (state_) is pushed onto menu_stack_. This allows
601 // MenuController to restore the state when the nested run returns. 601 // MenuController to restore the state when the nested run returns.
602 using NestedState = 602 using NestedState =
603 std::pair<State, std::unique_ptr<MenuButton::PressedLock>>; 603 std::pair<State, std::unique_ptr<MenuButton::PressedLock>>;
604 std::list<NestedState> menu_stack_; 604 std::list<NestedState> menu_stack_;
605 605
606 // When Run is invoked during an active Run, it may be called from a separate 606 // When Run is invoked during an active Run, it may be called from a separate
607 // MenuControllerDelegate. If not empty is means we are nested, and the 607 // MenuControllerDelegate. If not empty is means we are nested, and the
608 // stacked delegates should be notified instead of |delegate_|. 608 // stacked delegates should be notified instead of |delegate_|.
609 typedef std::pair<internal::MenuControllerDelegate*, bool> NestedDelegate; 609 typedef std::pair<base::WeakPtr<internal::MenuControllerDelegate>, bool>
610 NestedDelegate;
610 std::list<NestedDelegate> delegate_stack_; 611 std::list<NestedDelegate> delegate_stack_;
611 612
612 // As the mouse moves around submenus are not opened immediately. Instead 613 // As the mouse moves around submenus are not opened immediately. Instead
613 // they open after this timer fires. 614 // they open after this timer fires.
614 base::OneShotTimer show_timer_; 615 base::OneShotTimer show_timer_;
615 616
616 // Used to invoke CancelAll(). This is used during drag and drop to hide the 617 // Used to invoke CancelAll(). This is used during drag and drop to hide the
617 // menu after the mouse moves out of the of the menu. This is necessitated by 618 // menu after the mouse moves out of the of the menu. This is necessitated by
618 // the lack of an ability to detect when the drag has completed from the drop 619 // the lack of an ability to detect when the drag has completed from the drop
619 // side. 620 // side.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // The lock to keep the menu button pressed while a menu is visible. 658 // The lock to keep the menu button pressed while a menu is visible.
658 std::unique_ptr<MenuButton::PressedLock> pressed_lock_; 659 std::unique_ptr<MenuButton::PressedLock> pressed_lock_;
659 660
660 // ViewStorage id used to store the view mouse drag events are forwarded to. 661 // ViewStorage id used to store the view mouse drag events are forwarded to.
661 // See UpdateActiveMouseView() for details. 662 // See UpdateActiveMouseView() for details.
662 const int active_mouse_view_id_; 663 const int active_mouse_view_id_;
663 664
664 // Current hot tracked child button if any. 665 // Current hot tracked child button if any.
665 CustomButton* hot_button_; 666 CustomButton* hot_button_;
666 667
667 internal::MenuControllerDelegate* delegate_; 668 base::WeakPtr<internal::MenuControllerDelegate> delegate_;
668 669
669 // How deep we are in nested message loops. This should be at most 2 (when 670 // How deep we are in nested message loops. This should be at most 2 (when
670 // showing a context menu from a menu). 671 // showing a context menu from a menu).
671 int message_loop_depth_; 672 int message_loop_depth_;
672 673
673 // The timestamp of the event which closed the menu - or 0 otherwise. 674 // The timestamp of the event which closed the menu - or 0 otherwise.
674 base::TimeTicks closing_event_time_; 675 base::TimeTicks closing_event_time_;
675 676
676 // Time when the menu is first shown. 677 // Time when the menu is first shown.
677 base::TimeTicks menu_start_time_; 678 base::TimeTicks menu_start_time_;
(...skipping 27 matching lines...) Expand all
705 #if defined(USE_AURA) 706 #if defined(USE_AURA)
706 std::unique_ptr<MenuPreTargetHandler> menu_pre_target_handler_; 707 std::unique_ptr<MenuPreTargetHandler> menu_pre_target_handler_;
707 #endif 708 #endif
708 709
709 DISALLOW_COPY_AND_ASSIGN(MenuController); 710 DISALLOW_COPY_AND_ASSIGN(MenuController);
710 }; 711 };
711 712
712 } // namespace views 713 } // namespace views
713 714
714 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 715 #endif // UI_VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698