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

Unified Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 7457001: Adding support for mount point different from removable devices to MountLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/extension_file_browser_private_api.cc
===================================================================
--- chrome/browser/extensions/extension_file_browser_private_api.cc (revision 93731)
+++ chrome/browser/extensions/extension_file_browser_private_api.cc (working copy)
@@ -1075,31 +1075,133 @@
return true;
}
-UnmountVolumeFunction::UnmountVolumeFunction() {
+AddMountFunction::AddMountFunction() {
}
-UnmountVolumeFunction::~UnmountVolumeFunction() {
+AddMountFunction::~AddMountFunction() {
}
-bool UnmountVolumeFunction::RunImpl() {
+bool AddMountFunction::RunImpl() {
+ if (args_->GetSize() != 2 && args_->GetSize() != 3) {
+ error_ = "Invalid argument count";
+ return false;
+ }
+
+ std::string source;
+ if (!args_->GetString(0, &source)) {
+ NOTREACHED();
zel 2011/07/22 23:50:42 change NOTREACHED() in this function to this inste
+ }
+
+ std::string mount_type_str;
+ if (!args_->GetString(1, &mount_type_str)) {
+ NOTREACHED();
+ }
+
+#ifdef OS_CHROMEOS
+ chromeos::MountLibrary *mount_lib =
+ chromeos::CrosLibrary::Get()->GetMountLibrary();
+
+ chromeos::MountType mount_type =
+ mount_lib->MountTypeFromString(mount_type_str);
+ if (mount_type == chromeos::MOUNT_TYPE_INVALID) {
+ error_ = "Invalid mount type";
+ return false;
+ }
+
+ chromeos::MountPathOptions options;
+
+ if (args_->GetSize() == 3) {
+ DictionaryValue *dict;
+ if (!args_->GetDictionary(2, &dict)) {
+ NOTREACHED();
+ }
+
+ for (base::DictionaryValue::key_iterator it = dict->begin_keys();
+ it != dict->end_keys();
+ ++it) {
+ std::string value;
+ if (!dict->GetString(*it, &value)) {
+ NOTREACHED();
+ }
+
+ options.push_back(chromeos::MountPointOptions::value_type(*it, value));
+ }
+ }
+
+ mount_lib->Mount(source.c_str(), mount_type, options);
+#endif
+
+ SendResponse(true);
zel 2011/07/22 23:50:42 If this class derives from SyncExtensionFunction c
+ return true;
+}
+
+RemoveMountFunction::RemoveMountFunction() {
+}
+
+RemoveMountFunction::~RemoveMountFunction() {
+}
+
+bool RemoveMountFunction::RunImpl() {
if (args_->GetSize() != 1) {
return false;
}
- std::string volume_device_path;
- if (!args_->GetString(0, &volume_device_path)) {
+ std::string mount_path;
+ if (!args_->GetString(0, &mount_path)) {
NOTREACHED();
zel 2011/07/22 23:50:42 replace NOTREACHED(); with return false;
}
#ifdef OS_CHROMEOS
- chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath(
- volume_device_path.c_str());
+ chromeos::CrosLibrary::Get()->GetMountLibrary()->RemoveMount(
+ mount_path.c_str());
#endif
SendResponse(true);
return true;
}
+GetMountPointsFunction::GetMountPointsFunction() {
+}
+
+GetMountPointsFunction::~GetMountPointsFunction() {
+}
+
+bool GetMountPointsFunction::RunImpl() {
+ if (args_->GetSize() != 0) {
zel 2011/07/22 23:50:42 nit: {}
+ return false;
+ }
+
+#ifdef OS_CHROMEOS
+ chromeos::MountLibrary *mount_lib =
+ chromeos::CrosLibrary::Get()->GetMountLibrary();
+ chromeos::MountLibrary::MountPointMap mount_points =
+ mount_lib->mount_points();
+
+ base::DictionaryValue *mounts = new base::DictionaryValue();
+
+ for (chromeos::MountLibrary::MountPointMap::const_iterator it =
+ mount_points.begin();
+ it != mount_points.end();
+ ++it) {
+ chromeos::MountLibrary::MountPointInfo mount_point_info = it->second;
+ base::DictionaryValue *mount_info = new base::DictionaryValue();
zel 2011/07/22 23:50:42 make a helper function MountPointInfoToValue() for
+
+ mount_info->SetString("mountPath", mount_point_info.mount_path);
+ mount_info->SetString(
+ "mountType",
+ mount_lib->MountTypeToString(mount_point_info.mount_type));
+ mount_info->SetString("sourcePath", mount_point_info.source_path);
+
+ mounts->Set(mount_point_info.mount_path, mount_info);
+ }
+
+ result_.reset(mounts);
+#endif
+
+ SendResponse(true);
+ return true;
+}
+
GetVolumeMetadataFunction::GetVolumeMetadataFunction() {
}
@@ -1165,7 +1267,38 @@
return kVolumeTypeUnknown;
}
#endif
+/*
+MountVolumeFunction::MountVolumeFunction() {
zel 2011/07/22 23:50:42 remove this one, it's commented out anyway
+}
+MountVolumeFunction::~MountVolumeFunction() {
+}
+
+void MountCompleted() {
+ SendResponce(error_code == NO_ERROR);
+}
+
+bool MountVolumeFunction::RunImpl() {
+ if (args_->GetSize() != 1) {
+ return false;
+ }
+
+ std::string volume_device_path;
+ if (!args_->GetString(0, &volume_device_path)) {
+ NOTREACHED();
+ }
+
+ bool success = false;
+#ifdef OS_CHROMEOS
+// success = chromeos::CrosLibrary::Get()->GetMountLibrary()->MountDevice(
+ // volume_device_path.c_str(), type, options, this);
+#endif
+
+ if (success)
+ SendResponse(success);
+ return success;
+}
+*/
bool FileDialogStringsFunction::RunImpl() {
result_.reset(new DictionaryValue());
DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());

Powered by Google App Engine
This is Rietveld 408576698