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 return [defaults boolForKey:@"AppleEnableSwipeNavigateWithScrolls"]; |
| 33 } |
| 34 |
| 35 // On Lion, returns YES if the scroll direction is "natural"/inverted. All other |
| 36 // OSes will return NO. |
| 37 BOOL IsScrollDirectionInverted() { |
| 38 if (!base::mac::IsOSLionOrLater()) |
| 39 return NO; |
| 40 |
| 41 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 42 // The defaults must be synchronized here otherwise a stale value will be |
| 43 // returned for an indeterminante amount of time. For some reason, this is |
| 44 // not necessary in |-recognizeTwoFingerGestures|. |
| 45 [defaults synchronize]; |
| 46 return [defaults boolForKey:@"com.apple.swipescrolldirection"]; |
| 47 } |
| 48 |
| 49 } // namespace gesture_utils |
OLD | NEW |