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

Unified Diff: chrome/browser/extensions/api/image_writer_private/removable_storage_provider_chromeos.cc

Issue 207383004: Adds a new removable storage provider for imageWriterPrivate on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates test checks to avoid ordering issues. Created 6 years, 9 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/browser/extensions/api/image_writer_private/removable_storage_provider_chromeos.cc
diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_chromeos.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59d71daccc0c6e17580c81c8b469536949109779
--- /dev/null
+++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_chromeos.cc
@@ -0,0 +1,55 @@
+// 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/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;
+
+// The Chrome OS implementation takes advantage of the Chrome OS
+// DiskMountManager. This does not expose whether the device is a removable or
+// fixed disk. In fact, some SD cards will present themselves as fixed disks
+// (see http://crbug.com/340761). Thus we just expose all USB and SD drives.
+// static
+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);
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698