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

Unified Diff: content/browser/frame_host/popup_menu_helper_mac.h

Issue 2888803002: Handle WebContentsViewMac being destroyed while a <select> menu is showing. (Closed)
Patch Set: respond to comments Created 3 years, 7 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
Index: content/browser/frame_host/popup_menu_helper_mac.h
diff --git a/content/browser/frame_host/popup_menu_helper_mac.h b/content/browser/frame_host/popup_menu_helper_mac.h
index 27d3f718c5f4c28632ccbf6fb1bd4dd1fdecb7ab..1fd5b95a450f05cafde75465c1d1f6d2f0d2e4a4 100644
--- a/content/browser/frame_host/popup_menu_helper_mac.h
+++ b/content/browser/frame_host/popup_menu_helper_mac.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -29,9 +30,16 @@ struct MenuItem;
class PopupMenuHelper : public NotificationObserver {
public:
+ class Delegate {
+ public:
+ virtual void OnMenuClosed() = 0;
+ };
+
// Creates a PopupMenuHelper that will notify |render_frame_host| when a user
- // selects or cancels the popup.
- explicit PopupMenuHelper(RenderFrameHost* render_frame_host);
+ // selects or cancels the popup. |delegate| is notified when the menu is
+ // closed.
+ PopupMenuHelper(Delegate* delegate, RenderFrameHost* render_frame_host);
+ ~PopupMenuHelper() override;
void Hide();
// Shows the popup menu and notifies the RenderFrameHost of the selection/
@@ -50,16 +58,21 @@ class PopupMenuHelper : public NotificationObserver {
protected:
virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const;
+ private:
// NotificationObserver implementation:
void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) override;
+ Delegate* delegate_; // Weak. Owns |this|.
+
NotificationRegistrar notification_registrar_;
RenderFrameHostImpl* render_frame_host_;
WebMenuRunner* menu_runner_;
bool popup_was_hidden_;
+ base::WeakPtrFactory<PopupMenuHelper> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper);
};

Powered by Google App Engine
This is Rietveld 408576698