Chromium Code Reviews| 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 BrowserThread::UI, FROM_HERE, | 644 BrowserThread::UI, FROM_HERE, |
| 645 NewRunnableMethod(function_, | 645 NewRunnableMethod(function_, |
| 646 &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); | 646 &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); |
| 647 } | 647 } |
| 648 | 648 |
| 649 private: | 649 private: |
| 650 // Checks legitimacy of file url and grants file RO access permissions from | 650 // Checks legitimacy of file url and grants file RO access permissions from |
| 651 // handler (target) extension and its renderer process. | 651 // handler (target) extension and its renderer process. |
| 652 bool SetupFileAccessPermissions(const GURL& origin_file_url, | 652 bool SetupFileAccessPermissions(const GURL& origin_file_url, |
| 653 GURL* target_file_url, FilePath* file_path, bool* is_directory) { | 653 GURL* target_file_url, FilePath* file_path, bool* is_directory) { |
| 654 | |
| 655 if (!extension_.get()) | 654 if (!extension_.get()) |
| 656 return false; | 655 return false; |
| 657 | 656 |
| 658 GURL file_origin_url; | 657 GURL file_origin_url; |
| 659 FilePath virtual_path; | 658 FilePath virtual_path; |
| 660 fileapi::FileSystemType type; | 659 fileapi::FileSystemType type; |
| 661 if (!CrackFileSystemURL(origin_file_url, &file_origin_url, &type, | 660 if (!CrackFileSystemURL(origin_file_url, &file_origin_url, &type, |
| 662 &virtual_path)) { | 661 &virtual_path)) { |
| 663 return false; | 662 return false; |
| 664 } | 663 } |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1280 } | 1279 } |
| 1281 | 1280 |
| 1282 FormatDeviceFunction::~FormatDeviceFunction() { | 1281 FormatDeviceFunction::~FormatDeviceFunction() { |
| 1283 } | 1282 } |
| 1284 | 1283 |
| 1285 bool FormatDeviceFunction::RunImpl() { | 1284 bool FormatDeviceFunction::RunImpl() { |
| 1286 if (args_->GetSize() != 1) { | 1285 if (args_->GetSize() != 1) { |
| 1287 return false; | 1286 return false; |
| 1288 } | 1287 } |
| 1289 | 1288 |
| 1290 std::string volume_mount_path; | 1289 std::string volume_file_url; |
| 1291 if (!args_->GetString(0, &volume_mount_path)) { | 1290 if (!args_->GetString(0, &volume_file_url)) { |
| 1292 NOTREACHED(); | 1291 NOTREACHED(); |
| 1293 return false; | 1292 return false; |
| 1294 } | 1293 } |
| 1295 | 1294 |
| 1295 UrlList file_paths; | |
| 1296 file_paths.push_back(GURL(volume_file_url)); | |
| 1297 | |
| 1298 BrowserThread::PostTask( | |
| 1299 BrowserThread::FILE, FROM_HERE, | |
| 1300 NewRunnableMethod(this, | |
| 1301 &FormatDeviceFunction::GetLocalPathsOnFileThread, | |
| 1302 file_paths, reinterpret_cast<void*>(NULL))); | |
| 1303 return true; | |
| 1304 } | |
| 1305 | |
| 1306 void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( | |
| 1307 const FilePathList& files, void* context) { | |
| 1308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 1309 | |
| 1310 if (!files.size()) { | |
|
tbarzic
2011/08/10 21:04:56
files.size() != 1 (you can format only one device)
sidor.dev
2011/08/10 22:38:17
Done.
| |
| 1311 SendResponse(false); | |
| 1312 return; | |
| 1313 } | |
| 1314 // FormatMountedDevice expects that path ends with '/'. | |
| 1315 std::string mount_path = files[0].value().data(); | |
|
tbarzic
2011/08/10 21:04:56
files[0].value() should be sufficient..
You could
sidor.dev
2011/08/10 22:38:17
Done.
| |
| 1316 if (mount_path[mount_path.length()-1] != '/') | |
|
tbarzic
2011/08/10 21:04:56
spaces around -
Also, I don't think you shouldn't
sidor.dev
2011/08/10 22:38:17
spaces done.
second issue - discussed.
| |
| 1317 mount_path.push_back('/'); | |
| 1318 | |
| 1296 #ifdef OS_CHROMEOS | 1319 #ifdef OS_CHROMEOS |
| 1297 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( | 1320 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( |
| 1298 volume_mount_path.c_str()); | 1321 mount_path.c_str()); |
| 1299 #endif | 1322 #endif |
| 1300 | 1323 |
| 1301 SendResponse(true); | 1324 SendResponse(true); |
| 1302 return true; | |
| 1303 } | 1325 } |
| 1304 | 1326 |
| 1305 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { | 1327 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { |
| 1306 } | 1328 } |
| 1307 | 1329 |
| 1308 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { | 1330 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { |
| 1309 } | 1331 } |
| 1310 | 1332 |
| 1311 bool GetVolumeMetadataFunction::RunImpl() { | 1333 bool GetVolumeMetadataFunction::RunImpl() { |
| 1312 if (args_->GetSize() != 1) { | 1334 if (args_->GetSize() != 1) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1400 SET_STRING(IDS_FILE_BROWSER, DIMENSIONS_FORMAT); | 1422 SET_STRING(IDS_FILE_BROWSER, DIMENSIONS_FORMAT); |
| 1401 | 1423 |
| 1402 SET_STRING(IDS_FILE_BROWSER, EJECT_BUTTON); | 1424 SET_STRING(IDS_FILE_BROWSER, EJECT_BUTTON); |
| 1403 SET_STRING(IDS_FILE_BROWSER, IMAGE_DIMENSIONS); | 1425 SET_STRING(IDS_FILE_BROWSER, IMAGE_DIMENSIONS); |
| 1404 SET_STRING(IDS_FILE_BROWSER, VOLUME_LABEL); | 1426 SET_STRING(IDS_FILE_BROWSER, VOLUME_LABEL); |
| 1405 SET_STRING(IDS_FILE_BROWSER, READ_ONLY); | 1427 SET_STRING(IDS_FILE_BROWSER, READ_ONLY); |
| 1406 | 1428 |
| 1407 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_MOUNT_FAILED); | 1429 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_MOUNT_FAILED); |
| 1408 SET_STRING(IDS_FILE_BROWSER, MOUNT_ARCHIVE); | 1430 SET_STRING(IDS_FILE_BROWSER, MOUNT_ARCHIVE); |
| 1409 SET_STRING(IDS_FILE_BROWSER, UNMOUNT_ARCHIVE); | 1431 SET_STRING(IDS_FILE_BROWSER, UNMOUNT_ARCHIVE); |
| 1432 SET_STRING(IDS_FILE_BROWSER, FORMAT_DEVICE); | |
| 1410 | 1433 |
| 1411 SET_STRING(IDS_FILE_BROWSER, CONFIRM_OVERWRITE_FILE); | 1434 SET_STRING(IDS_FILE_BROWSER, CONFIRM_OVERWRITE_FILE); |
| 1412 SET_STRING(IDS_FILE_BROWSER, FILE_ALREADY_EXISTS); | 1435 SET_STRING(IDS_FILE_BROWSER, FILE_ALREADY_EXISTS); |
| 1413 SET_STRING(IDS_FILE_BROWSER, DIRECTORY_ALREADY_EXISTS); | 1436 SET_STRING(IDS_FILE_BROWSER, DIRECTORY_ALREADY_EXISTS); |
| 1414 SET_STRING(IDS_FILE_BROWSER, ERROR_RENAMING); | 1437 SET_STRING(IDS_FILE_BROWSER, ERROR_RENAMING); |
| 1415 SET_STRING(IDS_FILE_BROWSER, RENAME_PROMPT); | 1438 SET_STRING(IDS_FILE_BROWSER, RENAME_PROMPT); |
| 1416 SET_STRING(IDS_FILE_BROWSER, RENAME_BUTTON_LABEL); | 1439 SET_STRING(IDS_FILE_BROWSER, RENAME_BUTTON_LABEL); |
| 1417 | 1440 |
| 1418 SET_STRING(IDS_FILE_BROWSER, ERROR_DELETING); | 1441 SET_STRING(IDS_FILE_BROWSER, ERROR_DELETING); |
| 1419 SET_STRING(IDS_FILE_BROWSER, DELETE_BUTTON_LABEL); | 1442 SET_STRING(IDS_FILE_BROWSER, DELETE_BUTTON_LABEL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1464 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); | 1487 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); |
| 1465 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); | 1488 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); |
| 1466 SET_STRING(IDS_FILE_BROWSER, ONE_DIRECTORY_SELECTED); | 1489 SET_STRING(IDS_FILE_BROWSER, ONE_DIRECTORY_SELECTED); |
| 1467 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); | 1490 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); |
| 1468 SET_STRING(IDS_FILE_BROWSER, MANY_DIRECTORIES_SELECTED); | 1491 SET_STRING(IDS_FILE_BROWSER, MANY_DIRECTORIES_SELECTED); |
| 1469 SET_STRING(IDS_FILE_BROWSER, MANY_ENTRIES_SELECTED); | 1492 SET_STRING(IDS_FILE_BROWSER, MANY_ENTRIES_SELECTED); |
| 1470 | 1493 |
| 1471 SET_STRING(IDS_FILE_BROWSER, PLAYBACK_ERROR); | 1494 SET_STRING(IDS_FILE_BROWSER, PLAYBACK_ERROR); |
| 1472 | 1495 |
| 1473 // MP3 metadata extractor plugin | 1496 // MP3 metadata extractor plugin |
| 1474 SET_STRING(IDS_FILE_BROWSER, ID3_ALBUM); // TALB | 1497 SET_STRING(IDS_FILE_BROWSER, ID3_ALBUM); // TALB |
| 1475 SET_STRING(IDS_FILE_BROWSER, ID3_BPM); // TBPM | 1498 SET_STRING(IDS_FILE_BROWSER, ID3_BPM); // TBPM |
| 1476 SET_STRING(IDS_FILE_BROWSER, ID3_COMPOSER); // TCOM | 1499 SET_STRING(IDS_FILE_BROWSER, ID3_COMPOSER); // TCOM |
| 1477 SET_STRING(IDS_FILE_BROWSER, ID3_COPYRIGHT_MESSAGE); // TCOP | 1500 SET_STRING(IDS_FILE_BROWSER, ID3_COPYRIGHT_MESSAGE); // TCOP |
| 1478 SET_STRING(IDS_FILE_BROWSER, ID3_DATE); // TDAT | 1501 SET_STRING(IDS_FILE_BROWSER, ID3_DATE); // TDAT |
| 1479 SET_STRING(IDS_FILE_BROWSER, ID3_PLAYLIST_DELAY); // TDLY | 1502 SET_STRING(IDS_FILE_BROWSER, ID3_PLAYLIST_DELAY); // TDLY |
| 1480 SET_STRING(IDS_FILE_BROWSER, ID3_ENCODED_BY); // TENC | 1503 SET_STRING(IDS_FILE_BROWSER, ID3_ENCODED_BY); // TENC |
| 1481 SET_STRING(IDS_FILE_BROWSER, ID3_LYRICIST); // TEXT | 1504 SET_STRING(IDS_FILE_BROWSER, ID3_LYRICIST); // TEXT |
| 1482 SET_STRING(IDS_FILE_BROWSER, ID3_FILE_TYPE); // TFLT | 1505 SET_STRING(IDS_FILE_BROWSER, ID3_FILE_TYPE); // TFLT |
| 1483 SET_STRING(IDS_FILE_BROWSER, ID3_TIME); // TIME | 1506 SET_STRING(IDS_FILE_BROWSER, ID3_TIME); // TIME |
| 1484 SET_STRING(IDS_FILE_BROWSER, ID3_TITLE); // TIT2 | 1507 SET_STRING(IDS_FILE_BROWSER, ID3_TITLE); // TIT2 |
| 1485 SET_STRING(IDS_FILE_BROWSER, ID3_LENGTH); // TLEN | 1508 SET_STRING(IDS_FILE_BROWSER, ID3_LENGTH); // TLEN |
| 1486 SET_STRING(IDS_FILE_BROWSER, ID3_FILE_OWNER); // TOWN | 1509 SET_STRING(IDS_FILE_BROWSER, ID3_FILE_OWNER); // TOWN |
| 1487 SET_STRING(IDS_FILE_BROWSER, ID3_LEAD_PERFORMER); // TPE1 | 1510 SET_STRING(IDS_FILE_BROWSER, ID3_LEAD_PERFORMER); // TPE1 |
| 1488 SET_STRING(IDS_FILE_BROWSER, ID3_BAND); // TPE2 | 1511 SET_STRING(IDS_FILE_BROWSER, ID3_BAND); // TPE2 |
| 1489 SET_STRING(IDS_FILE_BROWSER, ID3_TRACK_NUMBER); // TRCK | 1512 SET_STRING(IDS_FILE_BROWSER, ID3_TRACK_NUMBER); // TRCK |
| 1490 SET_STRING(IDS_FILE_BROWSER, ID3_YEAR); // TYER | 1513 SET_STRING(IDS_FILE_BROWSER, ID3_YEAR); // TYER |
| 1491 SET_STRING(IDS_FILE_BROWSER, ID3_COPYRIGHT); // WCOP | 1514 SET_STRING(IDS_FILE_BROWSER, ID3_COPYRIGHT); // WCOP |
| 1492 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_AUDIO_FILE_WEBPAGE); // WOAF | 1515 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_AUDIO_FILE_WEBPAGE); // WOAF |
| 1493 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_ARTIST); // WOAR | 1516 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_ARTIST); // WOAR |
| 1494 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_AUDIO_SOURCE_WEBPAGE); // WOAS | 1517 SET_STRING(IDS_FILE_BROWSER, ID3_OFFICIAL_AUDIO_SOURCE_WEBPAGE); // WOAS |
| 1495 SET_STRING(IDS_FILE_BROWSER, ID3_PUBLISHERS_OFFICIAL_WEBPAGE); // WPUB | 1518 SET_STRING(IDS_FILE_BROWSER, ID3_PUBLISHERS_OFFICIAL_WEBPAGE); // WPUB |
| 1496 SET_STRING(IDS_FILE_BROWSER, ID3_USER_DEFINED_URL_LINK_FRAME); // WXXX | 1519 SET_STRING(IDS_FILE_BROWSER, ID3_USER_DEFINED_URL_LINK_FRAME); // WXXX |
| 1497 | 1520 |
| 1498 SET_STRING(IDS_FILEBROWSER, ENQUEUE); | 1521 SET_STRING(IDS_FILEBROWSER, ENQUEUE); |
| 1499 #undef SET_STRING | 1522 #undef SET_STRING |
| 1500 | 1523 |
| 1501 // TODO(serya): Create a new string in .grd file for this one in M13. | 1524 // TODO(serya): Create a new string in .grd file for this one in M13. |
| 1502 dict->SetString("PREVIEW_IMAGE", | 1525 dict->SetString("PREVIEW_IMAGE", |
| 1503 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1526 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
| 1504 dict->SetString("PLAY_MEDIA", | 1527 dict->SetString("PLAY_MEDIA", |
| 1505 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1528 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
| 1506 | 1529 |
| 1507 return true; | 1530 return true; |
| 1508 } | 1531 } |
| OLD | NEW |