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

Unified Diff: chrome/browser/ui/views/reload_button.cc

Issue 10832184: Fixed memory leak. Untangled confusing code with menu initialization and ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/reload_button.h ('k') | ui/views/controls/button/button_dropdown.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/reload_button.cc
===================================================================
--- chrome/browser/ui/views/reload_button.cc (revision 150365)
+++ chrome/browser/ui/views/reload_button.cc (working copy)
@@ -39,7 +39,7 @@
ReloadButton::ReloadButton(LocationBarView* location_bar,
CommandUpdater* command_updater)
- : ALLOW_THIS_IN_INITIALIZER_LIST(ButtonDropDown(this, CreateMenuModel())),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(ButtonDropDown(this, NULL)),
location_bar_(location_bar),
command_updater_(command_updater),
intended_mode_(MODE_RELOAD),
@@ -50,9 +50,16 @@
menu_enabled_(false),
testing_mouse_hovered_(false),
testing_reload_count_(0) {
+ menu_model_.reset(new ui::SimpleMenuModel(this));
+ for (size_t i = 0; i < arraysize(kReloadMenuItems); i++) {
+ menu_model_->AddItemWithStringId(kReloadMenuItems[i],
+ kReloadMenuItems[i]);
+ }
+ ButtonDropDown::set_menu_model(menu_model_.get());
}
ReloadButton::~ReloadButton() {
+ ButtonDropDown::set_menu_model(NULL);
Peter Kasting 2012/08/07 19:43:03 This doesn't seem necessary.
gene 2012/08/07 20:58:34 You are right, it does not now. However ButtonDrop
}
void ReloadButton::ChangeMode(Mode mode, bool force) {
@@ -232,15 +239,6 @@
////////////////////////////////////////////////////////////////////////////////
// ReloadButton, private:
-ui::SimpleMenuModel* ReloadButton::CreateMenuModel() {
- ui::SimpleMenuModel* menu_model_ = new ui::SimpleMenuModel(this);
- for (size_t i = 0; i < arraysize(kReloadMenuItems); i++) {
- menu_model_->AddItemWithStringId(kReloadMenuItems[i],
- kReloadMenuItems[i]);
- }
- return menu_model_;
-}
-
void ReloadButton::ExecuteBrowserCommand(int command, int event_flags) {
if (!command_updater_)
return;
« no previous file with comments | « chrome/browser/ui/views/reload_button.h ('k') | ui/views/controls/button/button_dropdown.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698