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

Unified Diff: chrome/browser/chromeos/extensions/file_browser_event_router.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/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,13 @@
}
}
+void ExtensionFileBrowserEventRouter::MountCompleted(
+ chromeos::MountLibrary::MountEvent event_type,
+ chromeos::MountError error_code,
+ const chromeos::MountLibrary::MountPointInfo& mount_info) {
+ DispatchMountCompletedEvent(event_type, error_code, mount_info);
+}
+
void ExtensionFileBrowserEventRouter::HandleFileWatchNotification(
const FilePath& local_path, bool got_error) {
base::AutoLock lock(lock_);
@@ -218,6 +247,37 @@
GURL());
}
+void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
+ chromeos::MountLibrary::MountEvent event,
+ chromeos::MountError error_code,
+ const chromeos::MountLibrary::MountPointInfo& mount_info) {
+ if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) {
+ NOTREACHED();
+ return;
+ }
+
+ ListValue args;
+ DictionaryValue* mount_info_value = new DictionaryValue();
+ args.Append(mount_info_value);
+ mount_info_value->SetString("sourcePath", mount_info.source_path);
+ if (event == chromeos::MountLibrary::MOUNTING) {
+ mount_info_value->SetString("eventType", "mount");
+ } else {
+ mount_info_value->SetString("eventType", "unmount");
+ }
+ mount_info_value->SetString("status", MountErrorToString(error_code));
+ chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary();
+ mount_info_value->SetString("mountType",
+ lib->MountTypeToString(mount_info.mount_type));
+ mount_info_value->SetString("mountPath", mount_info.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 +297,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.
}
}
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_event_router.h ('k') | chrome/browser/extensions/extension_event_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698