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

Side by Side 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 unified diff | Download patch
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 #ifndef CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_
6 #define CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
16 17
17 #ifdef __OBJC__ 18 #ifdef __OBJC__
18 @class WebMenuRunner; 19 @class WebMenuRunner;
19 #else 20 #else
20 class WebMenuRunner; 21 class WebMenuRunner;
21 #endif 22 #endif
22 23
23 namespace content { 24 namespace content {
24 25
25 class RenderFrameHost; 26 class RenderFrameHost;
26 class RenderFrameHostImpl; 27 class RenderFrameHostImpl;
27 class RenderWidgetHostViewMac; 28 class RenderWidgetHostViewMac;
28 struct MenuItem; 29 struct MenuItem;
29 30
30 class PopupMenuHelper : public NotificationObserver { 31 class PopupMenuHelper : public NotificationObserver {
31 public: 32 public:
33 class Delegate {
34 public:
35 virtual void OnMenuClosed() = 0;
36 };
37
32 // Creates a PopupMenuHelper that will notify |render_frame_host| when a user 38 // Creates a PopupMenuHelper that will notify |render_frame_host| when a user
33 // selects or cancels the popup. 39 // selects or cancels the popup. |delegate| is notified when the menu is
34 explicit PopupMenuHelper(RenderFrameHost* render_frame_host); 40 // closed.
41 PopupMenuHelper(Delegate* delegate, RenderFrameHost* render_frame_host);
42 ~PopupMenuHelper() override;
35 void Hide(); 43 void Hide();
36 44
37 // Shows the popup menu and notifies the RenderFrameHost of the selection/ 45 // Shows the popup menu and notifies the RenderFrameHost of the selection/
38 // cancellation. This call is blocking. 46 // cancellation. This call is blocking.
39 void ShowPopupMenu(const gfx::Rect& bounds, 47 void ShowPopupMenu(const gfx::Rect& bounds,
40 int item_height, 48 int item_height,
41 double item_font_size, 49 double item_font_size,
42 int selected_item, 50 int selected_item,
43 const std::vector<MenuItem>& items, 51 const std::vector<MenuItem>& items,
44 bool right_aligned, 52 bool right_aligned,
45 bool allow_multiple_selection); 53 bool allow_multiple_selection);
46 54
47 // Immediately return from ShowPopupMenu. 55 // Immediately return from ShowPopupMenu.
48 CONTENT_EXPORT static void DontShowPopupMenuForTesting(); 56 CONTENT_EXPORT static void DontShowPopupMenuForTesting();
49 57
50 protected: 58 protected:
51 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const; 59 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const;
52 60
61 private:
53 // NotificationObserver implementation: 62 // NotificationObserver implementation:
54 void Observe(int type, 63 void Observe(int type,
55 const NotificationSource& source, 64 const NotificationSource& source,
56 const NotificationDetails& details) override; 65 const NotificationDetails& details) override;
57 66
67 Delegate* delegate_; // Weak. Owns |this|.
68
58 NotificationRegistrar notification_registrar_; 69 NotificationRegistrar notification_registrar_;
59 RenderFrameHostImpl* render_frame_host_; 70 RenderFrameHostImpl* render_frame_host_;
60 WebMenuRunner* menu_runner_; 71 WebMenuRunner* menu_runner_;
61 bool popup_was_hidden_; 72 bool popup_was_hidden_;
62 73
74 base::WeakPtrFactory<PopupMenuHelper> weak_ptr_factory_;
75
63 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper); 76 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper);
64 }; 77 };
65 78
66 } // namespace content 79 } // namespace content
67 80
68 #endif // CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_ 81 #endif // CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698