Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: ios/web/web_view_util.mm

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ios/web/web_state/blocked_popup_info.mm ('K') | « ios/web/web_view_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_view_util.mm
diff --git a/ios/web/web_view_util.mm b/ios/web/web_view_util.mm
index d983306338807f8e8f30a289cae46167c2924516..6807d5073f586580b9c8c3c2730d3b8898789bf6 100644
--- a/ios/web/web_view_util.mm
+++ b/ios/web/web_view_util.mm
@@ -4,33 +4,39 @@
#include "ios/web/web_view_util.h"
-#include "base/ios/ios_util.h"
-
-namespace {
+#include <Foundation/Foundation.h>
+#include <sys/sysctl.h>
-// If true, UIWebView is always used even if WKWebView is available.
-bool g_force_ui_web_view = false;
-
-} // namespace
+#include "base/ios/ios_util.h"
namespace web {
-bool IsWKWebViewEnabled() {
-#if defined(ENABLE_WKWEBVIEW)
- // Eventually this may be a dynamic flag, but for now it's purely a
- // compile-time option.
- return !g_force_ui_web_view && base::ios::IsRunningOnIOS8OrLater();
+bool IsWKWebViewSupported() {
+ // WKWebView is available starting from iOS8.
+ if (!base::ios::IsRunningOnIOS8OrLater())
+ return false;
+
+// WKWebView does not work with 32-bit binaries running on 64-bit hardware.
+// (rdar://18268087)
+#if !defined(__LP64__)
+ NSString* simulator_model_id =
+ [[NSProcessInfo processInfo] environment][@"SIMULATOR_MODEL_IDENTIFIER"];
+ // For simulator it's not possible to query hw.cpu64bit_capable value as the
+ // function will return information for mac hardware rather than simulator.
+ if (simulator_model_id) {
+ // A set of known 32-bit simulators that are also iOS 8 compatible.
+ // (taken from iOS 8.1 SDK simulators list).
+ NSSet* known_32_bit_devices = [NSSet
+ setWithArray:@[ @"iPad2,1", @"iPad3,1", @"iPhone4,1", @"iPhone5,1" ]];
+ return [known_32_bit_devices containsObject:simulator_model_id];
+ }
+ uint32_t cpu64bit_capable = 0;
+ size_t sizes = sizeof(cpu64bit_capable);
+ sysctlbyname("hw.cpu64bit_capable", &cpu64bit_capable, &sizes, NULL, 0);
+ return !cpu64bit_capable;
#else
- return false;
+ return true;
#endif
}
-void SetForceUIWebView(bool flag) {
- g_force_ui_web_view = flag;
-}
-
-bool GetForceUIWebView() {
- return g_force_ui_web_view;
-}
-
} // namespace web
« ios/web/web_state/blocked_popup_info.mm ('K') | « ios/web/web_view_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698