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

Unified Diff: content/browser/cocoa/system_hotkey_map.mm

Issue 370293004: mac: Load the system hotkeys after launch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from rsesek by removing gcd. 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 side-by-side diff with in-line comments
Download patch
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 89%
rename from chrome/browser/ui/cocoa/system_hotkey_map.mm
rename to content/browser/cocoa/system_hotkey_map.mm
index 9b649fbc729ca3745f81c1c926c0123543f566db..4ec7d620c784129169c0f306141c55c487884d40 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;
@@ -50,6 +50,9 @@ SystemHotkeyMap::~SystemHotkeyMap() {
bool SystemHotkeyMap::ParseData(NSData* data) {
system_hotkeys_.clear();
+ if (!data)
+ return false;
+
NSError* error = nil;
NSPropertyListFormat format;
NSDictionary* dictionary =
@@ -103,8 +106,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 +138,5 @@ void SystemHotkeyMap::ReserveHotkey(int key_code, int modifiers) {
hotkey.modifiers = modifiers;
system_hotkeys_.push_back(hotkey);
}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698