| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 | 484 |
| 485 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( | 485 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( |
| 486 const std::string& name, const GURL& root_path) { | 486 const std::string& name, const GURL& root_path) { |
| 487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 488 // Add gdata mount point immediately when we kick of first instance of file | 488 // Add gdata mount point immediately when we kick of first instance of file |
| 489 // manager. The actual mount event will be sent to UI only when we perform | 489 // manager. The actual mount event will be sent to UI only when we perform |
| 490 // proper authentication. | 490 // proper authentication. |
| 491 if (gdata::util::IsGDataAvailable(profile_)) | 491 if (gdata::util::IsGDataAvailable(profile_)) |
| 492 AddGDataMountPoint(profile_, extension_id(), render_view_host()); | 492 AddGDataMountPoint(profile_, extension_id(), render_view_host()); |
| 493 result_.reset(new DictionaryValue()); | 493 DictionaryValue* dict = new DictionaryValue(); |
| 494 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); | 494 SetResult(dict); |
| 495 dict->SetString("name", name); | 495 dict->SetString("name", name); |
| 496 dict->SetString("path", root_path.spec()); | 496 dict->SetString("path", root_path.spec()); |
| 497 dict->SetInteger("error", base::PLATFORM_FILE_OK); | 497 dict->SetInteger("error", base::PLATFORM_FILE_OK); |
| 498 SendResponse(true); | 498 SendResponse(true); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( | 501 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( |
| 502 base::PlatformFileError error_code) { | 502 base::PlatformFileError error_code) { |
| 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 504 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code)); | 504 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 524 *virtual_path, | 524 *virtual_path, |
| 525 false); | 525 false); |
| 526 if (root_path == FilePath()) | 526 if (root_path == FilePath()) |
| 527 return false; | 527 return false; |
| 528 | 528 |
| 529 *local_path = root_path.Append(*virtual_path); | 529 *local_path = root_path.Append(*virtual_path); |
| 530 return true; | 530 return true; |
| 531 } | 531 } |
| 532 | 532 |
| 533 void FileWatchBrowserFunctionBase::RespondOnUIThread(bool success) { | 533 void FileWatchBrowserFunctionBase::RespondOnUIThread(bool success) { |
| 534 result_.reset(Value::CreateBooleanValue(success)); | 534 SetResult(Value::CreateBooleanValue(success)); |
| 535 SendResponse(success); | 535 SendResponse(success); |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool FileWatchBrowserFunctionBase::RunImpl() { | 538 bool FileWatchBrowserFunctionBase::RunImpl() { |
| 539 if (!render_view_host() || !render_view_host()->GetProcess()) | 539 if (!render_view_host() || !render_view_host()->GetProcess()) |
| 540 return false; | 540 return false; |
| 541 | 541 |
| 542 // First param is url of a file to watch. | 542 // First param is url of a file to watch. |
| 543 std::string url; | 543 std::string url; |
| 544 if (!args_->GetString(0, &url) || url.empty()) | 544 if (!args_->GetString(0, &url) || url.empty()) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 665 |
| 666 std::vector<GURL> file_urls; | 666 std::vector<GURL> file_urls; |
| 667 for (size_t i = 0; i < files_list->GetSize(); ++i) { | 667 for (size_t i = 0; i < files_list->GetSize(); ++i) { |
| 668 std::string file_url; | 668 std::string file_url; |
| 669 if (!files_list->GetString(i, &file_url)) | 669 if (!files_list->GetString(i, &file_url)) |
| 670 return false; | 670 return false; |
| 671 file_urls.push_back(GURL(file_url)); | 671 file_urls.push_back(GURL(file_url)); |
| 672 } | 672 } |
| 673 | 673 |
| 674 ListValue* result_list = new ListValue(); | 674 ListValue* result_list = new ListValue(); |
| 675 result_.reset(result_list); | 675 SetResult(result_list); |
| 676 | 676 |
| 677 file_handler_util::LastUsedHandlerList common_tasks; | 677 file_handler_util::LastUsedHandlerList common_tasks; |
| 678 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) | 678 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) |
| 679 return false; | 679 return false; |
| 680 | 680 |
| 681 ExtensionService* service = profile_->GetExtensionService(); | 681 ExtensionService* service = profile_->GetExtensionService(); |
| 682 for (file_handler_util::LastUsedHandlerList::const_iterator iter = | 682 for (file_handler_util::LastUsedHandlerList::const_iterator iter = |
| 683 common_tasks.begin(); | 683 common_tasks.begin(); |
| 684 iter != common_tasks.end(); | 684 iter != common_tasks.end(); |
| 685 ++iter) { | 685 ++iter) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 FileTaskExecutor::Create(profile(), | 765 FileTaskExecutor::Create(profile(), |
| 766 source_url(), | 766 source_url(), |
| 767 extension_id, | 767 extension_id, |
| 768 action_id)); | 768 action_id)); |
| 769 | 769 |
| 770 if (!executor->ExecuteAndNotify( | 770 if (!executor->ExecuteAndNotify( |
| 771 file_urls, | 771 file_urls, |
| 772 base::Bind(&ExecuteTasksFileBrowserFunction::OnTaskExecuted, this))) | 772 base::Bind(&ExecuteTasksFileBrowserFunction::OnTaskExecuted, this))) |
| 773 return false; | 773 return false; |
| 774 | 774 |
| 775 result_.reset(new base::FundamentalValue(true)); | 775 SetResult(new base::FundamentalValue(true)); |
| 776 return true; | 776 return true; |
| 777 } | 777 } |
| 778 | 778 |
| 779 SetDefaultTaskFileBrowserFunction::SetDefaultTaskFileBrowserFunction() {} | 779 SetDefaultTaskFileBrowserFunction::SetDefaultTaskFileBrowserFunction() {} |
| 780 | 780 |
| 781 SetDefaultTaskFileBrowserFunction::~SetDefaultTaskFileBrowserFunction() {} | 781 SetDefaultTaskFileBrowserFunction::~SetDefaultTaskFileBrowserFunction() {} |
| 782 | 782 |
| 783 bool SetDefaultTaskFileBrowserFunction::RunImpl() { | 783 bool SetDefaultTaskFileBrowserFunction::RunImpl() { |
| 784 // First param is task id that was to the extension with setDefaultTask call. | 784 // First param is task id that was to the extension with setDefaultTask call. |
| 785 std::string task_id; | 785 std::string task_id; |
| 786 if (!args_->GetString(0, &task_id) || !task_id.size()) | 786 if (!args_->GetString(0, &task_id) || !task_id.size()) |
| 787 return false; | 787 return false; |
| 788 | 788 |
| 789 BrowserThread::PostTask( | 789 BrowserThread::PostTask( |
| 790 BrowserThread::UI, FROM_HERE, | 790 BrowserThread::UI, FROM_HERE, |
| 791 base::Bind( | 791 base::Bind( |
| 792 &file_handler_util::UpdateFileHandlerUsageStats, | 792 &file_handler_util::UpdateFileHandlerUsageStats, |
| 793 profile_, task_id)); | 793 profile_, task_id)); |
| 794 | 794 |
| 795 result_.reset(new base::FundamentalValue(true)); | 795 SetResult(new base::FundamentalValue(true)); |
| 796 return true; | 796 return true; |
| 797 } | 797 } |
| 798 | 798 |
| 799 FileBrowserFunction::FileBrowserFunction() { | 799 FileBrowserFunction::FileBrowserFunction() { |
| 800 } | 800 } |
| 801 | 801 |
| 802 FileBrowserFunction::~FileBrowserFunction() { | 802 FileBrowserFunction::~FileBrowserFunction() { |
| 803 } | 803 } |
| 804 | 804 |
| 805 int32 FileBrowserFunction::GetTabId() const { | 805 int32 FileBrowserFunction::GetTabId() const { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1002 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1003 bool success = true; | 1003 bool success = true; |
| 1004 for (SelectedFileInfoList::const_iterator iter = files.begin(); | 1004 for (SelectedFileInfoList::const_iterator iter = files.begin(); |
| 1005 iter != files.end(); | 1005 iter != files.end(); |
| 1006 ++iter) { | 1006 ++iter) { |
| 1007 bool handled = file_manager_util::ExecuteBuiltinHandler( | 1007 bool handled = file_manager_util::ExecuteBuiltinHandler( |
| 1008 GetCurrentBrowser(), iter->path, internal_task_id); | 1008 GetCurrentBrowser(), iter->path, internal_task_id); |
| 1009 if (!handled && files.size() == 1) | 1009 if (!handled && files.size() == 1) |
| 1010 success = false; | 1010 success = false; |
| 1011 } | 1011 } |
| 1012 result_.reset(Value::CreateBooleanValue(success)); | 1012 SetResult(Value::CreateBooleanValue(success)); |
| 1013 SendResponse(true); | 1013 SendResponse(true); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 SelectFilesFunction::SelectFilesFunction() { | 1016 SelectFilesFunction::SelectFilesFunction() { |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 SelectFilesFunction::~SelectFilesFunction() { | 1019 SelectFilesFunction::~SelectFilesFunction() { |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 bool SelectFilesFunction::RunImpl() { | 1022 bool SelectFilesFunction::RunImpl() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 if (!args_->GetString(0, &file_url)) { | 1075 if (!args_->GetString(0, &file_url)) { |
| 1076 return false; | 1076 return false; |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 std::string mount_type_str; | 1079 std::string mount_type_str; |
| 1080 if (!args_->GetString(1, &mount_type_str)) { | 1080 if (!args_->GetString(1, &mount_type_str)) { |
| 1081 return false; | 1081 return false; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 // Set default return source path to the empty string. | 1084 // Set default return source path to the empty string. |
| 1085 result_.reset(Value::CreateStringValue("")); | 1085 SetResult(Value::CreateStringValue("")); |
| 1086 | 1086 |
| 1087 chromeos::MountType mount_type = | 1087 chromeos::MountType mount_type = |
| 1088 DiskMountManager::MountTypeFromString(mount_type_str); | 1088 DiskMountManager::MountTypeFromString(mount_type_str); |
| 1089 switch (mount_type) { | 1089 switch (mount_type) { |
| 1090 case chromeos::MOUNT_TYPE_INVALID: { | 1090 case chromeos::MOUNT_TYPE_INVALID: { |
| 1091 error_ = "Invalid mount type"; | 1091 error_ = "Invalid mount type"; |
| 1092 SendResponse(false); | 1092 SendResponse(false); |
| 1093 break; | 1093 break; |
| 1094 } | 1094 } |
| 1095 case chromeos::MOUNT_TYPE_GDATA: { | 1095 case chromeos::MOUNT_TYPE_GDATA: { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1121 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { | 1121 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { |
| 1122 chromeos::MountError error_code = chromeos::MOUNT_ERROR_NONE; | 1122 chromeos::MountError error_code = chromeos::MOUNT_ERROR_NONE; |
| 1123 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. | 1123 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. |
| 1124 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) { | 1124 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) { |
| 1125 error_code = chromeos::MOUNT_ERROR_NONE; | 1125 error_code = chromeos::MOUNT_ERROR_NONE; |
| 1126 } else { | 1126 } else { |
| 1127 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; | 1127 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; |
| 1128 } | 1128 } |
| 1129 // Pass back the gdata mount point path as source path. | 1129 // Pass back the gdata mount point path as source path. |
| 1130 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); | 1130 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); |
| 1131 result_.reset(Value::CreateStringValue(gdata_path)); | 1131 SetResult(Value::CreateStringValue(gdata_path)); |
| 1132 DiskMountManager::MountPointInfo mount_info( | 1132 DiskMountManager::MountPointInfo mount_info( |
| 1133 gdata_path, | 1133 gdata_path, |
| 1134 gdata_path, | 1134 gdata_path, |
| 1135 chromeos::MOUNT_TYPE_GDATA, | 1135 chromeos::MOUNT_TYPE_GDATA, |
| 1136 chromeos::disks::MOUNT_CONDITION_NONE); | 1136 chromeos::disks::MOUNT_CONDITION_NONE); |
| 1137 // Raise mount event | 1137 // Raise mount event |
| 1138 FileBrowserEventRouterFactory::GetForProfile(profile_)-> | 1138 FileBrowserEventRouterFactory::GetForProfile(profile_)-> |
| 1139 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); | 1139 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 } | 1173 } |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, | 1176 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, |
| 1177 const FilePath::StringType& file_name, | 1177 const FilePath::StringType& file_name, |
| 1178 base::PlatformFileError error, | 1178 base::PlatformFileError error, |
| 1179 const FilePath& file_path) { | 1179 const FilePath& file_path) { |
| 1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1181 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 1181 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
| 1182 // Pass back the actual source path of the mount point. | 1182 // Pass back the actual source path of the mount point. |
| 1183 result_.reset(Value::CreateStringValue(file_path.value())); | 1183 SetResult(Value::CreateStringValue(file_path.value())); |
| 1184 SendResponse(true); | 1184 SendResponse(true); |
| 1185 // MountPath() takes a std::string. | 1185 // MountPath() takes a std::string. |
| 1186 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), | 1186 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), |
| 1187 FilePath(file_name).Extension(), file_name, | 1187 FilePath(file_name).Extension(), file_name, |
| 1188 DiskMountManager::MountTypeFromString( | 1188 DiskMountManager::MountTypeFromString( |
| 1189 mount_type)); | 1189 mount_type)); |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 RemoveMountFunction::RemoveMountFunction() { | 1192 RemoveMountFunction::RemoveMountFunction() { |
| 1193 } | 1193 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 GetMountPointsFunction::~GetMountPointsFunction() { | 1231 GetMountPointsFunction::~GetMountPointsFunction() { |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 bool GetMountPointsFunction::RunImpl() { | 1234 bool GetMountPointsFunction::RunImpl() { |
| 1235 if (args_->GetSize()) | 1235 if (args_->GetSize()) |
| 1236 return false; | 1236 return false; |
| 1237 | 1237 |
| 1238 base::ListValue *mounts = new base::ListValue(); | 1238 base::ListValue *mounts = new base::ListValue(); |
| 1239 result_.reset(mounts); | 1239 SetResult(mounts); |
| 1240 | 1240 |
| 1241 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 1241 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
| 1242 DiskMountManager::MountPointMap mount_points = | 1242 DiskMountManager::MountPointMap mount_points = |
| 1243 disk_mount_manager->mount_points(); | 1243 disk_mount_manager->mount_points(); |
| 1244 | 1244 |
| 1245 for (DiskMountManager::MountPointMap::const_iterator it = | 1245 for (DiskMountManager::MountPointMap::const_iterator it = |
| 1246 mount_points.begin(); | 1246 mount_points.begin(); |
| 1247 it != mount_points.end(); | 1247 it != mount_points.end(); |
| 1248 ++it) { | 1248 ++it) { |
| 1249 mounts->Append(CreateValueFromMountPoint(profile_, it->second, | 1249 mounts->Append(CreateValueFromMountPoint(profile_, it->second, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 this, | 1340 this, |
| 1341 total_size_kb, remaining_size_kb)); | 1341 total_size_kb, remaining_size_kb)); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( | 1344 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( |
| 1345 size_t total_size_kb, | 1345 size_t total_size_kb, |
| 1346 size_t remaining_size_kb) { | 1346 size_t remaining_size_kb) { |
| 1347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1348 | 1348 |
| 1349 base::DictionaryValue* sizes = new base::DictionaryValue(); | 1349 base::DictionaryValue* sizes = new base::DictionaryValue(); |
| 1350 result_.reset(sizes); | 1350 SetResult(sizes); |
| 1351 | 1351 |
| 1352 sizes->SetInteger("totalSizeKB", total_size_kb); | 1352 sizes->SetInteger("totalSizeKB", total_size_kb); |
| 1353 sizes->SetInteger("remainingSizeKB", remaining_size_kb); | 1353 sizes->SetInteger("remainingSizeKB", remaining_size_kb); |
| 1354 | 1354 |
| 1355 SendResponse(true); | 1355 SendResponse(true); |
| 1356 } | 1356 } |
| 1357 | 1357 |
| 1358 FormatDeviceFunction::FormatDeviceFunction() { | 1358 FormatDeviceFunction::FormatDeviceFunction() { |
| 1359 } | 1359 } |
| 1360 | 1360 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 const SelectedFileInfoList& files) { | 1426 const SelectedFileInfoList& files) { |
| 1427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1428 | 1428 |
| 1429 // Should contain volume's mount path. | 1429 // Should contain volume's mount path. |
| 1430 if (files.size() != 1) { | 1430 if (files.size() != 1) { |
| 1431 error_ = "Invalid mount path."; | 1431 error_ = "Invalid mount path."; |
| 1432 SendResponse(false); | 1432 SendResponse(false); |
| 1433 return; | 1433 return; |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 result_.reset(); | 1436 results_.reset(); |
| 1437 | 1437 |
| 1438 const DiskMountManager::Disk* volume = GetVolumeAsDisk( | 1438 const DiskMountManager::Disk* volume = GetVolumeAsDisk( |
| 1439 files[0].path.value()); | 1439 files[0].path.value()); |
| 1440 if (volume) { | 1440 if (volume) { |
| 1441 DictionaryValue* volume_info = | 1441 DictionaryValue* volume_info = |
| 1442 CreateValueFromDisk(profile_, volume); | 1442 CreateValueFromDisk(profile_, volume); |
| 1443 result_.reset(volume_info); | 1443 SetResult(volume_info); |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 SendResponse(true); | 1446 SendResponse(true); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 bool ToggleFullscreenFunction::RunImpl() { | 1449 bool ToggleFullscreenFunction::RunImpl() { |
| 1450 Browser* browser = GetCurrentBrowser(); | 1450 Browser* browser = GetCurrentBrowser(); |
| 1451 if (browser) { | 1451 if (browser) { |
| 1452 browser->ToggleFullscreenModeWithExtension( | 1452 browser->ToggleFullscreenModeWithExtension( |
| 1453 file_manager_util::GetFileBrowserExtensionUrl()); | 1453 file_manager_util::GetFileBrowserExtensionUrl()); |
| 1454 } | 1454 } |
| 1455 return true; | 1455 return true; |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 bool IsFullscreenFunction::RunImpl() { | 1458 bool IsFullscreenFunction::RunImpl() { |
| 1459 Browser* browser = GetCurrentBrowser(); | 1459 Browser* browser = GetCurrentBrowser(); |
| 1460 result_.reset(Value::CreateBooleanValue( | 1460 SetResult(Value::CreateBooleanValue( |
| 1461 browser && browser->window() && browser->window()->IsFullscreen())); | 1461 browser && browser->window() && browser->window()->IsFullscreen())); |
| 1462 return true; | 1462 return true; |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 bool FileDialogStringsFunction::RunImpl() { | 1465 bool FileDialogStringsFunction::RunImpl() { |
| 1466 result_.reset(new DictionaryValue()); | 1466 DictionaryValue* dict = new DictionaryValue(); |
| 1467 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); | 1467 SetResult(dict); |
| 1468 | 1468 |
| 1469 #define SET_STRING(ns, id) \ | 1469 #define SET_STRING(ns, id) \ |
| 1470 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) | 1470 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) |
| 1471 | 1471 |
| 1472 SET_STRING(IDS, WEB_FONT_FAMILY); | 1472 SET_STRING(IDS, WEB_FONT_FAMILY); |
| 1473 SET_STRING(IDS, WEB_FONT_SIZE); | 1473 SET_STRING(IDS, WEB_FONT_SIZE); |
| 1474 | 1474 |
| 1475 SET_STRING(IDS_FILE_BROWSER, ROOT_DIRECTORY_LABEL); | 1475 SET_STRING(IDS_FILE_BROWSER, ROOT_DIRECTORY_LABEL); |
| 1476 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_DIRECTORY_LABEL); | 1476 SET_STRING(IDS_FILE_BROWSER, ARCHIVE_DIRECTORY_LABEL); |
| 1477 SET_STRING(IDS_FILE_BROWSER, REMOVABLE_DIRECTORY_LABEL); | 1477 SET_STRING(IDS_FILE_BROWSER, REMOVABLE_DIRECTORY_LABEL); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 | 1761 |
| 1762 file_properties_.reset(new base::ListValue); | 1762 file_properties_.reset(new base::ListValue); |
| 1763 | 1763 |
| 1764 current_index_ = 0; | 1764 current_index_ = 0; |
| 1765 GetNextFileProperties(); | 1765 GetNextFileProperties(); |
| 1766 } | 1766 } |
| 1767 | 1767 |
| 1768 void GetGDataFilePropertiesFunction::GetNextFileProperties() { | 1768 void GetGDataFilePropertiesFunction::GetNextFileProperties() { |
| 1769 if (current_index_ >= path_list_->GetSize()) { | 1769 if (current_index_ >= path_list_->GetSize()) { |
| 1770 // Exit of asynchronous look and return the result. | 1770 // Exit of asynchronous look and return the result. |
| 1771 result_.reset(file_properties_.release()); | 1771 SetResult(file_properties_.release()); |
| 1772 SendResponse(true); | 1772 SendResponse(true); |
| 1773 return; | 1773 return; |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 std::string file_str; | 1776 std::string file_str; |
| 1777 path_list_->GetString(current_index_, &file_str); | 1777 path_list_->GetString(current_index_, &file_str); |
| 1778 GURL file_url = GURL(file_str); | 1778 GURL file_url = GURL(file_str); |
| 1779 FilePath file_path = GetVirtualPathFromURL(file_url); | 1779 FilePath file_path = GetVirtualPathFromURL(file_url); |
| 1780 | 1780 |
| 1781 base::DictionaryValue* property_dict = new base::DictionaryValue; | 1781 base::DictionaryValue* property_dict = new base::DictionaryValue; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 | 1976 |
| 1977 ListValue* locations = new ListValue; | 1977 ListValue* locations = new ListValue; |
| 1978 for (size_t i = 0; i < files.size(); ++i) { | 1978 for (size_t i = 0; i < files.size(); ++i) { |
| 1979 if (gdata::util::IsUnderGDataMountPoint(files[i].path)) { | 1979 if (gdata::util::IsUnderGDataMountPoint(files[i].path)) { |
| 1980 locations->Append(Value::CreateStringValue("drive")); | 1980 locations->Append(Value::CreateStringValue("drive")); |
| 1981 } else { | 1981 } else { |
| 1982 locations->Append(Value::CreateStringValue("local")); | 1982 locations->Append(Value::CreateStringValue("local")); |
| 1983 } | 1983 } |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 result_.reset(locations); | 1986 SetResult(locations); |
| 1987 SendResponse(true); | 1987 SendResponse(true); |
| 1988 } | 1988 } |
| 1989 | 1989 |
| 1990 GetGDataFilesFunction::GetGDataFilesFunction() | 1990 GetGDataFilesFunction::GetGDataFilesFunction() |
| 1991 : local_paths_(NULL) { | 1991 : local_paths_(NULL) { |
| 1992 } | 1992 } |
| 1993 | 1993 |
| 1994 GetGDataFilesFunction::~GetGDataFilesFunction() { | 1994 GetGDataFilesFunction::~GetGDataFilesFunction() { |
| 1995 } | 1995 } |
| 1996 | 1996 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2025 remaining_gdata_paths_.push(gdata_path); | 2025 remaining_gdata_paths_.push(gdata_path); |
| 2026 } | 2026 } |
| 2027 | 2027 |
| 2028 local_paths_ = new ListValue; | 2028 local_paths_ = new ListValue; |
| 2029 GetFileOrSendResponse(); | 2029 GetFileOrSendResponse(); |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 void GetGDataFilesFunction::GetFileOrSendResponse() { | 2032 void GetGDataFilesFunction::GetFileOrSendResponse() { |
| 2033 // Send the response if all files are obtained. | 2033 // Send the response if all files are obtained. |
| 2034 if (remaining_gdata_paths_.empty()) { | 2034 if (remaining_gdata_paths_.empty()) { |
| 2035 result_.reset(local_paths_); | 2035 SetResult(local_paths_); |
| 2036 SendResponse(true); | 2036 SendResponse(true); |
| 2037 return; | 2037 return; |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 gdata::GDataSystemService* system_service = | 2040 gdata::GDataSystemService* system_service = |
| 2041 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2041 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2042 DCHECK(system_service); | 2042 DCHECK(system_service); |
| 2043 | 2043 |
| 2044 // Get the file on the top of the queue. | 2044 // Get the file on the top of the queue. |
| 2045 FilePath gdata_path = remaining_gdata_paths_.front(); | 2045 FilePath gdata_path = remaining_gdata_paths_.front(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 profile_, source_url_.GetOrigin(), list); | 2095 profile_, source_url_.GetOrigin(), list); |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 bool GetFileTransfersFunction::RunImpl() { | 2098 bool GetFileTransfersFunction::RunImpl() { |
| 2099 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); | 2099 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); |
| 2100 if (!progress_status_list.get()) { | 2100 if (!progress_status_list.get()) { |
| 2101 SendResponse(false); | 2101 SendResponse(false); |
| 2102 return false; | 2102 return false; |
| 2103 } | 2103 } |
| 2104 | 2104 |
| 2105 result_.reset(progress_status_list.release()); | 2105 SetResult(progress_status_list.release()); |
| 2106 SendResponse(true); | 2106 SendResponse(true); |
| 2107 return true; | 2107 return true; |
| 2108 } | 2108 } |
| 2109 | 2109 |
| 2110 | 2110 |
| 2111 CancelFileTransfersFunction::CancelFileTransfersFunction() {} | 2111 CancelFileTransfersFunction::CancelFileTransfersFunction() {} |
| 2112 | 2112 |
| 2113 CancelFileTransfersFunction::~CancelFileTransfersFunction() {} | 2113 CancelFileTransfersFunction::~CancelFileTransfersFunction() {} |
| 2114 | 2114 |
| 2115 bool CancelFileTransfersFunction::RunImpl() { | 2115 bool CancelFileTransfersFunction::RunImpl() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 GURL file_url; | 2159 GURL file_url; |
| 2160 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, | 2160 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, |
| 2161 gdata::util::GetSpecialRemoteRootPath().Append(file_path), | 2161 gdata::util::GetSpecialRemoteRootPath().Append(file_path), |
| 2162 source_url_.GetOrigin(), | 2162 source_url_.GetOrigin(), |
| 2163 &file_url)) { | 2163 &file_url)) { |
| 2164 result->SetString("fileUrl", file_url.spec()); | 2164 result->SetString("fileUrl", file_url.spec()); |
| 2165 } | 2165 } |
| 2166 | 2166 |
| 2167 responses->Append(result.release()); | 2167 responses->Append(result.release()); |
| 2168 } | 2168 } |
| 2169 result_.reset(responses.release()); | 2169 SetResult(responses.release()); |
| 2170 SendResponse(true); | 2170 SendResponse(true); |
| 2171 } | 2171 } |
| 2172 | 2172 |
| 2173 TransferFileFunction::TransferFileFunction() {} | 2173 TransferFileFunction::TransferFileFunction() {} |
| 2174 | 2174 |
| 2175 TransferFileFunction::~TransferFileFunction() {} | 2175 TransferFileFunction::~TransferFileFunction() {} |
| 2176 | 2176 |
| 2177 bool TransferFileFunction::RunImpl() { | 2177 bool TransferFileFunction::RunImpl() { |
| 2178 std::string local_file_url; | 2178 std::string local_file_url; |
| 2179 std::string remote_file_url; | 2179 std::string remote_file_url; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 AddGDataMountPoint(profile_, extension_id(), render_view_host()); | 2260 AddGDataMountPoint(profile_, extension_id(), render_view_host()); |
| 2261 | 2261 |
| 2262 value->SetBoolean("driveEnabled", driveEnabled); | 2262 value->SetBoolean("driveEnabled", driveEnabled); |
| 2263 | 2263 |
| 2264 value->SetBoolean("cellularDisabled", | 2264 value->SetBoolean("cellularDisabled", |
| 2265 service->GetBoolean(prefs::kDisableGDataOverCellular)); | 2265 service->GetBoolean(prefs::kDisableGDataOverCellular)); |
| 2266 | 2266 |
| 2267 value->SetBoolean("hostedFilesDisabled", | 2267 value->SetBoolean("hostedFilesDisabled", |
| 2268 service->GetBoolean(prefs::kDisableGDataHostedFiles)); | 2268 service->GetBoolean(prefs::kDisableGDataHostedFiles)); |
| 2269 | 2269 |
| 2270 result_.reset(value.release()); | 2270 SetResult(value.release()); |
| 2271 return true; | 2271 return true; |
| 2272 } | 2272 } |
| 2273 | 2273 |
| 2274 // Write GData-related preferences. | 2274 // Write GData-related preferences. |
| 2275 bool SetGDataPreferencesFunction::RunImpl() { | 2275 bool SetGDataPreferencesFunction::RunImpl() { |
| 2276 base::DictionaryValue* value = NULL; | 2276 base::DictionaryValue* value = NULL; |
| 2277 | 2277 |
| 2278 if (!args_->GetDictionary(0, &value) || !value) | 2278 if (!args_->GetDictionary(0, &value) || !value) |
| 2279 return false; | 2279 return false; |
| 2280 | 2280 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2312 |
| 2313 void GetPathForDriveSearchResultFunction::OnEntryFound( | 2313 void GetPathForDriveSearchResultFunction::OnEntryFound( |
| 2314 base::PlatformFileError error, | 2314 base::PlatformFileError error, |
| 2315 const FilePath& entry_path, | 2315 const FilePath& entry_path, |
| 2316 scoped_ptr<gdata::GDataEntryProto> entry_proto) { | 2316 scoped_ptr<gdata::GDataEntryProto> entry_proto) { |
| 2317 if (error != base::PLATFORM_FILE_OK) { | 2317 if (error != base::PLATFORM_FILE_OK) { |
| 2318 SendResponse(false); | 2318 SendResponse(false); |
| 2319 return; | 2319 return; |
| 2320 } | 2320 } |
| 2321 | 2321 |
| 2322 result_.reset(Value::CreateStringValue(entry_path.value())); | 2322 SetResult(Value::CreateStringValue(entry_path.value())); |
| 2323 SendResponse(true); | 2323 SendResponse(true); |
| 2324 } | 2324 } |
| 2325 | 2325 |
| 2326 bool SearchDriveFunction::RunImpl() { | 2326 bool SearchDriveFunction::RunImpl() { |
| 2327 if (!args_->GetString(0, &query_)) | 2327 if (!args_->GetString(0, &query_)) |
| 2328 return false; | 2328 return false; |
| 2329 | 2329 |
| 2330 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( | 2330 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( |
| 2331 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, | 2331 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, |
| 2332 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); | 2332 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2372 for (size_t i = 0; i < results->size(); ++i) { | 2372 for (size_t i = 0; i < results->size(); ++i) { |
| 2373 DictionaryValue* entry = new DictionaryValue(); | 2373 DictionaryValue* entry = new DictionaryValue(); |
| 2374 entry->SetString("fileSystemName", file_system_name_); | 2374 entry->SetString("fileSystemName", file_system_name_); |
| 2375 entry->SetString("fileSystemRoot", file_system_url_.spec()); | 2375 entry->SetString("fileSystemRoot", file_system_url_.spec()); |
| 2376 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 2376 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
| 2377 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 2377 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
| 2378 | 2378 |
| 2379 entries->Append(entry); | 2379 entries->Append(entry); |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 result_.reset(entries); | 2382 SetResult(entries); |
| 2383 SendResponse(true); | 2383 SendResponse(true); |
| 2384 } | 2384 } |
| 2385 | 2385 |
| 2386 bool GetNetworkConnectionStateFunction::RunImpl() { | 2386 bool GetNetworkConnectionStateFunction::RunImpl() { |
| 2387 chromeos::NetworkLibrary* network_library = | 2387 chromeos::NetworkLibrary* network_library = |
| 2388 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 2388 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 2389 if (!network_library) | 2389 if (!network_library) |
| 2390 return false; | 2390 return false; |
| 2391 | 2391 |
| 2392 const chromeos::Network* active_network = network_library->active_network(); | 2392 const chromeos::Network* active_network = network_library->active_network(); |
| 2393 | 2393 |
| 2394 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 2394 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| 2395 value->SetBoolean("online", active_network && active_network->online()); | 2395 value->SetBoolean("online", active_network && active_network->online()); |
| 2396 | 2396 |
| 2397 std::string type_string; | 2397 std::string type_string; |
| 2398 if (!active_network) | 2398 if (!active_network) |
| 2399 type_string = "none"; | 2399 type_string = "none"; |
| 2400 else if (active_network->type() == chromeos::TYPE_CELLULAR) | 2400 else if (active_network->type() == chromeos::TYPE_CELLULAR) |
| 2401 type_string = "cellular"; | 2401 type_string = "cellular"; |
| 2402 else | 2402 else |
| 2403 type_string = "ethernet"; // Currently we do not care about other types. | 2403 type_string = "ethernet"; // Currently we do not care about other types. |
| 2404 | 2404 |
| 2405 value->SetString("type", type_string); | 2405 value->SetString("type", type_string); |
| 2406 result_.reset(value.release()); | 2406 SetResult(value.release()); |
| 2407 | 2407 |
| 2408 return true; | 2408 return true; |
| 2409 } | 2409 } |
| 2410 | 2410 |
| 2411 bool RequestDirectoryRefreshFunction::RunImpl() { | 2411 bool RequestDirectoryRefreshFunction::RunImpl() { |
| 2412 std::string file_url_as_string; | 2412 std::string file_url_as_string; |
| 2413 if (!args_->GetString(0, &file_url_as_string)) | 2413 if (!args_->GetString(0, &file_url_as_string)) |
| 2414 return false; | 2414 return false; |
| 2415 | 2415 |
| 2416 gdata::GDataSystemService* system_service = | 2416 gdata::GDataSystemService* system_service = |
| 2417 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2417 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2418 if (!system_service || !system_service->file_system()) | 2418 if (!system_service || !system_service->file_system()) |
| 2419 return false; | 2419 return false; |
| 2420 | 2420 |
| 2421 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2421 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
| 2422 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2422 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
| 2423 | 2423 |
| 2424 return true; | 2424 return true; |
| 2425 } | 2425 } |
| OLD | NEW |