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