OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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(); | |
Alexei Svitkine (slow)
2015/04/13 15:08:15
Do you need a null check on the return value befor
raymes
2015/04/14 00:37:03
Done.
| |
115 content::BrowserPluginGuestManager* guest_manager = | |
116 web_contents->GetBrowserContext()->GetGuestManager(); | |
Alexei Svitkine (slow)
2015/04/13 15:08:15
Also, perhaps a null check on this is needed too?
raymes
2015/04/14 00:37:03
Done.
| |
117 content::WebContents* guest = | |
118 guest_manager->GetFullPageGuest(web_contents); | |
119 if (!guest) | |
120 return render_widget_host_view; | |
121 return static_cast<RenderWidgetHostViewMac*>( | |
122 guest->GetRenderWidgetHostView()); | |
123 } | |
124 | |
110 } // namespace | 125 } // namespace |
111 | 126 |
112 // These are not documented, so use only after checking -respondsToSelector:. | 127 // These are not documented, so use only after checking -respondsToSelector:. |
113 @interface NSApplication (UndocumentedSpeechMethods) | 128 @interface NSApplication (UndocumentedSpeechMethods) |
114 - (void)speakString:(NSString*)string; | 129 - (void)speakString:(NSString*)string; |
115 - (void)stopSpeaking:(id)sender; | 130 - (void)stopSpeaking:(id)sender; |
116 - (BOOL)isSpeaking; | 131 - (BOOL)isSpeaking; |
117 @end | 132 @end |
118 | 133 |
119 // This method will return YES for OS X versions 10.7.3 and later, and NO | 134 // 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 Loading... | |
3276 // one of the Select methods on RWH. Since selectAll: is called from the | 3291 // one of the Select methods on RWH. Since selectAll: is called from the |
3277 // menu handler, neither is true. | 3292 // menu handler, neither is true. |
3278 // Explicitly call SelectAll() here to make sure the renderer returns | 3293 // Explicitly call SelectAll() here to make sure the renderer returns |
3279 // selection results. | 3294 // selection results. |
3280 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3295 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); |
3281 if (web_contents) | 3296 if (web_contents) |
3282 web_contents->SelectAll(); | 3297 web_contents->SelectAll(); |
3283 } | 3298 } |
3284 | 3299 |
3285 - (void)startSpeaking:(id)sender { | 3300 - (void)startSpeaking:(id)sender { |
3286 renderWidgetHostView_->SpeakSelection(); | 3301 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection(); |
3287 } | 3302 } |
3288 | 3303 |
3289 - (void)stopSpeaking:(id)sender { | 3304 - (void)stopSpeaking:(id)sender { |
3290 renderWidgetHostView_->StopSpeaking(); | 3305 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking(); |
3291 } | 3306 } |
3292 | 3307 |
3293 - (void)cancelComposition { | 3308 - (void)cancelComposition { |
3294 if (!hasMarkedText_) | 3309 if (!hasMarkedText_) |
3295 return; | 3310 return; |
3296 | 3311 |
3297 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] | 3312 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] |
3298 // doesn't call any NSTextInput functions, such as setMarkedText or | 3313 // 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 | 3314 // insertText. So, we need to send an IPC message to a renderer so it can |
3300 // delete the composition node. | 3315 // delete the composition node. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3451 | 3466 |
3452 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3467 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3453 // regions that are not draggable. (See ControlRegionView in | 3468 // regions that are not draggable. (See ControlRegionView in |
3454 // native_app_window_cocoa.mm). This requires the render host view to be | 3469 // native_app_window_cocoa.mm). This requires the render host view to be |
3455 // draggable by default. | 3470 // draggable by default. |
3456 - (BOOL)mouseDownCanMoveWindow { | 3471 - (BOOL)mouseDownCanMoveWindow { |
3457 return YES; | 3472 return YES; |
3458 } | 3473 } |
3459 | 3474 |
3460 @end | 3475 @end |
OLD | NEW |