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

Side by Side Diff: ui/base/models/simple_menu_model.cc

Issue 7492054: Don't send ViewMsg_ContextMenuClosed to the renderer process for submenus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 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
« no previous file with comments | « ui/base/models/simple_menu_model.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "ui/base/models/simple_menu_model.h" 5 #include "ui/base/models/simple_menu_model.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 10
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 bool SimpleMenuModel::Delegate::GetIconForCommandId( 41 bool SimpleMenuModel::Delegate::GetIconForCommandId(
42 int command_id, SkBitmap* bitmap) const { 42 int command_id, SkBitmap* bitmap) const {
43 return false; 43 return false;
44 } 44 }
45 45
46 void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) { 46 void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) {
47 } 47 }
48 48
49 void SimpleMenuModel::Delegate::MenuWillShow() { 49 void SimpleMenuModel::Delegate::MenuWillShow(SimpleMenuModel* /*source*/) {
50 } 50 }
51 51
52 void SimpleMenuModel::Delegate::MenuClosed() { 52 void SimpleMenuModel::Delegate::MenuClosed(SimpleMenuModel* /*source*/) {
53 } 53 }
54 54
55 //////////////////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////////////////
56 // SimpleMenuModel, public: 56 // SimpleMenuModel, public:
57 57
58 SimpleMenuModel::SimpleMenuModel(Delegate* delegate) 58 SimpleMenuModel::SimpleMenuModel(Delegate* delegate)
59 : delegate_(delegate), 59 : delegate_(delegate),
60 menu_model_delegate_(NULL), 60 menu_model_delegate_(NULL),
61 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 61 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
62 } 62 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (delegate_) 289 if (delegate_)
290 delegate_->ExecuteCommand(GetCommandIdAt(index)); 290 delegate_->ExecuteCommand(GetCommandIdAt(index));
291 } 291 }
292 292
293 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { 293 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const {
294 return items_.at(FlipIndex(index)).submenu; 294 return items_.at(FlipIndex(index)).submenu;
295 } 295 }
296 296
297 void SimpleMenuModel::MenuWillShow() { 297 void SimpleMenuModel::MenuWillShow() {
298 if (delegate_) 298 if (delegate_)
299 delegate_->MenuWillShow(); 299 delegate_->MenuWillShow(this);
300 } 300 }
301 301
302 void SimpleMenuModel::MenuClosed() { 302 void SimpleMenuModel::MenuClosed() {
303 // Due to how menus work on the different platforms, ActivatedAt will be 303 // Due to how menus work on the different platforms, ActivatedAt will be
304 // called after this. It's more convenient for the delegate to be called 304 // called after this. It's more convenient for the delegate to be called
305 // afterwards though, so post a task. 305 // afterwards though, so post a task.
306 MessageLoop::current()->PostTask( 306 MessageLoop::current()->PostTask(
307 FROM_HERE, 307 FROM_HERE,
308 method_factory_.NewRunnableMethod(&SimpleMenuModel::OnMenuClosed)); 308 method_factory_.NewRunnableMethod(&SimpleMenuModel::OnMenuClosed));
309 } 309 }
310 310
311 void SimpleMenuModel::SetMenuModelDelegate( 311 void SimpleMenuModel::SetMenuModelDelegate(
312 ui::MenuModelDelegate* menu_model_delegate) { 312 ui::MenuModelDelegate* menu_model_delegate) {
313 menu_model_delegate_ = menu_model_delegate; 313 menu_model_delegate_ = menu_model_delegate;
314 } 314 }
315 315
316 void SimpleMenuModel::OnMenuClosed() { 316 void SimpleMenuModel::OnMenuClosed() {
317 if (delegate_) 317 if (delegate_)
318 delegate_->MenuClosed(); 318 delegate_->MenuClosed(this);
319 } 319 }
320 320
321 int SimpleMenuModel::FlipIndex(int index) const { 321 int SimpleMenuModel::FlipIndex(int index) const {
322 return index; 322 return index;
323 } 323 }
324 324
325 //////////////////////////////////////////////////////////////////////////////// 325 ////////////////////////////////////////////////////////////////////////////////
326 // SimpleMenuModel, Private: 326 // SimpleMenuModel, Private:
327 327
328 void SimpleMenuModel::AppendItem(const Item& item) { 328 void SimpleMenuModel::AppendItem(const Item& item) {
(...skipping 10 matching lines...) Expand all
339 #ifndef NDEBUG 339 #ifndef NDEBUG
340 if (item.type == TYPE_SEPARATOR) { 340 if (item.type == TYPE_SEPARATOR) {
341 DCHECK_EQ(item.command_id, kSeparatorId); 341 DCHECK_EQ(item.command_id, kSeparatorId);
342 } else { 342 } else {
343 DCHECK_GE(item.command_id, 0); 343 DCHECK_GE(item.command_id, 0);
344 } 344 }
345 #endif // NDEBUG 345 #endif // NDEBUG
346 } 346 }
347 347
348 } // namespace ui 348 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/models/simple_menu_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698