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

Side by Side Diff: ui/views/controls/button/button_dropdown.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 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 #include "ui/views/controls/button/button_dropdown.h" 5 #include "ui/views/controls/button/button_dropdown.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 #endif 168 #endif
169 if (menu_position.x() < left_bound) 169 if (menu_position.x() < left_bound)
170 menu_position.set_x(left_bound); 170 menu_position.set_x(left_bound);
171 171
172 // Make the button look depressed while the menu is open. 172 // Make the button look depressed while the menu is open.
173 SetState(BS_PUSHED); 173 SetState(BS_PUSHED);
174 174
175 menu_showing_ = true; 175 menu_showing_ = true;
176 176
177 // Create and run menu. Display an empty menu if model is NULL. 177 // Create and run menu. Display an empty menu if model is NULL.
178 if (model_) { 178 if (model_.get()) {
179 MenuModelAdapter menu_delegate(model_); 179 MenuModelAdapter menu_delegate(model_.get());
180 menu_delegate.set_triggerable_event_flags(triggerable_event_flags()); 180 menu_delegate.set_triggerable_event_flags(triggerable_event_flags());
181 menu_runner_.reset(new MenuRunner(menu_delegate.CreateMenu())); 181 menu_runner_.reset(new MenuRunner(menu_delegate.CreateMenu()));
182 MenuRunner::RunResult result = 182 MenuRunner::RunResult result =
183 menu_runner_->RunMenuAt(GetWidget(), NULL, 183 menu_runner_->RunMenuAt(GetWidget(), NULL,
184 gfx::Rect(menu_position, gfx::Size(0, 0)), 184 gfx::Rect(menu_position, gfx::Size(0, 0)),
185 MenuItemView::TOPLEFT, 185 MenuItemView::TOPLEFT,
186 MenuRunner::HAS_MNEMONICS); 186 MenuRunner::HAS_MNEMONICS);
187 if (result == MenuRunner::MENU_DELETED) 187 if (result == MenuRunner::MENU_DELETED)
188 return; 188 return;
189 } else { 189 } else {
(...skipping 21 matching lines...) Expand all
211 SetState(BS_NORMAL); 211 SetState(BS_NORMAL);
212 } 212 }
213 213
214 //////////////////////////////////////////////////////////////////////////////// 214 ////////////////////////////////////////////////////////////////////////////////
215 // 215 //
216 // ButtonDropDown - Accessibility 216 // ButtonDropDown - Accessibility
217 // 217 //
218 //////////////////////////////////////////////////////////////////////////////// 218 ////////////////////////////////////////////////////////////////////////////////
219 219
220 } // namespace views 220 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698