| Index: content/browser/cocoa/system_hotkey_map.mm
|
| diff --git a/chrome/browser/ui/cocoa/system_hotkey_map.mm b/content/browser/cocoa/system_hotkey_map.mm
|
| similarity index 85%
|
| rename from chrome/browser/ui/cocoa/system_hotkey_map.mm
|
| rename to content/browser/cocoa/system_hotkey_map.mm
|
| index 9b649fbc729ca3745f81c1c926c0123543f566db..98a27483bef96e2c14ce01e59387583593b387be 100644
|
| --- a/chrome/browser/ui/cocoa/system_hotkey_map.mm
|
| +++ b/content/browser/cocoa/system_hotkey_map.mm
|
| @@ -2,9 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#import "chrome/browser/ui/cocoa/system_hotkey_map.h"
|
| -
|
| -#import <Cocoa/Cocoa.h>
|
| +#import "content/browser/cocoa/system_hotkey_map.h"
|
|
|
| #pragma mark - NSDictionary Helper Functions
|
|
|
| @@ -35,6 +33,8 @@ NSNumber* NumberForKey(NSDictionary* dict, NSString* key) {
|
|
|
| #pragma mark - SystemHotkey
|
|
|
| +namespace content {
|
| +
|
| struct SystemHotkey {
|
| int key_code;
|
| int modifiers;
|
| @@ -47,8 +47,9 @@ SystemHotkeyMap::SystemHotkeyMap() {
|
| SystemHotkeyMap::~SystemHotkeyMap() {
|
| }
|
|
|
| -bool SystemHotkeyMap::ParseData(NSData* data) {
|
| - system_hotkeys_.clear();
|
| +NSDictionary* SystemHotkeyMap::DictionaryFromData(NSData* data) {
|
| + if (!data)
|
| + return nil;
|
|
|
| NSError* error = nil;
|
| NSPropertyListFormat format;
|
| @@ -57,10 +58,17 @@ bool SystemHotkeyMap::ParseData(NSData* data) {
|
| options:0
|
| format:&format
|
| error:&error];
|
| - if (error)
|
| - return false;
|
|
|
| if (![dictionary isKindOfClass:[NSDictionary class]])
|
| + return nil;
|
| +
|
| + return dictionary;
|
| +}
|
| +
|
| +bool SystemHotkeyMap::ParseDictionary(NSDictionary* dictionary) {
|
| + system_hotkeys_.clear();
|
| +
|
| + if (!dictionary)
|
| return false;
|
|
|
| NSDictionary* hotkey_dictionaries =
|
| @@ -103,8 +111,14 @@ bool SystemHotkeyMap::ParseData(NSData* data) {
|
| return true;
|
| }
|
|
|
| -bool SystemHotkeyMap::IsHotkeyReserved(int key_code, int modifiers) {
|
| - std::vector<SystemHotkey>::iterator it;
|
| +bool SystemHotkeyMap::IsEventReserved(NSEvent* event) const {
|
| + NSUInteger modifiers =
|
| + NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask;
|
| + return IsHotkeyReserved(event.keyCode, event.modifierFlags & modifiers);
|
| +}
|
| +
|
| +bool SystemHotkeyMap::IsHotkeyReserved(int key_code, int 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)
|
| return true;
|
| @@ -129,3 +143,5 @@ void SystemHotkeyMap::ReserveHotkey(int key_code, int modifiers) {
|
| hotkey.modifiers = modifiers;
|
| system_hotkeys_.push_back(hotkey);
|
| }
|
| +
|
| +} // namespace content
|
|
|