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

Unified Diff: ui/views/controls/menu/menu_item_view.h

Issue 2684993009: Stop MenuItemView From Directly Caching MenuController (Closed)
Patch Set: Created 3 years, 10 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 | « ui/views/controls/menu/menu_controller_unittest.cc ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_item_view.h
diff --git a/ui/views/controls/menu/menu_item_view.h b/ui/views/controls/menu/menu_item_view.h
index ec8aa982884f35ea139c0994dc608b08d83d62d2..c375343698b9ff56022b404f0b505ed7ef9b1cf7 100644
--- a/ui/views/controls/menu/menu_item_view.h
+++ b/ui/views/controls/menu/menu_item_view.h
@@ -11,11 +11,13 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "ui/base/models/menu_separator_types.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/menu/menu_config.h"
+#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_types.h"
#include "ui/views/view.h"
@@ -412,7 +414,12 @@ class VIEWS_EXPORT MenuItemView : public View {
actual_menu_position_ = actual_menu_position;
}
- void set_controller(MenuController* controller) { controller_ = controller; }
+ void set_controller(MenuController* controller) {
+ if (controller)
+ controller_ = controller->AsWeakPtr();
+ else
+ controller_.reset();
+ }
// Returns true if this MenuItemView contains a single child
// that is responsible for rendering the content.
@@ -436,7 +443,7 @@ class VIEWS_EXPORT MenuItemView : public View {
MenuDelegate* delegate_;
// The controller for the run operation, or NULL if the menu isn't showing.
- MenuController* controller_;
+ base::WeakPtr<MenuController> controller_;
// Used to detect when Cancel was invoked.
bool canceled_;
« no previous file with comments | « ui/views/controls/menu/menu_controller_unittest.cc ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698