Skip to content

Commit

Permalink
mac: Remove more 10.5-only code
Browse files Browse the repository at this point in the history
BUG=137676
TBR=jamiewalch,tony

Review URL: https://chromiumcodereview.appspot.com/10825302

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151142 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Aug 10, 2012
1 parent 8e87c36 commit 59e82f0
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 133 deletions.
9 changes: 0 additions & 9 deletions base/mac/mac_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ BASE_EXPORT bool WasLaunchedAsHiddenLoginItem();

// Snow Leopard is Mac OS X 10.6, Darwin 10.
BASE_EXPORT bool IsOSSnowLeopard();
BASE_EXPORT bool IsOSSnowLeopardOrEarlier();
BASE_EXPORT bool IsOSSnowLeopardOrLater();

// Lion is Mac OS X 10.7, Darwin 11.
BASE_EXPORT bool IsOSLion();
Expand All @@ -151,17 +149,10 @@ BASE_EXPORT
// 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 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 IsOSSnowLeopard() { return false; }
inline bool IsOSSnowLeopardOrEarlier() { return false; }
inline bool IsOSLionOrLater() { return true; }
#endif

Expand Down
14 changes: 1 addition & 13 deletions base/mac/mac_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ bool WasLaunchedAsHiddenLoginItem() {
if (!item.get()) {
// Lion can launch items for the resume feature. So log an error only for
// Snow Leopard or earlier.
if (IsOSSnowLeopardOrEarlier())
if (IsOSSnowLeopard())
DLOG(ERROR) <<
"Process launched at Login but can't access Login Item List.";

Expand Down Expand Up @@ -573,18 +573,6 @@ bool IsOSSnowLeopard() {
}
#endif

#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

#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
bool IsOSLion() {
return MacOSXMinorVersion() == LION_MINOR_VERSION;
Expand Down
6 changes: 0 additions & 6 deletions base/mac/mac_util_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@
if (major == 10) {
if (minor == 6) {
EXPECT_TRUE(IsOSSnowLeopard());
EXPECT_TRUE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_FALSE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_FALSE(IsOSLionOrLater());
Expand All @@ -164,8 +162,6 @@
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else if (minor == 7) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_TRUE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater());
Expand All @@ -175,8 +171,6 @@
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else if (minor == 8) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_FALSE(IsOSLion());
EXPECT_FALSE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater());
Expand Down
17 changes: 8 additions & 9 deletions chrome/browser/ui/cocoa/browser_window_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt {

// Set the window to not have rounded corners, which prevents the resize
// control from being inset slightly and looking ugly. Only bother to do
// this on Snow Leopard and earlier; on Lion and later all windows have
// rounded bottom corners, and this won't work anyway.
if (base::mac::IsOSSnowLeopardOrEarlier() &&
// this on Snow Leopard; on Lion and later all windows have rounded bottom
// corners, and this won't work anyway.
if (base::mac::IsOSSnowLeopard() &&
[window respondsToSelector:@selector(setBottomCornerRounded:)])
[window setBottomCornerRounded:NO];

Expand Down Expand Up @@ -1045,7 +1045,7 @@ - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
IDS_ENTER_FULLSCREEN_MAC);
[static_cast<NSMenuItem*>(item) setTitle:menuTitle];

if (base::mac::IsOSSnowLeopardOrEarlier())
if (base::mac::IsOSSnowLeopard())
[static_cast<NSMenuItem*>(item) setHidden:YES];
}
break;
Expand Down Expand Up @@ -1981,9 +1981,9 @@ - (void)setFullscreen:(BOOL)fullscreen
[static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen];
} else {
if (fullscreen)
[self enterFullscreenForSnowLeopardOrEarlier];
[self enterFullscreenForSnowLeopard];
else
[self exitFullscreenForSnowLeopardOrEarlier];
[self exitFullscreenForSnowLeopard];
}
}

Expand Down Expand Up @@ -2022,9 +2022,8 @@ - (void)setPresentationMode:(BOOL)presentationMode
fullscreenUrl_ = url;
fullscreenBubbleType_ = bubbleType;

// Presentation mode on Leopard and Snow Leopard maps directly to fullscreen
// mode.
if (base::mac::IsOSSnowLeopardOrEarlier()) {
// Presentation mode on Snow Leopard maps directly to fullscreen mode.
if (base::mac::IsOSSnowLeopard()) {
[self setFullscreen:presentationMode url:url bubbleType:bubbleType];
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CreateProfileCallback(const base::Closure& quit_closure,
// correctly.
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
ProfileAvatarFullscreenButton) {
if (base::mac::IsOSSnowLeopardOrEarlier())
if (base::mac::IsOSSnowLeopard())
return;

// Initialize the locals.
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/ui/cocoa/browser_window_controller_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
- (BOOL)shouldShowPresentationModeToggle;

// Moves views between windows in preparation for fullscreen mode on Snow
// Leopard or earlier. (Lion and later reuses the original window for
// Leopard. (Lion and later reuses the original window for
// fullscreen mode, so there is no need to move views around.) This method does
// not position views; callers must also call |-layoutSubviews|. This method
// must not be called on Lion or later.
- (void)moveViewsForFullscreenForSnowLeopardOrEarlier:(BOOL)fullscreen
regularWindow:(NSWindow*)regularWindow
fullscreenWindow:(NSWindow*)fullscreenWindow;
- (void)moveViewsForFullscreenForSnowLeopard:(BOOL)fullscreen
regularWindow:(NSWindow*)regularWindow
fullscreenWindow:(NSWindow*)fullscreenWindow;

// Sets presentation mode, creating the PresentationModeController if needed and
// forcing a relayout. If |forceDropdown| is YES, this method will always
Expand All @@ -129,8 +129,8 @@
// Called on Snow Leopard or earlier to enter or exit fullscreen. These methods
// are internal implementations of |-setFullscreen:|. These methods must not be
// called on Lion or later.
- (void)enterFullscreenForSnowLeopardOrEarlier;
- (void)exitFullscreenForSnowLeopardOrEarlier;
- (void)enterFullscreenForSnowLeopard;
- (void)exitFullscreenForSnowLeopard;

// Register or deregister for content view resize notifications. These
// notifications are used while transitioning to fullscreen mode in Lion or
Expand Down
22 changes: 11 additions & 11 deletions chrome/browser/ui/cocoa/browser_window_controller_private.mm
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ - (BOOL)shouldShowPresentationModeToggle {
return base::mac::IsOSLionOrLater() && [self isFullscreen];
}

- (void)moveViewsForFullscreenForSnowLeopardOrEarlier:(BOOL)fullscreen
- (void)moveViewsForFullscreenForSnowLeopard:(BOOL)fullscreen
regularWindow:(NSWindow*)regularWindow
fullscreenWindow:(NSWindow*)fullscreenWindow {
// This method is only for Snow Leopard and earlier.
DCHECK(base::mac::IsOSSnowLeopardOrEarlier());
// This method is only for Snow Leopard.
DCHECK(base::mac::IsOSSnowLeopard());

NSWindow* sourceWindow = fullscreen ? regularWindow : fullscreenWindow;
NSWindow* destWindow = fullscreen ? fullscreenWindow : regularWindow;
Expand Down Expand Up @@ -634,8 +634,8 @@ - (void)setPresentationModeInternal:(BOOL)presentationMode
[self layoutSubviews];
}

- (void)enterFullscreenForSnowLeopardOrEarlier {
DCHECK(base::mac::IsOSSnowLeopardOrEarlier());
- (void)enterFullscreenForSnowLeopard {
DCHECK(base::mac::IsOSSnowLeopard());

// Fade to black.
const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
Expand All @@ -654,9 +654,9 @@ - (void)enterFullscreenForSnowLeopardOrEarlier {
savedRegularWindow_ = [[self window] retain];
savedRegularWindowFrame_ = [savedRegularWindow_ frame];

[self moveViewsForFullscreenForSnowLeopardOrEarlier:YES
regularWindow:[self window]
fullscreenWindow:fullscreenWindow_.get()];
[self moveViewsForFullscreenForSnowLeopard:YES
regularWindow:[self window]
fullscreenWindow:fullscreenWindow_.get()];
[self adjustUIForPresentationMode:YES];
[self setPresentationModeInternal:YES forceDropdown:NO];
[self layoutSubviews];
Expand All @@ -671,8 +671,8 @@ - (void)enterFullscreenForSnowLeopardOrEarlier {
}
}

- (void)exitFullscreenForSnowLeopardOrEarlier {
DCHECK(base::mac::IsOSSnowLeopardOrEarlier());
- (void)exitFullscreenForSnowLeopard {
DCHECK(base::mac::IsOSSnowLeopard());

// Fade to black.
const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
Expand All @@ -687,7 +687,7 @@ - (void)exitFullscreenForSnowLeopardOrEarlier {

[self windowWillExitFullScreen:nil];

[self moveViewsForFullscreenForSnowLeopardOrEarlier:NO
[self moveViewsForFullscreenForSnowLeopard:NO
regularWindow:savedRegularWindow_
fullscreenWindow:fullscreenWindow_.get()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void WaitForFullScreenTransition() {
[controller_ activate];

// No fullscreen window on 10.7+.
if (base::mac::IsOSSnowLeopardOrEarlier())
if (base::mac::IsOSSnowLeopard())
EXPECT_TRUE(IsFrontWindow([controller_ createFullscreenWindow]));

// We have to cleanup after ourselves by unfullscreening.
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
[window setContentMaxSize:NSMakeSize(max_width, max_height)];
}

if (base::mac::IsOSSnowLeopardOrEarlier() &&
if (base::mac::IsOSSnowLeopard() &&
[window respondsToSelector:@selector(setBottomCornerRounded:)])
[window setBottomCornerRounded:NO];

Expand Down Expand Up @@ -200,7 +200,7 @@ - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
return;
}

DCHECK(base::mac::IsOSSnowLeopardOrEarlier());
DCHECK(base::mac::IsOSSnowLeopard());

// Fade to black.
const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/cocoa/presentation_mode_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ - (void)enterPresentationModeForContentView:(NSView*)contentView
// Disable these notifications on Lion as they cause crashes.
// TODO(rohitrao): Figure out what happens if a fullscreen window changes
// monitors on Lion.
if (base::mac::IsOSSnowLeopardOrEarlier()) {
if (base::mac::IsOSSnowLeopard()) {
[nc addObserver:self
selector:@selector(windowDidChangeScreen:)
name:NSWindowDidChangeScreenNotification
Expand Down Expand Up @@ -421,7 +421,7 @@ - (BOOL)isWindowOnPrimaryScreen {
}

- (BOOL)shouldToggleMenuBar {
return base::mac::IsOSSnowLeopardOrEarlier() &&
return base::mac::IsOSSnowLeopard() &&
[self isWindowOnPrimaryScreen] &&
[[browserController_ window] isMainWindow];
}
Expand Down
2 changes: 1 addition & 1 deletion content/common/sandbox_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ NOINLINE void FatalStringQuoteException(const std::string& str) {
// dlopen() fails without file-read-metadata access if the executable image
// contains LC_RPATH load commands. The components build uses those.
// See http://crbug.com/127465
if (base::mac::IsOSSnowLeopardOrEarlier()) {
if (base::mac::IsOSSnowLeopard()) {
FilePath bundle_executable = base::mac::NSStringToFilePath(
[base::mac::MainBundle() executablePath]);
NSString* sandbox_command = AllowMetadataForPath(
Expand Down
27 changes: 17 additions & 10 deletions content/renderer/renderer_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,23 @@ void InstallFrameworkHacks() {
// 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 (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.
mach_error_t err = mach_override_ptr(
(void*)&TISCreateInputSourceList,
(void*)&ChromeTISCreateInputSourceList,
NULL);
CHECK_EQ(err_none, err);
}
// To check if this is broken:
// 1. Enable Multi language input (simplified chinese)
// 2. Ensure "Show/Hide Trackpad Handwriting" shortcut works.
// (ctrl+shift+space).
// 3. Now open a new tab in Google Chrome or start Google Chrome
// 4. Try ctrl+shift+space shortcut again. Shortcut will not work, IME will
// either not appear or (worse) not disappear on ctrl-shift-space.
// (Run `ps aux | grep Chinese` (10.6/10.7) or `ps aux | grep Trackpad`
// and then kill that pid to make it go away.)

// Chinese Handwriting was introduced in 10.6 and is confirmed broken on
// 10.6, 10.7, and 10.8.
mach_error_t err = mach_override_ptr(
(void*)&TISCreateInputSourceList,
(void*)&ChromeTISCreateInputSourceList,
NULL);
CHECK_EQ(err_none, err);
}

#endif // OS_MACOSX
Expand Down
2 changes: 1 addition & 1 deletion printing/pdf_metafile_cg_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PdfMetafileCg::PdfMetafileCg()
: page_is_open_(false),
thread_pdf_docs_owned_(false) {
if (!thread_pdf_docs.Pointer()->Get() &&
base::mac::IsOSSnowLeopardOrEarlier()) {
base::mac::IsOSSnowLeopard()) {
thread_pdf_docs_owned_ = true;
thread_pdf_docs.Pointer()->Set(
CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks));
Expand Down
3 changes: 0 additions & 3 deletions remoting/host/plugin/daemon_controller_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ void DaemonControllerMac::DeregisterForPreferencePaneNotifications() {
}

DaemonController::State DaemonControllerMac::GetState() {
if (!base::mac::IsOSSnowLeopardOrLater()) {
return DaemonController::STATE_NOT_IMPLEMENTED;
}
pid_t job_pid = base::mac::PIDForJob(kServiceName);
if (job_pid < 0) {
return DaemonController::STATE_NOT_INSTALLED;
Expand Down
18 changes: 0 additions & 18 deletions remoting/host/video_frame_capturer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ namespace remoting {

namespace {

bool IsOsSupported() {
#if defined(OS_MACOSX)
// Verify that the OS is at least Snow Leopard (10.6).
// Chromoting doesn't support 10.5 or earlier.
return base::mac::IsOSSnowLeopardOrLater();
#else
return true;
#endif
}

void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) {
}

Expand All @@ -53,19 +43,11 @@ class VideoFrameCapturerTest : public testing::Test {
};

TEST_F(VideoFrameCapturerTest, StartCapturer) {
if (!IsOsSupported()) {
return;
}

capturer_->Start(base::Bind(&IgnoreCursorShapeChanged));
capturer_->Stop();
}

TEST_F(VideoFrameCapturerTest, Capture) {
if (!IsOsSupported()) {
return;
}

// Assume that Start() treats the screen as invalid initially.
EXPECT_CALL(capture_completed_callback_,
CaptureCompletedPtr(DirtyRegionIsNonEmptyRect()));
Expand Down
Loading

0 comments on commit 59e82f0

Please sign in to comment.