Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / common / extensions / image_writer / image_writer_util_mac.cc
blob70f4460505470bb2650e5461c0bf3a46fbdd23d6
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
18 // GetParentEntry.
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));
28 if (!class_name) {
29 LOG(ERROR) << "Could not get object class of IO Registry Entry.";
30 continue;
33 if (CFStringCompare(class_name.get(), CFSTR("IOUSBMassStorageClass"), 0) ==
34 kCFCompareEqualTo) {
35 return true;
39 return false;
42 } // namespace extensions