diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h index 84948f7ce89fc8..746c3da7a19a0b 100644 --- a/base/mac/mac_util.h +++ b/base/mac/mac_util.h @@ -5,7 +5,6 @@ #ifndef BASE_MAC_MAC_UTIL_H_ #define BASE_MAC_MAC_UTIL_H_ -#include #include #include #include @@ -108,85 +107,77 @@ BASE_EXPORT bool WasLaunchedAsHiddenLoginItem(); // an error, or true otherwise. BASE_EXPORT bool RemoveQuarantineAttribute(const FilePath& file_path); -// 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. - -// Mavericks is OS X 10.9, Darwin 13. -BASE_EXPORT bool IsOSMavericks(); - -// Yosemite is OS X 10.10, Darwin 14. -BASE_EXPORT bool IsOSYosemite(); -BASE_EXPORT bool IsOSYosemiteOrEarlier(); -BASE_EXPORT bool IsOSYosemiteOrLater(); - -// El Capitan is OS X 10.11, Darwin 15. -BASE_EXPORT bool IsOSElCapitan(); -BASE_EXPORT bool IsOSElCapitanOrEarlier(); -BASE_EXPORT bool IsOSElCapitanOrLater(); +namespace internal { -// Sierra is macOS 10.12, Darwin 16. -BASE_EXPORT bool IsOSSierra(); -BASE_EXPORT bool IsOSSierraOrLater(); +// Returns the system's Mac OS X minor version. This is the |y| value +// in 10.y or 10.y.z. +BASE_EXPORT int MacOSXMinorVersion(); -// 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, or to log when the OS is newer than any known version. -BASE_EXPORT bool IsOSLaterThanSierra_DontCallThis(); - -// Inline functions that are redundant due to version ranges being mutually- -// exclusive. -inline bool IsOSYosemiteOrEarlier() { return !IsOSElCapitanOrLater(); } -inline bool IsOSElCapitanOrEarlier() { return !IsOSSierraOrLater(); } - -// 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_9) && \ - MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 -#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9 -inline bool IsOSMavericks() { return false; } -#endif +} // namespace internal -#if defined(MAC_OS_X_VERSION_10_10) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 -#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10 -inline bool IsOSYosemiteOrLater() { return true; } -#endif +// Run-time OS version checks. Use these instead of +// base::SysInfo::OperatingSystemVersionNumbers. Prefer the "AtLeast" and +// "AtMost" variants to those that check for a specific version, unless you +// know for sure that you need to check for a specific version. -#if defined(MAC_OS_X_VERSION_10_10) && \ - MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_10 -#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10 -inline bool IsOSYosemite() { return false; } +#define _DEFINE_IS_OS_FUNCS(V, ID) \ + inline bool IsOS10_##V() { \ + return MAC_OS_X_VERSION_MIN_REQUIRED <= ID && \ + internal::MacOSXMinorVersion() == V; \ + } \ + inline bool IsAtLeastOS10_##V() { \ + return MAC_OS_X_VERSION_MIN_REQUIRED >= ID || \ + internal::MacOSXMinorVersion() >= V; \ + } \ + inline bool IsAtMostOS10_##V() { \ + return MAC_OS_X_VERSION_MIN_REQUIRED <= ID && \ + internal::MacOSXMinorVersion() <= V; \ + } + +// Apple adopted this format in 10.10: 10.11.0 becomes 101100 +#define OS_X_VERSION_ID(V) 10##V##00 +#define DEFINE_IS_OS_FUNCS(V) _DEFINE_IS_OS_FUNCS(V, OS_X_VERSION_ID(V)) + +// Sanity check that our computed IDs match the SDK +#define STR(S) _STR(S) +#define _STR(S) #S +#define ASSERT_OS_ID_CONSTANT(V) \ + static_assert(OS_X_VERSION_ID(V) == MAC_OS_X_VERSION_10_##V, \ + "ID for macOS 10." #V \ + " (" STR(OS_X_VERSION_ID(V)) ") doesn't match the SDK (" STR( \ + MAC_OS_X_VERSION_10_##V) ")."); + +// 10.9 uses an old format. +// TODO(sdy): Ditch, most callers are better served by !IsAtLeastOS10_10(). +_DEFINE_IS_OS_FUNCS(9, MAC_OS_X_VERSION_10_9) + +DEFINE_IS_OS_FUNCS(10) +ASSERT_OS_ID_CONSTANT(10) + +DEFINE_IS_OS_FUNCS(11) +#ifdef MAC_OS_X_VERSION_10_11 +ASSERT_OS_ID_CONSTANT(11) #endif -#if defined(MAC_OS_X_VERSION_10_11) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 -#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11 -inline bool IsOSElCapitanOrLater() { return true; } +DEFINE_IS_OS_FUNCS(12) +#ifdef MAC_OS_X_VERSION_10_12 +ASSERT_OS_ID_CONSTANT(12) #endif -#if defined(MAC_OS_X_VERSION_10_11) && \ - MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_11 -#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11 -inline bool IsOSElCapitan() { return false; } -#endif +#undef ASSERT_OS_ID_CONSTANT +#undef _STR +#undef STR -#if defined(MAC_OS_X_VERSION_10_12) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 -#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12 -inline bool IsOSSierraOrLater() { return true; } -#endif +#undef DEFINE_IS_OS_FUNCS +#undef MAC_OS_X_VERISON_ID +#undef _DEFINE_IS_OS_FUNCS -#if defined(MAC_OS_X_VERSION_10_12) && \ - MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 -#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12 -inline bool IsOSSierra() { return false; } -inline bool IsOSLaterThanSierra_DontCallThis() { return true; } -#endif +// 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, or to log when the OS is newer than any known version. +inline bool IsOSLaterThan10_12_DontCallThis() { + return !IsAtMostOS10_12(); +} // Retrieve the system's model identifier string from the IOKit registry: // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index c2ca83fa738ad0..d4b584debb78cd 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -448,69 +448,14 @@ int MacOSXMinorVersionInternal() { 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. +} // namespace + +namespace internal { int MacOSXMinorVersion() { static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); return mac_os_x_minor_version; } - -enum { - MAVERICKS_MINOR_VERSION = 9, - YOSEMITE_MINOR_VERSION = 10, - EL_CAPITAN_MINOR_VERSION = 11, - SIERRA_MINOR_VERSION = 12, -}; - -} // namespace - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) -bool IsOSMavericks() { - return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10) -bool IsOSYosemite() { - return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10) -bool IsOSYosemiteOrLater() { - return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11) -bool IsOSElCapitan() { - return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11) -bool IsOSElCapitanOrLater() { - return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12) -bool IsOSSierra() { - return MacOSXMinorVersion() == SIERRA_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12) -bool IsOSSierraOrLater() { - return MacOSXMinorVersion() >= SIERRA_MINOR_VERSION; -} -#endif - -#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12) -bool IsOSLaterThanSierra_DontCallThis() { - return MacOSXMinorVersion() > SIERRA_MINOR_VERSION; -} -#endif +} // namespace internal std::string GetModelIdentifier() { std::string return_string; diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 11003fa0bc557e..cf567c684cb520 100644 --- a/base/mac/mac_util_unittest.mm +++ b/base/mac/mac_util_unittest.mm @@ -146,49 +146,61 @@ if (major == 10) { if (minor == 9) { - EXPECT_TRUE(IsOSMavericks()); - EXPECT_FALSE(IsOSYosemite()); - EXPECT_TRUE(IsOSYosemiteOrEarlier()); - EXPECT_FALSE(IsOSYosemiteOrLater()); - EXPECT_FALSE(IsOSElCapitan()); - EXPECT_TRUE(IsOSElCapitanOrEarlier()); - EXPECT_FALSE(IsOSElCapitanOrLater()); - EXPECT_FALSE(IsOSSierra()); - EXPECT_FALSE(IsOSSierraOrLater()); - EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis()); + EXPECT_TRUE(IsOS10_9()); + EXPECT_TRUE(IsAtMostOS10_9()); + EXPECT_TRUE(IsAtLeastOS10_9()); + EXPECT_FALSE(IsOS10_10()); + EXPECT_TRUE(IsAtMostOS10_10()); + EXPECT_FALSE(IsAtLeastOS10_10()); + EXPECT_FALSE(IsOS10_11()); + EXPECT_TRUE(IsAtMostOS10_11()); + EXPECT_FALSE(IsAtLeastOS10_11()); + EXPECT_FALSE(IsOS10_12()); + EXPECT_FALSE(IsAtLeastOS10_12()); + EXPECT_TRUE(IsAtMostOS10_12()); + EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis()); } else if (minor == 10) { - EXPECT_FALSE(IsOSMavericks()); - EXPECT_TRUE(IsOSYosemite()); - EXPECT_TRUE(IsOSYosemiteOrEarlier()); - EXPECT_TRUE(IsOSYosemiteOrLater()); - EXPECT_FALSE(IsOSElCapitan()); - EXPECT_TRUE(IsOSElCapitanOrEarlier()); - EXPECT_FALSE(IsOSElCapitanOrLater()); - EXPECT_FALSE(IsOSSierra()); - EXPECT_FALSE(IsOSSierraOrLater()); - EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis()); + EXPECT_FALSE(IsOS10_9()); + EXPECT_FALSE(IsAtMostOS10_9()); + EXPECT_TRUE(IsAtLeastOS10_9()); + EXPECT_TRUE(IsOS10_10()); + EXPECT_TRUE(IsAtMostOS10_10()); + EXPECT_TRUE(IsAtLeastOS10_10()); + EXPECT_FALSE(IsOS10_11()); + EXPECT_TRUE(IsAtMostOS10_11()); + EXPECT_FALSE(IsAtLeastOS10_11()); + EXPECT_FALSE(IsOS10_12()); + EXPECT_FALSE(IsAtLeastOS10_12()); + EXPECT_TRUE(IsAtMostOS10_12()); + EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis()); } else if (minor == 11) { - EXPECT_FALSE(IsOSMavericks()); - EXPECT_FALSE(IsOSYosemite()); - EXPECT_FALSE(IsOSYosemiteOrEarlier()); - EXPECT_TRUE(IsOSYosemiteOrLater()); - EXPECT_TRUE(IsOSElCapitan()); - EXPECT_TRUE(IsOSElCapitanOrEarlier()); - EXPECT_TRUE(IsOSElCapitanOrLater()); - EXPECT_FALSE(IsOSSierra()); - EXPECT_FALSE(IsOSSierraOrLater()); - EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis()); + EXPECT_FALSE(IsOS10_9()); + EXPECT_FALSE(IsAtMostOS10_9()); + EXPECT_TRUE(IsAtLeastOS10_9()); + EXPECT_FALSE(IsOS10_10()); + EXPECT_FALSE(IsAtMostOS10_10()); + EXPECT_TRUE(IsAtLeastOS10_10()); + EXPECT_TRUE(IsOS10_11()); + EXPECT_TRUE(IsAtMostOS10_11()); + EXPECT_TRUE(IsAtLeastOS10_11()); + EXPECT_FALSE(IsOS10_12()); + EXPECT_FALSE(IsAtLeastOS10_12()); + EXPECT_TRUE(IsAtMostOS10_12()); + EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis()); } else if (minor == 12) { - EXPECT_FALSE(IsOSMavericks()); - EXPECT_FALSE(IsOSYosemite()); - EXPECT_FALSE(IsOSYosemiteOrEarlier()); - EXPECT_TRUE(IsOSYosemiteOrLater()); - EXPECT_FALSE(IsOSElCapitan()); - EXPECT_FALSE(IsOSElCapitanOrEarlier()); - EXPECT_TRUE(IsOSElCapitanOrLater()); - EXPECT_TRUE(IsOSSierra()); - EXPECT_TRUE(IsOSSierraOrLater()); - EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis()); + EXPECT_FALSE(IsOS10_9()); + EXPECT_FALSE(IsAtMostOS10_9()); + EXPECT_TRUE(IsAtLeastOS10_9()); + EXPECT_FALSE(IsOS10_10()); + EXPECT_FALSE(IsAtMostOS10_10()); + EXPECT_TRUE(IsAtLeastOS10_10()); + EXPECT_FALSE(IsOS10_11()); + EXPECT_FALSE(IsAtMostOS10_11()); + EXPECT_TRUE(IsAtLeastOS10_11()); + EXPECT_TRUE(IsOS10_12()); + EXPECT_TRUE(IsAtMostOS10_12()); + EXPECT_TRUE(IsAtLeastOS10_12()); + EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis()); } else { // Not nine, ten, eleven, or twelve. Ah, ah, ah. EXPECT_TRUE(false); diff --git a/base/process/memory_mac.mm b/base/process/memory_mac.mm index 32fdd38821dd12..bac75aeab156c6 100644 --- a/base/process/memory_mac.mm +++ b/base/process/memory_mac.mm @@ -248,7 +248,7 @@ void oom_killer_new() { // === Core Foundation CFAllocators === bool CanGetContextForCFAllocator() { - return !base::mac::IsOSLaterThanSierra_DontCallThis(); + return !base::mac::IsOSLaterThan10_12_DontCallThis(); } CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { diff --git a/base/sys_info_mac.mm b/base/sys_info_mac.mm index a2903a27fc6ab2..aab1103d4c401d 100644 --- a/base/sys_info_mac.mm +++ b/base/sys_info_mac.mm @@ -51,7 +51,7 @@ // cases in 10.9, rely on ::Gestalt(..). Since this code is only needed for // 10.9.0 and 10.9.1 and uses the recommended replacement thereafter, // suppress the warning for this fallback case. - DCHECK(base::mac::IsOSMavericks()); + DCHECK(base::mac::IsOS10_9()); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" Gestalt(gestaltSystemVersionMajor, diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 3d6688823e23d0..e25998eddd42a7 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -1642,7 +1642,7 @@ - (void)application:(NSApplication*)application #pragma mark - Handoff Manager - (BOOL)shouldUseHandoff { - return base::mac::IsOSYosemiteOrLater(); + return base::mac::IsAtLeastOS10_10(); } - (void)passURLToHandoffManager:(const GURL&)handoffURL { diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm index 8b7443c68146e0..6c49dca17469d3 100644 --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm @@ -556,7 +556,7 @@ void TestControls(AppWindow* app_window) { // fullscreen action. The above check that collectionBehavior does not include // NSWindowCollectionBehaviorFullScreenPrimary is sufficient to determine that // the window can't be fullscreened. - if (base::mac::IsOSMavericks()) { + if (base::mac::IsOS10_9()) { EXPECT_EQ(can_fullscreen, [[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); } @@ -636,7 +636,7 @@ void TestControls(AppWindow* app_window) { // NOTE: This doesn't work with Views, but the regular test does, so use that. bool mac_views = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableMacViewsNativeAppWindows); - if (base::mac::IsOSMavericks() && !mac_views) { + if (base::mac::IsOS10_9() && !mac_views) { // -[NSView setNeedsDisplay:YES] doesn't synchronously display the view, it // gets drawn by another event in the queue, so let that run first. content::RunAllPendingInMessageLoop(); diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index f1bdf19ccf9a6d..117f172fcd55c4 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm @@ -468,7 +468,7 @@ - (void)viewDidLoad { if (bridge_) { // When running on 10.10, expect both -awakeFromNib and -viewDidLoad to be // called, but only initialize once. - DCHECK(base::mac::IsOSYosemiteOrLater()); + DCHECK(base::mac::IsAtLeastOS10_10()); return; } diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm index 9ba3378bc83cb2..fb15b7d8da8251 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm @@ -1640,10 +1640,10 @@ virtual void AddCommandLineSwitches() {} 153.0, 143.0, 142.0 }; CGFloat* view_widths = NULL; bool is_mode_material = ui::MaterialDesignController::IsModeMaterial(); - if (base::mac::IsOSElCapitan()) { + if (base::mac::IsOS10_11()) { view_widths = is_mode_material ? material_view_widths_el_capitan : view_widths_el_capitan; - } else if (base::mac::IsOSYosemite()) { + } else if (base::mac::IsOS10_10()) { view_widths = is_mode_material ? material_view_widths_yosemite : view_widths_yosemite; } else { diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index d1e4ab64bf3c27..b92a19242a65be 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -1934,7 +1934,7 @@ - (void)enterWebContentFullscreen { // that the other monitors won't blank out. display::Screen* screen = display::Screen::GetScreen(); BOOL hasMultipleMonitors = screen && screen->GetNumDisplays() > 1; - if (base::mac::IsOSYosemiteOrLater() && + if (base::mac::IsAtLeastOS10_10() && !(hasMultipleMonitors && ![NSScreen screensHaveSeparateSpaces])) { [self enterAppKitFullscreen]; } else { diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm index 7e6e3eeb9ed995..dfbe07d60f91eb 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm @@ -680,7 +680,7 @@ - (void)windowDidEnterFullScreen:(NSNotification*)notification { // full-screen mode. We do not want either to show. Search for the window that // contains the views, and hide it. There is no need to ever unhide the view. // http://crbug.com/380235 - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsAtLeastOS10_10()) { for (NSWindow* window in [[NSApplication sharedApplication] windows]) { if ([window isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { @@ -1116,7 +1116,7 @@ - (void)setContentViewSubviews:(NSArray*)subviews { } + (BOOL)systemSettingsRequireMavericksAppKitFullscreenHack { - if (!base::mac::IsOSMavericks()) + if (!base::mac::IsOS10_9()) return NO; return [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && [NSScreen screensHaveSeparateSpaces]; @@ -1135,7 +1135,7 @@ - (BOOL)shouldUseMavericksAppKitFullscreenHack { - (BOOL)shouldUseCustomAppKitFullscreenTransition:(BOOL)enterFullScreen { // Disable the custom exit animation in OSX 10.9: http://crbug.com/526327#c3. - if (base::mac::IsOSMavericks() && !enterFullScreen) + if (base::mac::IsOS10_9() && !enterFullScreen) return NO; NSView* root = [[self.window contentView] superview]; diff --git a/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm b/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm index df3968b4e69011..2855e87e91def9 100644 --- a/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm +++ b/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm @@ -239,7 +239,7 @@ - (BOOL)isTransitionCompleted { } - (void)startCustomFullScreenAnimationWithDuration:(NSTimeInterval)duration { - CGFloat durationFraction = base::mac::IsOSYosemite() + CGFloat durationFraction = base::mac::IsOS10_10() ? kAnimationDurationFractionYosemite : kAnimationDurationFraction; CGFloat animationDuration = duration * durationFraction; diff --git a/chrome/browser/ui/cocoa/browser_window_layout.mm b/chrome/browser/ui/cocoa/browser_window_layout.mm index bcb64898702ffa..84a1c83ef8fd42 100644 --- a/chrome/browser/ui/cocoa/browser_window_layout.mm +++ b/chrome/browser/ui/cocoa/browser_window_layout.mm @@ -61,7 +61,7 @@ @implementation BrowserWindowLayout - (instancetype)init { if ((self = [super init])) { - parameters_.isOSYosemiteOrLater = base::mac::IsOSYosemiteOrLater(); + parameters_.isOSYosemiteOrLater = base::mac::IsAtLeastOS10_10(); } return self; } diff --git a/chrome/browser/ui/cocoa/custom_frame_view.mm b/chrome/browser/ui/cocoa/custom_frame_view.mm index 25b82e4192ea23..e5bcefc6c45580 100644 --- a/chrome/browser/ui/cocoa/custom_frame_view.mm +++ b/chrome/browser/ui/cocoa/custom_frame_view.mm @@ -50,7 +50,7 @@ + (void)load { // In Yosemite, the fullscreen button replaces the zoom button. We no longer // need to swizzle out this AppKit private method. - if (!base::mac::IsOSMavericks()) + if (!base::mac::IsOS10_9()) return; base::mac::ScopedNSAutoreleasePool pool; diff --git a/chrome/browser/ui/cocoa/custom_frame_view_unittest.mm b/chrome/browser/ui/cocoa/custom_frame_view_unittest.mm index 8b936906f03118..33339ada746943 100644 --- a/chrome/browser/ui/cocoa/custom_frame_view_unittest.mm +++ b/chrome/browser/ui/cocoa/custom_frame_view_unittest.mm @@ -28,7 +28,7 @@ TEST_F(CustomFrameViewTest, SuccessfulClassModifications) { // In Yosemite, the fullscreen button replaces the zoom button. We no longer // need to swizzle out this AppKit private method. - if (!base::mac::IsOSMavericks()) + if (!base::mac::IsOS10_9()) return; unsigned int count; diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm index 9253c07338e08f..3b227f8bdecad1 100644 --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm @@ -52,7 +52,7 @@ - (void)awakeFromNib { // Also, because NSPressureConfiguration is not in the original 10.10 SDK, // use NSClassFromString() to instantiate it (otherwise there's a // linker error). - if (base::mac::IsOSYosemiteOrLater() && + if (base::mac::IsAtLeastOS10_10() && [self respondsToSelector:@selector(setPressureConfiguration:)]) { NSPressureConfiguration* pressureConfiguration = [[[NSClassFromString(@"NSPressureConfiguration") alloc] diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm index 0d24bd97fa6777..ad7b278ca321f3 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm @@ -320,7 +320,7 @@ CGFloat PopupPaddingVertical() { // the window does not get redrawn. Use a completion handler to make sure // |popup_| gets redrawn once the animation completes. See // http://crbug.com/538590 and http://crbug.com/551007 . - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { NSWindow* popup = popup_.get(); [[NSAnimationContext currentContext] setCompletionHandler:^{ [popup display]; diff --git a/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac_browsertest.mm b/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac_browsertest.mm index 42b0fd6288c9f1..bf72da27803cd4 100644 --- a/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac_browsertest.mm +++ b/chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac_browsertest.mm @@ -98,6 +98,6 @@ void TearDownOnMainThread() override { // Confirm that Services items were removed from the contextual menu. This // check was failing on the 10.10 bot, for some reason. Most-important is // making sure it continues to work as OS X evolves. - if (base::mac::IsOSElCapitanOrLater()) + if (base::mac::IsAtLeastOS10_11()) EXPECT_LT(0LU, [filteredItems_ count]); } diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm index 33b7b9ef447dae..2329650aa54f45 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm @@ -374,7 +374,7 @@ - (NSVisualEffectView*)visualEffectView { // NSVisualEffectView is only used in Material Design, and only available on // OS X 10.10 and higher. if (!ui::MaterialDesignController::IsModeMaterial() || - !base::mac::IsOSYosemiteOrLater()) { + !base::mac::IsAtLeastOS10_10()) { return nil; } diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm index dc2c825a4f4c25..de26ecc82bcc9b 100644 --- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm +++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm @@ -297,7 +297,7 @@ - (void)viewDidLoad { // When linking and running on 10.10+, both -awakeFromNib and -viewDidLoad may // be called, don't initialize twice. if (locationBarView_) { - DCHECK(base::mac::IsOSYosemiteOrLater()); + DCHECK(base::mac::IsAtLeastOS10_10()); return; } diff --git a/components/crash/content/app/breakpad_mac.mm b/components/crash/content/app/breakpad_mac.mm index 6c6934bfa7ea83..d7ab1ae6389a1a 100644 --- a/components/crash/content/app/breakpad_mac.mm +++ b/components/crash/content/app/breakpad_mac.mm @@ -241,7 +241,7 @@ void InitCrashReporter(const std::string& process_type) { // Temporarily run Breakpad in-process on 10.10 and later because APIs that // it depends on got broken (http://crbug.com/386208). // This can catch crashes in the browser process only. - if (is_browser && base::mac::IsOSYosemiteOrLater()) { + if (is_browser && base::mac::IsAtLeastOS10_10()) { [breakpad_config setObject:[NSNumber numberWithBool:YES] forKey:@BREAKPAD_IN_PROCESS]; } diff --git a/components/handoff/handoff_manager.mm b/components/handoff/handoff_manager.mm index 0f4fa76a9ed9e1..23a557dce71ee0 100644 --- a/components/handoff/handoff_manager.mm +++ b/components/handoff/handoff_manager.mm @@ -58,7 +58,7 @@ - (void)updateActiveURL:(const GURL&)url { #if defined(OS_MACOSX) && !defined(OS_IOS) // Handoff is only available on OSX 10.10+. - DCHECK(base::mac::IsOSYosemiteOrLater()); + DCHECK(base::mac::IsAtLeastOS10_10()); #endif _activeURL = url; diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm index b2dff5cf91602e..11b485d794b253 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm @@ -213,7 +213,7 @@ NSAccessibilityPostNotification(ToBrowserAccessibilityCocoa(focus), mac_notification); - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X // 10.11 or later to notify Voiceover about text selection changes. This // API has been present on versions of OS X since 10.7 but doesn't @@ -238,7 +238,7 @@ break; case ui::AX_EVENT_VALUE_CHANGED: mac_notification = NSAccessibilityValueChangedNotification; - if (base::mac::IsOSElCapitanOrLater() && text_edits_.size()) { + if (base::mac::IsAtLeastOS10_11() && text_edits_.size()) { // It seems that we don't need to distinguish between deleted and // inserted text for now. base::string16 deleted_text; diff --git a/content/browser/bootstrap_sandbox_manager_mac.cc b/content/browser/bootstrap_sandbox_manager_mac.cc index 61d1b1e3b04bb0..0941895a60c68f 100644 --- a/content/browser/bootstrap_sandbox_manager_mac.cc +++ b/content/browser/bootstrap_sandbox_manager_mac.cc @@ -80,7 +80,7 @@ void BootstrapSandboxManager::RegisterRendererPolicy() { // Allow access to launchservicesd on 10.10+ otherwise the renderer will crash // attempting to get its ASN. http://crbug.com/533537 - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsAtLeastOS10_10()) { policy.rules["com.apple.coreservices.launchservicesd"] = sandbox::Rule(sandbox::POLICY_ALLOW); } diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm index bd9eb73cbd24ac..5271dcdd43c894 100644 --- a/content/common/sandbox_mac.mm +++ b/content/common/sandbox_mac.mm @@ -471,7 +471,7 @@ NOINLINE void FatalStringQuoteException(const std::string& str) { if (!compiler.InsertStringParam("USER_HOMEDIR_AS_LITERAL", quoted_home_dir)) return false; - bool elcap_or_later = base::mac::IsOSElCapitanOrLater(); + bool elcap_or_later = base::mac::IsAtLeastOS10_11(); if (!compiler.InsertBooleanParam("ELCAP_OR_LATER", elcap_or_later)) return false; diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm index ff59985ac0a87f..8215ca414a9f0d 100644 --- a/content/renderer/renderer_main_platform_delegate_mac.mm +++ b/content/renderer/renderer_main_platform_delegate_mac.mm @@ -116,7 +116,7 @@ void DisconnectCFNotificationCenter() { // running a renderer needs to also be reflected in chrome_main.cc for // --single-process support. void RendererMainPlatformDelegate::PlatformInitialize() { - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsAtLeastOS10_10()) { // This is needed by the NSAnimations run for the scrollbars. If we switch // from native scrollers to drawing them in some other way, this warmup can // be removed . diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm index 4fb66a251da76d..1690da6559fe95 100644 --- a/device/bluetooth/bluetooth_adapter_mac.mm +++ b/device/bluetooth/bluetooth_adapter_mac.mm @@ -68,7 +68,7 @@ // static BluetoothUUID BluetoothAdapterMac::BluetoothUUIDWithCBUUID(CBUUID* uuid) { // UUIDString only available OS X >= 10.10. - DCHECK(base::mac::IsOSYosemiteOrLater()); + DCHECK(base::mac::IsAtLeastOS10_10()); std::string uuid_c_string = base::SysNSStringToUTF8([uuid UUIDString]); return device::BluetoothUUID(uuid_c_string); } @@ -241,7 +241,7 @@ // static bool BluetoothAdapterMac::IsLowEnergyAvailable() { - return base::mac::IsOSYosemiteOrLater(); + return base::mac::IsAtLeastOS10_10(); } void BluetoothAdapterMac::RemovePairingDelegateInternal( diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm index e39e94966520ef..a6225a91c32ab0 100644 --- a/sandbox/mac/bootstrap_sandbox_unittest.mm +++ b/sandbox/mac/bootstrap_sandbox_unittest.mm @@ -138,7 +138,7 @@ void RunChildWithPolicy(int policy_id, // Run the test with the sandbox enabled without notifications on the policy // whitelist. TEST_F(BootstrapSandboxTest, DistributedNotifications_SandboxDeny) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -156,7 +156,7 @@ void RunChildWithPolicy(int policy_id, // Run the test with notifications permitted. TEST_F(BootstrapSandboxTest, DistributedNotifications_SandboxAllow) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -191,7 +191,7 @@ void RunChildWithPolicy(int policy_id, const char kTestServer[] = "org.chromium.test_bootstrap_server"; TEST_F(BootstrapSandboxTest, PolicyDenyError) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -218,7 +218,7 @@ void RunChildWithPolicy(int policy_id, } TEST_F(BootstrapSandboxTest, PolicyDenyDummyPort) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -250,7 +250,7 @@ void RunChildWithPolicy(int policy_id, const char kSubstituteAck[] = "Hello, this is doge!"; TEST_F(BootstrapSandboxTest, PolicySubstitutePort) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -371,7 +371,7 @@ void RunChildWithPolicy(int policy_id, "org.chromium.sandbox.test.DefaultRuleAllow.Deny"; TEST_F(BootstrapSandboxTest, DefaultRuleAllow) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } @@ -443,7 +443,7 @@ void RunChildWithPolicy(int policy_id, } TEST_F(BootstrapSandboxTest, ChildOutliveSandbox) { - if (base::mac::IsOSSierraOrLater()) { + if (base::mac::IsAtLeastOS10_12()) { LOG(ERROR) << "BootstrapSandbox does not work on macOS Sierra or later."; return; } diff --git a/sandbox/mac/launchd_interception_server.cc b/sandbox/mac/launchd_interception_server.cc index 69231b59508d16..167fbab5828bd3 100644 --- a/sandbox/mac/launchd_interception_server.cc +++ b/sandbox/mac/launchd_interception_server.cc @@ -54,7 +54,7 @@ bool LaunchdInterceptionServer::Initialize(mach_port_t server_receive_right) { } sandbox_send_port_.reset(sandbox_port_.get()); - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsAtLeastOS10_10()) { message_server_.reset(new XPCMessageServer(this, server_receive_right)); xpc_launchd_ = true; } else { diff --git a/sandbox/mac/os_compatibility.cc b/sandbox/mac/os_compatibility.cc index dce874c3c03ba7..1e0ba5be76faa7 100644 --- a/sandbox/mac/os_compatibility.cc +++ b/sandbox/mac/os_compatibility.cc @@ -181,7 +181,7 @@ class OSCompatibility_10_10 : public OSCompatibility { // static std::unique_ptr OSCompatibility::CreateForPlatform() { - if (base::mac::IsOSMavericks()) + if (base::mac::IsOS10_9()) return base::WrapUnique(new OSCompatibility_10_7()); else return base::WrapUnique(new OSCompatibility_10_10()); diff --git a/sandbox/mac/pre_exec_delegate.cc b/sandbox/mac/pre_exec_delegate.cc index 9d777d3f4d00d5..1aac68be87ed87 100644 --- a/sandbox/mac/pre_exec_delegate.cc +++ b/sandbox/mac/pre_exec_delegate.cc @@ -22,9 +22,8 @@ PreExecDelegate::PreExecDelegate( sandbox_server_bootstrap_name_ptr_( sandbox_server_bootstrap_name_.c_str()), sandbox_token_(sandbox_token), - is_yosemite_or_later_(base::mac::IsOSYosemiteOrLater()), - look_up_message_(CreateBootstrapLookUpMessage()) { -} + is_yosemite_or_later_(base::mac::IsAtLeastOS10_10()), + look_up_message_(CreateBootstrapLookUpMessage()) {} PreExecDelegate::~PreExecDelegate() {} diff --git a/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm b/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm index 318293ed309a4c..d8d2a531de30c4 100644 --- a/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm +++ b/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm @@ -256,7 +256,7 @@ static FontWeight toFontWeight(NSInteger appKitFontWeight) { // This hack is only applied on OSX 10.9. // https://code.google.com/p/chromium/issues/detail?id=515989#c8 - return IsOSMavericks() && family == "BlinkMacSystemFont"; + return IsOS10_9() && family == "BlinkMacSystemFont"; } static RGBA32 convertNSColorToColor(NSColor *color) @@ -478,7 +478,7 @@ static RGBA32 menuBackgroundColor() return true; // NSPopUpButtonCell on macOS 10.9 doesn't support // NSUserInterfaceLayoutDirectionRightToLeft. - if (IsOSMavericks() && style.direction() == RTL) + if (IsOS10_9() && style.direction() == RTL) return true; } // Some other cells don't work well when scaled. diff --git a/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMac.mm b/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMac.mm index c25728eabc1063..6f53a02b7e4a22 100644 --- a/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMac.mm +++ b/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMac.mm @@ -138,7 +138,7 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight, // so force layout tests to use "Lucida Grande". Once the 10.10 SDK // switch is made, this should be changed to return .LucidaGrandeUI and // the Layout Expectations should be updated. http://crbug.com/515836. - if (LayoutTestSupport::isRunningLayoutTest() && IsOSMavericks()) { + if (LayoutTestSupport::isRunningLayoutTest() && IsOS10_9()) { if (desiredWeight >= blink::FontWeightBold) return [NSFont fontWithName:@"Lucida Grande Bold" size:size]; else @@ -146,7 +146,7 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight, } NSFont* font = nil; - if (IsOSMavericks()) { + if (IsOS10_9()) { // On older OSX versions, only bold and regular are available. if (desiredWeight >= blink::FontWeightBold) font = [NSFont boldSystemFontOfSize:size]; diff --git a/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMacTest.mm b/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMacTest.mm index 661ff77ad1c1cf..14bfbd920c48f3 100644 --- a/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMacTest.mm +++ b/third_party/WebKit/Source/platform/fonts/mac/FontFamilyMatcherMacTest.mm @@ -23,7 +23,7 @@ void TestSystemFontContainsString(FontWeight desiredWeight, NSString* substring) TEST(FontFamilyMatcherMacTest, YosemiteFontWeights) { - if (!IsOSYosemite()) + if (!IsOS10_10()) return; TestSystemFontContainsString(FontWeight100, @"-UltraLight"); diff --git a/third_party/WebKit/Source/platform/mac/VersionUtilMac.h b/third_party/WebKit/Source/platform/mac/VersionUtilMac.h index ccff619df8d9d4..079825f11d010d 100644 --- a/third_party/WebKit/Source/platform/mac/VersionUtilMac.h +++ b/third_party/WebKit/Source/platform/mac/VersionUtilMac.h @@ -7,16 +7,26 @@ #include "platform/PlatformExport.h" +#include + namespace blink { -// Mavericks is Mac OS X 10.9, Darwin 13. -PLATFORM_EXPORT bool IsOSMavericks(); +namespace internal { + +PLATFORM_EXPORT int MacOSXMinorVersion(); + +template +constexpr bool IsOS() +{ + return MAC_OS_X_VERSION_MIN_REQUIRED <= ID && MacOSXMinorVersion() == V; +} -// Yosemite is Mac OS X 10.10, Darwin 14. -PLATFORM_EXPORT bool IsOSYosemite(); +} // namespace internal -// El Capitan is Mac OS X 10.11, Darwin 15. -PLATFORM_EXPORT bool IsOSElCapitan(); +const auto IsOS10_9 = internal::IsOS<9, 1090>; +const auto IsOS10_10 = internal::IsOS<10, 101000>; +const auto IsOS10_11 = internal::IsOS<11, 101100>; +const auto IsOS10_12 = internal::IsOS<12, 101200>; } // namespace blink diff --git a/third_party/WebKit/Source/platform/mac/VersionUtilMac.mm b/third_party/WebKit/Source/platform/mac/VersionUtilMac.mm index 7eb98199fbcbe3..17595fdf8763c2 100644 --- a/third_party/WebKit/Source/platform/mac/VersionUtilMac.mm +++ b/third_party/WebKit/Source/platform/mac/VersionUtilMac.mm @@ -48,37 +48,12 @@ int MacOSXMinorVersionInternal() return darwinMajorVersion - 4; } +} // namespace + // Returns the running system's Mac OS X minor version. This is the |y| value // in 10.y or 10.y.z. -int MacOSXMinorVersion() +int blink::internal::MacOSXMinorVersion() { static int minorVersion = MacOSXMinorVersionInternal(); return minorVersion; } - -enum { - MAVERICKS_MINOR_VERSION = 9, - YOSEMITE_MINOR_VERSION = 10, - EL_CAPITAN_MINOR_VERSION = 11, -}; - -} // namespace - -namespace blink { - -bool IsOSMavericks() -{ - return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; -} - -bool IsOSYosemite() -{ - return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION; -} - -bool IsOSElCapitan() -{ - return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION; -} - -} // namespace blink diff --git a/third_party/WebKit/Source/platform/mac/VersionUtilMacTest.mm b/third_party/WebKit/Source/platform/mac/VersionUtilMacTest.mm index da02f8b5e25fc5..7a6b66bac09751 100644 --- a/third_party/WebKit/Source/platform/mac/VersionUtilMacTest.mm +++ b/third_party/WebKit/Source/platform/mac/VersionUtilMacTest.mm @@ -29,24 +29,24 @@ TEST(VersionUtilMac, AppKitVersions) { if (floor(NSAppKitVersionNumber) == NSAppKitVersionNumber10_9) { - EXPECT_TRUE(blink::IsOSMavericks()); - EXPECT_FALSE(blink::IsOSYosemite()); - EXPECT_FALSE(blink::IsOSElCapitan()); + EXPECT_TRUE(blink::IsOS10_9()); + EXPECT_FALSE(blink::IsOS10_10()); + EXPECT_FALSE(blink::IsOS10_11()); return; } if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10Max && floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_10) { - EXPECT_FALSE(blink::IsOSMavericks()); - EXPECT_TRUE(blink::IsOSYosemite()); - EXPECT_FALSE(blink::IsOSElCapitan()); + EXPECT_FALSE(blink::IsOS10_9()); + EXPECT_TRUE(blink::IsOS10_10()); + EXPECT_FALSE(blink::IsOS10_11()); return; } if (floor(NSAppKitVersionNumber) == NSAppKitVersionNumber10_11Max) { - EXPECT_FALSE(blink::IsOSMavericks()); - EXPECT_FALSE(blink::IsOSYosemite()); - EXPECT_TRUE(blink::IsOSElCapitan()); + EXPECT_FALSE(blink::IsOS10_9()); + EXPECT_FALSE(blink::IsOS10_10()); + EXPECT_TRUE(blink::IsOS10_11()); return; } } diff --git a/ui/base/cocoa/appkit_utils.mm b/ui/base/cocoa/appkit_utils.mm index 1b0a61b2060314..95483cfd284ed3 100644 --- a/ui/base/cocoa/appkit_utils.mm +++ b/ui/base/cocoa/appkit_utils.mm @@ -34,7 +34,7 @@ DoubleClickAction WindowTitleBarDoubleClickAction() { // El Capitan introduced a Dock preference to configure the window title bar // double-click action (Minimize, Maximize, or nothing). - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleActionOnDoubleClick"]; @@ -60,8 +60,8 @@ DoubleClickAction WindowTitleBarDoubleClickAction() { // At this point _shouldMiniaturizeOnDoubleClick has returned |NO|. On // Yosemite, that means a double-click should Maximize the window, and on // all prior OSes a double-click should do nothing. - return base::mac::IsOSYosemite() ? DoubleClickAction::MAXIMIZE - : DoubleClickAction::NONE; + return base::mac::IsOS10_10() ? DoubleClickAction::MAXIMIZE + : DoubleClickAction::NONE; } } // namespace diff --git a/ui/base/cocoa/base_view.mm b/ui/base/cocoa/base_view.mm index ef3eb87f7917d2..47ccca96ad6dd8 100644 --- a/ui/base/cocoa/base_view.mm +++ b/ui/base/cocoa/base_view.mm @@ -61,7 +61,7 @@ - (void)updateTrackingAreas { // Work around it by reinstalling the tracking area after window resize. // This AppKit bug is fixed on Yosemite, so we only apply this workaround on // 10.9. - if (base::mac::IsOSMavericks()) { + if (base::mac::IsOS10_9()) { [self disableTracking]; [self enableTracking]; } diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc index 13b65aad740039..3560790b28138f 100644 --- a/ui/gfx/mac/io_surface.cc +++ b/ui/gfx/mac/io_surface.cc @@ -164,7 +164,7 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) { // https://crbug.com/594343. // IOSurface clearing causes significant performance regression on about half // of all devices running Yosemite. https://crbug.com/606850#c22. - bool should_clear = !base::mac::IsOSMavericks() && !base::mac::IsOSYosemite(); + bool should_clear = !base::mac::IsOS10_9() && !base::mac::IsOS10_10(); if (should_clear) { // Zero-initialize the IOSurface. Calling IOSurfaceLock/IOSurfaceUnlock diff --git a/ui/gfx/mac/scoped_cocoa_disable_screen_updates.h b/ui/gfx/mac/scoped_cocoa_disable_screen_updates.h index e431ecd586b08b..b20492cf197e97 100644 --- a/ui/gfx/mac/scoped_cocoa_disable_screen_updates.h +++ b/ui/gfx/mac/scoped_cocoa_disable_screen_updates.h @@ -20,7 +20,7 @@ namespace gfx { class ScopedCocoaDisableScreenUpdates { public: ScopedCocoaDisableScreenUpdates() { - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { // Beginning with OS X 10.11, [NSAnimationContext beginGrouping] is the // preferred way of disabling screen updates. Use of // NSDisableScreenUpdates() is discouraged. @@ -30,7 +30,7 @@ class ScopedCocoaDisableScreenUpdates { } } ~ScopedCocoaDisableScreenUpdates() { - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { [NSAnimationContext endGrouping]; } else { NSEnableScreenUpdates(); diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm index bd62b5d4aa0758..e380333c8c88f4 100644 --- a/ui/gfx/render_text_mac.mm +++ b/ui/gfx/render_text_mac.mm @@ -29,7 +29,7 @@ // 10.10. base::ScopedCFTypeRef CopyFontWithSymbolicTraits(CTFontRef font, int sym_traits) { - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsAtLeastOS10_11()) { return base::ScopedCFTypeRef(CTFontCreateCopyWithSymbolicTraits( font, 0, nullptr, sym_traits, sym_traits)); } diff --git a/ui/gl/test/gl_image_test_template.h b/ui/gl/test/gl_image_test_template.h index 51bcca4c306873..f12bafbe9d5270 100644 --- a/ui/gl/test/gl_image_test_template.h +++ b/ui/gl/test/gl_image_test_template.h @@ -225,12 +225,12 @@ TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) { #if defined(OS_MACOSX) // This functionality is disabled on Mavericks because it breaks PDF // rendering. https://crbug.com/594343. - if (base::mac::IsOSMavericks()) + if (base::mac::IsOS10_9()) return; // This functionality is disabled on Yosemite because it is suspected of // causing performance regressions on old hardware. https://crbug.com/606850. - if (base::mac::IsOSYosemite()) + if (base::mac::IsOS10_10()) return; #endif diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm index 1f757dd1cbe086..1716bebecbf068 100644 --- a/ui/native_theme/native_theme_mac.mm +++ b/ui/native_theme/native_theme_mac.mm @@ -188,8 +188,8 @@ SkColor ColorToGrayscale(SkColor color) { case kColorId_MenuBackgroundColor: return kMenuPopupBackgroundColor; case kColorId_MenuSeparatorColor: - return base::mac::IsOSMavericks() ? kMenuSeparatorColorMavericks - : kMenuSeparatorColor; + return base::mac::IsOS10_9() ? kMenuSeparatorColorMavericks + : kMenuSeparatorColor; case kColorId_MenuBorderColor: return kMenuBorderColor; @@ -250,7 +250,7 @@ SkColor ColorToGrayscale(SkColor color) { const MenuBackgroundExtraParams& menu_background) const { SkPaint paint; paint.setAntiAlias(true); - if (base::mac::IsOSMavericks()) + if (base::mac::IsOS10_9()) paint.setColor(kMenuPopupBackgroundColorMavericks); else paint.setColor(kMenuPopupBackgroundColor); diff --git a/ui/native_theme/native_theme_mac_unittest.cc b/ui/native_theme/native_theme_mac_unittest.cc index cd8d49bcf9f748..5d5f748fe145eb 100644 --- a/ui/native_theme/native_theme_mac_unittest.cc +++ b/ui/native_theme/native_theme_mac_unittest.cc @@ -41,7 +41,7 @@ TEST_F(NativeThemeMacTest, SystemColorSpotChecks) { const SkColor kWindowColorYosemite = SkColorSetARGB(255, 236, 236, 236); SkColor dialogColor = native_theme->GetSystemColor(NativeTheme::kColorId_WindowBackground); - if (base::mac::IsOSYosemiteOrLater()) + if (base::mac::IsAtLeastOS10_10()) EXPECT_EQ(dialogColor, kWindowColorYosemite); else EXPECT_EQ(dialogColor, kWindowColorCatsMavericks); diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm index 7cb9c0485819be..1623e32b8ede82 100644 --- a/ui/views/cocoa/bridged_content_view.mm +++ b/ui/views/cocoa/bridged_content_view.mm @@ -345,7 +345,7 @@ - (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent { - (void)updateWindowMask { DCHECK(![self inLiveResize]); - DCHECK(base::mac::IsOSMavericks()); + DCHECK(base::mac::IsOS10_9()); DCHECK(hostedView_); views::Widget* widget = hostedView_->GetWidget(); @@ -606,7 +606,7 @@ - (void)viewDidEndLiveResize { // We prevent updating the window mask and clipping the border around the // view, during a live resize. Hence update the window mask and redraw the // view after resize has completed. - if (base::mac::IsOSMavericks()) { + if (base::mac::IsOS10_9()) { [self updateWindowMask]; [self setNeedsDisplay:YES]; } @@ -633,7 +633,7 @@ - (void)drawRect:(NSRect)dirtyRect { // crbug.com/543671. if (windowMask_ && ![self inLiveResize] && !IsRectInsidePath(dirtyRect, windowMask_)) { - DCHECK(base::mac::IsOSMavericks()); + DCHECK(base::mac::IsOS10_9()); gfx::ScopedNSGraphicsContextSaveGState state; // The outer rectangular path corresponding to the window. diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm index 22798be75c2d58..16bf01b7b0360f 100644 --- a/ui/views/cocoa/bridged_native_widget.mm +++ b/ui/views/cocoa/bridged_native_widget.mm @@ -782,7 +782,7 @@ NSComparisonResult SubviewSorter(NSViewComparatorValue lhs, // We don't update the window mask during a live resize, instead it is done // after the resize is completed in viewDidEndLiveResize: in // BridgedContentView. - if (base::mac::IsOSMavericks() && ![window_ inLiveResize]) + if (base::mac::IsOS10_9() && ![window_ inLiveResize]) [bridged_view_ updateWindowMask]; } @@ -979,7 +979,7 @@ NSComparisonResult SubviewSorter(NSViewComparatorValue lhs, // to generate a window shadow from the composited CALayer. To get around // this, let the window background remain opaque and clip the window // boundary in drawRect method of BridgedContentView. See crbug.com/543671. - if (base::mac::IsOSYosemiteOrLater()) + if (base::mac::IsAtLeastOS10_10()) [window_ setBackgroundColor:[NSColor clearColor]]; } @@ -1270,7 +1270,7 @@ NSComparisonResult SubviewSorter(NSViewComparatorValue lhs, if (widget_type_ == Widget::InitParams::TYPE_MENU) { // Giving the canvas opacity messes up subpixel font rendering, so use a // solid background, but make the CALayer transparent. - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsAtLeastOS10_10()) { [background_layer setOpacity:kYosemiteMenuOpacity]; CGSSetWindowBackgroundBlurRadius( _CGSDefaultConnection(), [window_ windowNumber], kYosemiteMenuBlur); diff --git a/ui/views/controls/menu/menu_config_mac.mm b/ui/views/controls/menu/menu_config_mac.mm index 2e00665c377a99..fc66f894436da1 100644 --- a/ui/views/controls/menu/menu_config_mac.mm +++ b/ui/views/controls/menu/menu_config_mac.mm @@ -31,9 +31,8 @@ separator_height = 13; separator_upper_height = 7; separator_lower_height = 6; - separator_thickness = base::mac::IsOSMavericks() - ? kMenuSeparatorHeightMavericks - : kMenuSeparatorHeight; + separator_thickness = base::mac::IsOS10_9() ? kMenuSeparatorHeightMavericks + : kMenuSeparatorHeight; align_arrow_and_shortcut = true; icons_in_label = true; check_selected_combobox_item = true;