Chromium Code Reviews| Index: content/browser/cocoa/system_hotkey_map.mm |
| diff --git a/content/browser/cocoa/system_hotkey_map.mm b/content/browser/cocoa/system_hotkey_map.mm |
| index da04fa8b8442c66fa5c47410c25adeb2190fd3df..93fc105be2531bd57f26f65f49d1e4477533da23 100644 |
| --- a/content/browser/cocoa/system_hotkey_map.mm |
| +++ b/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 { |
| @@ -33,6 +37,21 @@ NSString* StringForKey(NSDictionary* dict, NSString* key) { |
| return ObjectForKey(dict, key, [NSString class]); |
| } |
| +NSDictionary* kDefaultSymbolicHotKeys = @{ |
|
Avi (use Gerrit)
2016/04/01 20:03:56
Does using @{} at the top level cause static initi
chongz
2016/04/01 20:46:46
Done.
|
| + // Default Window switch key binding: Command + ` |
| + // Copied from local com.apple.symbolichotkeys.plist file since @"27" might |
| + // missing but should still be handled as reserved. |
| + // Note: The first parameter @96 is not used by |SystemHotkeyMap|. |
| + @"27" : @{ |
| + @"enabled" : @YES, |
| + @"value" : @{ |
| + @"type" : @"standard", |
| + @"parameters" : |
| + @[ @96 /* unused */, @(kVK_ANSI_Grave), @(NSCommandKeyMask) ], |
| + } |
| + } |
| +}; |
| + |
| } // namespace |
| #pragma mark - SystemHotkey |
| @@ -75,11 +94,21 @@ 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. 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( |
| + [kDefaultSymbolicHotKeys mutableCopy]); |
| + [hotkey_dictionaries addEntriesFromDictionary:user_hotkey_dictionaries]; |
|
Avi (use Gerrit)
2016/04/01 20:03:56
... or rather than having a "constant" global kDef
chongz
2016/04/01 20:46:46
Didn't find a way to initialize NSMutableDictionar
|
| + |
| for (NSString* hotkey_system_effect in [hotkey_dictionaries allKeys]) { |
| if (![hotkey_system_effect isKindOfClass:[NSString class]]) |
| continue; |