| 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 <string> |
| 8 |
| 7 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 8 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 10 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 11 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| 11 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 13 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 12 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 14 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 13 #include "chrome/browser/drive/event_logger.h" | 15 #include "chrome/browser/drive/event_logger.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/extensions/api/file_browser_private.h" | 17 #include "chrome/common/extensions/api/file_browser_private.h" |
| 16 #include "chromeos/disks/disk_mount_manager.h" | 18 #include "chromeos/disks/disk_mount_manager.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 "%s[%d] called. (volume_id: '%s')", | 100 "%s[%d] called. (volume_id: '%s')", |
| 99 name().c_str(), | 101 name().c_str(), |
| 100 request_id(), | 102 request_id(), |
| 101 params->volume_id.c_str()); | 103 params->volume_id.c_str()); |
| 102 } | 104 } |
| 103 set_log_on_completion(true); | 105 set_log_on_completion(true); |
| 104 | 106 |
| 105 using file_manager::VolumeManager; | 107 using file_manager::VolumeManager; |
| 106 using file_manager::VolumeInfo; | 108 using file_manager::VolumeInfo; |
| 107 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); | 109 VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); |
| 108 if (!volume_manager) | 110 DCHECK(volume_manager); |
| 109 return false; | |
| 110 | 111 |
| 111 VolumeInfo volume_info; | 112 VolumeInfo volume_info; |
| 112 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) | 113 if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) |
| 113 return false; | 114 return false; |
| 114 | 115 |
| 115 // TODO(tbarzic): Send response when callback is received, it would make more | 116 // TODO(tbarzic): Send response when callback is received, it would make more |
| 116 // sense than remembering issued unmount requests in file manager and showing | 117 // sense than remembering issued unmount requests in file manager and showing |
| 117 // errors for them when MountCompleted event is received. | 118 // errors for them when MountCompleted event is received. |
| 118 DiskMountManager::GetInstance()->UnmountPath( | 119 switch (volume_info.type) { |
| 119 volume_info.mount_path.value(), | 120 case file_manager::VOLUME_TYPE_REMOVABLE_DISK_PARTITION: |
| 120 chromeos::UNMOUNT_OPTIONS_NONE, | 121 case file_manager::VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: { |
| 121 DiskMountManager::UnmountPathCallback()); | 122 DiskMountManager::GetInstance()->UnmountPath( |
| 123 volume_info.mount_path.value(), |
| 124 chromeos::UNMOUNT_OPTIONS_NONE, |
| 125 DiskMountManager::UnmountPathCallback()); |
| 126 break; |
| 127 } |
| 128 case file_manager::VOLUME_TYPE_PROVIDED: { |
| 129 chromeos::file_system_provider::Service* service = |
| 130 chromeos::file_system_provider::Service::Get(GetProfile()); |
| 131 DCHECK(service); |
| 132 // TODO(mtomasz): Pass a more detailed error than just a bool. |
| 133 if (!service->RequestUnmount(volume_info.file_system_id)) |
| 134 return false; |
| 135 break; |
| 136 } |
| 137 default: |
| 138 // Requested unmounting a device which is not unmountable. |
| 139 return false; |
| 140 } |
| 122 | 141 |
| 123 SendResponse(true); | 142 SendResponse(true); |
| 124 return true; | 143 return true; |
| 125 } | 144 } |
| 126 | 145 |
| 127 bool FileBrowserPrivateGetVolumeMetadataListFunction::RunImpl() { | 146 bool FileBrowserPrivateGetVolumeMetadataListFunction::RunImpl() { |
| 128 if (args_->GetSize()) | 147 if (args_->GetSize()) |
| 129 return false; | 148 return false; |
| 130 | 149 |
| 131 const std::vector<file_manager::VolumeInfo>& volume_info_list = | 150 const std::vector<file_manager::VolumeInfo>& volume_info_list = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 152 result.size()); | 171 result.size()); |
| 153 } | 172 } |
| 154 | 173 |
| 155 results_ = | 174 results_ = |
| 156 file_browser_private::GetVolumeMetadataList::Results::Create(result); | 175 file_browser_private::GetVolumeMetadataList::Results::Create(result); |
| 157 SendResponse(true); | 176 SendResponse(true); |
| 158 return true; | 177 return true; |
| 159 } | 178 } |
| 160 | 179 |
| 161 } // namespace extensions | 180 } // namespace extensions |
| OLD | NEW |