| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 8 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 "%s[%d] called. (volume_id: '%s')", | 98 "%s[%d] called. (volume_id: '%s')", |
| 99 name().c_str(), | 99 name().c_str(), |
| 100 request_id(), | 100 request_id(), |
| 101 params->volume_id.c_str()); | 101 params->volume_id.c_str()); |
| 102 } | 102 } |
| 103 set_log_on_completion(true); | 103 set_log_on_completion(true); |
| 104 | 104 |
| 105 using file_manager::VolumeManager; | 105 using file_manager::VolumeManager; |
| 106 using file_manager::VolumeInfo; | 106 using file_manager::VolumeInfo; |
| 107 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); | 107 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); |
| 108 if (!volume_manager) | 108 DCHECK(volume_manager); |
| 109 return false; | |
| 110 | 109 |
| 111 VolumeInfo volume_info; | 110 VolumeInfo volume_info; |
| 112 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) | 111 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) |
| 113 return false; | 112 return false; |
| 114 | 113 |
| 115 // TODO(tbarzic): Send response when callback is received, it would make more | 114 // TODO(tbarzic): Send response when callback is received, it would make more |
| 116 // sense than remembering issued unmount requests in file manager and showing | 115 // sense than remembering issued unmount requests in file manager and showing |
| 117 // errors for them when MountCompleted event is received. | 116 // errors for them when MountCompleted event is received. |
| 118 DiskMountManager::GetInstance()->UnmountPath( | 117 switch (volume_info.type) { |
| 119 volume_info.mount_path.value(), | 118 case file_manager::VOLUME_TYPE_REMOVABLE_DISK_PARTITION: |
| 120 chromeos::UNMOUNT_OPTIONS_NONE, | 119 case file_manager::VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: { |
| 121 DiskMountManager::UnmountPathCallback()); | 120 DiskMountManager::GetInstance()->UnmountPath( |
| 121 volume_info.mount_path.value(), |
| 122 chromeos::UNMOUNT_OPTIONS_NONE, |
| 123 DiskMountManager::UnmountPathCallback()); |
| 124 break; |
| 125 } |
| 126 case file_manager::VOLUME_TYPE_PROVIDED: { |
| 127 chromeos::file_system_provider::Service* service = |
| 128 chromeos::file_system_provider::Service::Get(GetProfile()); |
| 129 DCHECK(service); |
| 130 // TODO(mtomasz): Pass a more detailed error than just a bool. |
| 131 if (!service->RequestUnmount(volume_info.file_system_id)) |
| 132 return false; |
| 133 break; |
| 134 } |
| 135 default: |
| 136 // Requested unmounting a device which is not unmountable. |
| 137 return false; |
| 138 } |
| 122 | 139 |
| 123 SendResponse(true); | 140 SendResponse(true); |
| 124 return true; | 141 return true; |
| 125 } | 142 } |
| 126 | 143 |
| 127 bool FileBrowserPrivateGetVolumeMetadataListFunction::RunImpl() { | 144 bool FileBrowserPrivateGetVolumeMetadataListFunction::RunImpl() { |
| 128 if (args_->GetSize()) | 145 if (args_->GetSize()) |
| 129 return false; | 146 return false; |
| 130 | 147 |
| 131 const std::vector<file_manager::VolumeInfo>& volume_info_list = | 148 const std::vector<file_manager::VolumeInfo>& volume_info_list = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 152 result.size()); | 169 result.size()); |
| 153 } | 170 } |
| 154 | 171 |
| 155 results_ = | 172 results_ = |
| 156 file_browser_private::GetVolumeMetadataList::Results::Create(result); | 173 file_browser_private::GetVolumeMetadataList::Results::Create(result); |
| 157 SendResponse(true); | 174 SendResponse(true); |
| 158 return true; | 175 return true; |
| 159 } | 176 } |
| 160 | 177 |
| 161 } // namespace extensions | 178 } // namespace extensions |
| OLD | NEW |