OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_file_browser_private_api.h" | 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 | 261 |
262 FilePath relative_mount_path; | 262 FilePath relative_mount_path; |
263 // Convert mount point path to relative path with the external file system | 263 // Convert mount point path to relative path with the external file system |
264 // exposed within File API. | 264 // exposed within File API. |
265 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile, | 265 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile, |
266 FilePath(mount_point_info.mount_path), | 266 FilePath(mount_point_info.mount_path), |
267 &relative_mount_path)) { | 267 &relative_mount_path)) { |
268 mount_info->SetString("mountPath", relative_mount_path.value()); | 268 mount_info->SetString("mountPath", relative_mount_path.value()); |
269 } | 269 } |
270 | 270 |
271 mount_info->SetString("specialData", mount_point_info.special_data); | |
272 | |
271 return mount_info; | 273 return mount_info; |
272 } | 274 } |
273 #endif | 275 #endif |
274 | 276 |
275 | 277 |
276 class LocalFileSystemCallbackDispatcher | 278 class LocalFileSystemCallbackDispatcher |
277 : public fileapi::FileSystemCallbackDispatcher { | 279 : public fileapi::FileSystemCallbackDispatcher { |
278 public: | 280 public: |
279 explicit LocalFileSystemCallbackDispatcher( | 281 explicit LocalFileSystemCallbackDispatcher( |
280 RequestLocalFileSystemFunction* function, | 282 RequestLocalFileSystemFunction* function, |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 } | 1313 } |
1312 | 1314 |
1313 #ifdef OS_CHROMEOS | 1315 #ifdef OS_CHROMEOS |
1314 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( | 1316 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( |
1315 files[0].value().c_str()); | 1317 files[0].value().c_str()); |
1316 #endif | 1318 #endif |
1317 | 1319 |
1318 SendResponse(true); | 1320 SendResponse(true); |
1319 } | 1321 } |
1320 | 1322 |
1323 FormatUnmountedDeviceFunction::FormatUnmountedDeviceFunction() { | |
1324 } | |
1325 | |
1326 FormatUnmountedDeviceFunction::~FormatUnmountedDeviceFunction() { | |
1327 } | |
1328 | |
1329 bool FormatUnmountedDeviceFunction::RunImpl() { | |
1330 if (args_->GetSize() != 1) { | |
1331 return false; | |
1332 } | |
1333 | |
1334 std::string volume_file; | |
1335 if (!args_->GetString(0, &volume_file)) { | |
1336 NOTREACHED(); | |
1337 return false; | |
1338 } | |
1339 | |
1340 #ifdef OS_CHROMEOS | |
1341 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatUnmountedDevice( | |
tbarzic
2011/08/24 03:59:44
are you sure you don't have to call FormatMountedD
sidor
2011/08/24 04:26:06
I an not using this method at all, I just added it
| |
1342 volume_file.c_str()); | |
1343 #endif | |
1344 | |
1345 SendResponse(true); | |
1346 return true; | |
1347 } | |
1348 | |
1321 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { | 1349 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { |
1322 } | 1350 } |
1323 | 1351 |
1324 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { | 1352 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { |
1325 } | 1353 } |
1326 | 1354 |
1327 bool GetVolumeMetadataFunction::RunImpl() { | 1355 bool GetVolumeMetadataFunction::RunImpl() { |
1328 if (args_->GetSize() != 1) { | 1356 if (args_->GetSize() != 1) { |
1329 error_ = "Invalid argument count"; | 1357 error_ = "Invalid argument count"; |
1330 return false; | 1358 return false; |
1331 } | 1359 } |
1332 | 1360 |
1333 std::string volume_device_path; | 1361 std::string volume_device_path; |
1334 if (!args_->GetString(0, &volume_device_path)) { | 1362 if (!args_->GetString(0, &volume_device_path)) { |
1335 NOTREACHED(); | 1363 NOTREACHED(); |
1336 } | 1364 } |
1337 | 1365 |
1338 #ifdef OS_CHROMEOS | 1366 #ifdef OS_CHROMEOS |
1339 chromeos::MountLibrary* mount_lib = | 1367 chromeos::MountLibrary* mount_lib = |
1340 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 1368 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
1341 chromeos::MountLibrary::DiskMap::const_iterator volume_it = | 1369 chromeos::MountLibrary::DiskMap::const_iterator volume_it = |
1342 mount_lib->disks().find(volume_device_path); | 1370 mount_lib->disks().find(volume_device_path); |
1343 | 1371 |
1344 if (volume_it != mount_lib->disks().end()) { | 1372 if (volume_it != mount_lib->disks().end()) { |
1345 chromeos::MountLibrary::Disk* volume = volume_it->second; | 1373 chromeos::MountLibrary::Disk* volume = volume_it->second; |
1346 DictionaryValue* volume_info = new DictionaryValue(); | 1374 DictionaryValue* volume_info = new DictionaryValue(); |
1347 result_.reset(volume_info); | 1375 result_.reset(volume_info); |
1348 // Localising mount path. | 1376 // Localising mount path. |
1349 FilePath relative_mount_path; | 1377 std::string mount_path; |
1350 FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, | 1378 if (!volume->mount_path().empty()) { |
1351 FilePath(volume->mount_path()), &relative_mount_path); | 1379 FilePath relative_mount_path; |
1352 | 1380 FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, |
1381 FilePath(volume->mount_path()), &relative_mount_path); | |
1382 mount_path = relative_mount_path.value(); | |
1383 } else { | |
1384 mount_path = "unmounted"; | |
tbarzic
2011/08/24 03:59:44
leave mount_path empty if volume has no mount_path
sidor
2011/08/24 04:26:06
Will do this tomorrow.
| |
1385 } | |
1353 volume_info->SetString("devicePath", volume->device_path()); | 1386 volume_info->SetString("devicePath", volume->device_path()); |
1354 volume_info->SetString("mountPath", relative_mount_path.value()); | 1387 volume_info->SetString("mountPath", mount_path); |
1355 volume_info->SetString("systemPath", volume->system_path()); | 1388 volume_info->SetString("systemPath", volume->system_path()); |
1356 volume_info->SetString("filePath", volume->file_path()); | 1389 volume_info->SetString("filePath", volume->file_path()); |
1357 volume_info->SetString("deviceLabel", volume->device_label()); | 1390 volume_info->SetString("deviceLabel", volume->device_label()); |
1358 volume_info->SetString("driveLabel", volume->drive_label()); | 1391 volume_info->SetString("driveLabel", volume->drive_label()); |
1359 volume_info->SetString("deviceType", | 1392 volume_info->SetString("deviceType", |
1360 DeviceTypeToString(volume->device_type())); | 1393 DeviceTypeToString(volume->device_type())); |
1361 volume_info->SetInteger("totalSize", volume->total_size()); | 1394 volume_info->SetInteger("totalSize", volume->total_size()); |
1362 volume_info->SetBoolean("isParent", volume->is_parent()); | 1395 volume_info->SetBoolean("isParent", volume->is_parent()); |
1363 volume_info->SetBoolean("isReadOnly", volume->is_read_only()); | 1396 volume_info->SetBoolean("isReadOnly", volume->is_read_only()); |
1364 volume_info->SetBoolean("hasMedia", volume->has_media()); | 1397 volume_info->SetBoolean("hasMedia", volume->has_media()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1470 SET_STRING(IDS_FILE_BROWSER, OPEN_LABEL); | 1503 SET_STRING(IDS_FILE_BROWSER, OPEN_LABEL); |
1471 SET_STRING(IDS_FILE_BROWSER, SAVE_LABEL); | 1504 SET_STRING(IDS_FILE_BROWSER, SAVE_LABEL); |
1472 SET_STRING(IDS_FILE_BROWSER, OK_LABEL); | 1505 SET_STRING(IDS_FILE_BROWSER, OK_LABEL); |
1473 | 1506 |
1474 SET_STRING(IDS_FILE_BROWSER, DEFAULT_NEW_FOLDER_NAME); | 1507 SET_STRING(IDS_FILE_BROWSER, DEFAULT_NEW_FOLDER_NAME); |
1475 SET_STRING(IDS_FILE_BROWSER, MORE_FILES); | 1508 SET_STRING(IDS_FILE_BROWSER, MORE_FILES); |
1476 | 1509 |
1477 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_ONE); | 1510 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_ONE); |
1478 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_SOME); | 1511 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_SOME); |
1479 | 1512 |
1513 SET_STRING(IDS_FILE_BROWSER, UNKNOWN_FILESYSTEM_WARNING); | |
1514 SET_STRING(IDS_FILE_BROWSER, UNSUPPORTED_FILESYSTEM_WARNING); | |
1480 SET_STRING(IDS_FILE_BROWSER, FORMATTING_WARNING); | 1515 SET_STRING(IDS_FILE_BROWSER, FORMATTING_WARNING); |
1481 | 1516 |
1482 SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); | 1517 SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); |
1483 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_FILE_TITLE); | 1518 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_FILE_TITLE); |
1484 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_MULTI_FILE_TITLE); | 1519 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_MULTI_FILE_TITLE); |
1485 SET_STRING(IDS_FILE_BROWSER, SELECT_SAVEAS_FILE_TITLE); | 1520 SET_STRING(IDS_FILE_BROWSER, SELECT_SAVEAS_FILE_TITLE); |
1486 | 1521 |
1487 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); | 1522 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); |
1488 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); | 1523 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); |
1489 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); | 1524 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 #undef SET_STRING | 1558 #undef SET_STRING |
1524 | 1559 |
1525 // TODO(serya): Create a new string in .grd file for this one in M13. | 1560 // TODO(serya): Create a new string in .grd file for this one in M13. |
1526 dict->SetString("PREVIEW_IMAGE", | 1561 dict->SetString("PREVIEW_IMAGE", |
1527 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1562 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1528 dict->SetString("PLAY_MEDIA", | 1563 dict->SetString("PLAY_MEDIA", |
1529 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1564 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1530 | 1565 |
1531 return true; | 1566 return true; |
1532 } | 1567 } |
OLD | NEW |