summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_event_names.cc2
-rw-r--r--chrome/browser/extensions/extension_event_names.h1
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.cc124
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.h47
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc4
5 files changed, 164 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc
index 76c0d8f..fc226f3 100644
--- a/chrome/browser/extensions/extension_event_names.cc
+++ b/chrome/browser/extensions/extension_event_names.cc
@@ -25,6 +25,8 @@ const char kOnExtensionDisabled[] = "management.onDisabled";
const char kOnFileBrowserDiskChanged[] = "fileBrowserPrivate.onDiskChanged";
const char kOnFileChanged[] = "fileBrowserPrivate.onFileChanged";
+const char kOnFileBrowserMountCompleted[] =
+ "fileBrowserPrivate.onMountCompleted";
const char kOnInputMethodChanged[] = "inputMethodPrivate.onChanged";
} // namespace extension_event_names
diff --git a/chrome/browser/extensions/extension_event_names.h b/chrome/browser/extensions/extension_event_names.h
index b6958e2..0b26e4f 100644
--- a/chrome/browser/extensions/extension_event_names.h
+++ b/chrome/browser/extensions/extension_event_names.h
@@ -33,6 +33,7 @@ extern const char kOnExtensionDisabled[];
// FileBrowser.
extern const char kOnFileBrowserDiskChanged[];
extern const char kOnFileChanged[];
+extern const char kOnFileBrowserMountCompleted[];
// InputMethod.
extern const char kOnInputMethodChanged[];
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index 3f0cb0e..9549c78 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -1075,31 +1075,141 @@ bool CancelFileDialogFunction::RunImpl() {
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)) {
+ return false;
+ }
+
+ std::string mount_type_str;
+ if (!args_->GetString(1, &mount_type_str)) {
+ return false;
+ }
+
+#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::MountPathOptions::value_type((*it).c_str(),
+ value.c_str()));
+ }
+ }
+
+ mount_lib->MountPath(source.c_str(), mount_type, options);
+#endif
+
+ 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)) {
- NOTREACHED();
+ std::string mount_path;
+ if (!args_->GetString(0, &mount_path)) {
+ return false;
}
#ifdef OS_CHROMEOS
chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath(
- volume_device_path.c_str());
+ mount_path.c_str());
#endif
SendResponse(true);
return true;
}
+GetMountPointsFunction::GetMountPointsFunction() {
+}
+
+GetMountPointsFunction::~GetMountPointsFunction() {
+}
+
+bool GetMountPointsFunction::RunImpl() {
+ if (args_->GetSize() != 0)
+ 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;
+
+ mounts->Set(mount_point_info.mount_path,
+ MountPointToValue(mount_point_info, mount_lib));
+ }
+
+ result_.reset(mounts);
+#endif
+
+ return true;
+}
+
+#ifdef OS_CHROMEOS
+base::DictionaryValue* GetMountPointsFunction::MountPointToValue(
+ const chromeos::MountLibrary::MountPointInfo& mount_point_info,
+ chromeos::MountLibrary* mount_lib) {
+
+ base::DictionaryValue *mount_info = new base::DictionaryValue();
+
+ 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);
+ return mount_info;
+}
+#endif
+
GetVolumeMetadataFunction::GetVolumeMetadataFunction() {
}
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.h b/chrome/browser/extensions/extension_file_browser_private_api.h
index 065b9e2..90d44f3 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.h
+++ b/chrome/browser/extensions/extension_file_browser_private_api.h
@@ -217,19 +217,54 @@ class CancelFileDialogFunction
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.cancelDialog");
};
-// Unmounts selected device. Expects volume's device path as an argument.
-class UnmountVolumeFunction
+// Mount a device or a file.
+class AddMountFunction
: public SyncExtensionFunction {
- public:
- UnmountVolumeFunction();
+ public:
+ AddMountFunction();
+
+ protected:
+ virtual ~AddMountFunction();
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addMount");
+};
+
+// Unmounts selected device. Expects mount point path as an argument.
+class RemoveMountFunction
+ : public SyncExtensionFunction {
+ public:
+ RemoveMountFunction();
+
+ protected:
+ virtual ~RemoveMountFunction();
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount");
+};
+
+class GetMountPointsFunction
+ : public SyncExtensionFunction {
+ public:
+ GetMountPointsFunction();
protected:
- virtual ~UnmountVolumeFunction();
+ virtual ~GetMountPointsFunction();
virtual bool RunImpl() OVERRIDE;
private:
- DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.unmountVolume");
+#ifdef OS_CHROMEOS
+ base::DictionaryValue* MountPointToValue(
+ const chromeos::MountLibrary::MountPointInfo& mount_point_info,
+ chromeos::MountLibrary* mount_lib);
+#endif
+
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getMountPoints");
};
// Retrieves devices meta-data. Expects volume's device path as an argument.
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index e3ce123..640492f 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -347,7 +347,9 @@ void FactoryRegistry::ResetFunctions() {
RegisterFunction<RemoveFileWatchBrowserFunction>();
RegisterFunction<SelectFileFunction>();
RegisterFunction<SelectFilesFunction>();
- RegisterFunction<UnmountVolumeFunction>();
+ RegisterFunction<AddMountFunction>();
+ RegisterFunction<RemoveMountFunction>();
+ RegisterFunction<GetMountPointsFunction>();
RegisterFunction<ViewFilesFunction>();
// Mediaplayer