| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "ios/chrome/browser/ui/uikit_ui_util.h" | 5 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 6 | 6 |
| 7 #import <Accelerate/Accelerate.h> | 7 #import <Accelerate/Accelerate.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #import <QuartzCore/QuartzCore.h> | 9 #import <QuartzCore/QuartzCore.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 #import <UIKit/UIKit.h> | 12 #import <UIKit/UIKit.h> |
| 13 #include <cmath> | 13 #include <cmath> |
| 14 | 14 |
| 15 #include "base/ios/ios_util.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
| 17 #include "ios/chrome/browser/experimental_flags.h" | 18 #include "ios/chrome/browser/experimental_flags.h" |
| 18 #include "ios/chrome/browser/ui/rtl_geometry.h" | 19 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 19 #include "ios/chrome/browser/ui/ui_util.h" | 20 #include "ios/chrome/browser/ui/ui_util.h" |
| 20 #include "ios/web/public/web_thread.h" | 21 #include "ios/web/public/web_thread.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/gfx/ios/uikit_util.h" | 25 #include "ui/gfx/ios/uikit_util.h" |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 DCHECK(!gFirstResponder); | 654 DCHECK(!gFirstResponder); |
| 654 [[UIApplication sharedApplication] | 655 [[UIApplication sharedApplication] |
| 655 sendAction:@selector(cr_markSelfCurrentFirstResponder) | 656 sendAction:@selector(cr_markSelfCurrentFirstResponder) |
| 656 to:nil | 657 to:nil |
| 657 from:nil | 658 from:nil |
| 658 forEvent:nil]; | 659 forEvent:nil]; |
| 659 UIResponder* firstResponder = gFirstResponder; | 660 UIResponder* firstResponder = gFirstResponder; |
| 660 gFirstResponder = nil; | 661 gFirstResponder = nil; |
| 661 return firstResponder; | 662 return firstResponder; |
| 662 } | 663 } |
| 664 |
| 665 // On iOS10 and above, trigger a haptic vibration for the user selecting an |
| 666 // action. This is a no-op for devices that do not support it. |
| 667 void TriggerHapticFeedbackForAction() { |
| 668 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 669 UIImpactFeedbackGenerator* generator = |
| 670 [[UIImpactFeedbackGenerator alloc] init]; |
| 671 [generator impactOccurred]; |
| 672 } |
| 673 } |
| 674 |
| 675 // On iOS10 and above, trigger a haptic vibration for the change in selection. |
| 676 // This is a no-op for devices that do not support it. |
| 677 void TriggerHapticFeedbackForSelectionChange() { |
| 678 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 679 UISelectionFeedbackGenerator* generator = |
| 680 [[UISelectionFeedbackGenerator alloc] init]; |
| 681 [generator selectionChanged]; |
| 682 } |
| 683 } |
| OLD | NEW |