• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MESSAGE_LOOP_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_
7 
8 #include "ui/gfx/native_widget_types.h"
9 
10 namespace gfx {
11 class Point;
12 }
13 
14 namespace ui {
15 class LocatedEvent;
16 }
17 
18 namespace views {
19 
20 class MenuController;
21 class Widget;
22 
23 // Interface used by MenuController to run a nested message loop while
24 // showing a menu, allowing for platform specific implementations.
25 class MenuMessageLoop {
26  public:
~MenuMessageLoop()27   virtual ~MenuMessageLoop() {}
28 
29   // Create a platform specific instance.
30   static MenuMessageLoop* Create();
31 
32   // Runs the platform specific bits of the message loop. If |nested_menu| is
33   // true we're being asked to run a menu from within a menu (eg a context
34   // menu).
35   virtual void Run(MenuController*, Widget* owner, bool nested_menu) = 0;
36 
37   // Returns true if it is a good time to call QuitNow().
38   // Returns false otherwise, for example if a drag and drop is in progress.
39   virtual bool ShouldQuitNow() const = 0;
40 
41   // Quit an earlier call to Run().
42   virtual void QuitNow() = 0;
43 
44   // Repost |event| to |window|.
45   // |screen_loc| is the event's location in screen coordinates.
46   virtual void RepostEventToWindow(const ui::LocatedEvent& event,
47                                    gfx::NativeWindow window,
48                                    const gfx::Point& screen_loc) = 0;
49 
50   // Clear any references to the owner widget that was passed into the previous
51   // call to Run().
52   virtual void ClearOwner() = 0;
53 };
54 
55 }  // namespace views
56 
57 #endif  // UI_VIEWS_CONTROLS_MENU_MENU_MESSAGE_LOOP_H_
58