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

Unified Diff: views/controls/menu/submenu_view.cc

Issue 1664001: Fixes possible crash if the window hosting a menu was closed while the (Closed)
Patch Set: Incorporated review feedback Created 10 years, 8 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 | « views/controls/menu/submenu_view.h ('k') | views/view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/menu/submenu_view.cc
diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc
index 8136794349f760cda9d819c4240ffccd3018ca0e..52c91019ed0961b386499b53e27382f4357b9b7a 100644
--- a/views/controls/menu/submenu_view.cc
+++ b/views/controls/menu/submenu_view.cc
@@ -6,15 +6,10 @@
#include "gfx/canvas.h"
#include "views/controls/menu/menu_controller.h"
+#include "views/controls/menu/menu_host.h"
#include "views/controls/menu/menu_scroll_view_container.h"
#include "views/widget/root_view.h"
-#if defined(OS_WIN)
-#include "views/controls/menu/menu_host_win.h"
-#elif defined(OS_LINUX)
-#include "views/controls/menu/menu_host_gtk.h"
-#endif
-
// Height of the drop indicator. This should be an even number.
static const int kDropIndicatorHeight = 2;
@@ -208,20 +203,18 @@ bool SubmenuView::OnMouseWheel(const MouseWheelEvent& e) {
}
bool SubmenuView::IsShowing() {
- return host_ && host_->IsVisible();
+ return host_ && host_->IsMenuHostVisible();
}
void SubmenuView::ShowAt(gfx::NativeWindow parent,
const gfx::Rect& bounds,
bool do_capture) {
if (host_) {
- host_->Show();
- if (do_capture)
- host_->DoCapture();
+ host_->ShowMenuHost(do_capture);
return;
}
- host_ = new MenuHost(this);
+ host_ = MenuHost::Create(this);
// Force construction of the scroll view container.
GetScrollViewContainer();
// Make sure the first row is visible.
@@ -230,23 +223,25 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent,
}
void SubmenuView::Reposition(const gfx::Rect& bounds) {
- host_->SetBounds(bounds);
+ if (host_)
+ host_->SetMenuHostBounds(bounds);
}
void SubmenuView::Close() {
if (host_) {
- host_->Close();
+ host_->DestroyMenuHost();
host_ = NULL;
}
}
void SubmenuView::Hide() {
if (host_)
- host_->HideWindow();
+ host_->HideMenuHost();
}
void SubmenuView::ReleaseCapture() {
- host_->ReleaseCapture();
+ if (host_)
+ host_->ReleaseMenuHostCapture();
}
bool SubmenuView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
@@ -282,7 +277,12 @@ MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() {
}
gfx::NativeWindow SubmenuView::native_window() const {
- return host_ ? host_->GetNativeWindow() : NULL;
+ return host_ ? host_->GetMenuHostWindow() : NULL;
+}
+
+void SubmenuView::MenuHostDestroyed() {
+ host_ = NULL;
+ GetMenuItem()->GetMenuController()->Cancel(MenuController::EXIT_DESTROYED);
}
void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas,
« no previous file with comments | « views/controls/menu/submenu_view.h ('k') | views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698