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

Side by Side Diff: chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc

Issue 11673004: No need to pass DownloadItemModel ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DownloadShelfContextMenu class cleanup and require GetMenuModel() to return non-NULL Created 7 years, 11 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) 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 "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h" 5 #include "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/download/download_item_model.h" 8 #include "chrome/browser/download/download_item_model.h"
9 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" 9 #include "chrome/browser/ui/gtk/download/download_item_gtk.h"
10 #include "content/public/browser/page_navigator.h" 10 #include "content/public/browser/page_navigator.h"
11 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
12 12
13 DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk( 13 DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk(
14 DownloadItemModel* model,
15 DownloadItemGtk* download_item, 14 DownloadItemGtk* download_item,
16 content::PageNavigator* navigator) 15 content::PageNavigator* navigator)
17 : DownloadShelfContextMenu(model, navigator), 16 : DownloadShelfContextMenu(download_item->download(), navigator),
18 download_item_gtk_(download_item) { 17 download_item_gtk_(download_item) {
19 } 18 }
20 19
21 DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {} 20 DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {}
22 21
23 void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget, 22 void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget,
24 GdkEventButton* event) { 23 GdkEventButton* event) {
25 menu_.reset(new MenuGtk(this, GetMenuModel())); 24 ui::SimpleMenuModel* menu_model = GetMenuModel();
25 // Popup() should never be called after the DownloadItem is destroyed.
26 DCHECK(menu_model);
27
28 menu_.reset(new MenuGtk(this, menu_model));
26 29
27 if (widget) 30 if (widget)
28 menu_->PopupForWidget(widget, event->button, event->time); 31 menu_->PopupForWidget(widget, event->button, event->time);
29 else 32 else
30 menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), 33 menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root),
31 event->time); 34 event->time);
32 } 35 }
33 36
34 void DownloadShelfContextMenuGtk::StoppedShowing() { 37 void DownloadShelfContextMenuGtk::StoppedShowing() {
35 download_item_gtk_->menu_showing_ = false; 38 download_item_gtk_->menu_showing_ = false;
(...skipping 17 matching lines...) Expand all
53 case TOGGLE_PAUSE: 56 case TOGGLE_PAUSE:
54 stock = NULL; 57 stock = NULL;
55 break; 58 break;
56 59
57 default: 60 default:
58 NOTREACHED(); 61 NOTREACHED();
59 break; 62 break;
60 } 63 }
61 return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL; 64 return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL;
62 } 65 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h ('k') | chrome/browser/ui/gtk/download/download_shelf_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698