1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_MAC_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
13 @class MenuController;
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 {
20 RenderViewContextMenuMac(content::RenderFrameHost* render_frame_host,
21 const content::ContextMenuParams& params,
23 virtual ~RenderViewContextMenuMac();
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;
33 // RenderViewContextMenu implementation.
34 virtual bool GetAcceleratorForCommandId(
36 ui::Accelerator* accelerator) OVERRIDE;
37 virtual void AppendPlatformEditableItems() OVERRIDE;
40 friend class ToolkitDelegateMac;
42 // Adds menu to the platform's toolkit.
43 void InitToolkitMenu();
46 void CancelToolkitMenu();
48 // Updates the status and text of the specified context-menu item.
49 void UpdateToolkitMenuItem(int command_id,
52 const base::string16& title);
54 // Adds writing direction submenu.
55 void AppendBidiSubMenu();
57 // Handler for the "Look Up in Dictionary" menu item.
58 void LookUpInDictionary();
60 // Handler for the "Start Speaking" menu item.
63 // Handler for the "Stop Speaking" menu item.
66 // The Cocoa menu controller for this menu.
67 base::scoped_nsobject<MenuController> menu_controller_;
69 // Model for the "Speech" submenu.
70 ui::SimpleMenuModel speech_submenu_model_;
72 // Model for the BiDi input submenu.
73 ui::SimpleMenuModel bidi_submenu_model_;
75 // The Cocoa parent view.
78 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac);
81 #endif // CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_MAC_H_