OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/launchd_mac.h" | 5 #include "chrome/common/launchd_mac.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <launch.h> | 8 #include <launch.h> |
9 | 9 |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 ns_path = SanitizeShellArgument(ns_path); | 113 ns_path = SanitizeShellArgument(ns_path); |
114 const char* file_path = [ns_path fileSystemRepresentation]; | 114 const char* file_path = [ns_path fileSystemRepresentation]; |
115 | 115 |
116 NSString* ns_session_type = | 116 NSString* ns_session_type = |
117 SanitizeShellArgument(base::mac::CFToNSCast(cf_session_type)); | 117 SanitizeShellArgument(base::mac::CFToNSCast(cf_session_type)); |
118 if (!file_path || !ns_session_type) { | 118 if (!file_path || !ns_session_type) { |
119 return false; | 119 return false; |
120 } | 120 } |
121 | 121 |
122 std::vector<std::string> argv; | 122 std::vector<std::string> argv; |
123 argv.push_back("/bin/bash"); | 123 argv.push_back("/bin/bash"); |
Mark Mentovai
2011/06/29 21:58:37
This function is absolute crap anyway. I just wrot
Evan Martin
2011/06/29 22:02:55
Ah, feel free to land that before I land this, sin
| |
124 argv.push_back("--noprofile"); | 124 argv.push_back("--noprofile"); |
125 argv.push_back("-c"); | 125 argv.push_back("-c"); |
126 std::string command = base::StringPrintf( | 126 std::string command = base::StringPrintf( |
127 "/bin/launchctl unload -S %s %s;" | 127 "/bin/launchctl unload -S %s %s;" |
128 "/bin/launchctl load -S %s %s;", | 128 "/bin/launchctl load -S %s %s;", |
129 [ns_session_type UTF8String], file_path, | 129 [ns_session_type UTF8String], file_path, |
130 [ns_session_type UTF8String], file_path); | 130 [ns_session_type UTF8String], file_path); |
131 argv.push_back(command); | 131 argv.push_back(command); |
132 base::ProcessHandle handle; | 132 |
133 return base::LaunchAppInNewProcessGroup(argv, | 133 base::LaunchOptions options; |
134 base::environment_vector(), | 134 options.new_process_group = true; |
135 base::file_handle_mapping_vector(), | 135 return base::LaunchApp(argv, options); |
136 NO, | |
137 &handle); | |
138 } | 136 } |
139 | 137 |
140 CFMutableDictionaryRef Launchd::CreatePlistFromFile(Domain domain, | 138 CFMutableDictionaryRef Launchd::CreatePlistFromFile(Domain domain, |
141 Type type, | 139 Type type, |
142 CFStringRef name) { | 140 CFStringRef name) { |
143 base::mac::ScopedNSAutoreleasePool pool; | 141 base::mac::ScopedNSAutoreleasePool pool; |
144 NSURL* ns_url = GetPlistURL(domain, type, name); | 142 NSURL* ns_url = GetPlistURL(domain, type, name); |
145 NSMutableDictionary* plist = | 143 NSMutableDictionary* plist = |
146 [[NSMutableDictionary alloc] initWithContentsOfURL:ns_url]; | 144 [[NSMutableDictionary alloc] initWithContentsOfURL:ns_url]; |
147 return base::mac::NSToCFCast(plist); | 145 return base::mac::NSToCFCast(plist); |
(...skipping 14 matching lines...) Expand all Loading... | |
162 NSError* err = nil; | 160 NSError* err = nil; |
163 if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path] | 161 if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path] |
164 error:&err]) { | 162 error:&err]) { |
165 if ([err code] != NSFileNoSuchFileError) { | 163 if ([err code] != NSFileNoSuchFileError) { |
166 LOG(ERROR) << "DeletePlist: " << base::mac::NSToCFCast(err); | 164 LOG(ERROR) << "DeletePlist: " << base::mac::NSToCFCast(err); |
167 } | 165 } |
168 return false; | 166 return false; |
169 } | 167 } |
170 return true; | 168 return true; |
171 } | 169 } |
OLD | NEW |