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

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

Issue 294163008: Adds USB writing for OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@list-devices
Patch Set: Creates a location for code shared between browser and utility process. Created 6 years, 6 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_test_util_mac.cc
diff --git a/chrome/common/extensions/image_writer/image_writer_test_util_mac.cc b/chrome/common/extensions/image_writer/image_writer_test_util_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..871418e00a534245f0017f533ac3c0fc0976c11d
--- /dev/null
+++ b/chrome/common/extensions/image_writer/image_writer_test_util_mac.cc
@@ -0,0 +1,102 @@
+// 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_test_util_mac.h"
+
+namespace extensions {
+namespace image_writer {
+
+// Creates a disk-description dictionary.
+base::ScopedCFTypeRef<CFDictionaryRef> CreateDiskDictionary(
+ const std::string& bsd_name,
+ const std::string& vendor,
+ const std::string& model,
+ int64 capacity,
+ DriveType type) {
+ base::ScopedCFTypeRef<CFMutableDictionaryRef> dict(
+ CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks));
+
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionMediaBSDNameKey,
+ base::SysUTF8ToCFStringRef(bsd_name));
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceVendorKey,
+ base::SysUTF8ToCFStringRef(vendor));
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceModelKey,
+ base::SysUTF8ToCFStringRef(model));
+ CFDictionaryAddValue(dict, kDADiskDescriptionMediaWholeKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict,
+ kDADiskDescriptionMediaSizeKey,
+ CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &capacity));
+
+ if (type == DriveType::FIXED) {
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceProtocolKey,
+ CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanFalse);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanFalse);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDevicePathKey, CFSTR("Fixed Device Path"));
+ } else if (type == DriveType::USB) {
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceProtocolKey,
+ CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDevicePathKey, CFSTR("USB Device Path"));
+ } else if (type == DriveType::CD) {
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceProtocolKey,
+ CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaKindKey, CFSTR("IOCDMedia"));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDevicePathKey, CFSTR("CD Device Path"));
+ } else if (type == DriveType::SD) {
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDeviceProtocolKey,
+ CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
+ CFDictionaryAddValue(
+ dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
+ CFDictionaryAddValue(dict,
+ kDADiskDescriptionDevicePathKey,
+ CFSTR("SD Device Path e.g. AppleUSBCardReader"));
+ }
+
+ return base::ScopedCFTypeRef<CFDictionaryRef>(dict,
+ base::scoped_policy::RETAIN);
+}
+
+} // image_writer
+} // extensions

Powered by Google App Engine
This is Rietveld 408576698