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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1042743002: Make Edit>Speech>Speak Selection work for PDFs on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/metrics/histogram.h" 22 #include "base/metrics/histogram.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/strings/sys_string_conversions.h" 25 #include "base/strings/sys_string_conversions.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/sys_info.h" 27 #include "base/sys_info.h"
28 #include "base/trace_event/trace_event.h" 28 #include "base/trace_event/trace_event.h"
29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
31 #include "content/browser/bad_message.h" 31 #include "content/browser/bad_message.h"
32 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
33 #include "content/browser/browser_plugin/browser_plugin_guest.h"
32 #import "content/browser/cocoa/system_hotkey_helper_mac.h" 34 #import "content/browser/cocoa/system_hotkey_helper_mac.h"
33 #import "content/browser/cocoa/system_hotkey_map.h" 35 #import "content/browser/cocoa/system_hotkey_map.h"
34 #include "content/browser/compositor/resize_lock.h" 36 #include "content/browser/compositor/resize_lock.h"
35 #include "content/browser/frame_host/frame_tree.h" 37 #include "content/browser/frame_host/frame_tree.h"
36 #include "content/browser/frame_host/frame_tree_node.h" 38 #include "content/browser/frame_host/frame_tree_node.h"
37 #include "content/browser/frame_host/render_frame_host_impl.h" 39 #include "content/browser/frame_host/render_frame_host_impl.h"
38 #include "content/browser/gpu/compositor_util.h" 40 #include "content/browser/gpu/compositor_util.h"
39 #include "content/browser/renderer_host/render_view_host_impl.h" 41 #include "content/browser/renderer_host/render_view_host_impl.h"
40 #include "content/browser/renderer_host/render_widget_helper.h" 42 #include "content/browser/renderer_host/render_widget_helper.h"
41 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 43 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
42 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 44 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
43 #import "content/browser/renderer_host/text_input_client_mac.h" 45 #import "content/browser/renderer_host/text_input_client_mac.h"
46 #include "content/browser/web_contents/web_contents_impl.h"
44 #include "content/common/accessibility_messages.h" 47 #include "content/common/accessibility_messages.h"
45 #include "content/common/edit_command.h" 48 #include "content/common/edit_command.h"
46 #include "content/common/gpu/gpu_messages.h" 49 #include "content/common/gpu/gpu_messages.h"
47 #include "content/common/input_messages.h" 50 #include "content/common/input_messages.h"
48 #include "content/common/view_messages.h" 51 #include "content/common/view_messages.h"
49 #include "content/common/webplugin_geometry.h" 52 #include "content/common/webplugin_geometry.h"
50 #include "content/public/browser/browser_thread.h" 53 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/native_web_keyboard_event.h" 54 #include "content/public/browser/native_web_keyboard_event.h"
52 #include "content/public/browser/notification_service.h" 55 #include "content/public/browser/notification_service.h"
53 #include "content/public/browser/notification_types.h" 56 #include "content/public/browser/notification_types.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 using content::FrameTreeNode; 88 using content::FrameTreeNode;
86 using content::NativeWebKeyboardEvent; 89 using content::NativeWebKeyboardEvent;
87 using content::RenderFrameHost; 90 using content::RenderFrameHost;
88 using content::RenderViewHost; 91 using content::RenderViewHost;
89 using content::RenderViewHostImpl; 92 using content::RenderViewHostImpl;
90 using content::RenderWidgetHostImpl; 93 using content::RenderWidgetHostImpl;
91 using content::RenderWidgetHostViewMac; 94 using content::RenderWidgetHostViewMac;
92 using content::RenderWidgetHostViewMacEditCommandHelper; 95 using content::RenderWidgetHostViewMacEditCommandHelper;
93 using content::TextInputClientMac; 96 using content::TextInputClientMac;
94 using content::WebContents; 97 using content::WebContents;
98 using content::WebContentsImpl;
95 using blink::WebInputEvent; 99 using blink::WebInputEvent;
96 using blink::WebInputEventFactory; 100 using blink::WebInputEventFactory;
97 using blink::WebMouseEvent; 101 using blink::WebMouseEvent;
98 using blink::WebMouseWheelEvent; 102 using blink::WebMouseWheelEvent;
99 using blink::WebGestureEvent; 103 using blink::WebGestureEvent;
100 104
101 namespace { 105 namespace {
102 106
103 // Whether a keyboard event has been reserved by OSX. 107 // Whether a keyboard event has been reserved by OSX.
104 BOOL EventIsReservedBySystem(NSEvent* event) { 108 BOOL EventIsReservedBySystem(NSEvent* event) {
105 content::SystemHotkeyHelperMac* helper = 109 content::SystemHotkeyHelperMac* helper =
106 content::SystemHotkeyHelperMac::GetInstance(); 110 content::SystemHotkeyHelperMac::GetInstance();
107 return helper->map()->IsEventReserved(event); 111 return helper->map()->IsEventReserved(event);
108 } 112 }
109 113
114 RenderWidgetHostViewMac* GetRenderWidgetHostViewToUse(
115 RenderWidgetHostViewMac* render_widget_host_view) {
116 WebContentsImpl* contents =
117 static_cast<WebContentsImpl*>(render_widget_host_view->GetWebContents());
raymes 2015/03/30 23:02:03 Fady: WebContentsImpl* can't be referenced from he
Fady Samuel 2015/03/31 15:40:22 How about adding GetFullPageGuest(embedder) to Bro
118 content::BrowserPluginEmbedder* embedder =
119 contents->GetBrowserPluginEmbedder();
120 if (!embedder)
121 return render_widget_host_view;
122 content::BrowserPluginGuest* guest = embedder->GetFullPageGuest();
Fady Samuel 2015/03/31 15:40:22 How about adding GetFullPageGuest(embedder) to Bro
123 if (!guest)
124 return render_widget_host_view;
125 return static_cast<RenderWidgetHostViewMac*>(
126 guest->GetWebContents()->GetRenderWidgetHostView());
127 }
128
110 } // namespace 129 } // namespace
111 130
112 // These are not documented, so use only after checking -respondsToSelector:. 131 // These are not documented, so use only after checking -respondsToSelector:.
113 @interface NSApplication (UndocumentedSpeechMethods) 132 @interface NSApplication (UndocumentedSpeechMethods)
114 - (void)speakString:(NSString*)string; 133 - (void)speakString:(NSString*)string;
115 - (void)stopSpeaking:(id)sender; 134 - (void)stopSpeaking:(id)sender;
116 - (BOOL)isSpeaking; 135 - (BOOL)isSpeaking;
117 @end 136 @end
118 137
119 // This method will return YES for OS X versions 10.7.3 and later, and NO 138 // This method will return YES for OS X versions 10.7.3 and later, and NO
(...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3276 // one of the Select methods on RWH. Since selectAll: is called from the 3295 // one of the Select methods on RWH. Since selectAll: is called from the
3277 // menu handler, neither is true. 3296 // menu handler, neither is true.
3278 // Explicitly call SelectAll() here to make sure the renderer returns 3297 // Explicitly call SelectAll() here to make sure the renderer returns
3279 // selection results. 3298 // selection results.
3280 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); 3299 WebContents* web_contents = renderWidgetHostView_->GetWebContents();
3281 if (web_contents) 3300 if (web_contents)
3282 web_contents->SelectAll(); 3301 web_contents->SelectAll();
3283 } 3302 }
3284 3303
3285 - (void)startSpeaking:(id)sender { 3304 - (void)startSpeaking:(id)sender {
3286 renderWidgetHostView_->SpeakSelection(); 3305 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection();
3287 } 3306 }
3288 3307
3289 - (void)stopSpeaking:(id)sender { 3308 - (void)stopSpeaking:(id)sender {
3290 renderWidgetHostView_->StopSpeaking(); 3309 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking();
3291 } 3310 }
3292 3311
3293 - (void)cancelComposition { 3312 - (void)cancelComposition {
3294 if (!hasMarkedText_) 3313 if (!hasMarkedText_)
3295 return; 3314 return;
3296 3315
3297 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] 3316 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:]
3298 // doesn't call any NSTextInput functions, such as setMarkedText or 3317 // doesn't call any NSTextInput functions, such as setMarkedText or
3299 // insertText. So, we need to send an IPC message to a renderer so it can 3318 // insertText. So, we need to send an IPC message to a renderer so it can
3300 // delete the composition node. 3319 // delete the composition node.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 3470
3452 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3471 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3453 // regions that are not draggable. (See ControlRegionView in 3472 // regions that are not draggable. (See ControlRegionView in
3454 // native_app_window_cocoa.mm). This requires the render host view to be 3473 // native_app_window_cocoa.mm). This requires the render host view to be
3455 // draggable by default. 3474 // draggable by default.
3456 - (BOOL)mouseDownCanMoveWindow { 3475 - (BOOL)mouseDownCanMoveWindow {
3457 return YES; 3476 return YES;
3458 } 3477 }
3459 3478
3460 @end 3479 @end
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698