clang-format objc files (#12673)

This commit is contained in:
Shelley Vohr 2018-04-20 14:47:04 -04:00 committed by Charles Kerr
parent 94236bf4eb
commit 12a57ff1c2
54 changed files with 1298 additions and 1033 deletions

View file

@ -75,9 +75,7 @@ std::string MessageForOSStatus(OSStatus status, const char* default_message) {
std::string OpenURL(NSURL* ns_url, bool activate) {
CFURLRef openingApp = nullptr;
OSStatus status = LSGetApplicationForURL(base::mac::NSToCFCast(ns_url),
kLSRolesAll,
nullptr,
&openingApp);
kLSRolesAll, nullptr, &openingApp);
if (status != noErr)
return MessageForOSStatus(status, "Failed to open");
@ -87,12 +85,11 @@ std::string OpenURL(NSURL* ns_url, bool activate) {
if (!activate)
launchOptions |= NSWorkspaceLaunchWithoutActivation;
bool opened = [[NSWorkspace sharedWorkspace]
openURLs:@[ns_url]
withAppBundleIdentifier:nil
options:launchOptions
additionalEventParamDescriptor:nil
launchIdentifiers:nil];
bool opened = [[NSWorkspace sharedWorkspace] openURLs:@[ ns_url ]
withAppBundleIdentifier:nil
options:launchOptions
additionalEventParamDescriptor:nil
launchIdentifiers:nil];
if (!opened)
return "Failed to open URL";
@ -100,7 +97,8 @@ std::string OpenURL(NSURL* ns_url, bool activate) {
}
NSString* GetLoginHelperBundleIdentifier() {
return [[[NSBundle mainBundle] bundleIdentifier] stringByAppendingString:@".loginhelper"];
return [[[NSBundle mainBundle] bundleIdentifier]
stringByAppendingString:@".loginhelper"];
}
} // namespace
@ -135,10 +133,10 @@ bool OpenItem(const base::FilePath& full_path) {
const NSWorkspaceLaunchOptions launch_options =
NSWorkspaceLaunchAsync | NSWorkspaceLaunchWithErrorPresentation;
return [[NSWorkspace sharedWorkspace] openURLs:@[ url ]
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
}
bool OpenExternal(const GURL& url, bool activate) {
@ -149,7 +147,8 @@ bool OpenExternal(const GURL& url, bool activate) {
return false;
}
void OpenExternal(const GURL& url, bool activate,
void OpenExternal(const GURL& url,
bool activate,
const OpenExternalCallback& callback) {
NSURL* ns_url = net::NSURLWithGURL(url);
if (!ns_url) {
@ -158,20 +157,21 @@ void OpenExternal(const GURL& url, bool activate,
}
__block OpenExternalCallback c = callback;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
__block std::string error = OpenURL(ns_url, activate);
dispatch_async(dispatch_get_main_queue(), ^{
c.Run(error);
});
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
__block std::string error = OpenURL(ns_url, activate);
dispatch_async(dispatch_get_main_queue(), ^{
c.Run(error);
});
});
}
bool MoveItemToTrash(const base::FilePath& full_path) {
NSString* path_string = base::SysUTF8ToNSString(full_path.value());
BOOL status = [[NSFileManager defaultManager]
trashItemAtURL:[NSURL fileURLWithPath:path_string]
resultingItemURL:nil
error:nil];
trashItemAtURL:[NSURL fileURLWithPath:path_string]
resultingItemURL:nil
error:nil];
if (!path_string || !status)
LOG(WARNING) << "NSWorkspace failed to move file " << full_path.value()
<< " to trash";
@ -201,7 +201,7 @@ bool GetLoginItemEnabled() {
void SetLoginItemEnabled(bool enabled) {
NSString* identifier = GetLoginHelperBundleIdentifier();
SMLoginItemSetEnabled((__bridge CFStringRef) identifier, enabled);
SMLoginItemSetEnabled((__bridge CFStringRef)identifier, enabled);
}
} // namespace platform_util