| // Copyright 2020 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #import "ios/chrome/browser/ui/incognito_reauth/incognito_reauth_util.h" |
| |
| #import <LocalAuthentication/LocalAuthentication.h> |
| #include "ios/chrome/grit/ios_strings.h" |
| #include "ui/base/l10n/l10n_util.h" |
| |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| #error "This file requires ARC support." |
| #endif |
| |
| NSString* biometricAuthenticationTypeString() { |
| LAContext* ctx = [[LAContext alloc] init]; |
| // Call canEvaluatePolicy:error: once to populate biometrics type |
| NSError* error; |
| [ctx canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics |
| error:&error]; |
| if (error.code == LAErrorBiometryNotAvailable || |
| error.code == LAErrorBiometryNotEnrolled) { |
| return l10n_util::GetNSString(IDS_IOS_INCOGNITO_REAUTH_PASSCODE); |
| } |
| |
| switch (ctx.biometryType) { |
| case LABiometryTypeFaceID: |
| return @"Face ID"; |
| case LABiometryTypeTouchID: |
| return @"Touch ID"; |
| default: |
| return l10n_util::GetNSString(IDS_IOS_INCOGNITO_REAUTH_PASSCODE); |
| } |
| } |