This source file includes following definitions.
- GetAllDevices
#include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h"
#include "chromeos/disks/disk_mount_manager.h"
namespace extensions {
const char kUnknownSDDiskModel[] = "SD Card";
const char kUnknownUSBDiskModel[] = "USB Drive";
using chromeos::disks::DiskMountManager;
void RemovableStorageProvider::GetAllDevices(DeviceListReadyCallback callback) {
scoped_refptr<StorageDeviceList> device_list(new StorageDeviceList());
DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
const DiskMountManager::DiskMap& disks = disk_mount_manager->disks();
for (DiskMountManager::DiskMap::const_iterator iter = disks.begin();
iter != disks.end();
++iter) {
const DiskMountManager::Disk& disk = *iter->second;
if (disk.is_parent() && !disk.on_boot_device() && disk.has_media() &&
(disk.device_type() == chromeos::DEVICE_TYPE_USB ||
disk.device_type() == chromeos::DEVICE_TYPE_SD)) {
linked_ptr<api::image_writer_private::RemovableStorageDevice> device(
new api::image_writer_private::RemovableStorageDevice());
device->storage_unit_id = disk.file_path();
device->capacity = disk.total_size_in_bytes();
device->vendor = disk.vendor_name();
device->model = disk.product_name();
if (device->model.empty() && device->vendor.empty()) {
if (disk.device_type() == chromeos::DEVICE_TYPE_USB) {
device->model = kUnknownUSBDiskModel;
} else {
device->model = kUnknownSDDiskModel;
}
}
device_list->data.push_back(device);
}
}
callback.Run(device_list, true);
}
}