| Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| index a2aeb7be0ee887b191bd5104aed87dbb09f04ece..27bb7a2e944ba56dc34ba8f9dfbcb63a2be96316 100644
|
| --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| @@ -9,7 +9,6 @@
|
| #include "base/message_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/extensions/file_browser_notifications.h"
|
| #include "chrome/browser/chromeos/login/user_manager.h"
|
| #include "chrome/browser/extensions/extension_event_names.h"
|
| @@ -45,13 +44,13 @@ namespace {
|
| }
|
|
|
| DictionaryValue* DiskToDictionaryValue(
|
| - const chromeos::MountLibrary::Disk* disk) {
|
| + const chromeos::disks::DiskMountManager::Disk* disk) {
|
| DictionaryValue* result = new DictionaryValue();
|
| result->SetString("mountPath", disk->mount_path());
|
| result->SetString("devicePath", disk->device_path());
|
| result->SetString("label", disk->device_label());
|
| result->SetString("deviceType", DeviceTypeToString(disk->device_type()));
|
| - result->SetInteger("totalSizeKB", disk->total_size() / 1024);
|
| + result->SetInteger("totalSizeKB", disk->total_size_in_bytes() / 1024);
|
| result->SetBoolean("readOnly", disk->is_read_only());
|
| return result;
|
| }
|
| @@ -95,11 +94,7 @@ ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() {
|
| return;
|
| }
|
| profile_ = NULL;
|
| - if (!chromeos::CrosLibrary::Get()->EnsureLoaded())
|
| - return;
|
| - chromeos::MountLibrary* lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->RemoveObserver(this);
|
| + chromeos::disks::DiskMountManager::GetInstance()->RemoveObserver(this);
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() {
|
| @@ -107,14 +102,12 @@ void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() {
|
| NOTREACHED();
|
| return;
|
| }
|
| - if (!chromeos::CrosLibrary::Get()->EnsureLoaded())
|
| - return;
|
| if (chromeos::UserManager::Get()->user_is_logged_in()) {
|
| - chromeos::MountLibrary* lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->RemoveObserver(this);
|
| - lib->AddObserver(this);
|
| - lib->RequestMountInfoRefresh();
|
| + chromeos::disks::DiskMountManager* disk_mount_manager =
|
| + chromeos::disks::DiskMountManager::GetInstance();
|
| + disk_mount_manager->RemoveObserver(this);
|
| + disk_mount_manager->AddObserver(this);
|
| + disk_mount_manager->RequestMountInfoRefresh();
|
| }
|
| }
|
|
|
| @@ -155,35 +148,35 @@ void ExtensionFileBrowserEventRouter::RemoveFileWatch(
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::DiskChanged(
|
| - chromeos::MountLibraryEventType event,
|
| - const chromeos::MountLibrary::Disk* disk) {
|
| + chromeos::disks::DiskMountManagerEventType event,
|
| + const chromeos::disks::DiskMountManager::Disk* disk) {
|
| // Disregard hidden devices.
|
| if (disk->is_hidden())
|
| return;
|
| - if (event == chromeos::MOUNT_DISK_ADDED) {
|
| + if (event == chromeos::disks::MOUNT_DISK_ADDED) {
|
| OnDiskAdded(disk);
|
| - } else if (event == chromeos::MOUNT_DISK_REMOVED) {
|
| + } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) {
|
| OnDiskRemoved(disk);
|
| }
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::DeviceChanged(
|
| - chromeos::MountLibraryEventType event,
|
| + chromeos::disks::DiskMountManagerEventType event,
|
| const std::string& device_path) {
|
| - if (event == chromeos::MOUNT_DEVICE_ADDED) {
|
| + if (event == chromeos::disks::MOUNT_DEVICE_ADDED) {
|
| OnDeviceAdded(device_path);
|
| - } else if (event == chromeos::MOUNT_DEVICE_REMOVED) {
|
| + } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) {
|
| OnDeviceRemoved(device_path);
|
| - } else if (event == chromeos::MOUNT_DEVICE_SCANNED) {
|
| + } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) {
|
| OnDeviceScanned(device_path);
|
| - } else if (event == chromeos::MOUNT_FORMATTING_STARTED) {
|
| + } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) {
|
| // TODO(tbarzic): get rid of '!'.
|
| if (device_path[0] == '!') {
|
| OnFormattingStarted(device_path.substr(1), false);
|
| } else {
|
| OnFormattingStarted(device_path, true);
|
| }
|
| - } else if (event == chromeos::MOUNT_FORMATTING_FINISHED) {
|
| + } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) {
|
| if (device_path[0] == '!') {
|
| OnFormattingFinished(device_path.substr(1), false);
|
| } else {
|
| @@ -193,21 +186,21 @@ void ExtensionFileBrowserEventRouter::DeviceChanged(
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::MountCompleted(
|
| - chromeos::MountLibrary::MountEvent event_type,
|
| + chromeos::disks::DiskMountManager::MountEvent event_type,
|
| chromeos::MountError error_code,
|
| - const chromeos::MountLibrary::MountPointInfo& mount_info) {
|
| + const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) {
|
| DispatchMountCompletedEvent(event_type, error_code, mount_info);
|
|
|
| if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE &&
|
| - event_type == chromeos::MountLibrary::MOUNTING) {
|
| - chromeos::MountLibrary* mount_lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - chromeos::MountLibrary::DiskMap::const_iterator disk_it =
|
| - mount_lib->disks().find(mount_info.source_path);
|
| - if (disk_it == mount_lib->disks().end()) {
|
| + event_type == chromeos::disks::DiskMountManager::MOUNTING) {
|
| + chromeos::disks::DiskMountManager* disk_mount_manager =
|
| + chromeos::disks::DiskMountManager::GetInstance();
|
| + chromeos::disks::DiskMountManager::DiskMap::const_iterator disk_it =
|
| + disk_mount_manager->disks().find(mount_info.source_path);
|
| + if (disk_it == disk_mount_manager->disks().end()) {
|
| return;
|
| }
|
| - chromeos::MountLibrary::Disk* disk = disk_it->second;
|
| + chromeos::disks::DiskMountManager::Disk* disk = disk_it->second;
|
|
|
| notifications_->ManageNotificationsOnMountCompleted(
|
| disk->system_path_prefix(), disk->drive_label(), disk->is_parent(),
|
| @@ -260,7 +253,7 @@ void ExtensionFileBrowserEventRouter::DispatchFolderChangeEvent(
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::DispatchDiskEvent(
|
| - const chromeos::MountLibrary::Disk* disk, bool added) {
|
| + const chromeos::disks::DiskMountManager::Disk* disk, bool added) {
|
| if (!profile_) {
|
| NOTREACHED();
|
| return;
|
| @@ -282,9 +275,9 @@ void ExtensionFileBrowserEventRouter::DispatchDiskEvent(
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
|
| - chromeos::MountLibrary::MountEvent event,
|
| + chromeos::disks::DiskMountManager::MountEvent event,
|
| chromeos::MountError error_code,
|
| - const chromeos::MountLibrary::MountPointInfo& mount_info) {
|
| + const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) {
|
| if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) {
|
| NOTREACHED();
|
| return;
|
| @@ -293,14 +286,16 @@ void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
|
| ListValue args;
|
| DictionaryValue* mount_info_value = new DictionaryValue();
|
| args.Append(mount_info_value);
|
| - if (event == chromeos::MountLibrary::MOUNTING) {
|
| + if (event == chromeos::disks::DiskMountManager::MOUNTING) {
|
| mount_info_value->SetString("eventType", "mount");
|
| } else {
|
| mount_info_value->SetString("eventType", "unmount");
|
| }
|
| mount_info_value->SetString("status", MountErrorToString(error_code));
|
| - mount_info_value->SetString("mountType",
|
| - chromeos::MountLibrary::MountTypeToString(mount_info.mount_type));
|
| + mount_info_value->SetString(
|
| + "mountType",
|
| + chromeos::disks::DiskMountManager::MountTypeToString(
|
| + mount_info.mount_type));
|
|
|
| if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
|
| GURL source_url;
|
| @@ -341,13 +336,13 @@ void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
|
| if (relative_mount_path_set &&
|
| mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE &&
|
| !mount_info.mount_condition &&
|
| - event == chromeos::MountLibrary::MOUNTING) {
|
| + event == chromeos::disks::DiskMountManager::MOUNTING) {
|
| FileManagerUtil::ViewFolder(FilePath(mount_info.mount_path));
|
| }
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::OnDiskAdded(
|
| - const chromeos::MountLibrary::Disk* disk) {
|
| + const chromeos::disks::DiskMountManager::Disk* disk) {
|
| VLOG(1) << "Disk added: " << disk->device_path();
|
| if (disk->device_path().empty()) {
|
| VLOG(1) << "Empty system path for " << disk->device_path();
|
| @@ -357,23 +352,19 @@ void ExtensionFileBrowserEventRouter::OnDiskAdded(
|
| // If disk is not mounted yet, give it a try.
|
| if (disk->mount_path().empty()) {
|
| // Initiate disk mount operation.
|
| - chromeos::MountLibrary* lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->MountPath(disk->device_path().c_str(),
|
| - chromeos::MOUNT_TYPE_DEVICE,
|
| - chromeos::MountPathOptions()); // Unused.
|
| + chromeos::disks::DiskMountManager::GetInstance()->MountPath(
|
| + disk->device_path(), chromeos::MOUNT_TYPE_DEVICE);
|
| }
|
| DispatchDiskEvent(disk, true);
|
| }
|
|
|
| void ExtensionFileBrowserEventRouter::OnDiskRemoved(
|
| - const chromeos::MountLibrary::Disk* disk) {
|
| + const chromeos::disks::DiskMountManager::Disk* disk) {
|
| VLOG(1) << "Disk removed: " << disk->device_path();
|
|
|
| if (!disk->mount_path().empty()) {
|
| - chromeos::MountLibrary* lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->UnmountPath(disk->mount_path().c_str());
|
| + chromeos::disks::DiskMountManager::GetInstance()->UnmountPath(
|
| + disk->mount_path());
|
| }
|
| DispatchDiskEvent(disk, false);
|
| }
|
| @@ -425,11 +416,8 @@ void ExtensionFileBrowserEventRouter::OnFormattingFinished(
|
| notifications_->HideNotificationDelayed(
|
| FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000);
|
|
|
| - chromeos::MountLibrary* lib =
|
| - chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->MountPath(device_path.c_str(),
|
| - chromeos::MOUNT_TYPE_DEVICE,
|
| - chromeos::MountPathOptions()); // Unused.
|
| + chromeos::disks::DiskMountManager::GetInstance()->MountPath(
|
| + device_path, chromeos::MOUNT_TYPE_DEVICE);
|
| } else {
|
| notifications_->HideNotification(FileBrowserNotifications::FORMAT_START,
|
| device_path);
|
|
|