1 // Copyright 2014 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.
5 #include "ios/web/web_view_util.h"
7 #include <Foundation/Foundation.h>
8 #include <sys/sysctl.h>
10 #include "base/ios/ios_util.h"
14 bool IsWKWebViewSupported() {
15 // WKWebView is available starting from iOS8.
16 if (!base::ios::IsRunningOnIOS8OrLater())
19 // WKWebView does not work with 32-bit binaries running on 64-bit hardware.
21 #if !defined(__LP64__)
22 NSString* simulator_model_id =
23 [[NSProcessInfo processInfo] environment][@"SIMULATOR_MODEL_IDENTIFIER"];
24 // For simulator it's not possible to query hw.cpu64bit_capable value as the
25 // function will return information for mac hardware rather than simulator.
26 if (simulator_model_id) {
27 // A set of known 32-bit simulators that are also iOS 8 compatible.
28 // (taken from iOS 8.1 SDK simulators list).
29 NSSet* known_32_bit_devices = [NSSet
30 setWithArray:@[ @"iPad2,1", @"iPad3,1", @"iPhone4,1", @"iPhone5,1" ]];
31 return [known_32_bit_devices containsObject:simulator_model_id];
33 uint32_t cpu64bit_capable = 0;
34 size_t sizes = sizeof(cpu64bit_capable);
35 sysctlbyname("hw.cpu64bit_capable", &cpu64bit_capable, &sizes, NULL, 0);
36 return !cpu64bit_capable;