| 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 98a27483bef96e2c14ce01e59387583593b387be..a64ee361fbbb42cbad4ef05f28ac7d2b907ce19a 100644
|
| --- a/content/browser/cocoa/system_hotkey_map.mm
|
| +++ b/content/browser/cocoa/system_hotkey_map.mm
|
| @@ -29,6 +29,10 @@ NSNumber* NumberForKey(NSDictionary* dict, NSString* key) {
|
| return ObjectForKey(dict, key, [NSNumber class]);
|
| }
|
|
|
| +NSString* StringForKey(NSDictionary* dict, NSString* key) {
|
| + return ObjectForKey(dict, key, [NSString class]);
|
| +}
|
| +
|
| } // namespace
|
|
|
| #pragma mark - SystemHotkey
|
| @@ -36,8 +40,8 @@ NSNumber* NumberForKey(NSDictionary* dict, NSString* key) {
|
| namespace content {
|
|
|
| struct SystemHotkey {
|
| - int key_code;
|
| - int modifiers;
|
| + unsigned short key_code;
|
| + NSUInteger modifiers;
|
| };
|
|
|
| #pragma mark - SystemHotkeyMap
|
| @@ -93,6 +97,10 @@ bool SystemHotkeyMap::ParseDictionary(NSDictionary* dictionary) {
|
| if (!value)
|
| continue;
|
|
|
| + NSString* type = StringForKey(value, @"type");
|
| + if (!type || ![type isEqualToString:@"standard"])
|
| + continue;
|
| +
|
| NSArray* parameters = ArrayForKey(value, @"parameters");
|
| if (!parameters || [parameters count] != 3)
|
| continue;
|
| @@ -105,7 +113,9 @@ bool SystemHotkeyMap::ParseDictionary(NSDictionary* dictionary) {
|
| if (![modifiers isKindOfClass:[NSNumber class]])
|
| continue;
|
|
|
| - ReserveHotkey(key_code.intValue, modifiers.intValue, hotkey_system_effect);
|
| + ReserveHotkey(key_code.unsignedShortValue,
|
| + modifiers.unsignedIntegerValue,
|
| + hotkey_system_effect);
|
| }
|
|
|
| return true;
|
| @@ -117,7 +127,8 @@ bool SystemHotkeyMap::IsEventReserved(NSEvent* event) const {
|
| return IsHotkeyReserved(event.keyCode, event.modifierFlags & modifiers);
|
| }
|
|
|
| -bool SystemHotkeyMap::IsHotkeyReserved(int key_code, int modifiers) const {
|
| +bool SystemHotkeyMap::IsHotkeyReserved(unsigned short key_code,
|
| + NSUInteger modifiers) const {
|
| std::vector<SystemHotkey>::const_iterator it;
|
| for (it = system_hotkeys_.begin(); it != system_hotkeys_.end(); ++it) {
|
| if (it->key_code == key_code && it->modifiers == modifiers)
|
| @@ -126,8 +137,8 @@ bool SystemHotkeyMap::IsHotkeyReserved(int key_code, int modifiers) const {
|
| return false;
|
| }
|
|
|
| -void SystemHotkeyMap::ReserveHotkey(int key_code,
|
| - int modifiers,
|
| +void SystemHotkeyMap::ReserveHotkey(unsigned short key_code,
|
| + NSUInteger modifiers,
|
| NSString* system_effect) {
|
| ReserveHotkey(key_code, modifiers);
|
|
|
| @@ -137,7 +148,15 @@ void SystemHotkeyMap::ReserveHotkey(int key_code,
|
| ReserveHotkey(key_code, modifiers | NSShiftKeyMask);
|
| }
|
|
|
| -void SystemHotkeyMap::ReserveHotkey(int key_code, int modifiers) {
|
| +void SystemHotkeyMap::ReserveHotkey(unsigned short key_code,
|
| + NSUInteger modifiers) {
|
| + // Hotkeys require at least one of control, command, or alternate keys to be
|
| + // down.
|
| + NSUInteger required_modifiers =
|
| + NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask;
|
| + if ((modifiers & required_modifiers) == 0)
|
| + return;
|
| +
|
| SystemHotkey hotkey;
|
| hotkey.key_code = key_code;
|
| hotkey.modifiers = modifiers;
|
|
|