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

Unified Diff: chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ditto Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm
diff --git a/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm b/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm
index 21963a0703afdd4b764a4b8b8e079dd055ae283a..dfd5cd9b15ce8b7f08cae585e3c1a039cdd1573a 100644
--- a/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm
+++ b/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm
@@ -183,9 +183,9 @@ RenderViewContextMenuMac::RenderViewContextMenuMac(
const content::ContextMenuParams& params,
NSView* parent_view)
: RenderViewContextMenu(render_frame_host, params),
- speech_submenu_model_(this),
bidi_submenu_model_(this),
- parent_view_(parent_view) {
+ parent_view_(parent_view),
+ text_context_menu_(new TextContextMenu(this)) {
std::unique_ptr<ToolkitDelegate> delegate(new ToolkitDelegateMac(this));
set_toolkit_delegate(std::move(delegate));
}
@@ -250,14 +250,6 @@ void RenderViewContextMenuMac::ExecuteCommand(int command_id, int event_flags) {
LookUpInDictionary();
break;
- case IDC_CONTENT_CONTEXT_SPEECH_START_SPEAKING:
- StartSpeaking();
- break;
-
- case IDC_CONTENT_CONTEXT_SPEECH_STOP_SPEAKING:
- StopSpeaking();
- break;
-
case IDC_WRITING_DIRECTION_DEFAULT:
// WebKit's current behavior is for this menu item to always be disabled.
NOTREACHED();
@@ -305,17 +297,6 @@ bool RenderViewContextMenuMac::IsCommandIdEnabled(int command_id) const {
// appropriate.
return true;
- case IDC_CONTENT_CONTEXT_SPEECH_START_SPEAKING:
- // This is OK because the menu is not shown when it isn't
- // appropriate.
- return true;
-
- case IDC_CONTENT_CONTEXT_SPEECH_STOP_SPEAKING: {
- content::RenderWidgetHostView* view =
- GetRenderViewHost()->GetWidget()->GetView();
- return view && view->IsSpeaking();
- }
-
case IDC_WRITING_DIRECTION_DEFAULT: // Provided to match OS defaults.
return params_.writing_direction_default &
blink::WebContextMenuData::CheckableMenuItemEnabled;
@@ -373,21 +354,7 @@ void RenderViewContextMenuMac::InitToolkitMenu() {
menu_model_.InsertSeparatorAt(index++, ui::NORMAL_SEPARATOR);
}
- content::RenderWidgetHostView* view =
- GetRenderViewHost()->GetWidget()->GetView();
- if (view && view->SupportsSpeech()) {
- menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
- speech_submenu_model_.AddItemWithStringId(
- IDC_CONTENT_CONTEXT_SPEECH_START_SPEAKING,
- IDS_SPEECH_START_SPEAKING_MAC);
- speech_submenu_model_.AddItemWithStringId(
- IDC_CONTENT_CONTEXT_SPEECH_STOP_SPEAKING,
- IDS_SPEECH_STOP_SPEAKING_MAC);
- menu_model_.AddSubMenu(
- IDC_CONTENT_CONTEXT_SPEECH_MENU,
- l10n_util::GetStringUTF16(IDS_SPEECH_MAC),
- &speech_submenu_model_);
- }
+ text_context_menu_->AppendToContextMenu(&menu_model_);
}
void RenderViewContextMenuMac::CancelToolkitMenu() {
@@ -438,10 +405,3 @@ void RenderViewContextMenuMac::StartSpeaking() {
if (view)
view->SpeakSelection();
}
-
-void RenderViewContextMenuMac::StopSpeaking() {
- content::RenderWidgetHostView* view =
- GetRenderViewHost()->GetWidget()->GetView();
- if (view)
- view->StopSpeaking();
-}

Powered by Google App Engine
This is Rietveld 408576698