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

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

Issue 2394123002: Views: Expose an on_closed callback via the MenuRunner constructor. (Closed)
Patch Set: default arg Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_RUNNER_IMPL_COCOA_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_
7 7
8 #include "ui/views/controls/menu/menu_runner_impl_interface.h"
9
10 #include <stdint.h> 8 #include <stdint.h>
11 9
10 #include "base/callback.h"
12 #import "base/mac/scoped_nsobject.h" 11 #import "base/mac/scoped_nsobject.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "ui/views/controls/menu/menu_runner_impl_interface.h"
15 15
16 @class MenuController; 16 @class MenuController;
17 17
18 namespace views { 18 namespace views {
19 namespace internal { 19 namespace internal {
20 20
21 // A menu runner implementation that uses NSMenu to show a context menu. 21 // A menu runner implementation that uses NSMenu to show a context menu.
22 class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface { 22 class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface {
23 public: 23 public:
24 explicit MenuRunnerImplCocoa(ui::MenuModel* menu); 24 MenuRunnerImplCocoa(ui::MenuModel* menu,
25 const base::Closure& on_menu_closed_callback);
25 26
26 bool IsRunning() const override; 27 bool IsRunning() const override;
27 void Release() override; 28 void Release() override;
28 MenuRunner::RunResult RunMenuAt(Widget* parent, 29 MenuRunner::RunResult RunMenuAt(Widget* parent,
29 MenuButton* button, 30 MenuButton* button,
30 const gfx::Rect& bounds, 31 const gfx::Rect& bounds,
31 MenuAnchorPosition anchor, 32 MenuAnchorPosition anchor,
32 int32_t run_types) override; 33 int32_t run_types) override;
33 void Cancel() override; 34 void Cancel() override;
34 base::TimeTicks GetClosingEventTime() const override; 35 base::TimeTicks GetClosingEventTime() const override;
35 36
36 private: 37 private:
37 ~MenuRunnerImplCocoa() override; 38 ~MenuRunnerImplCocoa() override;
38 39
39 // The Cocoa menu controller that this instance is bridging. 40 // The Cocoa menu controller that this instance is bridging.
40 base::scoped_nsobject<MenuController> menu_controller_; 41 base::scoped_nsobject<MenuController> menu_controller_;
41 42
42 // Are we in run waiting for it to return? 43 // Are we in run waiting for it to return?
43 bool running_; 44 bool running_;
44 45
45 // Set if |running_| and Release() has been invoked. 46 // Set if |running_| and Release() has been invoked.
46 bool delete_after_run_; 47 bool delete_after_run_;
47 48
48 // The timestamp of the event which closed the menu - or 0. 49 // The timestamp of the event which closed the menu - or 0.
49 base::TimeTicks closing_event_time_; 50 base::TimeTicks closing_event_time_;
50 51
52 // Invoked before RunMenuAt() returns, except upon a Release().
53 base::Closure on_menu_closed_callback_;
54
51 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImplCocoa); 55 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImplCocoa);
52 }; 56 };
53 57
54 } // namespace internal 58 } // namespace internal
55 } // namespace views 59 } // namespace views
56 60
57 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ 61 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_runner_impl_adapter.cc ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698