Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/storage_monitor/media_storage_util.h" | 5 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // TODO(gbillock): Make sure return values from that class are definitive, | 173 // TODO(gbillock): Make sure return values from that class are definitive, |
| 174 // and don't do this here. | 174 // and don't do this here. |
| 175 info.set_device_id( | 175 info.set_device_id( |
| 176 StorageInfo::MakeDeviceId(StorageInfo::FIXED_MASS_STORAGE, | 176 StorageInfo::MakeDeviceId(StorageInfo::FIXED_MASS_STORAGE, |
| 177 path.AsUTF8Unsafe())); | 177 path.AsUTF8Unsafe())); |
| 178 *device_info = info; | 178 *device_info = info; |
| 179 *relative_path = base::FilePath(); | 179 *relative_path = base::FilePath(); |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 | 182 |
| 183 string16 MediaStorageUtil::GetGalleryDisplayNameFromPath( | |
| 184 const base::FilePath& absolute_path) { | |
| 185 StorageInfo storage_info; | |
| 186 base::FilePath relative_path; | |
| 187 if (!GetDeviceInfoFromPath(absolute_path, &storage_info, &relative_path)) | |
|
vandebo (ex-Chrome)
2014/01/08 19:46:25
I think this ends up jumping through more hoops th
Haojian Wu
2014/01/20 09:43:00
Done. I keep this function(just invoke StorageInfo
| |
| 188 return string16(); | |
| 189 // Set media gallery absolute path to StorageInfo. | |
| 190 storage_info.set_location(absolute_path.value()); | |
| 191 return storage_info.GetDisplayName(); | |
| 192 } | |
| 193 | |
| 183 // static | 194 // static |
| 184 base::FilePath MediaStorageUtil::FindDevicePathById( | 195 base::FilePath MediaStorageUtil::FindDevicePathById( |
| 185 const std::string& device_id) { | 196 const std::string& device_id) { |
| 186 StorageInfo::Type type; | 197 StorageInfo::Type type; |
| 187 std::string unique_id; | 198 std::string unique_id; |
| 188 if (!StorageInfo::CrackDeviceId(device_id, &type, &unique_id)) | 199 if (!StorageInfo::CrackDeviceId(device_id, &type, &unique_id)) |
| 189 return base::FilePath(); | 200 return base::FilePath(); |
| 190 | 201 |
| 191 if (type == StorageInfo::FIXED_MASS_STORAGE || | 202 if (type == StorageInfo::FIXED_MASS_STORAGE || |
| 192 type == StorageInfo::ITUNES || | 203 type == StorageInfo::ITUNES || |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { | 248 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { |
| 238 StorageInfoList devices = | 249 StorageInfoList devices = |
| 239 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 250 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 240 for (StorageInfoList::const_iterator it = devices.begin(); | 251 for (StorageInfoList::const_iterator it = devices.begin(); |
| 241 it != devices.end(); ++it) { | 252 it != devices.end(); ++it) { |
| 242 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) | 253 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) |
| 243 return true; | 254 return true; |
| 244 } | 255 } |
| 245 return false; | 256 return false; |
| 246 } | 257 } |
| OLD | NEW |