1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/image_writer/image_writer_util_mac.h"
7 #include <CoreFoundation/CoreFoundation.h>
9 #include "base/mac/scoped_cftyperef.h"
10 #include "base/mac/scoped_ioobject.h"
12 namespace extensions {
14 bool IsUsbDevice(io_object_t disk_obj) {
15 io_object_t current_obj = disk_obj;
16 io_object_t parent_obj = 0;
17 // Keep scoped object outside the loop so the object lives to the next
19 base::mac::ScopedIOObject<io_object_t> parent_obj_ref(parent_obj);
21 while ((IORegistryEntryGetParentEntry(
22 current_obj, kIOServicePlane, &parent_obj)) == KERN_SUCCESS) {
23 current_obj = parent_obj;
24 parent_obj_ref.reset(parent_obj);
26 base::ScopedCFTypeRef<CFStringRef> class_name(
27 IOObjectCopyClass(current_obj));
29 LOG(ERROR) << "Could not get object class of IO Registry Entry.";
33 if (CFStringCompare(class_name.get(), CFSTR("IOUSBMassStorageClass"), 0) ==
42 } // namespace extensions