| OLD | NEW |
| 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_RENDERER_HOST_POPUP_MENU_HELPER_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_POPUP_MENU_HELPER_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_POPUP_MENU_HELPER_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_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 "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 | 15 |
| 16 #ifdef __OBJC__ |
| 17 @class WebMenuRunner; |
| 18 #else |
| 19 class WebMenuRunner; |
| 20 #endif |
| 21 |
| 16 namespace content { | 22 namespace content { |
| 17 class RenderViewHost; | 23 class RenderViewHost; |
| 18 class RenderViewHostImpl; | 24 class RenderViewHostImpl; |
| 19 class RenderWidgetHostViewMac; | 25 class RenderWidgetHostViewMac; |
| 20 struct MenuItem; | 26 struct MenuItem; |
| 21 | 27 |
| 22 class PopupMenuHelper : public NotificationObserver { | 28 class PopupMenuHelper : public NotificationObserver { |
| 23 public: | 29 public: |
| 24 // Creates a PopupMenuHelper that will notify |render_view_host| when a user | 30 // Creates a PopupMenuHelper that will notify |render_view_host| when a user |
| 25 // selects or cancels the popup. | 31 // selects or cancels the popup. |
| 26 explicit PopupMenuHelper(RenderViewHost* render_view_host); | 32 explicit PopupMenuHelper(RenderViewHost* render_view_host); |
| 33 void Hide(); |
| 27 | 34 |
| 28 // Shows the popup menu and notifies the RenderViewHost of the selection/ | 35 // Shows the popup menu and notifies the RenderViewHost of the selection/ |
| 29 // cancel. | 36 // cancel. |
| 30 // This call is blocking. | 37 // This call is blocking. |
| 31 void ShowPopupMenu(const gfx::Rect& bounds, | 38 void ShowPopupMenu(const gfx::Rect& bounds, |
| 32 int item_height, | 39 int item_height, |
| 33 double item_font_size, | 40 double item_font_size, |
| 34 int selected_item, | 41 int selected_item, |
| 35 const std::vector<MenuItem>& items, | 42 const std::vector<MenuItem>& items, |
| 36 bool right_aligned, | 43 bool right_aligned, |
| 37 bool allow_multiple_selection); | 44 bool allow_multiple_selection); |
| 38 | 45 |
| 39 // Immediately return from ShowPopupMenu. | 46 // Immediately return from ShowPopupMenu. |
| 40 CONTENT_EXPORT static void DontShowPopupMenuForTesting(); | 47 CONTENT_EXPORT static void DontShowPopupMenuForTesting(); |
| 41 | 48 |
| 42 protected: | 49 protected: |
| 43 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const; | 50 virtual RenderWidgetHostViewMac* GetRenderWidgetHostView() const; |
| 44 | 51 |
| 45 // NotificationObserver implementation: | 52 // NotificationObserver implementation: |
| 46 virtual void Observe(int type, | 53 virtual void Observe(int type, |
| 47 const NotificationSource& source, | 54 const NotificationSource& source, |
| 48 const NotificationDetails& details) OVERRIDE; | 55 const NotificationDetails& details) OVERRIDE; |
| 49 | 56 |
| 50 NotificationRegistrar notification_registrar_; | 57 NotificationRegistrar notification_registrar_; |
| 51 | |
| 52 RenderViewHostImpl* render_view_host_; | 58 RenderViewHostImpl* render_view_host_; |
| 59 WebMenuRunner* menu_runner_; |
| 60 bool popup_was_hidden_; |
| 53 | 61 |
| 54 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper); | 62 DISALLOW_COPY_AND_ASSIGN(PopupMenuHelper); |
| 55 }; | 63 }; |
| 56 | 64 |
| 57 } // namespace content | 65 } // namespace content |
| 58 | 66 |
| 59 #endif // CONTENT_BROWSER_RENDERER_HOST_POPUP_MENU_HELPER_MAC_H_ | 67 #endif // CONTENT_BROWSER_RENDERER_HOST_POPUP_MENU_HELPER_MAC_H_ |
| OLD | NEW |