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

Unified Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 1137383002: Show the eject button only for removabled and file handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments + fixed tests. Created 5 years, 7 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/chromeos/file_manager/volume_manager.cc
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc
index 6f0e6efb1558d216d9478011706d9e3659dd33ac..a3e79f6d0efb4730fb1dd1a6f82cea73d2cf65d3 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -130,13 +130,15 @@ std::string GetMountPointNameForMediaStorage(
} // namespace
Volume::Volume()
- : type_(VOLUME_TYPE_GOOGLE_DRIVE),
+ : source_(SOURCE_FILE),
+ type_(VOLUME_TYPE_GOOGLE_DRIVE),
device_type_(chromeos::DEVICE_TYPE_UNKNOWN),
mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE),
mount_context_(MOUNT_CONTEXT_UNKNOWN),
is_parent_(false),
is_read_only_(false),
- has_media_(false) {
+ has_media_(false),
+ configurable_(false) {
}
Volume::~Volume() {
@@ -150,11 +152,9 @@ Volume* Volume::CreateForDrive(Profile* profile) {
volume->type_ = VOLUME_TYPE_GOOGLE_DRIVE;
volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN;
volume->source_path_ = drive_path;
+ volume->source_ = SOURCE_NETWORK;
volume->mount_path_ = drive_path;
volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE;
- volume->is_parent_ = false;
- volume->is_read_only_ = false;
- volume->has_media_ = false;
volume->volume_id_ = GenerateVolumeId(*volume);
return volume;
}
@@ -165,11 +165,9 @@ Volume* Volume::CreateForDownloads(const base::FilePath& downloads_path) {
volume->type_ = VOLUME_TYPE_DOWNLOADS_DIRECTORY;
volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN;
// Keep source_path empty.
+ volume->source_ = SOURCE_SYSTEM;
volume->mount_path_ = downloads_path;
volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE;
- volume->is_parent_ = false;
- volume->is_read_only_ = false;
- volume->has_media_ = false;
volume->volume_id_ = GenerateVolumeId(*volume);
return volume;
}
@@ -181,6 +179,9 @@ Volume* Volume::CreateForRemovable(
Volume* const volume = new Volume;
volume->type_ = MountTypeToVolumeType(mount_point.mount_type);
volume->source_path_ = base::FilePath(mount_point.source_path);
+ volume->source_ = mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE
+ ? SOURCE_FILE
+ : SOURCE_DEVICE;
volume->mount_path_ = base::FilePath(mount_point.mount_path);
volume->mount_condition_ = mount_point.mount_condition;
volume->volume_label_ = volume->mount_path().BaseName().AsUTF8Unsafe();
@@ -192,10 +193,8 @@ Volume* Volume::CreateForRemovable(
volume->has_media_ = disk->has_media();
} else {
volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN;
- volume->is_parent_ = false;
volume->is_read_only_ =
(mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE);
- volume->has_media_ = false;
}
volume->volume_id_ = GenerateVolumeId(*volume);
return volume;
@@ -209,6 +208,17 @@ Volume* Volume::CreateForProvidedFileSystem(
Volume* const volume = new Volume;
volume->file_system_id_ = file_system_info.file_system_id();
volume->extension_id_ = file_system_info.extension_id();
+ switch (file_system_info.source()) {
+ case extensions::SOURCE_FILE:
+ volume->source_ = SOURCE_FILE;
+ break;
+ case extensions::SOURCE_DEVICE:
+ volume->source_ = SOURCE_DEVICE;
+ break;
+ case extensions::SOURCE_NETWORK:
+ volume->source_ = SOURCE_NETWORK;
+ break;
+ }
volume->volume_label_ = file_system_info.display_name();
volume->type_ = VOLUME_TYPE_PROVIDED;
volume->mount_path_ = file_system_info.mount_path();
@@ -216,7 +226,7 @@ Volume* Volume::CreateForProvidedFileSystem(
volume->mount_context_ = mount_context;
volume->is_parent_ = true;
volume->is_read_only_ = !file_system_info.writable();
- volume->has_media_ = false;
+ volume->configurable_ = file_system_info.configurable();
volume->volume_id_ = GenerateVolumeId(*volume);
return volume;
}
@@ -234,6 +244,7 @@ Volume* Volume::CreateForMTP(const base::FilePath& mount_path,
volume->volume_id_ = kMtpVolumeIdPrefix + label;
volume->volume_label_ = label;
volume->source_path_ = mount_path;
+ volume->source_ = SOURCE_DEVICE;
volume->device_type_ = chromeos::DEVICE_TYPE_MOBILE;
return volume;
}
@@ -247,11 +258,10 @@ Volume* Volume::CreateForTesting(const base::FilePath& path,
volume->type_ = volume_type;
volume->device_type_ = device_type;
// Keep source_path empty.
+ volume->source_ = SOURCE_DEVICE;
volume->mount_path_ = path;
volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE;
- volume->is_parent_ = false;
volume->is_read_only_ = read_only;
- volume->has_media_ = false;
volume->volume_id_ = GenerateVolumeId(*volume);
return volume;
}
@@ -421,6 +431,11 @@ void VolumeManager::AddVolumeForTesting(const base::FilePath& path,
path, volume_type, device_type, read_only)));
}
+void VolumeManager::AddVolumeForTesting(linked_ptr<Volume> volume) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume);
+}
+
void VolumeManager::OnFileSystemMounted() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);

Powered by Google App Engine
This is Rietveld 408576698