Commit 500c212a authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Update Universal Links for using the 10.15 SDK.

BUG=1023913

Change-Id: Ibfcc2411221e05e0318c4924173792df0b41d72a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031761
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742397}
parent 8a0e0dc4
......@@ -84,18 +84,6 @@ BASE_EXPORT extern "C" NSString* const kCWSSIDDidChangeNotification;
API_AVAILABLE(macos(10.15));
@end
NS_CLASS_AVAILABLE_MAC(10_15)
@interface SFUniversalLink : NSObject
- (instancetype)initWithWebpageURL:(NSURL*)url;
@property(readonly) NSURL* webpageURL;
@property(readonly) NSURL* applicationURL;
@property(getter=isEnabled) BOOL enabled;
@end
#else
#import <SafariServices/SafariServices.h>
#endif // MAC_OS_X_VERSION_10_15
......
......@@ -4106,6 +4106,7 @@ jumbo_static_library("browser") {
"ImageCaptureCore.framework",
"OpenGL.framework",
"QuartzCore.framework",
"SafariServices.framework",
"SecurityInterface.framework",
]
}
......
......@@ -5,9 +5,8 @@
#include "chrome/browser/apps/intent_helper/mac_apps_navigation_throttle.h"
#import <Cocoa/Cocoa.h>
#include <dlfcn.h>
#import <SafariServices/SafariServices.h>
#include "base/mac/sdk_forward_declarations.h"
#include "base/optional.h"
#include "base/strings/sys_string_conversions.h"
#include "content/public/browser/navigation_handle.h"
......@@ -17,10 +16,6 @@ namespace apps {
namespace {
const char kSafariServicesFrameworkPath[] =
"/System/Library/Frameworks/SafariServices.framework/"
"Versions/Current/SafariServices";
IntentPickerAppInfo AppInfoForAppUrl(NSURL* app_url) {
NSString* app_name = nil;
if (![app_url getResourceValue:&app_name
......@@ -43,30 +38,14 @@ IntentPickerAppInfo AppInfoForAppUrl(NSURL* app_url) {
base::SysNSStringToUTF8(app_name));
}
// TODO(avi): When we move to the 10.15 SDK, use correct weak-linking of this
// framework rather than dlopen(), and correct @available syntax to access this
// class.
SFUniversalLink* API_AVAILABLE(macos(10.15)) GetUniversalLink(const GURL& url) {
static void* safari_services = []() -> void* {
return dlopen(kSafariServicesFrameworkPath, RTLD_LAZY);
}();
static const Class SFUniversalLink_class =
NSClassFromString(@"SFUniversalLink");
if (!safari_services || !SFUniversalLink_class)
return nil;
NSURL* nsurl = net::NSURLWithGURL(url);
if (!nsurl)
return nil;
return [[[SFUniversalLink_class alloc] initWithWebpageURL:nsurl] autorelease];
}
base::Optional<IntentPickerAppInfo> AppInfoForUrl(const GURL& url) {
if (@available(macOS 10.15, *)) {
SFUniversalLink* link = GetUniversalLink(url);
NSURL* nsurl = net::NSURLWithGURL(url);
if (!nsurl)
return base::nullopt;
SFUniversalLink* link =
[[[SFUniversalLink alloc] initWithWebpageURL:nsurl] autorelease];
if (link)
return AppInfoForAppUrl(link.applicationURL);
}
......@@ -175,4 +154,4 @@ IntentPickerResponse MacAppsNavigationThrottle::GetOnPickerClosedCallback(
ui_auto_display_service, url);
}
} // namespace apps
\ No newline at end of file
} // namespace apps
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