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

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 93425)
+++ chrome/browser/chromeos/extensions/file_browser_event_router.cc (working copy)
@@ -55,6 +55,39 @@
return result;
}
+const char* MountTypeToString(chromeos::MountType type) {
+ switch (type) {
+ case chromeos::DEVICE:
+ return "device";
+ case chromeos::LOCAL_FILE:
+ return "file";
+ default:
+ return "unknown";
+ }
+}
+
+const char* MountErrorToString(chromeos::MountError error) {
+ switch (error) {
+ case chromeos::NO_ERROR:
+ return "success";
+ case chromeos::NO_AUTH:
+ return "auth_required";
+ case chromeos::BAD_PASSWORD:
+ return "bad_pasword";
+ case chromeos::NETWORK_ERROR:
+ return "network_error";
+ case chromeos::LIBRARY_NOT_LOADED:
+ return "libcros_missing";
+ case chromeos::INTERNAL_ERROR:
+ return "internal";
+ case chromeos::UNKNOWN_ERROR:
+ return "unknown";
+ default:
+ NOTREACHED();
+ }
+ return "";
+}
+
ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter()
: delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate()),
profile_(NULL) {
@@ -168,6 +201,14 @@
}
}
+void ExtensionFileBrowserEventRouter::MountCompleted(
+ chromeos::MountError error_code,
+ const std::string& source_path,
+ chromeos::MountType type,
+ const std::string& mount_path) {
+ DispatchMountCompletedEvent(error_code, source_path, type, mount_path);
+}
+
void ExtensionFileBrowserEventRouter::HandleFileWatchNotification(
const FilePath& local_path, bool got_error) {
base::AutoLock lock(lock_);
@@ -233,6 +274,29 @@
GURL());
}
+void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent(
+ chromeos::MountError error_code, const std::string& source_path,
+ chromeos::MountType type, const std::string& mount_path ) {
+ if (!profile_) {
+ NOTREACHED();
+ return;
+ }
+
+ ListValue args;
+ DictionaryValue* mount_info = new DictionaryValue();
+ args.Append(mount_info);
+ mount_info->SetString("sourcePath", source_path);
+ mount_info->SetString("eventType", MountErrorToString(error_code));
+ mount_info->SetString("mountType", MountTypeToString(type));
+ mount_info->SetString("mountPath", mount_path);
+LOG(WARNING) << "MountCompleted" << error_code << source_path;
zel 2011/07/22 00:48:37 space
tbarzic 2011/07/22 00:57:58 I will remove this line
+ 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();
@@ -252,7 +316,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::DEVICE,
+ chromeos::MountPathOptions()); // Unused.
}
}

Powered by Google App Engine
This is Rietveld 408576698