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

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

Issue 331993009: MacViews: Run native Cocoa context menus to support Services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_
7
8 #include "ui/views/controls/menu/menu_runner_impl_interface.h"
9
10 #include <set>
11
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "ui/views/controls/menu/menu_controller_delegate.h"
15
16 namespace views {
17
18 class MenuController;
19 class MenuDelegate;
20 class MenuItemView;
21
22 namespace internal {
23
24 class MenuRunnerImpl : public MenuRunnerImplInterface,
tapted 2014/06/25 08:30:28 nit: needs a class comment
25 public MenuControllerDelegate {
26 public:
27 explicit MenuRunnerImpl(MenuItemView* menu);
28
29 virtual bool running() const OVERRIDE;
30 virtual void Release() OVERRIDE;
31 virtual MenuRunner::RunResult RunMenuAt(Widget* parent,
32 MenuButton* button,
33 const gfx::Rect& bounds,
34 MenuAnchorPosition anchor,
35 int32 types) OVERRIDE;
36 virtual void Cancel() OVERRIDE;
37 virtual base::TimeDelta closing_event_time() const OVERRIDE;
38
39 // MenuControllerDelegate:
40 virtual void DropMenuClosed(NotifyType type, MenuItemView* menu) OVERRIDE;
41 virtual void SiblingMenuCreated(MenuItemView* menu) OVERRIDE;
42
43 private:
44 virtual ~MenuRunnerImpl();
45
46 // Cleans up after the menu is no longer showing. |result| is the menu that
47 // the user selected, or NULL if nothing was selected.
48 MenuRunner::RunResult MenuDone(MenuItemView* result, int mouse_event_flags);
49
50 // Returns true if mnemonics should be shown in the menu.
51 bool ShouldShowMnemonics(MenuButton* button);
52
53 // The menu. We own this. We don't use scoped_ptr as the destructor is
54 // protected and we're a friend.
55 MenuItemView* menu_;
56
57 // Any sibling menus. Does not include |menu_|. We own these too.
58 std::set<MenuItemView*> sibling_menus_;
59
60 // Created and set as the delegate of the MenuItemView if Release() is
61 // invoked. This is done to make sure the delegate isn't notified after
62 // Release() is invoked. We do this as we assume the delegate is no longer
63 // valid if MenuRunner has been deleted.
64 scoped_ptr<MenuDelegate> empty_delegate_;
65
66 // Are we in run waiting for it to return?
67 bool running_;
68
69 // Set if |running_| and Release() has been invoked.
70 bool delete_after_run_;
71
72 // Are we running for a drop?
73 bool for_drop_;
74
75 // The controller.
76 MenuController* controller_;
77
78 // Do we own the controller?
79 bool owns_controller_;
80
81 // The timestamp of the event which closed the menu - or 0.
82 base::TimeDelta closing_event_time_;
83
84 // Used to detect deletion of |this| when notifying delegate of success.
85 base::WeakPtrFactory<MenuRunnerImpl> weak_factory_;
86
87 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImpl);
88 };
89
90 } // namespace internal
91 } // namespace views
92
93 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698