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

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: Epic test 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 };
Avi (use Gerrit) 2017/05/17 15:35:59 blank line after
tapted 2017/05/18 03:25:56 Done.
32 // Creates a PopupMenuHelper that will notify |render_frame_host| when a user 37 // Creates a PopupMenuHelper that will notify |render_frame_host| when a user
33 // selects or cancels the popup. 38 // selects or cancels the popup. |delegate| is notified when the menu is
34 explicit PopupMenuHelper(RenderFrameHost* render_frame_host); 39 // closed.
40 PopupMenuHelper(Delegate* delegate, RenderFrameHost* render_frame_host);
41 ~PopupMenuHelper() override;
35 void Hide(); 42 void Hide();
36 43
37 // Shows the popup menu and notifies the RenderFrameHost of the selection/ 44 // Shows the popup menu and notifies the RenderFrameHost of the selection/
38 // cancellation. This call is blocking. 45 // cancellation. This call is blocking.
39 void ShowPopupMenu(const gfx::Rect& bounds, 46 void ShowPopupMenu(const gfx::Rect& bounds,
40 int item_height, 47 int item_height,
41 double item_font_size, 48 double item_font_size,
42 int selected_item, 49 int selected_item,
43 const std::vector<MenuItem>& items, 50 const std::vector<MenuItem>& items,
44 bool right_aligned, 51 bool right_aligned,
45 bool allow_multiple_selection); 52 bool allow_multiple_selection);
46 53
47 // Immediately return from ShowPopupMenu. 54 // Immediately return from ShowPopupMenu.
48 CONTENT_EXPORT static void DontShowPopupMenuForTesting(); 55 CONTENT_EXPORT static void DontShowPopupMenuForTesting();
49 56
50 protected: 57 protected:
51 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const; 58 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const;
52 59
60 private:
53 // NotificationObserver implementation: 61 // NotificationObserver implementation:
54 void Observe(int type, 62 void Observe(int type,
55 const NotificationSource& source, 63 const NotificationSource& source,
56 const NotificationDetails& details) override; 64 const NotificationDetails& details) override;
57 65
66 Delegate* delegate_; // Weak. Owns |this|.
67
58 NotificationRegistrar notification_registrar_; 68 NotificationRegistrar notification_registrar_;
59 RenderFrameHostImpl* render_frame_host_; 69 RenderFrameHostImpl* render_frame_host_;
60 WebMenuRunner* menu_runner_; 70 WebMenuRunner* menu_runner_;
61 bool popup_was_hidden_; 71 bool popup_was_hidden_;
62 72
73 base::WeakPtrFactory<PopupMenuHelper> weak_ptr_factory_;
74
63 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper); 75 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper);
64 }; 76 };
65 77
66 } // namespace content 78 } // namespace content
67 79
68 #endif // CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_ 80 #endif // CONTENT_BROWSER_FRAME_HOST_POPUP_MENU_HELPER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698