OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/mac/dock.h" | 5 #import "chrome/browser/mac/dock.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <CoreFoundation/CoreFoundation.h> | 9 #include <CoreFoundation/CoreFoundation.h> |
10 #include <signal.h> | 10 #include <signal.h> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/launchd.h" |
13 #include "base/mac/mac_logging.h" | 14 #include "base/mac/mac_logging.h" |
14 #include "base/mac/mac_util.h" | 15 #include "base/mac/mac_util.h" |
15 #include "base/mac/scoped_cftyperef.h" | 16 #include "base/mac/scoped_cftyperef.h" |
16 #include "base/mac/scoped_nsautorelease_pool.h" | 17 #include "base/mac/scoped_nsautorelease_pool.h" |
17 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
18 #include "chrome/browser/mac/launchd.h" | |
19 | 19 |
20 extern "C" { | 20 extern "C" { |
21 | 21 |
22 // Undocumented private internal CFURL functions. The Dock uses these to | 22 // Undocumented private internal CFURL functions. The Dock uses these to |
23 // serialize and deserialize CFURLs for use in its plist's file-data keys. See | 23 // serialize and deserialize CFURLs for use in its plist's file-data keys. See |
24 // 10.5.8 CF-476.19 and 10.7.2 CF-635.15's CFPriv.h and CFURL.c. The property | 24 // 10.5.8 CF-476.19 and 10.7.2 CF-635.15's CFPriv.h and CFURL.c. The property |
25 // list representation will contain, at the very least, the _CFURLStringType | 25 // list representation will contain, at the very least, the _CFURLStringType |
26 // and _CFURLString keys. _CFURLStringType is a number that defines the | 26 // and _CFURLString keys. _CFURLStringType is a number that defines the |
27 // interpretation of the _CFURLString. It may be a CFURLPathStyle value, or | 27 // interpretation of the _CFURLString. It may be a CFURLPathStyle value, or |
28 // the CFURL-internal FULL_URL_REPRESENTATION value (15). Prior to Mac OS X | 28 // the CFURL-internal FULL_URL_REPRESENTATION value (15). Prior to Mac OS X |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 // Restart the Dock process by sending it a SIGHUP. | 171 // Restart the Dock process by sending it a SIGHUP. |
172 void Restart() { | 172 void Restart() { |
173 pid_t pid; | 173 pid_t pid; |
174 | 174 |
175 if (base::mac::IsOSSnowLeopardOrLater()) { | 175 if (base::mac::IsOSSnowLeopardOrLater()) { |
176 // Doing this via launchd using the proper job label is the safest way to | 176 // Doing this via launchd using the proper job label is the safest way to |
177 // handle the restart. Unlike "killall Dock", looking this up via launchd | 177 // handle the restart. Unlike "killall Dock", looking this up via launchd |
178 // guarantees that only the right process will be targeted. | 178 // guarantees that only the right process will be targeted. |
179 pid = launchd::PIDForJob("com.apple.Dock.agent"); | 179 pid = base::mac::PIDForJob("com.apple.Dock.agent"); |
180 } else { | 180 } else { |
181 // On Leopard, the Dock doesn't have a known fixed job label name as it | 181 // On Leopard, the Dock doesn't have a known fixed job label name as it |
182 // does on Snow Leopard and Lion because it's not launched as a launch | 182 // does on Snow Leopard and Lion because it's not launched as a launch |
183 // agent. Look the PID up by finding a process with the expected bundle | 183 // agent. Look the PID up by finding a process with the expected bundle |
184 // identifier using the Process Manager. | 184 // identifier using the Process Manager. |
185 pid = PIDForProcessBundleID("com.apple.dock"); | 185 pid = PIDForProcessBundleID("com.apple.dock"); |
186 } | 186 } |
187 | 187 |
188 if (pid <= 0) { | 188 if (pid <= 0) { |
189 return; | 189 return; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 | 386 |
387 // Rewrite the plist. | 387 // Rewrite the plist. |
388 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; | 388 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; |
389 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; | 389 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; |
390 | 390 |
391 Restart(); | 391 Restart(); |
392 } | 392 } |
393 | 393 |
394 } // namespace dock | 394 } // namespace dock |
OLD | NEW |