Index: chrome/browser/chromeos/extensions/file_browser_private_api.cc |
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
index 57c700d77e3ae81402a9e016b5ec08bd4d5634d2..8c376adb765a2697f0e8277b39efd80790779053 100644 |
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
@@ -1001,11 +1001,34 @@ void AddMountFunction::GetLocalPathsResponseOnUIThread( |
} |
#if defined(OS_CHROMEOS) |
- FilePath source_file = files[0].path; |
+ const FilePath& source_path = files[0].path; |
+ const std::string& display_name = files[0].display_name; |
Ben Chan
2012/04/17 20:57:53
const FilePath::StringType&
|
+ // check if the source path is under GData cache directory |
+ gdata::GDataSystemService* system_service = |
+ gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
+ if (system_service && system_service->file_system() && |
+ system_service->file_system()->IsUnderGDataCacheDirectory(source_path)) { |
tbarzic
2012/04/17 21:33:13
are you sure this is ever satisfied?
afaik |files|
tbarzic
2012/04/17 21:51:04
Ok, looks like this changed recently :)
ignore the
|
+ system_service->file_system()->SetMountedState(source_path, display_name, |
+ mount_type_str, base::Bind(&AddMountFunction::OnMountedStateSet, this)); |
+ } else { |
+ OnMountedStateSet(base::PLATFORM_FILE_OK, source_path, std::string(), |
+ mount_type_str); |
+ } |
+#else |
+ SendResponse(true); |
+#endif // defined(OS_CHROMEOS) |
+} |
+ |
+void AddMountFunction::OnMountedStateSet(base::PlatformFileError error, |
Ben Chan
2012/04/17 20:57:53
seems like this method is only used on Chrome OS,
tbarzic
2012/04/17 21:33:13
actually, whole file is used only on chromeos.. bu
|
+ const FilePath& file_path, |
+ const std::string& file_name, |
+ const std::string& mount_type) { |
+#if defined(OS_CHROMEOS) |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
// MountPath() takes a std::string. |
- disk_mount_manager->MountPath(source_file.AsUTF8Unsafe(), |
- DiskMountManager::MountTypeFromString(mount_type_str)); |
+ disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), file_name, |
Ben Chan
2012/04/17 20:57:53
passing file_name as the second argument to MountP
|
+ DiskMountManager::MountTypeFromString(mount_type)); |
#endif // defined(OS_CHROMEOS) |
SendResponse(true); |
@@ -1044,9 +1067,37 @@ void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
return; |
} |
#if defined(OS_CHROMEOS) |
- DiskMountManager::GetInstance()->UnmountPath(files[0].path.value()); |
+ // look up source path from mount path |
+ const std::string& mount_path = files[0].path.value(); |
+ DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
+ DiskMountManager::MountPointMap mount_points = |
+ disk_mount_manager->mount_points(); |
+ DiskMountManager::MountPointMap::const_iterator it = |
+ mount_points.find(mount_path); |
+ if (it == mount_points.end()) { |
+ SendResponse(false); |
+ return; |
+ } |
+ DiskMountManager::MountPointInfo mount_point_info = it->second; |
+ FilePath source_path = FilePath(mount_point_info.source_path); |
+ // unmount archive |
+ disk_mount_manager->UnmountPath(mount_path); |
+ // check if the source path is under GData cache directory |
tbarzic
2012/04/17 21:33:13
Comments have to end with .
Also, they have to beg
|
+ gdata::GDataSystemService* system_service = |
+ gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
+ if (system_service && system_service->file_system() && |
+ system_service->file_system()->IsUnderGDataCacheDirectory(source_path)) { |
+ system_service->file_system()->ClearMountedState(source_path, base::Bind( |
Ben Chan
2012/04/17 20:57:53
nit: line break before base::Bind
|
+ &RemoveMountFunction::OnMountedStateCleared, this)); |
+ } else { |
+ OnMountedStateCleared(base::PLATFORM_FILE_OK); |
+ } |
+#else |
+ SendResponse(true); |
#endif |
+} |
+void RemoveMountFunction::OnMountedStateCleared(base::PlatformFileError error) { |
SendResponse(true); |
} |