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

Side by Side Diff: chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_M AC_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_M AC_H_
6 #define CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_M AC_H_ 6 #define CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_M AC_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
13 #include "ui/base/cocoa/text_services_context_menu.h"
13 14
14 @class MenuController; 15 @class MenuController;
15 16
16 // Mac implementation of the context menu display code. Uses a Cocoa NSMenu 17 // Mac implementation of the context menu display code. Uses a Cocoa NSMenu
17 // to display the context menu. Internally uses an obj-c object as the 18 // to display the context menu. Internally uses an obj-c object as the
18 // target of the NSMenu, bridging back to this C++ class. 19 // target of the NSMenu, bridging back to this C++ class.
19 class RenderViewContextMenuMac : public RenderViewContextMenu { 20 class RenderViewContextMenuMac : public RenderViewContextMenu,
21 public ui::TextServicesContextMenu::Delegate {
20 public: 22 public:
21 RenderViewContextMenuMac(content::RenderFrameHost* render_frame_host, 23 RenderViewContextMenuMac(content::RenderFrameHost* render_frame_host,
22 const content::ContextMenuParams& params, 24 const content::ContextMenuParams& params,
23 NSView* parent_view); 25 NSView* parent_view);
24 ~RenderViewContextMenuMac() override; 26 ~RenderViewContextMenuMac() override;
25 27
26 // SimpleMenuModel::Delegate implementation. 28 // SimpleMenuModel::Delegate:
27 void ExecuteCommand(int command_id, int event_flags) override;
28 bool IsCommandIdChecked(int command_id) const override; 29 bool IsCommandIdChecked(int command_id) const override;
29 bool IsCommandIdEnabled(int command_id) const override; 30 bool IsCommandIdEnabled(int command_id) const override;
31 void ExecuteCommand(int command_id, int event_flags) override;
30 32
31 // RenderViewContextMenuBase implementation. 33 // TextServicesContextMenu::Delegate:
34 base::string16 GetSelectedText() const override;
35 bool IsTextDirectionEnabled(
36 base::i18n::TextDirection direction) const override;
37 bool IsTextDirectionChecked(
38 base::i18n::TextDirection direction) const override;
39 void UpdateTextDirection(base::i18n::TextDirection direction) override;
40
41 // RenderViewContextMenuBase:
32 void Show() override; 42 void Show() override;
33 43
34 protected:
35 // RenderViewContextMenu implementation.
36 void AppendPlatformEditableItems() override;
37
38 private: 44 private:
39 friend class ToolkitDelegateMac; 45 friend class ToolkitDelegateMac;
40 46
41 // Adds menu to the platform's toolkit. 47 // Adds menu to the platform's toolkit.
42 void InitToolkitMenu(); 48 void InitToolkitMenu();
43 49
44 // Cancels the menu. 50 // Cancels the menu.
45 void CancelToolkitMenu(); 51 void CancelToolkitMenu();
46 52
47 // Updates the status and text of the specified context-menu item. 53 // Updates the status and text of the specified context-menu item.
48 void UpdateToolkitMenuItem(int command_id, 54 void UpdateToolkitMenuItem(int command_id,
49 bool enabled, 55 bool enabled,
50 bool hidden, 56 bool hidden,
51 const base::string16& title); 57 const base::string16& title);
52 58
53 // Adds writing direction submenu. 59 // Handler for the "Look Up" menu item.
54 void AppendBidiSubMenu();
55
56 // Handler for the "Look Up in Dictionary" menu item.
57 void LookUpInDictionary(); 60 void LookUpInDictionary();
58 61
59 // Handler for the "Start Speaking" menu item. 62 // Returns value of the context menu parameter associated with |direction|.
60 void StartSpeaking(); 63 int ParamsForTextDirection(base::i18n::TextDirection direction) const;
61
62 // Handler for the "Stop Speaking" menu item.
63 void StopSpeaking();
64 64
65 // The Cocoa menu controller for this menu. 65 // The Cocoa menu controller for this menu.
66 base::scoped_nsobject<MenuController> menu_controller_; 66 base::scoped_nsobject<MenuController> menu_controller_;
67 67
68 // Model for the "Speech" submenu.
69 ui::SimpleMenuModel speech_submenu_model_;
70
71 // Model for the BiDi input submenu.
72 ui::SimpleMenuModel bidi_submenu_model_;
73
74 // The Cocoa parent view. 68 // The Cocoa parent view.
75 NSView* parent_view_; 69 NSView* parent_view_;
76 70
71 // The context menu that adds and handles Speech, Lookup and BiDi.
72 ui::TextServicesContextMenu text_services_context_menu_;
73
77 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac); 74 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac);
78 }; 75 };
79 76
80 // The ChromeSwizzleServicesMenuUpdater filters Services menu items in the 77 // The ChromeSwizzleServicesMenuUpdater filters Services menu items in the
81 // contextual menus and elsewhere using swizzling. 78 // contextual menus and elsewhere using swizzling.
82 @interface ChromeSwizzleServicesMenuUpdater : NSObject 79 @interface ChromeSwizzleServicesMenuUpdater : NSObject
83 // Return filtered entries, for testing. 80 // Return filtered entries, for testing.
84 + (void)storeFilteredEntriesForTestingInArray:(NSMutableArray*)array; 81 + (void)storeFilteredEntriesForTestingInArray:(NSMutableArray*)array;
85 @end 82 @end
86 83
87 #endif // CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MEN U_MAC_H_ 84 #endif // CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MEN U_MAC_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698