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 67e85b4ba56e19118040382cf0d896efcc3daba3..2a94208440681a4032b70e675e87e8c5d8a61838 100644 |
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
@@ -1015,14 +1015,40 @@ void AddMountFunction::GetLocalPathsResponseOnUIThread( |
} |
#if defined(OS_CHROMEOS) |
- FilePath source_file = files[0].path; |
- DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
- // MountPath() takes a std::string. |
- disk_mount_manager->MountPath(source_file.AsUTF8Unsafe(), |
- DiskMountManager::MountTypeFromString(mount_type_str)); |
+ const FilePath& source_path = files[0].path; |
+ const FilePath::StringType& display_name = files[0].display_name; |
+ // 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)) { |
+ system_service->file_system()->SetMountedState( |
+ source_path, true, |
+ base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, |
+ display_name)); |
+ } else { |
+ OnMountedStateSet(mount_type_str, FilePath::StringType(), |
+ base::PLATFORM_FILE_OK, source_path); |
+ } |
+#else |
+ SendResponse(true); |
#endif // defined(OS_CHROMEOS) |
+} |
+void AddMountFunction::OnMountedStateSet(const std::string& mount_type, |
+ const FilePath::StringType& file_name, |
+ base::PlatformFileError error, |
+ const FilePath& file_path) { |
+#if defined(OS_CHROMEOS) |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
+ // MountPath() takes a std::string. |
+ disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), |
+ FilePath(file_name).Extension(), |
+ DiskMountManager::MountTypeFromString( |
+ mount_type)); |
SendResponse(true); |
+#endif // defined(OS_CHROMEOS) |
} |
RemoveMountFunction::RemoveMountFunction() { |
@@ -1058,9 +1084,40 @@ void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
return; |
} |
#if defined(OS_CHROMEOS) |
- DiskMountManager::GetInstance()->UnmountPath(files[0].path.value()); |
-#endif |
+ // 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. |
+ 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()->SetMountedState( |
+ source_path, false, |
+ base::Bind(&RemoveMountFunction::OnMountedStateSet, this)); |
+ } else { |
+ OnMountedStateSet(base::PLATFORM_FILE_OK, source_path); |
+ } |
+#else |
+ SendResponse(true); |
+#endif // defined(OS_CHROMEOS) |
+} |
+void RemoveMountFunction::OnMountedStateSet(base::PlatformFileError error, |
+ const FilePath& file_path) { |
+ // Ignore the file_path argument for now. |
SendResponse(true); |
} |