| Index: chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.cc
|
| diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.cc
|
| index c59c6b4d82e52519e237e6cab3088792af0ed424..4df7c5fa5181cb6244c5ed268be7d2c6959435e1 100644
|
| --- a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.cc
|
| +++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.cc
|
| @@ -4,12 +4,11 @@
|
|
|
| #include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.h"
|
|
|
| -#include <IOKit/storage/IOStorageProtocolCharacteristics.h>
|
| -
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/time/time.h"
|
| #include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h"
|
| +#include "chrome/common/extensions/image_writer_util_mac.h"
|
| #include "content/public/browser/browser_thread.h"
|
|
|
| namespace extensions {
|
| @@ -64,7 +63,7 @@ void RemovableStorageProviderMac::ProcessDisk(
|
|
|
| void RemovableStorageProviderMac::AddDisk(
|
| base::ScopedCFTypeRef<CFDictionaryRef> dict) {
|
| - if (DiskIsValidTarget(dict.get())) {
|
| + if (extensions::image_writer::IsRemovableDevice(dict.get())) {
|
| CFStringRef cf_bsd_name = base::mac::GetValueFromDictionary<CFStringRef>(
|
| dict, kDADiskDescriptionMediaBSDNameKey);
|
| CFStringRef cf_vendor = base::mac::GetValueFromDictionary<CFStringRef>(
|
| @@ -108,61 +107,6 @@ void RemovableStorageProviderMac::DiskAppearedCallback(DADiskRef disk,
|
| }
|
|
|
| // static
|
| -bool RemovableStorageProviderMac::DiskIsValidTarget(CFDictionaryRef dict) {
|
| - CFBooleanRef internal = base::mac::GetValueFromDictionary<CFBooleanRef>(
|
| - dict, kDADiskDescriptionDeviceInternalKey);
|
| - CFStringRef protocol = base::mac::GetValueFromDictionary<CFStringRef>(
|
| - dict, kDADiskDescriptionDeviceProtocolKey);
|
| - CFStringRef io_reg_path = base::mac::GetValueFromDictionary<CFStringRef>(
|
| - dict, kDADiskDescriptionDevicePathKey);
|
| - CFBooleanRef ejectable = base::mac::GetValueFromDictionary<CFBooleanRef>(
|
| - dict, kDADiskDescriptionMediaEjectableKey);
|
| - CFBooleanRef removable = base::mac::GetValueFromDictionary<CFBooleanRef>(
|
| - dict, kDADiskDescriptionMediaRemovableKey);
|
| - CFBooleanRef whole = base::mac::GetValueFromDictionary<CFBooleanRef>(
|
| - dict, kDADiskDescriptionMediaWholeKey);
|
| - CFStringRef kind = base::mac::GetValueFromDictionary<CFStringRef>(
|
| - dict, kDADiskDescriptionMediaKindKey);
|
| -
|
| - // A drive is a USB stick iff:
|
| - // - it is not internal
|
| - // - it is attached to the USB bus
|
| - // - it is ejectable (because it will be ejected after written to)
|
| - // - it is removable
|
| - // - it is the whole drive (although the use of
|
| - // kDADiskDescriptionMatchMediaWhole should have ensured this)
|
| - // - it is of type IOMedia (external DVD drives and the like are IOCDMedia
|
| - // or
|
| - // IODVDMedia)
|
| - bool is_usb_stick =
|
| - !CFBooleanGetValue(internal) &&
|
| - CFEqual(protocol, CFSTR(kIOPropertyPhysicalInterconnectTypeUSB)) &&
|
| - CFBooleanGetValue(ejectable) && CFBooleanGetValue(removable) &&
|
| - CFBooleanGetValue(whole) &&
|
| - CFStringCompare(kind, CFSTR("IOMedia"), 0) == kCFCompareEqualTo;
|
| -
|
| - // A drive is an SD card iff:
|
| - // - it is attached to the USB bus
|
| - // - it is ejectable (because it will be ejected after written to)
|
| - // - it is removable
|
| - // - it is the whole drive (although the use of
|
| - // kDADiskDescriptionMatchMediaWhole should have ensured this)
|
| - // - it is of type IOMedia (external DVD drives and the like are IOCDMedia
|
| - // or
|
| - // IODVDMedia)
|
| - // - the IORegistry device path contains "AppleUSBCardReader"
|
| - bool is_sd_card =
|
| - CFEqual(protocol, CFSTR(kIOPropertyPhysicalInterconnectTypeUSB)) &&
|
| - CFBooleanGetValue(ejectable) && CFBooleanGetValue(removable) &&
|
| - CFBooleanGetValue(whole) &&
|
| - CFStringCompare(kind, CFSTR("IOMedia"), 0) == kCFCompareEqualTo &&
|
| - CFStringFind(io_reg_path, CFSTR("AppleUSBCardReader"), 0).location !=
|
| - kCFNotFound;
|
| -
|
| - return is_usb_stick || is_sd_card;
|
| -}
|
| -
|
| -// static
|
| void RemovableStorageProviderMac::ProviderDeleter(
|
| RemovableStorageProviderMac* provider,
|
| const DeviceListReadyCallback& callback,
|
|
|