Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_mac.mm |
| diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| index c7a78ff0f1e97c6911bb50254f6b6f8b6c0f6ddc..f3d39ed7c651f4a4352400a03fb96233991ad510 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -73,6 +73,7 @@ |
| #import "ui/base/cocoa/appkit_utils.h" |
| #include "ui/base/cocoa/cocoa_base_utils.h" |
| #import "ui/base/cocoa/fullscreen_window_manager.h" |
| +#include "ui/base/cocoa/text_services_context_menu.h" |
| #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| #include "ui/base/layout.h" |
| #include "ui/compositor/compositor.h" |
| @@ -137,13 +138,6 @@ RenderWidgetHostView* GetRenderWidgetHostViewToUse( |
| } // namespace |
| -// These are not documented, so use only after checking -respondsToSelector:. |
| -@interface NSApplication (UndocumentedSpeechMethods) |
| -- (void)speakString:(NSString*)string; |
| -- (void)stopSpeaking:(id)sender; |
| -- (BOOL)isSpeaking; |
| -@end |
| - |
| // Private methods: |
| @interface RenderWidgetHostViewCocoa () |
| @property(nonatomic, assign) NSRange selectedRange; |
| @@ -705,10 +699,6 @@ void RenderWidgetHostViewMac::UpdateDisplayVSyncParameters() { |
| browser_compositor_->UpdateVSyncParameters(vsync_timebase_, vsync_interval_); |
| } |
| -void RenderWidgetHostViewMac::SpeakText(const std::string& text) { |
| - [NSApp speakString:base::SysUTF8ToNSString(text)]; |
| -} |
| - |
| RenderWidgetHostViewBase* |
| RenderWidgetHostViewMac::GetFocusedViewForTextSelection() { |
| // We obtain the TextSelection from focused RWH which is obtained from the |
| @@ -1095,11 +1085,6 @@ void RenderWidgetHostViewMac::SetTooltipText( |
| } |
| } |
| -bool RenderWidgetHostViewMac::SupportsSpeech() const { |
| - return [NSApp respondsToSelector:@selector(speakString:)] && |
| - [NSApp respondsToSelector:@selector(stopSpeaking:)]; |
| -} |
| - |
| void RenderWidgetHostViewMac::SpeakSelection() { |
| if (![NSApp respondsToSelector:@selector(speakString:)]) |
| return; |
| @@ -1113,17 +1098,7 @@ void RenderWidgetHostViewMac::SpeakSelection() { |
| return; |
| } |
| - SpeakText(selected_text_); |
| -} |
| - |
| -bool RenderWidgetHostViewMac::IsSpeaking() const { |
| - return [NSApp respondsToSelector:@selector(isSpeaking)] && |
| - [NSApp isSpeaking]; |
| -} |
| - |
| -void RenderWidgetHostViewMac::StopSpeaking() { |
| - if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) |
| - [NSApp stopSpeaking:cocoa_view_]; |
| + ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(selected_text_)); |
|
tapted
2016/12/13 05:11:22
Can we make |selected_text_| a string16?
It looks
spqchan
2016/12/15 23:29:00
Added a TODO
|
| } |
| // |
| @@ -1677,7 +1652,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { |
| void RenderWidgetHostViewMac::OnGetRenderedTextCompleted( |
| const std::string& text) { |
| - SpeakText(text); |
| + ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(text)); |
|
tapted
2016/12/13 05:11:22
i.e. Ideally this uses string16 as well, but maybe
spqchan
2016/12/15 23:29:00
Acknowledged.
|
| } |
| void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { |
| @@ -2744,10 +2719,10 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| nullptr; |
| if (action == @selector(stopSpeaking:)) |
| - return is_render_view && renderWidgetHostView_->IsSpeaking(); |
| + return is_render_view; |
|
tapted
2016/12/13 05:11:22
can we do something like && ui::TextServicesContex
spqchan
2016/12/15 23:29:00
Whoops, thanks for the catch
|
| if (action == @selector(startSpeaking:)) |
| - return is_render_view && renderWidgetHostView_->SupportsSpeech(); |
| + return is_render_view; |
| // For now, these actions are always enabled for render view, |
| // this is sub-optimal. |
| @@ -3340,7 +3315,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; |
| } |
| - (void)stopSpeaking:(id)sender { |
| - GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking(); |
| + ui::TextServicesContextMenu::StopSpeaking(); |
| } |
| - (void)cancelComposition { |