Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/gesture_utils.h" | |
| 6 | |
| 7 #include "base/mac/mac_util.h" | |
| 8 | |
| 9 namespace gesture_utils { | |
| 10 | |
| 11 BOOL RecognizeTwoFingerGestures() { | |
| 12 // Lion or higher will have support for two-finger swipe gestures. | |
| 13 if (!base::mac::IsOSLionOrLater()) | |
| 14 return NO; | |
| 15 | |
| 16 // A note about preferences: | |
| 17 // On Lion System Preferences, the swipe gesture behavior is controlled by the | |
| 18 // setting in Trackpad --> More Gestures --> Swipe between pages. This setting | |
| 19 // has three values: | |
| 20 // A) Scroll left or right with two fingers. This should perform a cool | |
| 21 // scrolling animation, but doesn't yet <http://crbug.com/90228>. | |
| 22 // B) Swipe left or right with three fingers. | |
| 23 // C) Swipe with two or three fingers. | |
| 24 // | |
| 25 // The three-finger gesture is controlled by the integer preference | |
| 26 // |com.apple.trackpad.threeFingerHorizSwipeGesture|. Its value is 0 for (A) | |
| 27 // and 1 for (B, C). | |
| 28 // | |
| 29 // The two-finger gesture is controlled by the preference below and is boolean | |
| 30 // YES for (A, C) and NO for (B). | |
| 31 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | |
| 32 [defaults synchronize]; | |
| 33 | |
| 34 // By default, the preference is not set. When it's not, the intrinsic Lion | |
| 35 // default (YES) should be returned. | |
| 36 NSDictionary* prefs = [defaults dictionaryRepresentation]; | |
| 37 NSNumber* value = [prefs objectForKey:@"AppleEnableSwipeNavigateWithScrolls"]; | |
|
Mark Mentovai
2011/08/15 14:43:57
Buh-bye.
| |
| 38 if (!value) | |
| 39 return YES; | |
| 40 | |
| 41 // If the preference is set, return the value. | |
| 42 return [value boolValue]; | |
| 43 } | |
| 44 | |
| 45 // On Lion, returns YES if the scroll direction is "natural"/inverted. All other | |
| 46 // OSes will return NO. | |
| 47 BOOL IsScrollDirectionInverted() { | |
| 48 if (!base::mac::IsOSLionOrLater()) | |
| 49 return NO; | |
| 50 | |
| 51 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | |
| 52 [defaults synchronize]; | |
| 53 | |
| 54 // By default, the preference is not set. When it's not, the intrinsic Lion | |
| 55 // default (YES) should be returned. | |
| 56 NSDictionary* prefs = [defaults dictionaryRepresentation]; | |
| 57 NSNumber* value = [prefs objectForKey:@"com.apple.swipescrolldirection"]; | |
| 58 if (!value) | |
| 59 return YES; | |
| 60 | |
| 61 return [value boolValue]; | |
| 62 } | |
| 63 | |
| 64 } // namespace gesture_utils | |
| OLD | NEW |