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

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

Issue 374643002: Mac: Enable delegated renderer by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « content/browser/cocoa/system_hotkey_map.h ('k') | content/browser/cocoa/system_hotkey_map_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index 98a27483bef96e2c14ce01e59387583593b387be..0000000000000000000000000000000000000000
--- a/content/browser/cocoa/system_hotkey_map.mm
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "content/browser/cocoa/system_hotkey_map.h"
-
-#pragma mark - NSDictionary Helper Functions
-
-namespace {
-
-// All 4 following functions return nil if the object doesn't exist, or isn't of
-// the right class.
-id ObjectForKey(NSDictionary* dict, NSString* key, Class aClass) {
- id object = [dict objectForKey:key];
- if (![object isKindOfClass:aClass])
- return nil;
- return object;
-}
-
-NSDictionary* DictionaryForKey(NSDictionary* dict, NSString* key) {
- return ObjectForKey(dict, key, [NSDictionary class]);
-}
-
-NSArray* ArrayForKey(NSDictionary* dict, NSString* key) {
- return ObjectForKey(dict, key, [NSArray class]);
-}
-
-NSNumber* NumberForKey(NSDictionary* dict, NSString* key) {
- return ObjectForKey(dict, key, [NSNumber class]);
-}
-
-} // namespace
-
-#pragma mark - SystemHotkey
-
-namespace content {
-
-struct SystemHotkey {
- int key_code;
- int modifiers;
-};
-
-#pragma mark - SystemHotkeyMap
-
-SystemHotkeyMap::SystemHotkeyMap() {
-}
-SystemHotkeyMap::~SystemHotkeyMap() {
-}
-
-NSDictionary* SystemHotkeyMap::DictionaryFromData(NSData* data) {
- if (!data)
- return nil;
-
- NSError* error = nil;
- NSPropertyListFormat format;
- NSDictionary* dictionary =
- [NSPropertyListSerialization propertyListWithData:data
- options:0
- format:&format
- error:&error];
-
- if (![dictionary isKindOfClass:[NSDictionary class]])
- return nil;
-
- return dictionary;
-}
-
-bool SystemHotkeyMap::ParseDictionary(NSDictionary* dictionary) {
- system_hotkeys_.clear();
-
- if (!dictionary)
- return false;
-
- NSDictionary* hotkey_dictionaries =
- DictionaryForKey(dictionary, @"AppleSymbolicHotKeys");
- if (!hotkey_dictionaries)
- return false;
-
- for (NSString* hotkey_system_effect in [hotkey_dictionaries allKeys]) {
- if (![hotkey_system_effect isKindOfClass:[NSString class]])
- continue;
-
- NSDictionary* hotkey_dictionary =
- [hotkey_dictionaries objectForKey:hotkey_system_effect];
- if (![hotkey_dictionary isKindOfClass:[NSDictionary class]])
- continue;
-
- NSNumber* enabled = NumberForKey(hotkey_dictionary, @"enabled");
- if (!enabled || enabled.boolValue == NO)
- continue;
-
- NSDictionary* value = DictionaryForKey(hotkey_dictionary, @"value");
- if (!value)
- continue;
-
- NSArray* parameters = ArrayForKey(value, @"parameters");
- if (!parameters || [parameters count] != 3)
- continue;
-
- NSNumber* key_code = [parameters objectAtIndex:1];
- if (![key_code isKindOfClass:[NSNumber class]])
- continue;
-
- NSNumber* modifiers = [parameters objectAtIndex:2];
- if (![modifiers isKindOfClass:[NSNumber class]])
- continue;
-
- ReserveHotkey(key_code.intValue, modifiers.intValue, hotkey_system_effect);
- }
-
- return true;
-}
-
-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;
- }
- return false;
-}
-
-void SystemHotkeyMap::ReserveHotkey(int key_code,
- int modifiers,
- NSString* system_effect) {
- ReserveHotkey(key_code, modifiers);
-
- // If a hotkey exists for toggling through the windows of an application, then
- // adding shift to that hotkey toggles through the windows backwards.
- if ([system_effect isEqualToString:@"27"])
- ReserveHotkey(key_code, modifiers | NSShiftKeyMask);
-}
-
-void SystemHotkeyMap::ReserveHotkey(int key_code, int modifiers) {
- SystemHotkey hotkey;
- hotkey.key_code = key_code;
- hotkey.modifiers = modifiers;
- system_hotkeys_.push_back(hotkey);
-}
-
-} // namespace content
« no previous file with comments | « content/browser/cocoa/system_hotkey_map.h ('k') | content/browser/cocoa/system_hotkey_map_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698