Chromium Code Reviews| 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" |
| 18 #include "base/mac/scoped_nsobject.h" | |
| 17 #include "ios/chrome/browser/experimental_flags.h" | 19 #include "ios/chrome/browser/experimental_flags.h" |
| 18 #include "ios/chrome/browser/ui/rtl_geometry.h" | 20 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 19 #include "ios/chrome/browser/ui/ui_util.h" | 21 #include "ios/chrome/browser/ui/ui_util.h" |
| 20 #include "ios/web/public/web_thread.h" | 22 #include "ios/web/public/web_thread.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/l10n/l10n_util_mac.h" | 24 #include "ui/base/l10n/l10n_util_mac.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/gfx/ios/uikit_util.h" | 26 #include "ui/gfx/ios/uikit_util.h" |
| 25 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" | 27 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" |
| 26 | 28 |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 DCHECK(!gFirstResponder); | 655 DCHECK(!gFirstResponder); |
| 654 [[UIApplication sharedApplication] | 656 [[UIApplication sharedApplication] |
| 655 sendAction:@selector(cr_markSelfCurrentFirstResponder) | 657 sendAction:@selector(cr_markSelfCurrentFirstResponder) |
| 656 to:nil | 658 to:nil |
| 657 from:nil | 659 from:nil |
| 658 forEvent:nil]; | 660 forEvent:nil]; |
| 659 UIResponder* firstResponder = gFirstResponder; | 661 UIResponder* firstResponder = gFirstResponder; |
| 660 gFirstResponder = nil; | 662 gFirstResponder = nil; |
| 661 return firstResponder; | 663 return firstResponder; |
| 662 } | 664 } |
| 665 | |
| 666 // On iOS10 and above, trigger a haptic vibration for the user selecting an | |
| 667 // action. This is a no-op for devices that do not support it. | |
| 668 void TriggerHapticFeedbackForAction() { | |
| 669 if (base::ios::IsRunningOnIOS10OrLater()) { | |
| 670 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.
| |
| 671 [[UIImpactFeedbackGenerator alloc] init]); | |
| 672 [generator impactOccurred]; | |
| 673 } | |
| 674 } | |
| 675 | |
| 676 // On iOS10 and above, trigger a haptic vibration for the change in selection. | |
| 677 // This is a no-op for devices that do not support it. | |
| 678 void TriggerHapticFeedbackForSelectionChange() { | |
| 679 if (base::ios::IsRunningOnIOS10OrLater()) { | |
| 680 base::scoped_nsobject<UISelectionFeedbackGenerator> generator( | |
| 681 [[UISelectionFeedbackGenerator alloc] init]); | |
| 682 [generator selectionChanged]; | |
| 683 } | |
| 684 } | |
| OLD | NEW |