Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / tab_contents / render_view_context_menu_mac.h
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 CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_MAC_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #include "base/mac/scoped_nsobject.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12
13 @class MenuController;
14
15 // Mac implementation of the context menu display code. Uses a Cocoa NSMenu
16 // to display the context menu. Internally uses an obj-c object as the
17 // target of the NSMenu, bridging back to this C++ class.
18 class RenderViewContextMenuMac : public RenderViewContextMenu {
19  public:
20   RenderViewContextMenuMac(content::RenderFrameHost* render_frame_host,
21                            const content::ContextMenuParams& params,
22                            NSView* parent_view);
23   virtual ~RenderViewContextMenuMac();
24
25   // SimpleMenuModel::Delegate implementation.
26   virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
27   virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
28   virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
29
30   // RenderViewContextMenuDelegate implementation.
31   virtual void UpdateMenuItem(int command_id,
32                               bool enabled,
33                               bool hidden,
34                               const base::string16& title) OVERRIDE;
35
36  protected:
37   // RenderViewContextMenu implementation.
38   virtual void PlatformInit() OVERRIDE;
39   virtual void PlatformCancel() OVERRIDE;
40   virtual bool GetAcceleratorForCommandId(
41       int command_id,
42       ui::Accelerator* accelerator) OVERRIDE;
43   virtual void AppendPlatformEditableItems() OVERRIDE;
44
45  private:
46   // Adds platform-specific items to the menu.
47   void InitPlatformMenu();
48
49   // Adds writing direction submenu.
50   void AppendBidiSubMenu();
51
52   // Handler for the "Look Up in Dictionary" menu item.
53   void LookUpInDictionary();
54
55   // Handler for the "Start Speaking" menu item.
56   void StartSpeaking();
57
58   // Handler for the "Stop Speaking" menu item.
59   void StopSpeaking();
60
61   // The Cocoa menu controller for this menu.
62   base::scoped_nsobject<MenuController> menu_controller_;
63
64   // Model for the "Speech" submenu.
65   ui::SimpleMenuModel speech_submenu_model_;
66
67   // Model for the BiDi input submenu.
68   ui::SimpleMenuModel bidi_submenu_model_;
69
70   // The Cocoa parent view.
71   NSView* parent_view_;
72
73   DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac);
74 };
75
76 #endif  // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_MAC_H_