Commit 397009ea authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: remove 10.10 deployment target conditionals

This change replaces @available(macOS 10.10, *) with true and removes
API_AVAILABLE(macos(10.10)) annotations, then simplifies code where possible
as a result.

Bug: 841631
Change-Id: I55e0fbf23d836951354506f2058a419ebc95bb8b
Reviewed-on: https://chromium-review.googlesource.com/c/1437254Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626114}
parent 54fab028
...@@ -1628,8 +1628,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -1628,8 +1628,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
} }
- (BOOL)application:(NSApplication*)application - (BOOL)application:(NSApplication*)application
willContinueUserActivityWithType:(NSString*)userActivityType willContinueUserActivityWithType:(NSString*)userActivityType {
API_AVAILABLE(macos(10.10)) {
return [userActivityType isEqualToString:NSUserActivityTypeBrowsingWeb]; return [userActivityType isEqualToString:NSUserActivityTypeBrowsingWeb];
} }
...@@ -1642,7 +1641,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -1642,7 +1641,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
restorationHandler: restorationHandler:
(void (^)(NSArray<id<NSUserActivityRestoring>>*))restorationHandler (void (^)(NSArray<id<NSUserActivityRestoring>>*))restorationHandler
#endif #endif
API_AVAILABLE(macos(10.10)) { {
if (![userActivity.activityType if (![userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb]) { isEqualToString:NSUserActivityTypeBrowsingWeb]) {
return NO; return NO;
...@@ -1678,14 +1677,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -1678,14 +1677,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
} }
- (void)passURLToHandoffManager:(const GURL&)handoffURL { - (void)passURLToHandoffManager:(const GURL&)handoffURL {
if (@available(macOS 10.10, *)) { [handoffManager_ updateActiveURL:handoffURL];
[handoffManager_ updateActiveURL:handoffURL];
} else {
// Only ends up being called in 10.10+, i.e. if shouldUseHandoff returns
// true. Some tests override shouldUseHandoff to always return true, but
// then they also override this function to do something else.
NOTREACHED();
}
} }
- (void)updateHandoffManager:(content::WebContents*)webContents { - (void)updateHandoffManager:(content::WebContents*)webContents {
......
...@@ -14,10 +14,4 @@ ...@@ -14,10 +14,4 @@
: NSObject<NSMenuDelegate, NSSharingServiceDelegate> : NSObject<NSMenuDelegate, NSSharingServiceDelegate>
@end @end
@interface ShareMenuController (ExposedForTesting)
// Whether the menu should add a "More..." item that opens the
// Sharing Extension pref pane.
+ (BOOL)shouldShowMoreItem;
@end
#endif // CHROME_BROWSER_UI_COCOA_SHARE_MENU_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_SHARE_MENU_CONTROLLER_H_
...@@ -60,11 +60,7 @@ NSString* const kRemindersSharingServiceName = ...@@ -60,11 +60,7 @@ NSString* const kRemindersSharingServiceName =
base::scoped_nsobject<NSImage> snapshotForShare_; base::scoped_nsobject<NSImage> snapshotForShare_;
// The Reminders share extension reads title/URL from the currently active // The Reminders share extension reads title/URL from the currently active
// activity. // activity.
base::scoped_nsobject<NSUserActivity> activity_ API_AVAILABLE(macos(10.10)); base::scoped_nsobject<NSUserActivity> activity_;
}
+ (BOOL)shouldShowMoreItem {
return base::mac::IsAtLeastOS10_10();
} }
// NSMenuDelegate // NSMenuDelegate
...@@ -107,9 +103,6 @@ NSString* const kRemindersSharingServiceName = ...@@ -107,9 +103,6 @@ NSString* const kRemindersSharingServiceName =
[item setEnabled:canShare]; [item setEnabled:canShare];
[menu addItem:item]; [menu addItem:item];
} }
if (![[self class] shouldShowMoreItem]) {
return;
}
base::scoped_nsobject<NSMenuItem> moreItem([[NSMenuItem alloc] base::scoped_nsobject<NSMenuItem> moreItem([[NSMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_SHARING_MORE_MAC) initWithTitle:l10n_util::GetNSString(IDS_SHARING_MORE_MAC)
action:@selector(openSharingPrefs:) action:@selector(openSharingPrefs:)
...@@ -182,10 +175,8 @@ NSString* const kRemindersSharingServiceName = ...@@ -182,10 +175,8 @@ NSString* const kRemindersSharingServiceName =
windowForShare_ = nil; windowForShare_ = nil;
rectForShare_ = NSZeroRect; rectForShare_ = NSZeroRect;
snapshotForShare_.reset(); snapshotForShare_.reset();
if (@available(macOS 10.10, *)) { [activity_ invalidate];
[activity_ invalidate]; activity_.reset();
activity_.reset();
}
} }
// Performs the share action using the sharing service represented by |sender|. // Performs the share action using the sharing service represented by |sender|.
...@@ -212,24 +203,21 @@ NSString* const kRemindersSharingServiceName = ...@@ -212,24 +203,21 @@ NSString* const kRemindersSharingServiceName =
} else { } else {
itemsToShare = @[ url ]; itemsToShare = @[ url ];
} }
if (@available(macOS 10.10, *)) { if ([[service name] isEqual:kRemindersSharingServiceName]) {
if ([[service name] isEqual:kRemindersSharingServiceName]) { activity_.reset([[NSUserActivity alloc]
activity_.reset([[NSUserActivity alloc] initWithActivityType:NSUserActivityTypeBrowsingWeb]);
initWithActivityType:NSUserActivityTypeBrowsingWeb]); // webpageURL must be http or https or an exception is thrown.
// webpageURL must be http or https or an exception is thrown. if ([url.scheme hasPrefix:@"http"]) {
if ([url.scheme hasPrefix:@"http"]) { [activity_ setWebpageURL:url];
[activity_ setWebpageURL:url];
}
[activity_ setTitle:title];
[activity_ becomeCurrent];
} }
[activity_ setTitle:title];
[activity_ becomeCurrent];
} }
[service performWithItems:itemsToShare]; [service performWithItems:itemsToShare];
} }
// Opens the "Sharing" subpane of the "Extensions" macOS preference pane. // Opens the "Sharing" subpane of the "Extensions" macOS preference pane.
- (void)openSharingPrefs:(NSMenuItem*)sender { - (void)openSharingPrefs:(NSMenuItem*)sender {
DCHECK([[self class] shouldShowMoreItem]);
NSURL* prefPaneURL = NSURL* prefPaneURL =
[NSURL fileURLWithPath:kExtensionPrefPanePath isDirectory:YES]; [NSURL fileURLWithPath:kExtensionPrefPanePath isDirectory:YES];
NSDictionary* args = @{ NSDictionary* args = @{
......
...@@ -106,9 +106,6 @@ IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, PopulatesMenu) { ...@@ -106,9 +106,6 @@ IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, PopulatesMenu) {
// This cancels out, so only decrement if the "More..." item // This cancels out, so only decrement if the "More..." item
// isn't showing. // isn't showing.
NSInteger expected_count = [sharing_services_for_url count]; NSInteger expected_count = [sharing_services_for_url count];
if (![ShareMenuController shouldShowMoreItem]) {
--expected_count;
}
EXPECT_EQ([menu numberOfItems], expected_count); EXPECT_EQ([menu numberOfItems], expected_count);
NSSharingService* reading_list_service = [NSSharingService NSSharingService* reading_list_service = [NSSharingService
...@@ -131,9 +128,6 @@ IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, PopulatesMenu) { ...@@ -131,9 +128,6 @@ IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, PopulatesMenu) {
} }
IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, AddsMoreButton) { IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, AddsMoreButton) {
if (![ShareMenuController shouldShowMoreItem]) {
return;
}
base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"Share"]); base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"Share"]);
[controller_ menuNeedsUpdate:menu]; [controller_ menuNeedsUpdate:menu];
......
...@@ -30,11 +30,8 @@ void AppWindowNativeWidgetMac::PopulateCreateWindowParams( ...@@ -30,11 +30,8 @@ void AppWindowNativeWidgetMac::PopulateCreateWindowParams(
params->window_class = views_bridge_mac::mojom::WindowClass::kFrameless; params->window_class = views_bridge_mac::mojom::WindowClass::kFrameless;
params->style_mask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | params->style_mask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable; NSWindowStyleMaskResizable |
if (@available(macOS 10.10, *)) NSWindowStyleMaskFullSizeContentView;
params->style_mask |= NSWindowStyleMaskFullSizeContentView;
else
NOTREACHED();
} }
} }
......
...@@ -300,9 +300,7 @@ void BrowserFrameMac::PopulateCreateWindowParams( ...@@ -300,9 +300,7 @@ void BrowserFrameMac::PopulateCreateWindowParams(
if (browser_view_->IsBrowserTypeNormal() || if (browser_view_->IsBrowserTypeNormal() ||
browser_view_->IsBrowserTypeHostedApp()) { browser_view_->IsBrowserTypeHostedApp()) {
params->window_class = views_bridge_mac::mojom::WindowClass::kBrowser; params->window_class = views_bridge_mac::mojom::WindowClass::kBrowser;
params->style_mask |= NSFullSizeContentViewWindowMask;
if (@available(macOS 10.10, *))
params->style_mask |= NSFullSizeContentViewWindowMask;
// Ensure tabstrip/profile button are visible. // Ensure tabstrip/profile button are visible.
params->titlebar_appears_transparent = true; params->titlebar_appears_transparent = true;
......
...@@ -342,34 +342,13 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path, ...@@ -342,34 +342,13 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
} else { } else {
bool in_trash = false; bool in_trash = false;
NSFileManager* file_manager = [NSFileManager defaultManager]; NSFileManager* file_manager = [NSFileManager defaultManager];
// Apple deprecated FSDetermineIfRefIsEnclosedByFolder() when deploying to NSURLRelationship relationship;
// 10.8, but didn't add getRelationship:... until 10.10. So fall back to if ([file_manager getRelationship:&relationship
// the deprecated function while running on 10.9 (and delete the else block ofDirectory:NSTrashDirectory
// when Chromium requires OS X 10.10+). inDomain:0
if (@available(macOS 10.10, *)) { toItemAtURL:executable_fsref_
NSURLRelationship relationship; error:nil]) {
if ([file_manager getRelationship:&relationship in_trash = relationship == NSURLRelationshipContains;
ofDirectory:NSTrashDirectory
inDomain:0
toItemAtURL:executable_fsref_
error:nil]) {
in_trash = relationship == NSURLRelationshipContains;
}
} else {
DCHECK(base::mac::IsAtMostOS10_9());
Boolean fs_in_trash;
FSRef ref;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (CFURLGetFSRef(base::mac::NSToCFCast(executable_fsref_.get()), &ref)) {
// This is ok because it only happens on 10.9 and won't be needed once
// we stop supporting that.
OSErr err = FSDetermineIfRefIsEnclosedByFolder(
kOnAppropriateDisk, kTrashFolderType, &ref, &fs_in_trash);
#pragma clang diagnostic pop
if (err == noErr && fs_in_trash)
in_trash = true;
}
} }
if (in_trash) { if (in_trash) {
needs_shutdown = true; needs_shutdown = true;
......
...@@ -54,7 +54,7 @@ class SafeDMG { ...@@ -54,7 +54,7 @@ class SafeDMG {
bool EnableSandbox(); bool EnableSandbox();
// Performs the actual DMG operation. // Performs the actual DMG operation.
API_AVAILABLE(macos(10.10)) bool ParseDMG(); bool ParseDMG();
base::File dmg_file_; base::File dmg_file_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment