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 5fd0b1b2e23be0b57cb740280dfa3cab11645c7b..3584e56531ee43f493d405edc418d53b06f9d48d 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -28,6 +28,8 @@ |
| #include "base/sys_info.h" |
| #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
| +#import "content/browser/cocoa/system_hotkey_helper_mac.h" |
| +#import "content/browser/cocoa/system_hotkey_map.h" |
| #include "content/browser/compositor/resize_lock.h" |
| #include "content/browser/frame_host/frame_tree.h" |
| #include "content/browser/frame_host/frame_tree_node.h" |
| @@ -96,6 +98,17 @@ using blink::WebMouseEvent; |
| using blink::WebMouseWheelEvent; |
| using blink::WebGestureEvent; |
| +namespace { |
| + |
| +// Whether a keyboard event has been reserved by OSX. |
| +BOOL EventIsReservedBySystem(NSEvent* event) { |
| + content::SystemHotkeyHelperMac* helper = |
| + content::SystemHotkeyHelperMac::GetInstance(); |
| + return helper->map()->IsEventReserved(event); |
| +} |
| + |
| +} // namespace |
| + |
| // These are not documented, so use only after checking -respondsToSelector:. |
| @interface NSApplication (UndocumentedSpeechMethods) |
| - (void)speakString:(NSString*)string; |
| @@ -2517,6 +2530,10 @@ void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { |
| if ([[self window] firstResponder] != self) |
| return NO; |
| + // If the event is reserved by the system, then do not pass it to web content. |
| + if (EventIsReservedBySystem(theEvent)) |
| + return NO; |
| + |
| // If we return |NO| from this function, cocoa will send the key event to |
| // the menu and only if the menu does not process the event to |keyDown:|. We |
| // want to send the event to a renderer _before_ sending it to the menu, so |
| @@ -2564,6 +2581,18 @@ void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { |
| - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv { |
| TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::keyEvent"); |
| + |
| + // If the user changes the system hotkey mapping after Chrome has been |
| + // launched, then it is possible that a formerly reserved system hotkey is no |
| + // longer reserved. The hotkey would have skipped the renderer, but would |
| + // also have not been handled by the system. If this is the case, immediately |
| + // return. |
| + // TODO(erikchen): SystemHotkeyHelperMac should use FS api to monitor changes |
|
Robert Sesek
2014/07/08 13:40:01
"FS api" ? Don't use abbreviations in comments.
erikchen
2014/07/10 02:07:32
Done.
|
| + // to system hotkeys. This logic will have to be updated. |
| + // http://crbug.com/383558. |
| + if (EventIsReservedBySystem(theEvent)) |
| + return; |
| + |
| DCHECK([theEvent type] != NSKeyDown || |
| !equiv == !([theEvent modifierFlags] & NSCommandKeyMask)); |