diff options
Diffstat (limited to 'chromium/content/browser/cocoa')
3 files changed, 33 insertions, 7 deletions
diff --git a/chromium/content/browser/cocoa/system_hotkey_helper_mac.h b/chromium/content/browser/cocoa/system_hotkey_helper_mac.h index d8e0153fd63..004b2087c78 100644 --- a/chromium/content/browser/cocoa/system_hotkey_helper_mac.h +++ b/chromium/content/browser/cocoa/system_hotkey_helper_mac.h @@ -6,6 +6,7 @@ #define CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/memory/weak_ptr.h" diff --git a/chromium/content/browser/cocoa/system_hotkey_map.mm b/chromium/content/browser/cocoa/system_hotkey_map.mm index da04fa8b844..6ee40574420 100644 --- a/chromium/content/browser/cocoa/system_hotkey_map.mm +++ b/chromium/content/browser/cocoa/system_hotkey_map.mm @@ -4,6 +4,10 @@ #import "content/browser/cocoa/system_hotkey_map.h" +#import <Carbon/Carbon.h> + +#include "base/mac/scoped_nsobject.h" + #pragma mark - NSDictionary Helper Functions namespace { @@ -75,11 +79,32 @@ bool SystemHotkeyMap::ParseDictionary(NSDictionary* dictionary) { if (!dictionary) return false; - NSDictionary* hotkey_dictionaries = + NSDictionary* user_hotkey_dictionaries = DictionaryForKey(dictionary, @"AppleSymbolicHotKeys"); - if (!hotkey_dictionaries) + if (!user_hotkey_dictionaries) return false; + // Start with a dictionary of default OS X hotkeys that are not necessarily + // listed in com.apple.symbolichotkeys.plist, but should still be handled as + // reserved. + // If the user has overridden or disabled any of these hotkeys, + // -NSMutableDictionary addEntriesFromDictionary:] will ensure that the new + // values are used. + // See https://crbug.com/145062#c8 + base::scoped_nsobject<NSMutableDictionary> hotkey_dictionaries([@{ + // Default Window switch key binding: Command + ` + // Note: The first parameter @96 is not used by |SystemHotkeyMap|. + @"27" : @{ + @"enabled" : @YES, + @"value" : @{ + @"type" : @"standard", + @"parameters" : + @[ @96 /* unused */, @(kVK_ANSI_Grave), @(NSCommandKeyMask) ], + } + } + } mutableCopy]); + [hotkey_dictionaries addEntriesFromDictionary:user_hotkey_dictionaries]; + for (NSString* hotkey_system_effect in [hotkey_dictionaries allKeys]) { if (![hotkey_system_effect isKindOfClass:[NSString class]]) continue; diff --git a/chromium/content/browser/cocoa/system_hotkey_map_unittest.mm b/chromium/content/browser/cocoa/system_hotkey_map_unittest.mm index 37638d472ac..a0798bec241 100644 --- a/chromium/content/browser/cocoa/system_hotkey_map_unittest.mm +++ b/chromium/content/browser/cocoa/system_hotkey_map_unittest.mm @@ -134,13 +134,13 @@ TEST_F(SystemHotkeyMapTest, ParseMouse) { bool result = map.ParseDictionary(dictionary); EXPECT_TRUE(result); - // Command + ` is a common key binding. It is missing. - // TODO(erikchen): OSX uses the default value when the keybinding is missing, - // so the hotkey should still be reserved. - // http://crbug.com/383558 + // Command + ` is a common key binding. It is missing, but since OS X uses the + // default value the hotkey should still be reserved. + // https://crbug.com/383558 + // https://crbug.com/145062 unsigned short key_code = kVK_ANSI_Grave; NSUInteger modifiers = NSCommandKeyMask; - EXPECT_FALSE(map.IsHotkeyReserved(key_code, modifiers)); + EXPECT_TRUE(map.IsHotkeyReserved(key_code, modifiers)); // There is a mouse keybinding for 0x08. It should not apply to keyboard // hotkeys. |