Revert "Implement login helper to manage login item in Mac App Store build"

This commit is contained in:
Alexey Kuzmin 2017-11-16 19:05:13 +03:00 committed by GitHub
parent 668b736ef2
commit 8657169017
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 18 additions and 138 deletions

View file

@ -6,7 +6,6 @@
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#import <ServiceManagement/ServiceManagement.h>
#include "base/callback.h"
#include "base/files/file_path.h"
@ -99,10 +98,6 @@ std::string OpenURL(NSURL* ns_url, bool activate) {
return "";
}
NSString* GetLoginHelperBundleIdentifier() {
return [[[NSBundle mainBundle] bundleIdentifier] stringByAppendingString:@".loginhelper"];
}
} // namespace
namespace platform_util {
@ -182,26 +177,4 @@ void Beep() {
NSBeep();
}
bool GetLoginItemEnabled() {
BOOL enabled = NO;
// SMJobCopyDictionary does not work in sandbox (see rdar://13626319)
CFArrayRef jobs = SMCopyAllJobDictionaries(kSMDomainUserLaunchd);
NSArray* jobs_ = CFBridgingRelease(jobs);
NSString* identifier = GetLoginHelperBundleIdentifier();
if (jobs_ && [jobs_ count] > 0) {
for (NSDictionary* job in jobs_) {
if ([identifier isEqualToString:[job objectForKey:@"Label"]]) {
enabled = [[job objectForKey:@"OnDemand"] boolValue];
break;
}
}
}
return enabled;
}
void SetLoginItemEnabled(bool enabled) {
NSString* identifier = GetLoginHelperBundleIdentifier();
SMLoginItemSetEnabled((__bridge CFStringRef) identifier, enabled);
}
} // namespace platform_util