| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "ios/web/web_view_util.h" | 5 #include "ios/web/web_view_util.h" |
| 6 | 6 |
| 7 #include <Foundation/Foundation.h> |
| 8 #include <sys/sysctl.h> |
| 9 |
| 7 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| 8 | 11 |
| 9 namespace { | |
| 10 | |
| 11 // If true, UIWebView is always used even if WKWebView is available. | |
| 12 bool g_force_ui_web_view = false; | |
| 13 | |
| 14 } // namespace | |
| 15 | |
| 16 namespace web { | 12 namespace web { |
| 17 | 13 |
| 18 bool IsWKWebViewEnabled() { | 14 bool IsWKWebViewSupported() { |
| 19 #if defined(ENABLE_WKWEBVIEW) | 15 // WKWebView is available starting from iOS8. |
| 20 // Eventually this may be a dynamic flag, but for now it's purely a | 16 if (!base::ios::IsRunningOnIOS8OrLater()) |
| 21 // compile-time option. | 17 return false; |
| 22 return !g_force_ui_web_view && base::ios::IsRunningOnIOS8OrLater(); | 18 |
| 19 // WKWebView does not work with 32-bit binaries running on 64-bit hardware. |
| 20 // (rdar://18268087) |
| 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]; |
| 32 } |
| 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; |
| 23 #else | 37 #else |
| 24 return false; | 38 return true; |
| 25 #endif | 39 #endif |
| 26 } | 40 } |
| 27 | 41 |
| 28 void SetForceUIWebView(bool flag) { | |
| 29 g_force_ui_web_view = flag; | |
| 30 } | |
| 31 | |
| 32 bool GetForceUIWebView() { | |
| 33 return g_force_ui_web_view; | |
| 34 } | |
| 35 | |
| 36 } // namespace web | 42 } // namespace web |
| OLD | NEW |