OLD | NEW |
---|---|
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 implementation. |
27 void ExecuteCommand(int command_id, int event_flags) override; | 29 void ExecuteCommand(int command_id, int event_flags) override; |
28 bool IsCommandIdChecked(int command_id) const override; | 30 bool IsCommandIdChecked(int command_id) const override; |
29 bool IsCommandIdEnabled(int command_id) const override; | 31 bool IsCommandIdEnabled(int command_id) const override; |
30 | 32 |
33 // TextServicesContextMenu: | |
tapted
2016/12/16 07:01:19
nit: TextServicesContextMenu::Delegate:
spqchan
2016/12/17 00:34:21
Done.
| |
34 base::string16 GetSelectedText() const override; | |
35 void OnSpeakRequested() override; | |
36 bool IsLookUpAvailable() const override; | |
37 void LookUpInDictionary() override; | |
38 bool IsTextDirectionEnabled( | |
39 base::i18n::TextDirection direction) const override; | |
40 bool IsTextDirectionChecked( | |
41 base::i18n::TextDirection direction) const override; | |
42 void UpdateTextDirection(base::i18n::TextDirection direction) override; | |
43 | |
31 // RenderViewContextMenuBase implementation. | 44 // RenderViewContextMenuBase implementation. |
32 void Show() override; | 45 void Show() override; |
33 | 46 |
34 protected: | |
35 // RenderViewContextMenu implementation. | |
36 void AppendPlatformEditableItems() override; | |
37 | |
38 private: | 47 private: |
39 friend class ToolkitDelegateMac; | 48 friend class ToolkitDelegateMac; |
40 | 49 |
41 // Adds menu to the platform's toolkit. | 50 // Adds menu to the platform's toolkit. |
42 void InitToolkitMenu(); | 51 void InitToolkitMenu(); |
43 | 52 |
44 // Cancels the menu. | 53 // Cancels the menu. |
45 void CancelToolkitMenu(); | 54 void CancelToolkitMenu(); |
46 | 55 |
47 // Updates the status and text of the specified context-menu item. | 56 // Updates the status and text of the specified context-menu item. |
48 void UpdateToolkitMenuItem(int command_id, | 57 void UpdateToolkitMenuItem(int command_id, |
49 bool enabled, | 58 bool enabled, |
50 bool hidden, | 59 bool hidden, |
51 const base::string16& title); | 60 const base::string16& title); |
52 | 61 |
53 // Adds writing direction submenu. | |
54 void AppendBidiSubMenu(); | |
55 | |
56 // Handler for the "Look Up in Dictionary" menu item. | |
57 void LookUpInDictionary(); | |
58 | |
59 // Handler for the "Start Speaking" menu item. | |
60 void StartSpeaking(); | |
61 | |
62 // Handler for the "Stop Speaking" menu item. | |
63 void StopSpeaking(); | |
64 | |
65 // The Cocoa menu controller for this menu. | 62 // The Cocoa menu controller for this menu. |
66 base::scoped_nsobject<MenuController> menu_controller_; | 63 base::scoped_nsobject<MenuController> menu_controller_; |
67 | 64 |
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. | 65 // The Cocoa parent view. |
75 NSView* parent_view_; | 66 NSView* parent_view_; |
76 | 67 |
68 // The context menu that adds and handles Speech, Lookup and BiDi. | |
69 ui::TextServicesContextMenu text_services_context_menu_; | |
70 | |
77 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac); | 71 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuMac); |
78 }; | 72 }; |
79 | 73 |
80 // The ChromeSwizzleServicesMenuUpdater filters Services menu items in the | 74 // The ChromeSwizzleServicesMenuUpdater filters Services menu items in the |
81 // contextual menus and elsewhere using swizzling. | 75 // contextual menus and elsewhere using swizzling. |
82 @interface ChromeSwizzleServicesMenuUpdater : NSObject | 76 @interface ChromeSwizzleServicesMenuUpdater : NSObject |
83 // Return filtered entries, for testing. | 77 // Return filtered entries, for testing. |
84 + (void)storeFilteredEntriesForTestingInArray:(NSMutableArray*)array; | 78 + (void)storeFilteredEntriesForTestingInArray:(NSMutableArray*)array; |
85 @end | 79 @end |
86 | 80 |
87 #endif // CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MEN U_MAC_H_ | 81 #endif // CHROME_BROWSER_UI_COCOA_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MEN U_MAC_H_ |
OLD | NEW |