| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/gesture_utils.h" | 5 #import "chrome/browser/ui/cocoa/gesture_utils.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 | 8 |
| 9 namespace gesture_utils { | 9 namespace gesture_utils { |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // B) Swipe left or right with three fingers. | 22 // B) Swipe left or right with three fingers. |
| 23 // C) Swipe with two or three fingers. | 23 // C) Swipe with two or three fingers. |
| 24 // | 24 // |
| 25 // The three-finger gesture is controlled by the integer preference | 25 // The three-finger gesture is controlled by the integer preference |
| 26 // |com.apple.trackpad.threeFingerHorizSwipeGesture|. Its value is 0 for (A) | 26 // |com.apple.trackpad.threeFingerHorizSwipeGesture|. Its value is 0 for (A) |
| 27 // and 1 for (B, C). | 27 // and 1 for (B, C). |
| 28 // | 28 // |
| 29 // The two-finger gesture is controlled by the preference below and is boolean | 29 // The two-finger gesture is controlled by the preference below and is boolean |
| 30 // YES for (A, C) and NO for (B). | 30 // YES for (A, C) and NO for (B). |
| 31 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 31 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 32 return [defaults boolForKey:@"AppleEnableSwipeNavigateWithScrolls"]; | 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"]; |
| 38 if (!value) |
| 39 return YES; |
| 40 |
| 41 // If the preference is set, return the value. |
| 42 return [value boolValue]; |
| 33 } | 43 } |
| 34 | 44 |
| 35 // On Lion, returns YES if the scroll direction is "natural"/inverted. All other | 45 // On Lion, returns YES if the scroll direction is "natural"/inverted. All other |
| 36 // OSes will return NO. | 46 // OSes will return NO. |
| 37 BOOL IsScrollDirectionInverted() { | 47 BOOL IsScrollDirectionInverted() { |
| 38 if (!base::mac::IsOSLionOrLater()) | 48 if (!base::mac::IsOSLionOrLater()) |
| 39 return NO; | 49 return NO; |
| 40 | 50 |
| 41 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 51 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 42 // The defaults must be synchronized here otherwise a stale value will be | |
| 43 // returned for an indeterminate amount of time. For some reason, this is | |
| 44 // not necessary in |-recognizeTwoFingerGestures|. | |
| 45 [defaults synchronize]; | 52 [defaults synchronize]; |
| 46 return [defaults boolForKey:@"com.apple.swipescrolldirection"]; | 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]; |
| 47 } | 62 } |
| 48 | 63 |
| 49 } // namespace gesture_utils | 64 } // namespace gesture_utils |
| OLD | NEW |