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/chromeos/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 | 479 |
480 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( | 480 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( |
481 const std::string& name, const GURL& root_path) { | 481 const std::string& name, const GURL& root_path) { |
482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
483 // Add gdata mount point immediately when we kick of first instance of file | 483 // Add gdata mount point immediately when we kick of first instance of file |
484 // manager. The actual mount event will be sent to UI only when we perform | 484 // manager. The actual mount event will be sent to UI only when we perform |
485 // proper authentication. | 485 // proper authentication. |
486 if (gdata::util::IsGDataAvailable(profile_)) | 486 if (gdata::util::IsGDataAvailable(profile_)) |
487 AddGDataMountPoint(profile_, extension_id(), render_view_host()); | 487 AddGDataMountPoint(profile_, extension_id(), render_view_host()); |
488 result_.reset(new DictionaryValue()); | 488 SetSingleResult(new DictionaryValue()); |
489 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); | 489 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); |
490 dict->SetString("name", name); | 490 dict->SetString("name", name); |
491 dict->SetString("path", root_path.spec()); | 491 dict->SetString("path", root_path.spec()); |
492 dict->SetInteger("error", base::PLATFORM_FILE_OK); | 492 dict->SetInteger("error", base::PLATFORM_FILE_OK); |
493 SendResponse(true); | 493 SendResponse(true); |
494 } | 494 } |
495 | 495 |
496 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( | 496 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( |
497 base::PlatformFileError error_code) { | 497 base::PlatformFileError error_code) { |
498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 19 matching lines...) Expand all Loading... |
518 *virtual_path, | 518 *virtual_path, |
519 false); | 519 false); |
520 if (root_path == FilePath()) | 520 if (root_path == FilePath()) |
521 return false; | 521 return false; |
522 | 522 |
523 *local_path = root_path.Append(*virtual_path); | 523 *local_path = root_path.Append(*virtual_path); |
524 return true; | 524 return true; |
525 } | 525 } |
526 | 526 |
527 void FileWatchBrowserFunctionBase::RespondOnUIThread(bool success) { | 527 void FileWatchBrowserFunctionBase::RespondOnUIThread(bool success) { |
528 result_.reset(Value::CreateBooleanValue(success)); | 528 SetSingleResult(Value::CreateBooleanValue(success)); |
529 SendResponse(success); | 529 SendResponse(success); |
530 } | 530 } |
531 | 531 |
532 bool FileWatchBrowserFunctionBase::RunImpl() { | 532 bool FileWatchBrowserFunctionBase::RunImpl() { |
533 if (!render_view_host() || !render_view_host()->GetProcess()) | 533 if (!render_view_host() || !render_view_host()->GetProcess()) |
534 return false; | 534 return false; |
535 | 535 |
536 // First param is url of a file to watch. | 536 // First param is url of a file to watch. |
537 std::string url; | 537 std::string url; |
538 if (!args_->GetString(0, &url) || url.empty()) | 538 if (!args_->GetString(0, &url) || url.empty()) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 654 |
655 std::vector<GURL> file_urls; | 655 std::vector<GURL> file_urls; |
656 for (size_t i = 0; i < files_list->GetSize(); ++i) { | 656 for (size_t i = 0; i < files_list->GetSize(); ++i) { |
657 std::string file_url; | 657 std::string file_url; |
658 if (!files_list->GetString(i, &file_url)) | 658 if (!files_list->GetString(i, &file_url)) |
659 return false; | 659 return false; |
660 file_urls.push_back(GURL(file_url)); | 660 file_urls.push_back(GURL(file_url)); |
661 } | 661 } |
662 | 662 |
663 ListValue* result_list = new ListValue(); | 663 ListValue* result_list = new ListValue(); |
664 result_.reset(result_list); | 664 SetSingleResult(result_list); |
665 | 665 |
666 file_handler_util::LastUsedHandlerList common_tasks; | 666 file_handler_util::LastUsedHandlerList common_tasks; |
667 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) | 667 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) |
668 return false; | 668 return false; |
669 | 669 |
670 ExtensionService* service = profile_->GetExtensionService(); | 670 ExtensionService* service = profile_->GetExtensionService(); |
671 for (file_handler_util::LastUsedHandlerList::const_iterator iter = | 671 for (file_handler_util::LastUsedHandlerList::const_iterator iter = |
672 common_tasks.begin(); | 672 common_tasks.begin(); |
673 iter != common_tasks.end(); | 673 iter != common_tasks.end(); |
674 ++iter) { | 674 ++iter) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 FileTaskExecutor::Create(profile(), | 754 FileTaskExecutor::Create(profile(), |
755 source_url(), | 755 source_url(), |
756 extension_id, | 756 extension_id, |
757 action_id)); | 757 action_id)); |
758 | 758 |
759 if (!executor->ExecuteAndNotify( | 759 if (!executor->ExecuteAndNotify( |
760 file_urls, | 760 file_urls, |
761 base::Bind(&ExecuteTasksFileBrowserFunction::OnTaskExecuted, this))) | 761 base::Bind(&ExecuteTasksFileBrowserFunction::OnTaskExecuted, this))) |
762 return false; | 762 return false; |
763 | 763 |
764 result_.reset(new base::FundamentalValue(true)); | 764 SetSingleResult(new base::FundamentalValue(true)); |
765 return true; | 765 return true; |
766 } | 766 } |
767 | 767 |
768 SetDefaultTaskFileBrowserFunction::SetDefaultTaskFileBrowserFunction() {} | 768 SetDefaultTaskFileBrowserFunction::SetDefaultTaskFileBrowserFunction() {} |
769 | 769 |
770 SetDefaultTaskFileBrowserFunction::~SetDefaultTaskFileBrowserFunction() {} | 770 SetDefaultTaskFileBrowserFunction::~SetDefaultTaskFileBrowserFunction() {} |
771 | 771 |
772 bool SetDefaultTaskFileBrowserFunction::RunImpl() { | 772 bool SetDefaultTaskFileBrowserFunction::RunImpl() { |
773 // First param is task id that was to the extension with setDefaultTask call. | 773 // First param is task id that was to the extension with setDefaultTask call. |
774 std::string task_id; | 774 std::string task_id; |
775 if (!args_->GetString(0, &task_id) || !task_id.size()) | 775 if (!args_->GetString(0, &task_id) || !task_id.size()) |
776 return false; | 776 return false; |
777 | 777 |
778 BrowserThread::PostTask( | 778 BrowserThread::PostTask( |
779 BrowserThread::UI, FROM_HERE, | 779 BrowserThread::UI, FROM_HERE, |
780 base::Bind( | 780 base::Bind( |
781 &file_handler_util::UpdateFileHandlerUsageStats, | 781 &file_handler_util::UpdateFileHandlerUsageStats, |
782 profile_, task_id)); | 782 profile_, task_id)); |
783 | 783 |
784 result_.reset(new base::FundamentalValue(true)); | 784 SetSingleResult(new base::FundamentalValue(true)); |
785 return true; | 785 return true; |
786 } | 786 } |
787 | 787 |
788 FileBrowserFunction::FileBrowserFunction() { | 788 FileBrowserFunction::FileBrowserFunction() { |
789 } | 789 } |
790 | 790 |
791 FileBrowserFunction::~FileBrowserFunction() { | 791 FileBrowserFunction::~FileBrowserFunction() { |
792 } | 792 } |
793 | 793 |
794 int32 FileBrowserFunction::GetTabId() const { | 794 int32 FileBrowserFunction::GetTabId() const { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
989 bool success = true; | 989 bool success = true; |
990 for (SelectedFileInfoList::const_iterator iter = files.begin(); | 990 for (SelectedFileInfoList::const_iterator iter = files.begin(); |
991 iter != files.end(); | 991 iter != files.end(); |
992 ++iter) { | 992 ++iter) { |
993 bool handled = file_manager_util::ExecuteBuiltinHandler( | 993 bool handled = file_manager_util::ExecuteBuiltinHandler( |
994 GetCurrentBrowser(), iter->path, internal_task_id); | 994 GetCurrentBrowser(), iter->path, internal_task_id); |
995 if (!handled && files.size() == 1) | 995 if (!handled && files.size() == 1) |
996 success = false; | 996 success = false; |
997 } | 997 } |
998 result_.reset(Value::CreateBooleanValue(success)); | 998 SetSingleResult(Value::CreateBooleanValue(success)); |
999 SendResponse(true); | 999 SendResponse(true); |
1000 } | 1000 } |
1001 | 1001 |
1002 SelectFilesFunction::SelectFilesFunction() { | 1002 SelectFilesFunction::SelectFilesFunction() { |
1003 } | 1003 } |
1004 | 1004 |
1005 SelectFilesFunction::~SelectFilesFunction() { | 1005 SelectFilesFunction::~SelectFilesFunction() { |
1006 } | 1006 } |
1007 | 1007 |
1008 bool SelectFilesFunction::RunImpl() { | 1008 bool SelectFilesFunction::RunImpl() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if (!args_->GetString(0, &file_url)) { | 1061 if (!args_->GetString(0, &file_url)) { |
1062 return false; | 1062 return false; |
1063 } | 1063 } |
1064 | 1064 |
1065 std::string mount_type_str; | 1065 std::string mount_type_str; |
1066 if (!args_->GetString(1, &mount_type_str)) { | 1066 if (!args_->GetString(1, &mount_type_str)) { |
1067 return false; | 1067 return false; |
1068 } | 1068 } |
1069 | 1069 |
1070 // Set default return source path to the empty string. | 1070 // Set default return source path to the empty string. |
1071 result_.reset(Value::CreateStringValue("")); | 1071 SetSingleResult(Value::CreateStringValue("")); |
1072 | 1072 |
1073 chromeos::MountType mount_type = | 1073 chromeos::MountType mount_type = |
1074 DiskMountManager::MountTypeFromString(mount_type_str); | 1074 DiskMountManager::MountTypeFromString(mount_type_str); |
1075 switch (mount_type) { | 1075 switch (mount_type) { |
1076 case chromeos::MOUNT_TYPE_INVALID: { | 1076 case chromeos::MOUNT_TYPE_INVALID: { |
1077 error_ = "Invalid mount type"; | 1077 error_ = "Invalid mount type"; |
1078 SendResponse(false); | 1078 SendResponse(false); |
1079 break; | 1079 break; |
1080 } | 1080 } |
1081 case chromeos::MOUNT_TYPE_GDATA: { | 1081 case chromeos::MOUNT_TYPE_GDATA: { |
(...skipping 25 matching lines...) Expand all Loading... |
1107 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { | 1107 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { |
1108 chromeos::MountError error_code = chromeos::MOUNT_ERROR_NONE; | 1108 chromeos::MountError error_code = chromeos::MOUNT_ERROR_NONE; |
1109 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. | 1109 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. |
1110 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) { | 1110 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) { |
1111 error_code = chromeos::MOUNT_ERROR_NONE; | 1111 error_code = chromeos::MOUNT_ERROR_NONE; |
1112 } else { | 1112 } else { |
1113 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; | 1113 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; |
1114 } | 1114 } |
1115 // Pass back the gdata mount point path as source path. | 1115 // Pass back the gdata mount point path as source path. |
1116 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); | 1116 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); |
1117 result_.reset(Value::CreateStringValue(gdata_path)); | 1117 SetSingleResult(Value::CreateStringValue(gdata_path)); |
1118 DiskMountManager::MountPointInfo mount_info( | 1118 DiskMountManager::MountPointInfo mount_info( |
1119 gdata_path, | 1119 gdata_path, |
1120 gdata_path, | 1120 gdata_path, |
1121 chromeos::MOUNT_TYPE_GDATA, | 1121 chromeos::MOUNT_TYPE_GDATA, |
1122 chromeos::disks::MOUNT_CONDITION_NONE); | 1122 chromeos::disks::MOUNT_CONDITION_NONE); |
1123 // Raise mount event | 1123 // Raise mount event |
1124 FileBrowserEventRouterFactory::GetForProfile(profile_)-> | 1124 FileBrowserEventRouterFactory::GetForProfile(profile_)-> |
1125 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); | 1125 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
1126 } | 1126 } |
1127 | 1127 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1159 } |
1160 } | 1160 } |
1161 | 1161 |
1162 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, | 1162 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, |
1163 const FilePath::StringType& file_name, | 1163 const FilePath::StringType& file_name, |
1164 base::PlatformFileError error, | 1164 base::PlatformFileError error, |
1165 const FilePath& file_path) { | 1165 const FilePath& file_path) { |
1166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1167 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 1167 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
1168 // Pass back the actual source path of the mount point. | 1168 // Pass back the actual source path of the mount point. |
1169 result_.reset(Value::CreateStringValue(file_path.value())); | 1169 SetSingleResult(Value::CreateStringValue(file_path.value())); |
1170 SendResponse(true); | 1170 SendResponse(true); |
1171 // MountPath() takes a std::string. | 1171 // MountPath() takes a std::string. |
1172 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), | 1172 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), |
1173 FilePath(file_name).Extension(), file_name, | 1173 FilePath(file_name).Extension(), file_name, |
1174 DiskMountManager::MountTypeFromString( | 1174 DiskMountManager::MountTypeFromString( |
1175 mount_type)); | 1175 mount_type)); |
1176 } | 1176 } |
1177 | 1177 |
1178 RemoveMountFunction::RemoveMountFunction() { | 1178 RemoveMountFunction::RemoveMountFunction() { |
1179 } | 1179 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 } | 1215 } |
1216 | 1216 |
1217 GetMountPointsFunction::~GetMountPointsFunction() { | 1217 GetMountPointsFunction::~GetMountPointsFunction() { |
1218 } | 1218 } |
1219 | 1219 |
1220 bool GetMountPointsFunction::RunImpl() { | 1220 bool GetMountPointsFunction::RunImpl() { |
1221 if (args_->GetSize()) | 1221 if (args_->GetSize()) |
1222 return false; | 1222 return false; |
1223 | 1223 |
1224 base::ListValue *mounts = new base::ListValue(); | 1224 base::ListValue *mounts = new base::ListValue(); |
1225 result_.reset(mounts); | 1225 SetSingleResult(mounts); |
1226 | 1226 |
1227 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 1227 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
1228 DiskMountManager::MountPointMap mount_points = | 1228 DiskMountManager::MountPointMap mount_points = |
1229 disk_mount_manager->mount_points(); | 1229 disk_mount_manager->mount_points(); |
1230 | 1230 |
1231 for (DiskMountManager::MountPointMap::const_iterator it = | 1231 for (DiskMountManager::MountPointMap::const_iterator it = |
1232 mount_points.begin(); | 1232 mount_points.begin(); |
1233 it != mount_points.end(); | 1233 it != mount_points.end(); |
1234 ++it) { | 1234 ++it) { |
1235 mounts->Append(CreateValueFromMountPoint(profile_, it->second, | 1235 mounts->Append(CreateValueFromMountPoint(profile_, it->second, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 this, | 1326 this, |
1327 total_size_kb, remaining_size_kb)); | 1327 total_size_kb, remaining_size_kb)); |
1328 } | 1328 } |
1329 | 1329 |
1330 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( | 1330 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( |
1331 size_t total_size_kb, | 1331 size_t total_size_kb, |
1332 size_t remaining_size_kb) { | 1332 size_t remaining_size_kb) { |
1333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1334 | 1334 |
1335 base::DictionaryValue* sizes = new base::DictionaryValue(); | 1335 base::DictionaryValue* sizes = new base::DictionaryValue(); |
1336 result_.reset(sizes); | 1336 SetSingleResult(sizes); |
1337 | 1337 |
1338 sizes->SetInteger("totalSizeKB", total_size_kb); | 1338 sizes->SetInteger("totalSizeKB", total_size_kb); |
1339 sizes->SetInteger("remainingSizeKB", remaining_size_kb); | 1339 sizes->SetInteger("remainingSizeKB", remaining_size_kb); |
1340 | 1340 |
1341 SendResponse(true); | 1341 SendResponse(true); |
1342 } | 1342 } |
1343 | 1343 |
1344 FormatDeviceFunction::FormatDeviceFunction() { | 1344 FormatDeviceFunction::FormatDeviceFunction() { |
1345 } | 1345 } |
1346 | 1346 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 const SelectedFileInfoList& files) { | 1412 const SelectedFileInfoList& files) { |
1413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1414 | 1414 |
1415 // Should contain volume's mount path. | 1415 // Should contain volume's mount path. |
1416 if (files.size() != 1) { | 1416 if (files.size() != 1) { |
1417 error_ = "Invalid mount path."; | 1417 error_ = "Invalid mount path."; |
1418 SendResponse(false); | 1418 SendResponse(false); |
1419 return; | 1419 return; |
1420 } | 1420 } |
1421 | 1421 |
1422 result_.reset(); | 1422 SetSingleResult(); |
1423 | 1423 |
1424 const DiskMountManager::Disk* volume = GetVolumeAsDisk( | 1424 const DiskMountManager::Disk* volume = GetVolumeAsDisk( |
1425 files[0].path.value()); | 1425 files[0].path.value()); |
1426 if (volume) { | 1426 if (volume) { |
1427 DictionaryValue* volume_info = | 1427 DictionaryValue* volume_info = |
1428 CreateValueFromDisk(profile_, volume); | 1428 CreateValueFromDisk(profile_, volume); |
1429 result_.reset(volume_info); | 1429 SetSingleResult(volume_info); |
1430 } | 1430 } |
1431 | 1431 |
1432 SendResponse(true); | 1432 SendResponse(true); |
1433 } | 1433 } |
1434 | 1434 |
1435 bool ToggleFullscreenFunction::RunImpl() { | 1435 bool ToggleFullscreenFunction::RunImpl() { |
1436 Browser* browser = GetCurrentBrowser(); | 1436 Browser* browser = GetCurrentBrowser(); |
1437 if (browser) { | 1437 if (browser) { |
1438 browser->ToggleFullscreenModeWithExtension( | 1438 browser->ToggleFullscreenModeWithExtension( |
1439 file_manager_util::GetFileBrowserExtensionUrl()); | 1439 file_manager_util::GetFileBrowserExtensionUrl()); |
1440 } | 1440 } |
1441 return true; | 1441 return true; |
1442 } | 1442 } |
1443 | 1443 |
1444 bool IsFullscreenFunction::RunImpl() { | 1444 bool IsFullscreenFunction::RunImpl() { |
1445 Browser* browser = GetCurrentBrowser(); | 1445 Browser* browser = GetCurrentBrowser(); |
1446 result_.reset(Value::CreateBooleanValue( | 1446 SetSingleResult(Value::CreateBooleanValue( |
1447 browser && browser->window() && browser->window()->IsFullscreen())); | 1447 browser && browser->window() && browser->window()->IsFullscreen())); |
1448 return true; | 1448 return true; |
1449 } | 1449 } |
1450 | 1450 |
1451 bool FileDialogStringsFunction::RunImpl() { | 1451 bool FileDialogStringsFunction::RunImpl() { |
1452 result_.reset(new DictionaryValue()); | 1452 SetSingleResult(new DictionaryValue()); |
1453 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); | 1453 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); |
1454 | 1454 |
1455 #define SET_STRING(ns, id) \ | 1455 #define SET_STRING(ns, id) \ |
1456 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) | 1456 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) |
1457 | 1457 |
1458 SET_STRING(IDS, WEB_FONT_FAMILY); | 1458 SET_STRING(IDS, WEB_FONT_FAMILY); |
1459 SET_STRING(IDS, WEB_FONT_SIZE); | 1459 SET_STRING(IDS, WEB_FONT_SIZE); |
1460 | 1460 |
1461 SET_STRING(IDS_FILE_BROWSER, ROOT_DIRECTORY_LABEL); | 1461 SET_STRING(IDS_FILE_BROWSER, ROOT_DIRECTORY_LABEL); |
1462 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_DIRECTORY_LABEL); | 1462 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_DIRECTORY_LABEL); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 | 1745 |
1746 file_properties_.reset(new base::ListValue); | 1746 file_properties_.reset(new base::ListValue); |
1747 | 1747 |
1748 current_index_ = 0; | 1748 current_index_ = 0; |
1749 GetNextFileProperties(); | 1749 GetNextFileProperties(); |
1750 } | 1750 } |
1751 | 1751 |
1752 void GetGDataFilePropertiesFunction::GetNextFileProperties() { | 1752 void GetGDataFilePropertiesFunction::GetNextFileProperties() { |
1753 if (current_index_ >= path_list_->GetSize()) { | 1753 if (current_index_ >= path_list_->GetSize()) { |
1754 // Exit of asynchronous look and return the result. | 1754 // Exit of asynchronous look and return the result. |
1755 result_.reset(file_properties_.release()); | 1755 SetSingleResult(file_properties_.release()); |
1756 SendResponse(true); | 1756 SendResponse(true); |
1757 return; | 1757 return; |
1758 } | 1758 } |
1759 | 1759 |
1760 std::string file_str; | 1760 std::string file_str; |
1761 path_list_->GetString(current_index_, &file_str); | 1761 path_list_->GetString(current_index_, &file_str); |
1762 GURL file_url = GURL(file_str); | 1762 GURL file_url = GURL(file_str); |
1763 FilePath file_path = GetVirtualPathFromURL(file_url); | 1763 FilePath file_path = GetVirtualPathFromURL(file_url); |
1764 | 1764 |
1765 base::DictionaryValue* property_dict = new base::DictionaryValue; | 1765 base::DictionaryValue* property_dict = new base::DictionaryValue; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 | 1967 |
1968 ListValue* locations = new ListValue; | 1968 ListValue* locations = new ListValue; |
1969 for (size_t i = 0; i < files.size(); ++i) { | 1969 for (size_t i = 0; i < files.size(); ++i) { |
1970 if (gdata::util::IsUnderGDataMountPoint(files[i].path)) { | 1970 if (gdata::util::IsUnderGDataMountPoint(files[i].path)) { |
1971 locations->Append(Value::CreateStringValue("drive")); | 1971 locations->Append(Value::CreateStringValue("drive")); |
1972 } else { | 1972 } else { |
1973 locations->Append(Value::CreateStringValue("local")); | 1973 locations->Append(Value::CreateStringValue("local")); |
1974 } | 1974 } |
1975 } | 1975 } |
1976 | 1976 |
1977 result_.reset(locations); | 1977 SetSingleResult(locations); |
1978 SendResponse(true); | 1978 SendResponse(true); |
1979 } | 1979 } |
1980 | 1980 |
1981 GetGDataFilesFunction::GetGDataFilesFunction() | 1981 GetGDataFilesFunction::GetGDataFilesFunction() |
1982 : local_paths_(NULL) { | 1982 : local_paths_(NULL) { |
1983 } | 1983 } |
1984 | 1984 |
1985 GetGDataFilesFunction::~GetGDataFilesFunction() { | 1985 GetGDataFilesFunction::~GetGDataFilesFunction() { |
1986 } | 1986 } |
1987 | 1987 |
(...skipping 28 matching lines...) Expand all Loading... |
2016 remaining_gdata_paths_.push(gdata_path); | 2016 remaining_gdata_paths_.push(gdata_path); |
2017 } | 2017 } |
2018 | 2018 |
2019 local_paths_ = new ListValue; | 2019 local_paths_ = new ListValue; |
2020 GetFileOrSendResponse(); | 2020 GetFileOrSendResponse(); |
2021 } | 2021 } |
2022 | 2022 |
2023 void GetGDataFilesFunction::GetFileOrSendResponse() { | 2023 void GetGDataFilesFunction::GetFileOrSendResponse() { |
2024 // Send the response if all files are obtained. | 2024 // Send the response if all files are obtained. |
2025 if (remaining_gdata_paths_.empty()) { | 2025 if (remaining_gdata_paths_.empty()) { |
2026 result_.reset(local_paths_); | 2026 SetSingleResult(local_paths_); |
2027 SendResponse(true); | 2027 SendResponse(true); |
2028 return; | 2028 return; |
2029 } | 2029 } |
2030 | 2030 |
2031 gdata::GDataSystemService* system_service = | 2031 gdata::GDataSystemService* system_service = |
2032 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2032 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2033 DCHECK(system_service); | 2033 DCHECK(system_service); |
2034 | 2034 |
2035 // Get the file on the top of the queue. | 2035 // Get the file on the top of the queue. |
2036 FilePath gdata_path = remaining_gdata_paths_.front(); | 2036 FilePath gdata_path = remaining_gdata_paths_.front(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 profile_, source_url_.GetOrigin(), list); | 2086 profile_, source_url_.GetOrigin(), list); |
2087 } | 2087 } |
2088 | 2088 |
2089 bool GetFileTransfersFunction::RunImpl() { | 2089 bool GetFileTransfersFunction::RunImpl() { |
2090 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); | 2090 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); |
2091 if (!progress_status_list.get()) { | 2091 if (!progress_status_list.get()) { |
2092 SendResponse(false); | 2092 SendResponse(false); |
2093 return false; | 2093 return false; |
2094 } | 2094 } |
2095 | 2095 |
2096 result_.reset(progress_status_list.release()); | 2096 SetSingleResult(progress_status_list.release()); |
2097 SendResponse(true); | 2097 SendResponse(true); |
2098 return true; | 2098 return true; |
2099 } | 2099 } |
2100 | 2100 |
2101 | 2101 |
2102 CancelFileTransfersFunction::CancelFileTransfersFunction() {} | 2102 CancelFileTransfersFunction::CancelFileTransfersFunction() {} |
2103 | 2103 |
2104 CancelFileTransfersFunction::~CancelFileTransfersFunction() {} | 2104 CancelFileTransfersFunction::~CancelFileTransfersFunction() {} |
2105 | 2105 |
2106 bool CancelFileTransfersFunction::RunImpl() { | 2106 bool CancelFileTransfersFunction::RunImpl() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 GURL file_url; | 2150 GURL file_url; |
2151 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, | 2151 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, |
2152 gdata::util::GetSpecialRemoteRootPath().Append(file_path), | 2152 gdata::util::GetSpecialRemoteRootPath().Append(file_path), |
2153 source_url_.GetOrigin(), | 2153 source_url_.GetOrigin(), |
2154 &file_url)) { | 2154 &file_url)) { |
2155 result->SetString("fileUrl", file_url.spec()); | 2155 result->SetString("fileUrl", file_url.spec()); |
2156 } | 2156 } |
2157 | 2157 |
2158 responses->Append(result.release()); | 2158 responses->Append(result.release()); |
2159 } | 2159 } |
2160 result_.reset(responses.release()); | 2160 SetSingleResult(responses.release()); |
2161 SendResponse(true); | 2161 SendResponse(true); |
2162 } | 2162 } |
2163 | 2163 |
2164 TransferFileFunction::TransferFileFunction() {} | 2164 TransferFileFunction::TransferFileFunction() {} |
2165 | 2165 |
2166 TransferFileFunction::~TransferFileFunction() {} | 2166 TransferFileFunction::~TransferFileFunction() {} |
2167 | 2167 |
2168 bool TransferFileFunction::RunImpl() { | 2168 bool TransferFileFunction::RunImpl() { |
2169 std::string local_file_url; | 2169 std::string local_file_url; |
2170 std::string remote_file_url; | 2170 std::string remote_file_url; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 AddGDataMountPoint(profile_, extension_id(), render_view_host()); | 2251 AddGDataMountPoint(profile_, extension_id(), render_view_host()); |
2252 | 2252 |
2253 value->SetBoolean("driveEnabled", driveEnabled); | 2253 value->SetBoolean("driveEnabled", driveEnabled); |
2254 | 2254 |
2255 value->SetBoolean("cellularDisabled", | 2255 value->SetBoolean("cellularDisabled", |
2256 service->GetBoolean(prefs::kDisableGDataOverCellular)); | 2256 service->GetBoolean(prefs::kDisableGDataOverCellular)); |
2257 | 2257 |
2258 value->SetBoolean("hostedFilesDisabled", | 2258 value->SetBoolean("hostedFilesDisabled", |
2259 service->GetBoolean(prefs::kDisableGDataHostedFiles)); | 2259 service->GetBoolean(prefs::kDisableGDataHostedFiles)); |
2260 | 2260 |
2261 result_.reset(value.release()); | 2261 SetSingleResult(value.release()); |
2262 return true; | 2262 return true; |
2263 } | 2263 } |
2264 | 2264 |
2265 // Write GData-related preferences. | 2265 // Write GData-related preferences. |
2266 bool SetGDataPreferencesFunction::RunImpl() { | 2266 bool SetGDataPreferencesFunction::RunImpl() { |
2267 base::DictionaryValue* value = NULL; | 2267 base::DictionaryValue* value = NULL; |
2268 | 2268 |
2269 if (!args_->GetDictionary(0, &value) || !value) | 2269 if (!args_->GetDictionary(0, &value) || !value) |
2270 return false; | 2270 return false; |
2271 | 2271 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 | 2303 |
2304 void GetPathForDriveSearchResultFunction::OnEntryFound( | 2304 void GetPathForDriveSearchResultFunction::OnEntryFound( |
2305 base::PlatformFileError error, | 2305 base::PlatformFileError error, |
2306 const FilePath& entry_path, | 2306 const FilePath& entry_path, |
2307 scoped_ptr<gdata::GDataEntryProto> entry_proto) { | 2307 scoped_ptr<gdata::GDataEntryProto> entry_proto) { |
2308 if (error != base::PLATFORM_FILE_OK) { | 2308 if (error != base::PLATFORM_FILE_OK) { |
2309 SendResponse(false); | 2309 SendResponse(false); |
2310 return; | 2310 return; |
2311 } | 2311 } |
2312 | 2312 |
2313 result_.reset(Value::CreateStringValue(entry_path.value())); | 2313 SetSingleResult(Value::CreateStringValue(entry_path.value())); |
2314 SendResponse(true); | 2314 SendResponse(true); |
2315 } | 2315 } |
2316 | 2316 |
2317 bool SearchDriveFunction::RunImpl() { | 2317 bool SearchDriveFunction::RunImpl() { |
2318 if (!args_->GetString(0, &query_)) | 2318 if (!args_->GetString(0, &query_)) |
2319 return false; | 2319 return false; |
2320 | 2320 |
2321 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( | 2321 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( |
2322 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, | 2322 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, |
2323 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); | 2323 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 for (size_t i = 0; i < results->size(); ++i) { | 2363 for (size_t i = 0; i < results->size(); ++i) { |
2364 DictionaryValue* entry = new DictionaryValue(); | 2364 DictionaryValue* entry = new DictionaryValue(); |
2365 entry->SetString("fileSystemName", file_system_name_); | 2365 entry->SetString("fileSystemName", file_system_name_); |
2366 entry->SetString("fileSystemRoot", file_system_url_.spec()); | 2366 entry->SetString("fileSystemRoot", file_system_url_.spec()); |
2367 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 2367 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
2368 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 2368 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
2369 | 2369 |
2370 entries->Append(entry); | 2370 entries->Append(entry); |
2371 } | 2371 } |
2372 | 2372 |
2373 result_.reset(entries); | 2373 SetSingleResult(entries); |
2374 SendResponse(true); | 2374 SendResponse(true); |
2375 } | 2375 } |
2376 | 2376 |
2377 bool GetNetworkConnectionStateFunction::RunImpl() { | 2377 bool GetNetworkConnectionStateFunction::RunImpl() { |
2378 chromeos::NetworkLibrary* network_library = | 2378 chromeos::NetworkLibrary* network_library = |
2379 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 2379 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
2380 if (!network_library) | 2380 if (!network_library) |
2381 return false; | 2381 return false; |
2382 | 2382 |
2383 const chromeos::Network* active_network = network_library->active_network(); | 2383 const chromeos::Network* active_network = network_library->active_network(); |
2384 | 2384 |
2385 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 2385 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
2386 value->SetBoolean("online", active_network && active_network->online()); | 2386 value->SetBoolean("online", active_network && active_network->online()); |
2387 | 2387 |
2388 std::string type_string; | 2388 std::string type_string; |
2389 if (!active_network) | 2389 if (!active_network) |
2390 type_string = "none"; | 2390 type_string = "none"; |
2391 else if (active_network->type() == chromeos::TYPE_CELLULAR) | 2391 else if (active_network->type() == chromeos::TYPE_CELLULAR) |
2392 type_string = "cellular"; | 2392 type_string = "cellular"; |
2393 else | 2393 else |
2394 type_string = "ethernet"; // Currently we do not care about other types. | 2394 type_string = "ethernet"; // Currently we do not care about other types. |
2395 | 2395 |
2396 value->SetString("type", type_string); | 2396 value->SetString("type", type_string); |
2397 result_.reset(value.release()); | 2397 SetSingleResult(value.release()); |
2398 | 2398 |
2399 return true; | 2399 return true; |
2400 } | 2400 } |
2401 | 2401 |
2402 bool RequestDirectoryRefreshFunction::RunImpl() { | 2402 bool RequestDirectoryRefreshFunction::RunImpl() { |
2403 std::string file_url_as_string; | 2403 std::string file_url_as_string; |
2404 if (!args_->GetString(0, &file_url_as_string)) | 2404 if (!args_->GetString(0, &file_url_as_string)) |
2405 return false; | 2405 return false; |
2406 | 2406 |
2407 gdata::GDataSystemService* system_service = | 2407 gdata::GDataSystemService* system_service = |
2408 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2408 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2409 if (!system_service || !system_service->file_system()) | 2409 if (!system_service || !system_service->file_system()) |
2410 return false; | 2410 return false; |
2411 | 2411 |
2412 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2412 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2413 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2413 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2414 | 2414 |
2415 return true; | 2415 return true; |
2416 } | 2416 } |
OLD | NEW |