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

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

Issue 370293004: mac: Load the system hotkeys after launch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Histograms and dchecks. Created 6 years, 5 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 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 } 2510 }
2511 2511
2512 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { 2512 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
2513 // |performKeyEquivalent:| is sent to all views of a window, not only down the 2513 // |performKeyEquivalent:| is sent to all views of a window, not only down the
2514 // responder chain (cf. "Handling Key Equivalents" in 2514 // responder chain (cf. "Handling Key Equivalents" in
2515 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html 2515 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html
2516 // ). We only want to handle key equivalents if we're first responder. 2516 // ). We only want to handle key equivalents if we're first responder.
2517 if ([[self window] firstResponder] != self) 2517 if ([[self window] firstResponder] != self)
2518 return NO; 2518 return NO;
2519 2519
2520 // If the event is reserved by the system, then do not pass it to web content.
2521 if ([responderDelegate_ eventIsReservedBySystem:theEvent])
2522 return NO;
2523
2520 // If we return |NO| from this function, cocoa will send the key event to 2524 // If we return |NO| from this function, cocoa will send the key event to
2521 // the menu and only if the menu does not process the event to |keyDown:|. We 2525 // the menu and only if the menu does not process the event to |keyDown:|. We
2522 // want to send the event to a renderer _before_ sending it to the menu, so 2526 // want to send the event to a renderer _before_ sending it to the menu, so
2523 // we need to return |YES| for all events that might be swallowed by the menu. 2527 // we need to return |YES| for all events that might be swallowed by the menu.
2524 // We do not return |YES| for every keypress because we don't get |keyDown:| 2528 // We do not return |YES| for every keypress because we don't get |keyDown:|
2525 // events for keys that we handle this way. 2529 // events for keys that we handle this way.
2526 NSUInteger modifierFlags = [theEvent modifierFlags]; 2530 NSUInteger modifierFlags = [theEvent modifierFlags];
2527 if ((modifierFlags & NSCommandKeyMask) == 0) { 2531 if ((modifierFlags & NSCommandKeyMask) == 0) {
2528 // Make sure the menu does not contain key equivalents that don't 2532 // Make sure the menu does not contain key equivalents that don't
2529 // contain cmd. 2533 // contain cmd.
(...skipping 27 matching lines...) Expand all
2557 if (handled) 2561 if (handled)
2558 return kEventHandled; 2562 return kEventHandled;
2559 } 2563 }
2560 2564
2561 [self keyEvent:theEvent wasKeyEquivalent:NO]; 2565 [self keyEvent:theEvent wasKeyEquivalent:NO];
2562 return kEventHandled; 2566 return kEventHandled;
2563 } 2567 }
2564 2568
2565 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv { 2569 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
2566 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::keyEvent"); 2570 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::keyEvent");
2571
2572 // If the user changes the system hotkey mapping after Chrome has been
2573 // launched, then it is possible that a formerly reserved system hotkey is no
2574 // longer reserved. The hotkey would have skipped the renderer, but would
2575 // also have not been handled by the system. If this is the case, immediately
2576 // return.
2577 // TODO(erikchen): SystemHotkeyHelperMac should use FS api to monitor changes
2578 // to system hotkeys. This logic will have to be updated.
2579 // http://crbug.com/383558.
2580 if ([responderDelegate_ eventIsReservedBySystem:theEvent])
2581 return;
2582
2567 DCHECK([theEvent type] != NSKeyDown || 2583 DCHECK([theEvent type] != NSKeyDown ||
2568 !equiv == !([theEvent modifierFlags] & NSCommandKeyMask)); 2584 !equiv == !([theEvent modifierFlags] & NSCommandKeyMask));
2569 2585
2570 if ([theEvent type] == NSFlagsChanged) { 2586 if ([theEvent type] == NSFlagsChanged) {
2571 // Ignore NSFlagsChanged events from the NumLock and Fn keys as 2587 // Ignore NSFlagsChanged events from the NumLock and Fn keys as
2572 // Safari does in -[WebHTMLView flagsChanged:] (of "WebHTMLView.mm"). 2588 // Safari does in -[WebHTMLView flagsChanged:] (of "WebHTMLView.mm").
2573 int keyCode = [theEvent keyCode]; 2589 int keyCode = [theEvent keyCode];
2574 if (!keyCode || keyCode == 10 || keyCode == 63) 2590 if (!keyCode || keyCode == 10 || keyCode == 63)
2575 return; 2591 return;
2576 } 2592 }
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3950 3966
3951 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3967 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3952 // regions that are not draggable. (See ControlRegionView in 3968 // regions that are not draggable. (See ControlRegionView in
3953 // native_app_window_cocoa.mm). This requires the render host view to be 3969 // native_app_window_cocoa.mm). This requires the render host view to be
3954 // draggable by default. 3970 // draggable by default.
3955 - (BOOL)mouseDownCanMoveWindow { 3971 - (BOOL)mouseDownCanMoveWindow {
3956 return YES; 3972 return YES;
3957 } 3973 }
3958 3974
3959 @end 3975 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698