| Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| ===================================================================
|
| --- chrome/browser/chromeos/extensions/file_browser_event_router.cc (revision 93731)
|
| +++ chrome/browser/chromeos/extensions/file_browser_event_router.cc (working copy)
|
| @@ -54,6 +54,28 @@
|
| return result;
|
| }
|
|
|
| +const char* MountErrorToString(chromeos::MountError error) {
|
| + switch (error) {
|
| + case chromeos::MOUNT_ERROR_NONE:
|
| + return "success";
|
| + case chromeos::MOUNT_ERROR_UNKNOWN:
|
| + return "error_unknown";
|
| + case chromeos::MOUNT_ERROR_INTERNAL:
|
| + return "error_internal";
|
| + case chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM:
|
| + return "error_unknown_filesystem";
|
| + case chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM:
|
| + return "error_unsuported_filesystem";
|
| + case chromeos::MOUNT_ERROR_INVALID_ARCHIVE:
|
| + return "error_invalid_archive";
|
| + case chromeos::MOUNT_ERROR_LIBRARY_NOT_LOADED:
|
| + return "error_libcros_missing";
|
| + default:
|
| + NOTREACHED();
|
| + }
|
| + return "";
|
| +}
|
| +
|
| ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter(
|
| Profile* profile)
|
| : delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate(this)),
|
| @@ -153,6 +175,16 @@
|
| }
|
| }
|
|
|
| +void ExtensionFileBrowserEventRouter::MountCompleted(
|
| + chromeos::MountLibrary::MountEvent event_type,
|
| + chromeos::MountError error_code,
|
| + const std::string& source_path,
|
| + chromeos::MountType type,
|
| + const std::string& mount_path) {
|
| + DispatchMountCompletedEvent(event_type, error_code, source_path, type,
|
| + mount_path);
|
| +}
|
| +
|
| void ExtensionFileBrowserEventRouter::HandleFileWatchNotification(
|
| const FilePath& local_path, bool got_error) {
|
| base::AutoLock lock(lock_);
|
| @@ -218,6 +250,36 @@
|
| GURL());
|
| }
|
|
|
| +void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
|
| + chromeos::MountLibrary::MountEvent event,
|
| + chromeos::MountError error_code, const std::string& source_path,
|
| + chromeos::MountType type, const std::string& mount_path ) {
|
| + if (!profile_ || type == chromeos::MOUNT_TYPE_INVALID) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + ListValue args;
|
| + DictionaryValue* mount_info = new DictionaryValue();
|
| + args.Append(mount_info);
|
| + mount_info->SetString("sourcePath", source_path);
|
| + if (event == chromeos::MountLibrary::MOUNTING) {
|
| + mount_info->SetString("eventType", "mount");
|
| + } else {
|
| + mount_info->SetString("eventType", "unmount");
|
| + }
|
| + mount_info->SetString("status", MountErrorToString(error_code));
|
| + chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| + mount_info->SetString("mountType", lib->MountTypeToString(type));
|
| + mount_info->SetString("mountPath", mount_path);
|
| +
|
| + std::string args_json;
|
| + base::JSONWriter::Write(&args, false /* pretty_print */, &args_json);
|
| + profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
|
| + extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL,
|
| + GURL());
|
| +}
|
| +
|
| void ExtensionFileBrowserEventRouter::OnDiskAdded(
|
| const chromeos::MountLibrary::Disk* disk) {
|
| VLOG(1) << "Disk added: " << disk->device_path();
|
| @@ -237,7 +299,9 @@
|
| // Initiate disk mount operation.
|
| chromeos::MountLibrary* lib =
|
| chromeos::CrosLibrary::Get()->GetMountLibrary();
|
| - lib->MountPath(disk->device_path().c_str());
|
| + lib->MountPath(disk->device_path().c_str(),
|
| + chromeos::MOUNT_TYPE_DEVICE,
|
| + chromeos::MountPathOptions()); // Unused.
|
| }
|
| }
|
|
|
|
|