summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/mac/mac_util.h49
-rw-r--r--base/mac/mac_util.mm126
-rw-r--r--base/mac/mac_util_unittest.mm43
-rw-r--r--base/process_util_mac.mm53
-rw-r--r--base/sys_info.h5
-rw-r--r--chrome/browser/bug_report_util.cc6
-rw-r--r--chrome/browser/process_info_snapshot_mac.cc8
-rw-r--r--chrome/browser/ui/cocoa/objc_zombie.mm16
-rw-r--r--chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.mm12
-rw-r--r--content/browser/renderer_host/backing_store_mac.mm19
-rw-r--r--content/common/sandbox_mac.mm23
-rw-r--r--content/renderer/renderer_main.cc17
-rw-r--r--content/renderer/webplugin_delegate_proxy.cc14
-rw-r--r--media/audio/mac/audio_manager_mac.cc6
-rw-r--r--printing/pdf_metafile_cg_mac.cc16
-rw-r--r--third_party/apple_apsl/CFBase.h4
-rw-r--r--third_party/apple_apsl/README.chromium4
-rw-r--r--ui/base/resource/resource_bundle_mac.mm10
-rw-r--r--webkit/plugins/npapi/plugin_host.cc11
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl.h3
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_mac.mm18
21 files changed, 288 insertions, 175 deletions
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h
index 808716c..eed516e 100644
--- a/base/mac/mac_util.h
+++ b/base/mac/mac_util.h
@@ -6,6 +6,7 @@
#define BASE_MAC_MAC_UTIL_H_
#pragma once
+#include <AvailabilityMacros.h>
#include <Carbon/Carbon.h>
#include <string>
@@ -110,6 +111,54 @@ void RemoveFromLoginItems();
// 'Login Item' with 'hide on startup' flag. Used to suppress opening windows.
bool WasLaunchedAsHiddenLoginItem();
+// Run-time OS version checks. Use these instead of
+// base::SysInfo::OperatingSystemVersionNumbers. Prefer the "OrEarlier" and
+// "OrLater" variants to those that check for a specific version, unless you
+// know for sure that you need to check for a specific version.
+
+// Leopard is Mac OS X 10.5, Darwin 9.
+bool IsOSLeopard();
+bool IsOSLeopardOrEarlier();
+
+// Snow Leopard is Mac OS X 10.6, Darwin 10.
+bool IsOSSnowLeopard();
+bool IsOSSnowLeopardOrEarlier();
+bool IsOSSnowLeopardOrLater();
+
+// Lion is Mac OS X 10.7, Darwin 11.
+bool IsOSLion();
+bool IsOSLionOrLater();
+
+// This should be infrequently used. It only makes sense to use this to avoid
+// codepaths that are very likely to break on future (unreleased, untested,
+// unborn) OS releases.
+bool IsOSLaterThanLion();
+
+// When the deployment target is set, the code produced cannot run on earlier
+// OS releases. That enables some of the IsOS* family to be implemented as
+// constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro
+// contains the value of the deployment target.
+
+#if defined(MAC_OS_X_VERSION_10_6) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6
+inline bool IsOSLeopardOrEarlier() { return false; }
+inline bool IsOSSnowLeopardOrLater() { return true; }
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_7) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
+#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7
+inline bool IsOSSnowLeopardOrEarlier() { return false; }
+inline bool IsOSLionOrLater() { return true; }
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_7) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7
+#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7
+inline bool IsOSLaterThanLion() { return true; }
+#endif
+
} // namespace mac
} // namespace base
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index 16b3341..5a8cb4e 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -5,12 +5,15 @@
#include "base/mac/mac_util.h"
#import <Cocoa/Cocoa.h>
+#include <string.h>
+#include <sys/utsname.h>
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
+#include "base/string_number_conversions.h"
#include "base/sys_string_conversions.h"
namespace base {
@@ -463,5 +466,128 @@ bool WasLaunchedAsHiddenLoginItem() {
return IsHiddenLoginItem(item);
}
+namespace {
+
+// Returns the running system's Darwin major version. Don't call this, it's
+// an implementation detail and its result is meant to be cached by
+// MacOSXMinorVersion.
+int DarwinMajorVersionInternal() {
+ // base::OperatingSystemVersionNumbers calls Gestalt, which is a
+ // higher-level operation than is needed. It might perform unnecessary
+ // operations. On 10.6, it was observed to be able to spawn threads (see
+ // http://crbug.com/53200). It might also read files or perform other
+ // blocking operations. Actually, nobody really knows for sure just what
+ // Gestalt might do, or what it might be taught to do in the future.
+ //
+ // uname, on the other hand, is implemented as a simple series of sysctl
+ // system calls to obtain the relevant data from the kernel. The data is
+ // compiled right into the kernel, so no threads or blocking or other
+ // funny business is necessary.
+
+ struct utsname uname_info;
+ if (uname(&uname_info) != 0) {
+ PLOG(ERROR) << "uname";
+ return 0;
+ }
+
+ if (strcmp(uname_info.sysname, "Darwin") != 0) {
+ LOG(ERROR) << "unexpected uname sysname " << uname_info.sysname;
+ return 0;
+ }
+
+ int darwin_major_version = 0;
+ char* dot = strchr(uname_info.release, '.');
+ if (dot) {
+ if (!base::StringToInt(uname_info.release, dot, &darwin_major_version)) {
+ dot = NULL;
+ }
+ }
+
+ if (!dot) {
+ LOG(ERROR) << "could not parse uname release " << uname_info.release;
+ return 0;
+ }
+
+ return darwin_major_version;
+}
+
+// Returns the running system's Mac OS X minor version. This is the |y| value
+// in 10.y or 10.y.z. Don't call this, it's an implementation detail and the
+// result is meant to be cached by MacOSXMinorVersion.
+int MacOSXMinorVersionInternal() {
+ int darwin_major_version = DarwinMajorVersionInternal();
+
+ // The Darwin major version is always 4 greater than the Mac OS X minor
+ // version for Darwin versions beginning with 6, corresponding to Mac OS X
+ // 10.2. Since this correspondence may change in the future, warn when
+ // encountering a version higher than anything seen before. Older Darwin
+ // versions, or versions that can't be determined, result in
+ // immediate death.
+ CHECK(darwin_major_version >= 6);
+ int mac_os_x_minor_version = darwin_major_version - 4;
+ LOG_IF(WARNING, darwin_major_version > 11) << "Assuming Darwin "
+ << base::IntToString(darwin_major_version) << " is Mac OS X 10."
+ << base::IntToString(mac_os_x_minor_version);
+
+ return mac_os_x_minor_version;
+}
+
+// Returns the running system's Mac OS X minor version. This is the |y| value
+// in 10.y or 10.y.z.
+int MacOSXMinorVersion() {
+ static int mac_os_x_minor_version = MacOSXMinorVersionInternal();
+ return mac_os_x_minor_version;
+}
+
+enum {
+ LEOPARD_MINOR_VERSION = 5,
+ SNOW_LEOPARD_MINOR_VERSION = 6,
+ LION_MINOR_VERSION = 7
+};
+
+} // namespace
+
+bool IsOSLeopard() {
+ return MacOSXMinorVersion() == LEOPARD_MINOR_VERSION;
+}
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6)
+bool IsOSLeopardOrEarlier() {
+ return MacOSXMinorVersion() <= LEOPARD_MINOR_VERSION;
+}
+#endif
+
+bool IsOSSnowLeopard() {
+ return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION;
+}
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
+bool IsOSSnowLeopardOrEarlier() {
+ return MacOSXMinorVersion() <= SNOW_LEOPARD_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6)
+bool IsOSSnowLeopardOrLater() {
+ return MacOSXMinorVersion() >= SNOW_LEOPARD_MINOR_VERSION;
+}
+#endif
+
+bool IsOSLion() {
+ return MacOSXMinorVersion() == LION_MINOR_VERSION;
+}
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
+bool IsOSLionOrLater() {
+ return MacOSXMinorVersion() >= LION_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
+bool IsOSLaterThanLion() {
+ return MacOSXMinorVersion() > LION_MINOR_VERSION;
+}
+#endif
+
} // namespace mac
} // namespace base
diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm
index 92a6001..dd860a6 100644
--- a/base/mac/mac_util_unittest.mm
+++ b/base/mac/mac_util_unittest.mm
@@ -12,6 +12,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
#include "base/scoped_temp_dir.h"
+#include "base/sys_info.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -160,6 +161,48 @@ TEST_F(MacUtilTest, NSObjectRetainRelease) {
EXPECT_EQ(1U, [array retainCount]);
}
+TEST_F(MacUtilTest, IsOSEllipsis) {
+ int32 major, minor, bugfix;
+ base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
+
+ if (major == 10) {
+ if (minor == 5) {
+ EXPECT_TRUE(IsOSLeopard());
+ EXPECT_TRUE(IsOSLeopardOrEarlier());
+ EXPECT_FALSE(IsOSSnowLeopard());
+ EXPECT_TRUE(IsOSSnowLeopardOrEarlier());
+ EXPECT_FALSE(IsOSSnowLeopardOrLater());
+ EXPECT_FALSE(IsOSLion());
+ EXPECT_FALSE(IsOSLionOrLater());
+ EXPECT_FALSE(IsOSLaterThanLion());
+ } else if (minor == 6) {
+ EXPECT_FALSE(IsOSLeopard());
+ EXPECT_FALSE(IsOSLeopardOrEarlier());
+ EXPECT_TRUE(IsOSSnowLeopard());
+ EXPECT_TRUE(IsOSSnowLeopardOrEarlier());
+ EXPECT_TRUE(IsOSSnowLeopardOrLater());
+ EXPECT_FALSE(IsOSLion());
+ EXPECT_FALSE(IsOSLionOrLater());
+ EXPECT_FALSE(IsOSLaterThanLion());
+ } else if (minor == 7) {
+ EXPECT_FALSE(IsOSLeopard());
+ EXPECT_FALSE(IsOSLeopardOrEarlier());
+ EXPECT_FALSE(IsOSSnowLeopard());
+ EXPECT_FALSE(IsOSSnowLeopardOrEarlier());
+ EXPECT_TRUE(IsOSSnowLeopardOrLater());
+ EXPECT_TRUE(IsOSLion());
+ EXPECT_TRUE(IsOSLionOrLater());
+ EXPECT_FALSE(IsOSLaterThanLion());
+ } else {
+ // Not five, six, or seven. Ah, ah, ah.
+ EXPECT_TRUE(false);
+ }
+ } else {
+ // Not ten. What you gonna do?
+ EXPECT_FALSE(true);
+ }
+}
+
} // namespace
} // namespace mac
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm
index 5c81b2a..6e49d2c 100644
--- a/base/process_util_mac.mm
+++ b/base/process_util_mac.mm
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#include "base/process_util.h"
#import <Cocoa/Cocoa.h>
@@ -19,7 +18,6 @@
#include <sys/mman.h>
#include <sys/sysctl.h>
#include <sys/types.h>
-#include <sys/utsname.h>
#include <sys/wait.h>
#include <new>
@@ -29,6 +27,7 @@
#include "base/eintr_wrapper.h"
#include "base/hash_tables.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/string_util.h"
#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
@@ -622,28 +621,25 @@ void oom_killer_new() {
// === Core Foundation CFAllocators ===
-bool CanGetContextForCFAllocator(long darwin_version) {
+bool CanGetContextForCFAllocator() {
// TODO(avi): remove at final release; http://crbug.com/74589
- if (darwin_version == 11) {
+ if (base::mac::IsOSLion()) {
NSLog(@"Unsure about the internals of CFAllocator but going to patch them "
"anyway. Watch out for crashes inside of CFAllocatorAllocate.");
}
- return darwin_version == 9 ||
- darwin_version == 10 ||
- darwin_version == 11;
+ return !base::mac::IsOSLaterThanLion();
}
-CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator,
- long darwin_version) {
- if (darwin_version == 9 || darwin_version == 10) {
- ChromeCFAllocator9and10* our_allocator =
- const_cast<ChromeCFAllocator9and10*>(
- reinterpret_cast<const ChromeCFAllocator9and10*>(allocator));
+CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
+ if (base::mac::IsOSLeopard() || base::mac::IsOSSnowLeopard()) {
+ ChromeCFAllocatorLeopards* our_allocator =
+ const_cast<ChromeCFAllocatorLeopards*>(
+ reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator));
return &our_allocator->_context;
- } else if (darwin_version == 11) {
- ChromeCFAllocator11* our_allocator =
- const_cast<ChromeCFAllocator11*>(
- reinterpret_cast<const ChromeCFAllocator11*>(allocator));
+ } else if (base::mac::IsOSLion()) {
+ ChromeCFAllocatorLion* our_allocator =
+ const_cast<ChromeCFAllocatorLion*>(
+ reinterpret_cast<const ChromeCFAllocatorLion*>(allocator));
return &our_allocator->_context;
} else {
return NULL;
@@ -714,18 +710,6 @@ void EnableTerminationOnOutOfMemory() {
g_oom_killer_enabled = true;
- // Not SysInfo::OperatingSystemVersionNumbers as that calls through to Gestalt
- // which ends up (on > 10.6) spawning threads.
- struct utsname machine_info;
- if (uname(&machine_info)) {
- return;
- }
-
- // The string machine_info.release is the xnu/Darwin version number, "9.xxx"
- // on Mac OS X 10.5, and "10.xxx" on Mac OS X 10.6. See
- // http://en.wikipedia.org/wiki/Darwin_(operating_system) .
- long darwin_version = strtol(machine_info.release, NULL, 10);
-
// === C malloc/calloc/valloc/realloc/posix_memalign ===
// This approach is not perfect, as requests for amounts of memory larger than
@@ -743,7 +727,7 @@ void EnableTerminationOnOutOfMemory() {
!g_old_memalign_purgeable) << "Old allocators unexpectedly non-null";
// See http://trac.webkit.org/changeset/53362/trunk/Tools/DumpRenderTree/mac
- bool zone_allocators_protected = darwin_version > 10;
+ bool zone_allocators_protected = base::mac::IsOSLionOrLater();
ChromeMallocZone* default_zone =
reinterpret_cast<ChromeMallocZone*>(malloc_default_zone());
@@ -858,26 +842,25 @@ void EnableTerminationOnOutOfMemory() {
!g_old_cfallocator_malloc_zone)
<< "Old allocators unexpectedly non-null";
- bool cf_allocator_internals_known =
- CanGetContextForCFAllocator(darwin_version);
+ bool cf_allocator_internals_known = CanGetContextForCFAllocator();
if (cf_allocator_internals_known) {
CFAllocatorContext* context =
- ContextForCFAllocator(kCFAllocatorSystemDefault, darwin_version);
+ ContextForCFAllocator(kCFAllocatorSystemDefault);
CHECK(context) << "Failed to get context for kCFAllocatorSystemDefault.";
g_old_cfallocator_system_default = context->allocate;
CHECK(g_old_cfallocator_system_default)
<< "Failed to get kCFAllocatorSystemDefault allocation function.";
context->allocate = oom_killer_cfallocator_system_default;
- context = ContextForCFAllocator(kCFAllocatorMalloc, darwin_version);
+ context = ContextForCFAllocator(kCFAllocatorMalloc);
CHECK(context) << "Failed to get context for kCFAllocatorMalloc.";
g_old_cfallocator_malloc = context->allocate;
CHECK(g_old_cfallocator_malloc)
<< "Failed to get kCFAllocatorMalloc allocation function.";
context->allocate = oom_killer_cfallocator_malloc;
- context = ContextForCFAllocator(kCFAllocatorMallocZone, darwin_version);
+ context = ContextForCFAllocator(kCFAllocatorMallocZone);
CHECK(context) << "Failed to get context for kCFAllocatorMallocZone.";
g_old_cfallocator_malloc_zone = context->allocate;
CHECK(g_old_cfallocator_malloc_zone)
diff --git a/base/sys_info.h b/base/sys_info.h
index 863e068..89bd193 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -41,6 +41,11 @@ class BASE_API SysInfo {
// Retrieves detailed numeric values for the OS version.
// TODO(port): Implement a Linux version of this method and enable the
// corresponding unit test.
+ // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release
+ // for OS version-specific feature checks and workarounds. If you must use
+ // an OS version check instead of a feature check, use the base::mac::IsOS*
+ // family from base/mac/mac_util.h, or base::win::GetVersion from
+ // base/win/windows_version.h.
static void OperatingSystemVersionNumbers(int32* major_version,
int32* minor_version,
int32* bugfix_version);
diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/bug_report_util.cc
index 8be7f42..cedcbec 100644
--- a/chrome/browser/bug_report_util.cc
+++ b/chrome/browser/bug_report_util.cc
@@ -167,11 +167,7 @@ void BugReportUtil::SetOSVersion(std::string* os_version) {
if (service_pack > 0)
os_version->append(StringPrintf("Service Pack %d", service_pack));
#elif defined(OS_MACOSX)
- int32 major;
- int32 minor;
- int32 bugFix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugFix);
- *os_version = StringPrintf("%d.%d.%d", major, minor, bugFix);
+ *os_version = base::SysInfo::OperatingSystemVersion();
#else
*os_version = "unknown";
#endif
diff --git a/chrome/browser/process_info_snapshot_mac.cc b/chrome/browser/process_info_snapshot_mac.cc
index d0387b0..74d93bf 100644
--- a/chrome/browser/process_info_snapshot_mac.cc
+++ b/chrome/browser/process_info_snapshot_mac.cc
@@ -10,9 +10,9 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "base/sys_info.h"
#include "base/threading/thread.h"
// Default constructor.
@@ -380,11 +380,9 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) {
// Get memory information using top.
bool memory_info_success = false;
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- if (major == 10 && minor == 5)
+ if (base::mac::IsOSLeopardOrEarlier())
memory_info_success = GetProcessMemoryInfoUsingTop_10_5(proc_info_entries_);
- else if ((major == 10 && minor >= 6) || major > 10)
+ else
memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_);
// If top didn't work then fall back to ps.
diff --git a/chrome/browser/ui/cocoa/objc_zombie.mm b/chrome/browser/ui/cocoa/objc_zombie.mm
index d90be07..3e09736 100644
--- a/chrome/browser/ui/cocoa/objc_zombie.mm
+++ b/chrome/browser/ui/cocoa/objc_zombie.mm
@@ -11,9 +11,9 @@
#import <objc/objc-class.h>
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/metrics/histogram.h"
#include "base/synchronization/lock.h"
-#include "base/sys_info.h"
#import "chrome/app/breakpad_mac.h"
#import "chrome/browser/ui/cocoa/objc_method_swizzle.h"
@@ -279,25 +279,19 @@ BOOL ZombieInit() {
return YES;
// Whitelist releases that are compatible with objc zombies.
- int32 major_version = 0, minor_version = 0, bugfix_version = 0;
- base::SysInfo::OperatingSystemVersionNumbers(
- &major_version, &minor_version, &bugfix_version);
-
- if (major_version < 10 || (major_version == 10 && minor_version < 5)) {
- return NO;
- } else if (major_version == 10 && minor_version == 5) {
+ if (base::mac::IsOSLeopard()) {
g_objectDestruct = LookupObjectDestruct_10_5();
if (!g_objectDestruct) {
RecordZombieFailure(FAILED_10_5);
return NO;
}
- } else if (major_version == 10 && minor_version == 6) {
+ } else if (base::mac::IsOSSnowLeopard()) {
g_objectDestruct = LookupObjectDestruct_10_6();
if (!g_objectDestruct) {
RecordZombieFailure(FAILED_10_6);
return NO;
}
- } else {
+ } else if (base::mac::IsOSLionOrLater()) {
// Assume the future looks like the present.
g_objectDestruct = LookupObjectDestruct_10_6();
@@ -309,6 +303,8 @@ BOOL ZombieInit() {
RecordZombieFailure(FAILED_MAX);
return NO;
}
+ } else {
+ return NO;
}
Class rootClass = [NSObject class];
diff --git a/chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.mm b/chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.mm
index 3f65b36..e3e4fc1 100644
--- a/chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.mm
+++ b/chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.mm
@@ -1,10 +1,10 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.h"
-#include <cmath>
+#include "base/mac/mac_util.h"
@interface MenuTrackedButton (Private)
- (void)doHighlight:(BOOL)highlight;
@@ -104,15 +104,9 @@
}
- (BOOL)shouldHighlightOnHover {
- // Apple does not define NSAppKitVersionNumber10_5 when using the 10.5 SDK.
- // The Internets have come up with this solution.
- #ifndef NSAppKitVersionNumber10_5
- #define NSAppKitVersionNumber10_5 949
- #endif
-
// There's a cell drawing bug in 10.5 that was fixed on 10.6. Hover states
// look terrible due to this, so disable highlighting on 10.5.
- return std::floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
+ return base::mac::IsOSSnowLeopardOrLater();
}
@end
diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm
index bc0e0c0..d04f0de 100644
--- a/content/browser/renderer_host/backing_store_mac.mm
+++ b/content/browser/renderer_host/backing_store_mac.mm
@@ -9,7 +9,6 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/sys_info.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
@@ -26,19 +25,6 @@
// allows acclerated drawing into the layer and lets scrolling and such happen
// all or mostly on the GPU, which is good for performance.
-namespace {
-
-// Returns whether this version of OS X has broken CGLayers, see
-// http://crbug.com/45553 , comments 5 and 6.
-bool NeedsLayerWorkaround() {
- int32 os_major, os_minor, os_bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(
- &os_major, &os_minor, &os_bugfix);
- return os_major == 10 && os_minor == 5;
-}
-
-} // namespace
-
BackingStoreMac::BackingStoreMac(RenderWidgetHost* widget,
const gfx::Size& size)
: BackingStore(widget, size) {
@@ -155,8 +141,9 @@ void BackingStoreMac::ScrollBackingStore(int dx, int dy,
if ((dx || dy) && abs(dx) < size().width() && abs(dy) < size().height()) {
if (cg_layer()) {
- // See http://crbug.com/45553 , comments 5 and 6.
- static bool needs_layer_workaround = NeedsLayerWorkaround();
+ // Whether this version of OS X has broken CGLayers. See
+ // http://crbug.com/45553 , comments 5 and 6.
+ bool needs_layer_workaround = base::mac::IsOSLeopardOrEarlier();
base::mac::ScopedCFTypeRef<CGLayerRef> new_layer;
CGContextRef layer;
diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm
index fd3b352..5191eff 100644
--- a/content/common/sandbox_mac.mm
+++ b/content/common/sandbox_mac.mm
@@ -384,18 +384,6 @@ NSString* LoadSandboxTemplate(Sandbox::SandboxProcessType sandbox_type) {
return [common_sandbox_prefix_data stringByAppendingString:sandbox_data];
}
-// Retrieve OS X version, output parameters are self explanatory.
-void GetOSVersion(bool* snow_leopard_or_higher, bool* lion_or_higher) {
- int32 major_version, minor_version, bugfix_version;
- base::SysInfo::OperatingSystemVersionNumbers(&major_version,
- &minor_version,
- &bugfix_version);
- *snow_leopard_or_higher =
- (major_version > 10 || (major_version == 10 && minor_version >= 6));
- *lion_or_higher =
- (major_version > 10 || (major_version == 10 && minor_version >= 7));
-}
-
// static
bool Sandbox::PostProcessSandboxProfile(
NSString* sandbox_template,
@@ -506,14 +494,13 @@ bool Sandbox::EnableSandbox(SandboxProcessType sandbox_type,
[tokens_to_remove addObject:@";ENABLE_LOGGING"];
}
- bool snow_leopard_or_higher;
- bool lion_or_higher;
- GetOSVersion(&snow_leopard_or_higher, &lion_or_higher);
+ bool snow_leopard_or_later = base::mac::IsOSSnowLeopardOrLater();
+ bool lion_or_later = base::mac::IsOSLionOrLater();
// Without this, the sandbox will print a message to the system log every
// time it denies a request. This floods the console with useless spew. The
// (with no-log) syntax is only supported on 10.6+
- if (snow_leopard_or_higher && !enable_logging) {
+ if (snow_leopard_or_later && !enable_logging) {
substitutions["DISABLE_SANDBOX_DENIAL_LOGGING"] =
SandboxSubstring("(with no-log)");
} else {
@@ -531,12 +518,12 @@ bool Sandbox::EnableSandbox(SandboxProcessType sandbox_type,
SandboxSubstring(home_dir_canonical.value(),
SandboxSubstring::LITERAL);
- if (lion_or_higher) {
+ if (lion_or_later) {
// >=10.7 Sandbox rules.
[tokens_to_remove addObject:@";10.7_OR_ABOVE"];
}
- if (snow_leopard_or_higher) {
+ if (snow_leopard_or_later) {
// >=10.6 Sandbox rules.
[tokens_to_remove addObject:@";10.6_OR_ABOVE"];
} else {
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc
index 9ce70b5..2c1937b 100644
--- a/content/renderer/renderer_main.cc
+++ b/content/renderer/renderer_main.cc
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if defined(OS_MACOSX)
-#include <signal.h>
-#include <unistd.h>
-#endif // OS_MACOSX
-
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/i18n/rtl.h"
@@ -33,9 +28,11 @@
#include "ui/base/ui_base_switches.h"
#if defined(OS_MACOSX)
-#include <Carbon/Carbon.h> // TISCreateInputSourceList
+#include <Carbon/Carbon.h>
+#include <signal.h>
+#include <unistd.h>
-#include "base/sys_info.h"
+#include "base/mac/mac_util.h"
#include "third_party/mach_override/mach_override.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#endif // OS_MACOSX
@@ -52,14 +49,10 @@ CFArrayRef ChromeTISCreateInputSourceList(
}
void InstallFrameworkHacks() {
- int32 os_major, os_minor, os_bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(
- &os_major, &os_minor, &os_bugfix);
-
// See http://crbug.com/31225
// TODO: Don't do this on newer OS X revisions that have a fix for
// http://openradar.appspot.com/radar?id=1156410
- if (os_major == 10 && os_minor >= 6) {
+ if (base::mac::IsOSSnowLeopardOrLater()) {
// Chinese Handwriting was introduced in 10.6. Since doing this override
// regresses page cycler memory usage on 10.5, don't do the unnecessary
// override there.
diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc
index 9ac779a..7f15d11 100644
--- a/content/renderer/webplugin_delegate_proxy.cc
+++ b/content/renderer/webplugin_delegate_proxy.cc
@@ -18,7 +18,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/string_split.h"
#include "base/string_util.h"
-#include "base/sys_info.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
#include "content/common/child_process.h"
@@ -54,6 +53,10 @@
#include "ipc/ipc_channel_posix.h"
#endif
+#if defined(OS_MACOSX)
+#include "base/mac/mac_util.h"
+#endif
+
using WebKit::WebBindings;
using WebKit::WebCursorInfo;
using WebKit::WebDragData;
@@ -272,13 +275,6 @@ static bool SilverlightColorIsTransparent(const std::string& color) {
}
#if defined(OS_MACOSX)
-// Returns true if the OS is 10.5 (Leopard).
-static bool OSIsLeopard() {
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- return major == 10 && minor == 5;
-}
-
// Returns true if the given Flash version assumes QuickDraw support is present
// instead of checking using the negotiation system.
static bool FlashVersionAssumesQuickDrawSupport(const string16& version) {
@@ -365,7 +361,7 @@ bool WebPluginDelegateProxy::Initialize(
// (where Flash doesn't use CA) to prevent QuickDraw from being used.
// TODO(stuartmorgan): Remove this code once the two latest major Flash
// releases negotiate correctly.
- if (flash && !transparent_ && OSIsLeopard() &&
+ if (flash && !transparent_ && base::mac::IsOSLeopardOrEarlier() &&
FlashVersionAssumesQuickDrawSupport(info_.version)) {
params.arg_names.push_back("wmode");
params.arg_values.push_back("opaque");
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index 84d5fee..2679cac 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -4,7 +4,7 @@
#include <CoreAudio/AudioHardware.h>
-#include "base/sys_info.h"
+#include "base/mac/mac_util.h"
#include "media/audio/fake_audio_input_stream.h"
#include "media/audio/fake_audio_output_stream.h"
#include "media/audio/mac/audio_input_mac.h"
@@ -34,9 +34,7 @@ static size_t GetMaxAudioOutputStreamsAllowed() {
// there's no way to detect it within the AudioQueue API, so we put a
// special hard limit only for Leopard.
// See bug: http://crbug.com/30242
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- if (major < 10 || (major == 10 && minor <= 5)) {
+ if (base::mac::IsOSLeopardOrEarlier()) {
g_max_output_streams = kMaxOutputStreamsLeopard;
} else {
// In OS other than OSX Leopard, the number of audio streams
diff --git a/printing/pdf_metafile_cg_mac.cc b/printing/pdf_metafile_cg_mac.cc
index 4668b2d..994f58f 100644
--- a/printing/pdf_metafile_cg_mac.cc
+++ b/printing/pdf_metafile_cg_mac.cc
@@ -6,8 +6,8 @@
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
#include "base/threading/thread_local.h"
#include "ui/gfx/rect.h"
@@ -36,17 +36,6 @@ namespace {
base::ThreadLocalPointer<struct __CFSet> thread_pdf_docs;
-bool PDFBugFixed() {
- int32 major_version;
- int32 minor_version;
- int32 bugfix_version;
- base::SysInfo::OperatingSystemVersionNumbers(&major_version,
- &minor_version,
- &bugfix_version);
- return
- major_version > 10 || (major_version == 10 && minor_version >= 7);
-}
-
} // namespace
namespace printing {
@@ -54,8 +43,7 @@ namespace printing {
PdfMetafileCg::PdfMetafileCg()
: page_is_open_(false),
thread_pdf_docs_owned_(false) {
- static bool bug_fixed = PDFBugFixed();
- if (!thread_pdf_docs.Get() && !bug_fixed) {
+ if (!thread_pdf_docs.Get() && base::mac::IsOSSnowLeopardOrEarlier()) {
thread_pdf_docs_owned_ = true;
thread_pdf_docs.Set(CFSetCreateMutable(kCFAllocatorDefault,
0,
diff --git a/third_party/apple_apsl/CFBase.h b/third_party/apple_apsl/CFBase.h
index 4c52e0e..7942966 100644
--- a/third_party/apple_apsl/CFBase.h
+++ b/third_party/apple_apsl/CFBase.h
@@ -30,7 +30,7 @@
#include "CFRuntime.h"
-struct ChromeCFAllocator9and10 {
+struct ChromeCFAllocatorLeopards {
ChromeCFRuntimeBase _base;
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
size_t (*size)(struct _malloc_zone_t *zone, const void *ptr); /* returns the size of a block or 0 if not in this zone; must be fast, especially for negative answers */
@@ -51,7 +51,7 @@ struct ChromeCFAllocator9and10 {
};
// TODO(avi): update upon source release; http://crbug.com/74589
-struct ChromeCFAllocator11 {
+struct ChromeCFAllocatorLion {
ChromeCFRuntimeBase _base;
// CFAllocator in Darwin 9 included a complete copy of _malloc_zone_t. The
// version in Darwin 10 had an abbreviated _malloc_zone_t that ended after the
diff --git a/third_party/apple_apsl/README.chromium b/third_party/apple_apsl/README.chromium
index f183768..2f014a2 100644
--- a/third_party/apple_apsl/README.chromium
+++ b/third_party/apple_apsl/README.chromium
@@ -31,9 +31,9 @@ Modifications:
- Added an #include of the CFRuntime.h file.
- Removed everything but the definition of __CFAllocator.
- Modified the reference of CFRuntimeBase to ChromeCFRuntimeBase.
-- Renamed __CFAllocator to ChromeCFAllocator9and10 to avoid possible name
+- Renamed __CFAllocator to ChromeCFAllocatorLeopards to avoid possible name
conflicts.
-- Added a presumed definition of ChromeCFAllocator11.
+- Added a presumed definition of ChromeCFAllocatorLion.
cssmapplePriv.h from:
http://www.opensource.apple.com/source/libsecurity_cssm/libsecurity_cssm-31536/lib/cssmapplePriv.h
diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm
index 6e294ab..dc17894 100644
--- a/ui/base/resource/resource_bundle_mac.mm
+++ b/ui/base/resource/resource_bundle_mac.mm
@@ -11,7 +11,6 @@
#include "base/mac/mac_util.h"
#include "base/memory/scoped_nsobject.h"
#include "base/synchronization/lock.h"
-#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
#include "ui/gfx/image/image.h"
@@ -48,13 +47,8 @@ FilePath ResourceBundle::GetResourcesFilePath() {
// static
FilePath ResourceBundle::GetLargeIconResourcesFilePath() {
- int32 major = 0;
- int32 minor = 0;
- int32 bugfix = 0;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
-
- // Only load the large resource pak on if we're running on 10.7 or above.
- if (major > 10 || (major == 10 && minor >= 7))
+ // Only load the large resource pak when running on 10.7 or later.
+ if (base::mac::IsOSLionOrLater())
return GetResourcesPakFilePath(@"theme_resources_large", nil);
else
return FilePath();
diff --git a/webkit/plugins/npapi/plugin_host.cc b/webkit/plugins/npapi/plugin_host.cc
index 7e73ea7..2af729e 100644
--- a/webkit/plugins/npapi/plugin_host.cc
+++ b/webkit/plugins/npapi/plugin_host.cc
@@ -30,7 +30,7 @@
#include "webkit/plugins/npapi/webplugininfo.h"
#if defined(OS_MACOSX)
-#include "base/sys_info.h"
+#include "base/mac/mac_util.h"
#endif
using WebKit::WebBindings;
@@ -58,10 +58,7 @@ static PluginInstance* FindInstance(NPP id) {
// Returns true if the OS supports shared accelerated surfaces via IOSurface.
// This is true on Snow Leopard and higher.
static bool SupportsSharingAcceleratedSurfaces() {
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- bool isSnowLeopardOrLater = major > 10 || (major == 10 && minor > 5);
- if (!isSnowLeopardOrLater)
+ if (base::mac::IsOSLeopardOrEarlier())
return false;
// We also need to be running with desktop GL and not the software
// OSMesa renderer in order to share accelerated surfaces between
@@ -871,9 +868,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) {
// We support the clarifications to the Cocoa IME event spec, but since
// IME currently only works on 10.6, only answer true there.
NPBool* supports_update = reinterpret_cast<NPBool*>(value);
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- *supports_update = major > 10 || (major == 10 && minor > 5);
+ *supports_update = base::mac::IsOSSnowLeopardOrLater();
rv = NPERR_NO_ERROR;
break;
}
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h
index b3b294f..84c74fc 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl.h
+++ b/webkit/plugins/npapi/webplugin_delegate_impl.h
@@ -404,9 +404,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// Uses a CARenderer to draw the plug-in's layer in our OpenGL surface.
void DrawLayerInSurface();
- // Returns true if plugin IME is supported.
- bool IsImeSupported();
-
#ifndef NP_NO_CARBON
// Moves our dummy window to match the current screen location of the plugin.
void UpdateDummyWindowBounds(const gfx::Point& plugin_origin);
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
index 20db93a..a2b021a 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
@@ -12,12 +12,12 @@
#include <set>
#include "base/file_util.h"
+#include "base/mac/mac_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/metrics/stats_counters.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/glue/webkit_glue.h"
@@ -1007,8 +1007,9 @@ void WebPluginDelegateImpl::PluginVisibilityChanged() {
}
void WebPluginDelegateImpl::StartIme() {
+ // Currently the plugin IME implementation only works on 10.6.
if (instance()->event_model() != NPEventModelCocoa ||
- !IsImeSupported()) {
+ base::mac::IsOSLeopardOrEarlier()) {
return;
}
if (ime_enabled_)
@@ -1017,19 +1018,6 @@ void WebPluginDelegateImpl::StartIme() {
plugin_->StartIme();
}
-bool WebPluginDelegateImpl::IsImeSupported() {
- // Currently the plugin IME implementation only works on 10.6.
- static BOOL sImeSupported = NO;
- static BOOL sHaveCheckedSupport = NO;
- if (!sHaveCheckedSupport) {
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- sImeSupported = major > 10 || (major == 10 && minor > 5);
- sHaveCheckedSupport = YES;
- }
- return sImeSupported;
-}
-
#pragma mark -
#pragma mark Core Animation Support