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

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 29 matching lines...) Expand all
40 #include "content/browser/renderer_host/render_widget_helper.h" 40 #include "content/browser/renderer_host/render_widget_helper.h"
41 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 41 #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" 42 #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" 43 #import "content/browser/renderer_host/text_input_client_mac.h"
44 #include "content/common/accessibility_messages.h" 44 #include "content/common/accessibility_messages.h"
45 #include "content/common/edit_command.h" 45 #include "content/common/edit_command.h"
46 #include "content/common/gpu/gpu_messages.h" 46 #include "content/common/gpu/gpu_messages.h"
47 #include "content/common/input_messages.h" 47 #include "content/common/input_messages.h"
48 #include "content/common/view_messages.h" 48 #include "content/common/view_messages.h"
49 #include "content/common/webplugin_geometry.h" 49 #include "content/common/webplugin_geometry.h"
50 #include "content/public/browser/browser_context.h"
51 #include "content/public/browser/browser_plugin_guest_manager.h"
50 #include "content/public/browser/browser_thread.h" 52 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/native_web_keyboard_event.h" 53 #include "content/public/browser/native_web_keyboard_event.h"
52 #include "content/public/browser/notification_service.h" 54 #include "content/public/browser/notification_service.h"
53 #include "content/public/browser/notification_types.h" 55 #include "content/public/browser/notification_types.h"
54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 56 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
55 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 57 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
56 #include "content/public/browser/web_contents.h" 58 #include "content/public/browser/web_contents.h"
57 #include "skia/ext/platform_canvas.h" 59 #include "skia/ext/platform_canvas.h"
58 #include "skia/ext/skia_utils_mac.h" 60 #include "skia/ext/skia_utils_mac.h"
59 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 61 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 102
101 namespace { 103 namespace {
102 104
103 // Whether a keyboard event has been reserved by OSX. 105 // Whether a keyboard event has been reserved by OSX.
104 BOOL EventIsReservedBySystem(NSEvent* event) { 106 BOOL EventIsReservedBySystem(NSEvent* event) {
105 content::SystemHotkeyHelperMac* helper = 107 content::SystemHotkeyHelperMac* helper =
106 content::SystemHotkeyHelperMac::GetInstance(); 108 content::SystemHotkeyHelperMac::GetInstance();
107 return helper->map()->IsEventReserved(event); 109 return helper->map()->IsEventReserved(event);
108 } 110 }
109 111
112 RenderWidgetHostViewMac* GetRenderWidgetHostViewToUse(
113 RenderWidgetHostViewMac* render_widget_host_view) {
114 WebContents* web_contents = render_widget_host_view->GetWebContents();
115 if (!web_contents)
116 return render_widget_host_view;
117 content::BrowserPluginGuestManager* guest_manager =
118 web_contents->GetBrowserContext()->GetGuestManager();
119 if (!guest_manager)
120 return render_widget_host_view;
121 content::WebContents* guest =
122 guest_manager->GetFullPageGuest(web_contents);
123 if (!guest)
124 return render_widget_host_view;
125 return static_cast<RenderWidgetHostViewMac*>(
126 guest->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 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 // one of the Select methods on RWH. Since selectAll: is called from the 3294 // one of the Select methods on RWH. Since selectAll: is called from the
3276 // menu handler, neither is true. 3295 // menu handler, neither is true.
3277 // Explicitly call SelectAll() here to make sure the renderer returns 3296 // Explicitly call SelectAll() here to make sure the renderer returns
3278 // selection results. 3297 // selection results.
3279 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); 3298 WebContents* web_contents = renderWidgetHostView_->GetWebContents();
3280 if (web_contents) 3299 if (web_contents)
3281 web_contents->SelectAll(); 3300 web_contents->SelectAll();
3282 } 3301 }
3283 3302
3284 - (void)startSpeaking:(id)sender { 3303 - (void)startSpeaking:(id)sender {
3285 renderWidgetHostView_->SpeakSelection(); 3304 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection();
3286 } 3305 }
3287 3306
3288 - (void)stopSpeaking:(id)sender { 3307 - (void)stopSpeaking:(id)sender {
3289 renderWidgetHostView_->StopSpeaking(); 3308 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking();
3290 } 3309 }
3291 3310
3292 - (void)cancelComposition { 3311 - (void)cancelComposition {
3293 if (!hasMarkedText_) 3312 if (!hasMarkedText_)
3294 return; 3313 return;
3295 3314
3296 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] 3315 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:]
3297 // doesn't call any NSTextInput functions, such as setMarkedText or 3316 // doesn't call any NSTextInput functions, such as setMarkedText or
3298 // insertText. So, we need to send an IPC message to a renderer so it can 3317 // insertText. So, we need to send an IPC message to a renderer so it can
3299 // delete the composition node. 3318 // delete the composition node.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 3469
3451 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3470 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3452 // regions that are not draggable. (See ControlRegionView in 3471 // regions that are not draggable. (See ControlRegionView in
3453 // native_app_window_cocoa.mm). This requires the render host view to be 3472 // native_app_window_cocoa.mm). This requires the render host view to be
3454 // draggable by default. 3473 // draggable by default.
3455 - (BOOL)mouseDownCanMoveWindow { 3474 - (BOOL)mouseDownCanMoveWindow {
3456 return YES; 3475 return YES;
3457 } 3476 }
3458 3477
3459 @end 3478 @end
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698