Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2816)

Unified Diff: chrome/common/extensions/image_writer/image_writer_util_mac.cc

Issue 375703004: Changes Mac removable device listing to include all attached USB drives. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes minor style issues and documentation. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/image_writer/image_writer_util_mac.cc
diff --git a/chrome/common/extensions/image_writer/image_writer_util_mac.cc b/chrome/common/extensions/image_writer/image_writer_util_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70f4460505470bb2650e5461c0bf3a46fbdd23d6
--- /dev/null
+++ b/chrome/common/extensions/image_writer/image_writer_util_mac.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/image_writer/image_writer_util_mac.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "base/mac/scoped_cftyperef.h"
+#include "base/mac/scoped_ioobject.h"
+
+namespace extensions {
+
+bool IsUsbDevice(io_object_t disk_obj) {
+ io_object_t current_obj = disk_obj;
+ io_object_t parent_obj = 0;
+ // Keep scoped object outside the loop so the object lives to the next
+ // GetParentEntry.
+ base::mac::ScopedIOObject<io_object_t> parent_obj_ref(parent_obj);
+
+ while ((IORegistryEntryGetParentEntry(
+ current_obj, kIOServicePlane, &parent_obj)) == KERN_SUCCESS) {
+ current_obj = parent_obj;
+ parent_obj_ref.reset(parent_obj);
+
+ base::ScopedCFTypeRef<CFStringRef> class_name(
+ IOObjectCopyClass(current_obj));
+ if (!class_name) {
+ LOG(ERROR) << "Could not get object class of IO Registry Entry.";
+ continue;
+ }
+
+ if (CFStringCompare(class_name.get(), CFSTR("IOUSBMassStorageClass"), 0) ==
+ kCFCompareEqualTo) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/common/extensions/image_writer/image_writer_util_mac.h ('k') | chrome/utility/image_writer/image_writer_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698