Chromium Code Reviews| 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..a39e0317f25560ef333647e52909f176848c7215 |
| --- /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() { |
| + static int32 digits[3]; |
|
Mark Mentovai
2012/10/05 15:03:51
For a single-use function whose return value is st
qsr
2012/10/05 15:33:16
Done.
|
| + base::SysInfo::OperatingSystemVersionNumbers( |
| + &digits[0], &digits[1], &digits[2]); |
| + return digits; |
| +} |
| +} |
|
Mark Mentovai
2012/10/05 15:03:51
} // namespace
qsr
2012/10/05 15:33:16
Done.
|
| + |
| +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[3] = { major, minor, bug_fix }; |
|
Mark Mentovai
2012/10/05 15:03:51
[3] not necessary.
qsr
2012/10/05 15:33:16
Done.
|
| + for (int i = 0; i < 3; i++) { |
|
Mark Mentovai
2012/10/05 15:03:51
Use arraysize instead of 3.
qsr
2012/10/05 15:33:16
Done.
|
| + if (current_version[i] != version[i]) |
| + return current_version[i] > version[i]; |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace ios |
| +} // namespace base |