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
3 // found in the LICENSE file.
5 #include "base/ios/ios_util.h"
7 #import <Foundation/Foundation.h>
9 #include "base/sys_info.h"
12 // Return a 3 elements array containing the major, minor and bug fix version of
14 const int32* OSVersionAsArray() {
15 int32* digits = new int32[3];
16 base::SysInfo::OperatingSystemVersionNumbers(
17 &digits[0], &digits[1], &digits[2]);
25 // When dropping iOS7 support, also address issues listed in crbug.com/502968.
26 bool IsRunningOnIOS8OrLater() {
27 return IsRunningOnOrLater(8, 0, 0);
30 bool IsRunningOnIOS9OrLater() {
31 return IsRunningOnOrLater(9, 0, 0);
34 bool IsRunningOnOrLater(int32 major, int32 minor, int32 bug_fix) {
35 static const int32* current_version = OSVersionAsArray();
36 int32 version[] = { major, minor, bug_fix };
37 for (size_t i = 0; i < arraysize(version); i++) {
38 if (current_version[i] != version[i])
39 return current_version[i] > version[i];
44 bool IsInForcedRTL() {
45 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
46 return [defaults boolForKey:@"AppleTextDirection"];