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 #include "chrome/browser/mac/install_from_dmg.h" | 5 #include "chrome/browser/mac/install_from_dmg.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
9 #include <CoreFoundation/CoreFoundation.h> | 9 #include <CoreFoundation/CoreFoundation.h> |
10 #include <CoreServices/CoreServices.h> | 10 #include <CoreServices/CoreServices.h> |
11 #include <DiskArbitration/DiskArbitration.h> | 11 #include <DiskArbitration/DiskArbitration.h> |
12 #include <IOKit/IOKitLib.h> | 12 #include <IOKit/IOKitLib.h> |
13 #include <signal.h> | 13 #include <signal.h> |
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 #include <string.h> | 15 #include <string.h> |
16 #include <sys/param.h> | 16 #include <sys/param.h> |
17 #include <sys/mount.h> | 17 #include <sys/mount.h> |
18 | 18 |
19 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/mac/authorization_util.h" | 24 #include "base/mac/authorization_util.h" |
25 #include "base/mac/bundle_locations.h" | 25 #include "base/mac/bundle_locations.h" |
26 #include "base/mac/mac_logging.h" | 26 #include "base/mac/mac_logging.h" |
27 #include "base/mac/mach_logging.h" | |
28 #import "base/mac/mac_util.h" | 27 #import "base/mac/mac_util.h" |
29 #include "base/mac/scoped_authorizationref.h" | 28 #include "base/mac/scoped_authorizationref.h" |
30 #include "base/mac/scoped_cftyperef.h" | 29 #include "base/mac/scoped_cftyperef.h" |
31 #include "base/mac/scoped_ioobject.h" | 30 #include "base/mac/scoped_ioobject.h" |
32 #include "base/mac/scoped_nsautorelease_pool.h" | 31 #include "base/mac/scoped_nsautorelease_pool.h" |
33 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
34 #include "base/strings/sys_string_conversions.h" | 33 #include "base/strings/sys_string_conversions.h" |
35 #include "chrome/browser/mac/dock.h" | 34 #include "chrome/browser/mac/dock.h" |
36 #import "chrome/browser/mac/keystone_glue.h" | 35 #import "chrome/browser/mac/keystone_glue.h" |
37 #include "chrome/browser/mac/relauncher.h" | 36 #include "chrome/browser/mac/relauncher.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 74 } |
76 | 75 |
77 io_iterator_t iterator_ref; | 76 io_iterator_t iterator_ref; |
78 kern_return_t kr = | 77 kern_return_t kr = |
79 IORegistryEntryCreateIterator(media, | 78 IORegistryEntryCreateIterator(media, |
80 kIOServicePlane, | 79 kIOServicePlane, |
81 kIORegistryIterateRecursively | | 80 kIORegistryIterateRecursively | |
82 kIORegistryIterateParents, | 81 kIORegistryIterateParents, |
83 &iterator_ref); | 82 &iterator_ref); |
84 if (kr != KERN_SUCCESS) { | 83 if (kr != KERN_SUCCESS) { |
85 MACH_LOG(ERROR, kr) << "IORegistryEntryCreateIterator"; | 84 LOG(ERROR) << "IORegistryEntryCreateIterator: " << kr; |
86 return IO_OBJECT_NULL; | 85 return IO_OBJECT_NULL; |
87 } | 86 } |
88 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); | 87 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); |
89 iterator_ref = IO_OBJECT_NULL; | 88 iterator_ref = IO_OBJECT_NULL; |
90 | 89 |
91 // Look at each of the ancestor services, beginning with the parent, | 90 // Look at each of the ancestor services, beginning with the parent, |
92 // iterating all the way up to the device tree's root. If any ancestor | 91 // iterating all the way up to the device tree's root. If any ancestor |
93 // service matches the class used for disk images, the media resides on a | 92 // service matches the class used for disk images, the media resides on a |
94 // disk image, and the disk image file's path can be determined by examining | 93 // disk image, and the disk image file's path can be determined by examining |
95 // the image-path property. | 94 // the image-path property. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (!match_dict) { | 200 if (!match_dict) { |
202 LOG(ERROR) << "IOBSDNameMatching " << dmg_bsd_device_name; | 201 LOG(ERROR) << "IOBSDNameMatching " << dmg_bsd_device_name; |
203 return false; | 202 return false; |
204 } | 203 } |
205 | 204 |
206 io_iterator_t iterator_ref; | 205 io_iterator_t iterator_ref; |
207 kern_return_t kr = IOServiceGetMatchingServices(master_port, | 206 kern_return_t kr = IOServiceGetMatchingServices(master_port, |
208 match_dict, | 207 match_dict, |
209 &iterator_ref); | 208 &iterator_ref); |
210 if (kr != KERN_SUCCESS) { | 209 if (kr != KERN_SUCCESS) { |
211 MACH_LOG(ERROR, kr) << "IOServiceGetMatchingServices"; | 210 LOG(ERROR) << "IOServiceGetMatchingServices: " << kr; |
212 return false; | 211 return false; |
213 } | 212 } |
214 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); | 213 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); |
215 iterator_ref = IO_OBJECT_NULL; | 214 iterator_ref = IO_OBJECT_NULL; |
216 | 215 |
217 // There needs to be exactly one matching service. | 216 // There needs to be exactly one matching service. |
218 base::mac::ScopedIOObject<io_service_t> media(IOIteratorNext(iterator)); | 217 base::mac::ScopedIOObject<io_service_t> media(IOIteratorNext(iterator)); |
219 if (!media) { | 218 if (!media) { |
220 LOG(ERROR) << "IOIteratorNext: no service"; | 219 LOG(ERROR) << "IOIteratorNext: no service"; |
221 return false; | 220 return false; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( | 677 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( |
679 trash_path.value().c_str()); | 678 trash_path.value().c_str()); |
680 status = FNNotifyByPath(trash_path_u8, | 679 status = FNNotifyByPath(trash_path_u8, |
681 kFNDirectoryModifiedMessage, | 680 kFNDirectoryModifiedMessage, |
682 kNilOptions); | 681 kNilOptions); |
683 if (status != noErr) { | 682 if (status != noErr) { |
684 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath"; | 683 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath"; |
685 return; | 684 return; |
686 } | 685 } |
687 } | 686 } |
OLD | NEW |