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

Side by Side Diff: ui/views/controls/menu/menu_runner.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, 5 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
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_RUNNER_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 16 matching lines...) Expand all
27 namespace views { 27 namespace views {
28 28
29 class MenuButton; 29 class MenuButton;
30 class MenuItemView; 30 class MenuItemView;
31 class MenuModelAdapter; 31 class MenuModelAdapter;
32 class MenuRunnerHandler; 32 class MenuRunnerHandler;
33 class Widget; 33 class Widget;
34 34
35 namespace internal { 35 namespace internal {
36 class DisplayChangeListener; 36 class DisplayChangeListener;
37 class MenuRunnerImpl; 37 class MenuRunnerImplInterface;
38 } 38 }
39 39
40 namespace test { 40 namespace test {
41 class MenuRunnerTestAPI; 41 class MenuRunnerTestAPI;
42 } 42 }
43 43
44 // MenuRunner is responsible for showing (running) the menu and additionally 44 // MenuRunner is responsible for showing (running) the menu and additionally
45 // owning the MenuItemView. RunMenuAt() runs a nested message loop. It is safe 45 // owning the MenuItemView. RunMenuAt() runs a nested message loop. It is safe
46 // to delete MenuRunner at any point, but MenuRunner internally only deletes the 46 // to delete MenuRunner at any point, but MenuRunner internally only deletes the
47 // MenuItemView *after* the nested message loop completes. If MenuRunner is 47 // MenuItemView *after* the nested message loop completes. If MenuRunner is
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // Returns the time from the event which closed the menu - or 0. 127 // Returns the time from the event which closed the menu - or 0.
128 base::TimeDelta closing_event_time() const; 128 base::TimeDelta closing_event_time() const;
129 129
130 private: 130 private:
131 friend class test::MenuRunnerTestAPI; 131 friend class test::MenuRunnerTestAPI;
132 132
133 // Sets an implementation of RunMenuAt. This is intended to be used at test. 133 // Sets an implementation of RunMenuAt. This is intended to be used at test.
134 void SetRunnerHandler(scoped_ptr<MenuRunnerHandler> runner_handler); 134 void SetRunnerHandler(scoped_ptr<MenuRunnerHandler> runner_handler);
135 135
136 internal::MenuRunnerImplInterface* CreateImpl(int32 types);
137 internal::MenuRunnerImplInterface* CreateNativeImpl();
tapted 2014/06/24 23:28:08 Id probably try to have MenuRunnerImplInterface::
138
139 ui::MenuModel* menu_model_; // Weak. Owned by our owner.
140 // NULL if constructed with a MenuView.
136 scoped_ptr<MenuModelAdapter> menu_model_adapter_; 141 scoped_ptr<MenuModelAdapter> menu_model_adapter_;
142 MenuItemView* menu_view_; // Weak. Owned by holder_. Can be NULL.
137 143
138 internal::MenuRunnerImpl* holder_; 144 // We own this. No scoped_ptr because it is destroyed by calling Release().
145 internal::MenuRunnerImplInterface* holder_;
139 146
140 // An implementation of RunMenuAt. This is usually NULL and ignored. If this 147 // An implementation of RunMenuAt. This is usually NULL and ignored. If this
141 // is not NULL, this implementation will be used. 148 // is not NULL, this implementation will be used.
142 scoped_ptr<MenuRunnerHandler> runner_handler_; 149 scoped_ptr<MenuRunnerHandler> runner_handler_;
143 150
144 scoped_ptr<internal::DisplayChangeListener> display_change_listener_; 151 scoped_ptr<internal::DisplayChangeListener> display_change_listener_;
145 152
146 DISALLOW_COPY_AND_ASSIGN(MenuRunner); 153 DISALLOW_COPY_AND_ASSIGN(MenuRunner);
147 }; 154 };
148 155
149 namespace internal { 156 namespace internal {
150 157
151 // DisplayChangeListener is intended to listen for changes in the display size 158 // DisplayChangeListener is intended to listen for changes in the display size
152 // and cancel the menu. DisplayChangeListener is created when the menu is 159 // and cancel the menu. DisplayChangeListener is created when the menu is
153 // shown. 160 // shown.
154 class DisplayChangeListener { 161 class DisplayChangeListener {
155 public: 162 public:
156 virtual ~DisplayChangeListener() {} 163 virtual ~DisplayChangeListener() {}
157 164
158 // Creates the platform specified DisplayChangeListener, or NULL if there 165 // Creates the platform specified DisplayChangeListener, or NULL if there
159 // isn't one. Caller owns the returned value. 166 // isn't one. Caller owns the returned value.
160 static DisplayChangeListener* Create(Widget* parent, 167 static DisplayChangeListener* Create(Widget* parent,
161 MenuRunner* runner); 168 MenuRunner* runner);
162 169
163 protected: 170 protected:
164 DisplayChangeListener() {} 171 DisplayChangeListener() {}
165 }; 172 };
166 173
167 } 174 } // namespace internal
168 175
169 } // namespace views 176 } // namespace views
170 177
171 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ 178 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698