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

Unified Diff: base/ios/ios_util.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: Follow review. 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
« no previous file with comments | « base/ios/ios_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/ios/ios_util.mm
diff --git a/base/ios/ios_util.mm b/base/ios/ios_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..37f386dba8db6232715b32b982e898f66ee25372
--- /dev/null
+++ b/base/ios/ios_util.mm
@@ -0,0 +1,42 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/ios/ios_util.h"
+
+#include "base/sys_info.h"
+
+namespace {
+// Return a 3 elements array containing the major, minor and bug fix version of
+// the OS.
+const int32* OSVersionAsArray() {
+ int32* digits = new int32[3];
+ base::SysInfo::OperatingSystemVersionNumbers(
+ &digits[0], &digits[1], &digits[2]);
+ return digits;
+}
+} // namespace
+
+namespace base {
+namespace ios {
+
+bool IsRunningOnIOS5OrLater() {
+ return IsRunningOnOrLater(5, 0, 0);
+}
+
+bool IsRunningOnIOS6OrLater() {
+ return IsRunningOnOrLater(6, 0, 0);
+}
+
+bool IsRunningOnOrLater(int32 major, int32 minor, int32 bug_fix) {
+ static const int32* current_version = OSVersionAsArray();
+ int32 version[] = { major, minor, bug_fix };
+ for (size_t i = 0; i < arraysize(version); i++) {
+ if (current_version[i] != version[i])
+ return current_version[i] > version[i];
+ }
+ return true;
+}
+
+} // namespace ios
+} // namespace base
« no previous file with comments | « base/ios/ios_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698