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

Unified Diff: base/sys_info_ios.mm

Issue 11031066: Adding utility method to test the version of the OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile issue Created 8 years, 2 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
« base/sys_info.h ('K') | « base/sys_info.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_ios.mm
diff --git a/base/sys_info_ios.mm b/base/sys_info_ios.mm
index 8b1ffd4521192f0f9db7e9c2b3b6621a4e6d1838..8b25ef5c631eb6d0dd4d4ff00548aacf7d216c00 100644
--- a/base/sys_info_ios.mm
+++ b/base/sys_info_ios.mm
@@ -76,4 +76,36 @@ std::string SysInfo::CPUModelName() {
return std::string();
}
+// static
+bool SysInfo::IsRunningOnIOS5OrLater() {
+ return IsRunningOnOrLater(5, 0, 0);
+}
+
+// static
+bool SysInfo::IsRunningOnIOS6OrLater() {
+ return IsRunningOnOrLater(6, 0, 0);
+}
+
+// static
+bool SysInfo::IsRunningOnOrLater(int major, int minor, int bugFix) {
+ static int32 digits[3] = { 0, 0, 0 };
Mark Mentovai 2012/10/05 12:49:05 You know how I feel about these. I’d prefer to jus
qsr 2012/10/05 14:53:56 Done.
+ if (digits[0] == 0) {
+ OperatingSystemVersionNumbers(&digits[0], &digits[1], &digits[2]);
Mark Mentovai 2012/10/05 12:49:05 mac_util uses uname for its runtime OS version che
qsr 2012/10/05 14:53:56 On iOS, we are calling: [[UIDevice currentDevice]
+ }
+ if (digits[0] < major)
Mark Mentovai 2012/10/05 12:49:05 Seems like this could be written as a loop. Or wou
qsr 2012/10/05 14:53:56 I'll do a loop. Version is working on string. I do
+ return NO;
+ if (digits[0] > major)
+ return YES;
+ // digits[0] == major
+ if (digits[1] < minor)
+ return NO;
+ if (digits[1] > minor)
+ return YES;
+ // digits[1] == minor
+ if (digits[2] < bugFix)
+ return NO;
+ // digits[2] >= bugFix
+ return YES;
+}
+
} // namespace base
« base/sys_info.h ('K') | « base/sys_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698