Chromium Code Reviews| Index: ios/chrome/browser/ui/uikit_ui_util.mm |
| diff --git a/ios/chrome/browser/ui/uikit_ui_util.mm b/ios/chrome/browser/ui/uikit_ui_util.mm |
| index 381ffc198c98e5f63670977d94d4ca0e3c0caa78..957ed1e79ce618ff22521cf7f0afda61c020ce0f 100644 |
| --- a/ios/chrome/browser/ui/uikit_ui_util.mm |
| +++ b/ios/chrome/browser/ui/uikit_ui_util.mm |
| @@ -12,8 +12,10 @@ |
| #import <UIKit/UIKit.h> |
| #include <cmath> |
| +#include "base/ios/ios_util.h" |
| #include "base/logging.h" |
| #include "base/mac/foundation_util.h" |
| +#include "base/mac/scoped_nsobject.h" |
| #include "ios/chrome/browser/experimental_flags.h" |
| #include "ios/chrome/browser/ui/rtl_geometry.h" |
| #include "ios/chrome/browser/ui/ui_util.h" |
| @@ -660,3 +662,23 @@ UIResponder* GetFirstResponder() { |
| gFirstResponder = nil; |
| return firstResponder; |
| } |
| + |
| +// On iOS10 and above, trigger a haptic vibration for the user selecting an |
| +// action. This is a no-op for devices that do not support it. |
| +void TriggerHapticFeedbackForAction() { |
| + if (base::ios::IsRunningOnIOS10OrLater()) { |
| + base::scoped_nsobject<UIImpactFeedbackGenerator> generator( |
|
rohitrao (ping after 24h)
2017/02/23 16:15:54
This file is ARC, so you shouldn't need to use the
pink (ping after 24hrs)
2017/02/23 16:22:02
Done.
|
| + [[UIImpactFeedbackGenerator alloc] init]); |
| + [generator impactOccurred]; |
| + } |
| +} |
| + |
| +// On iOS10 and above, trigger a haptic vibration for the change in selection. |
| +// This is a no-op for devices that do not support it. |
| +void TriggerHapticFeedbackForSelectionChange() { |
| + if (base::ios::IsRunningOnIOS10OrLater()) { |
| + base::scoped_nsobject<UISelectionFeedbackGenerator> generator( |
| + [[UISelectionFeedbackGenerator alloc] init]); |
| + [generator selectionChanged]; |
| + } |
| +} |