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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 BrowserThread::UI, FROM_HERE, | 632 BrowserThread::UI, FROM_HERE, |
633 NewRunnableMethod(function_, | 633 NewRunnableMethod(function_, |
634 &ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread, | 634 &ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread, |
635 task_id_, | 635 task_id_, |
636 file_system_name, | 636 file_system_name, |
637 file_system_root, | 637 file_system_root, |
638 file_list)); | 638 file_list)); |
639 } | 639 } |
640 | 640 |
641 virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { | 641 virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { |
642 LOG(WARNING) << "Local file system cant be resolved"; | |
643 BrowserThread::PostTask( | 642 BrowserThread::PostTask( |
644 BrowserThread::UI, FROM_HERE, | 643 BrowserThread::UI, FROM_HERE, |
645 NewRunnableMethod(function_, | 644 NewRunnableMethod(function_, |
646 &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); | 645 &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); |
647 } | 646 } |
648 | 647 |
649 private: | 648 private: |
650 // Checks legitimacy of file url and grants file RO access permissions from | 649 // Checks legitimacy of file url and grants file RO access permissions from |
651 // handler (target) extension and its renderer process. | 650 // handler (target) extension and its renderer process. |
652 bool SetupFileAccessPermissions(const GURL& origin_file_url, | 651 bool SetupFileAccessPermissions(const GURL& origin_file_url, |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 RemoveMountFunction::~RemoveMountFunction() { | 1204 RemoveMountFunction::~RemoveMountFunction() { |
1206 } | 1205 } |
1207 | 1206 |
1208 bool RemoveMountFunction::RunImpl() { | 1207 bool RemoveMountFunction::RunImpl() { |
1209 if (args_->GetSize() != 1) { | 1208 if (args_->GetSize() != 1) { |
1210 return false; | 1209 return false; |
1211 } | 1210 } |
1212 | 1211 |
1213 std::string mount_path; | 1212 std::string mount_path; |
1214 if (!args_->GetString(0, &mount_path)) { | 1213 if (!args_->GetString(0, &mount_path)) { |
1215 return false; | 1214 return false; |
1216 } | 1215 } |
1217 | 1216 |
1218 UrlList file_paths; | 1217 UrlList file_paths; |
1219 file_paths.push_back(GURL(mount_path)); | 1218 file_paths.push_back(GURL(mount_path)); |
1220 | |
1221 BrowserThread::PostTask( | 1219 BrowserThread::PostTask( |
1222 BrowserThread::FILE, FROM_HERE, | 1220 BrowserThread::FILE, FROM_HERE, |
1223 NewRunnableMethod(this, | 1221 NewRunnableMethod(this, |
1224 &RemoveMountFunction::GetLocalPathsOnFileThread, | 1222 &RemoveMountFunction::GetLocalPathsOnFileThread, |
1225 file_paths, reinterpret_cast<void*>(NULL))); | 1223 file_paths, reinterpret_cast<void*>(NULL))); |
1226 return true; | 1224 return true; |
1227 } | 1225 } |
1228 | 1226 |
1229 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( | 1227 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
1230 const FilePathList& files, void* context) { | 1228 const FilePathList& files, void* context) { |
1231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1232 DCHECK(!context); | 1230 DCHECK(!context); |
1233 | 1231 |
1234 if (files.size() != 1) { | 1232 if (files.size() != 1) { |
1235 SendResponse(false); | 1233 SendResponse(false); |
1236 return; | 1234 return; |
1237 } | 1235 } |
1238 | |
1239 #ifdef OS_CHROMEOS | 1236 #ifdef OS_CHROMEOS |
1240 chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( | 1237 chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( |
1241 files[0].value().c_str()); | 1238 files[0].value().c_str()); |
1242 #endif | 1239 #endif |
1243 | 1240 |
1244 SendResponse(true); | 1241 SendResponse(true); |
1245 } | 1242 } |
1246 | 1243 |
1247 GetMountPointsFunction::GetMountPointsFunction() { | 1244 GetMountPointsFunction::GetMountPointsFunction() { |
1248 } | 1245 } |
1249 | 1246 |
1250 GetMountPointsFunction::~GetMountPointsFunction() { | 1247 GetMountPointsFunction::~GetMountPointsFunction() { |
1251 } | 1248 } |
1252 | 1249 |
1253 bool GetMountPointsFunction::RunImpl() { | 1250 bool GetMountPointsFunction::RunImpl() { |
1254 if (args_->GetSize()) | 1251 if (args_->GetSize()) |
1255 return false; | 1252 return false; |
1256 | 1253 |
1257 base::ListValue *mounts = new base::ListValue(); | 1254 base::ListValue *mounts = new base::ListValue(); |
1258 result_.reset(mounts); | 1255 result_.reset(mounts); |
1259 | 1256 |
1260 #ifdef OS_CHROMEOS | 1257 #ifdef OS_CHROMEOS |
1261 chromeos::MountLibrary *mount_lib = | 1258 chromeos::MountLibrary *mount_lib = |
1262 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 1259 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
1263 chromeos::MountLibrary::MountPointMap mount_points = | 1260 chromeos::MountLibrary::MountPointMap mount_points = |
1264 mount_lib->mount_points(); | 1261 mount_lib->mount_points(); |
1265 | 1262 |
1266 for (chromeos::MountLibrary::MountPointMap::const_iterator it = | 1263 for (chromeos::MountLibrary::MountPointMap::const_iterator it = |
1267 mount_points.begin(); | 1264 mount_points.begin(); |
1268 it != mount_points.end(); | 1265 it != mount_points.end(); |
1269 ++it) { | 1266 ++it) { |
1270 mounts->Append(MountPointToValue(profile_, it->second)); | 1267 mounts->Append(MountPointToValue(profile_, it->second)); |
1271 } | 1268 } |
1272 #endif | 1269 #endif |
| 1270 |
| 1271 SendResponse(true); |
| 1272 return true; |
| 1273 } |
| 1274 |
| 1275 FormatDeviceFunction::FormatDeviceFunction() { |
| 1276 } |
| 1277 |
| 1278 FormatDeviceFunction::~FormatDeviceFunction() { |
| 1279 } |
| 1280 |
| 1281 bool FormatDeviceFunction::RunImpl() { |
| 1282 if (args_->GetSize() != 1) { |
| 1283 return false; |
| 1284 } |
| 1285 |
| 1286 std::string volume_mount_path; |
| 1287 if (!args_->GetString(0, &volume_mount_path)) { |
| 1288 NOTREACHED(); |
| 1289 return false; |
| 1290 } |
| 1291 |
| 1292 #ifdef OS_CHROMEOS |
| 1293 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( |
| 1294 volume_mount_path.c_str()); |
| 1295 #endif |
| 1296 |
1273 SendResponse(true); | 1297 SendResponse(true); |
1274 return true; | 1298 return true; |
1275 } | 1299 } |
1276 | 1300 |
1277 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { | 1301 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { |
1278 } | 1302 } |
1279 | 1303 |
1280 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { | 1304 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { |
1281 } | 1305 } |
1282 | 1306 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 SET_STRING(IDS_FILE_BROWSER, OPEN_LABEL); | 1444 SET_STRING(IDS_FILE_BROWSER, OPEN_LABEL); |
1421 SET_STRING(IDS_FILE_BROWSER, SAVE_LABEL); | 1445 SET_STRING(IDS_FILE_BROWSER, SAVE_LABEL); |
1422 SET_STRING(IDS_FILE_BROWSER, OK_LABEL); | 1446 SET_STRING(IDS_FILE_BROWSER, OK_LABEL); |
1423 | 1447 |
1424 SET_STRING(IDS_FILE_BROWSER, DEFAULT_NEW_FOLDER_NAME); | 1448 SET_STRING(IDS_FILE_BROWSER, DEFAULT_NEW_FOLDER_NAME); |
1425 SET_STRING(IDS_FILE_BROWSER, MORE_FILES); | 1449 SET_STRING(IDS_FILE_BROWSER, MORE_FILES); |
1426 | 1450 |
1427 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_ONE); | 1451 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_ONE); |
1428 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_SOME); | 1452 SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_SOME); |
1429 | 1453 |
| 1454 SET_STRING(IDS_FILE_BROWSER, FORMATTING_WARNING); |
| 1455 |
1430 SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); | 1456 SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); |
1431 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_FILE_TITLE); | 1457 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_FILE_TITLE); |
1432 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_MULTI_FILE_TITLE); | 1458 SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_MULTI_FILE_TITLE); |
1433 SET_STRING(IDS_FILE_BROWSER, SELECT_SAVEAS_FILE_TITLE); | 1459 SET_STRING(IDS_FILE_BROWSER, SELECT_SAVEAS_FILE_TITLE); |
1434 | 1460 |
1435 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); | 1461 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); |
1436 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); | 1462 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); |
1437 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); | 1463 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); |
1438 SET_STRING(IDS_FILE_BROWSER, ONE_DIRECTORY_SELECTED); | 1464 SET_STRING(IDS_FILE_BROWSER, ONE_DIRECTORY_SELECTED); |
1439 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); | 1465 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 #undef SET_STRING | 1497 #undef SET_STRING |
1472 | 1498 |
1473 // TODO(serya): Create a new string in .grd file for this one in M13. | 1499 // TODO(serya): Create a new string in .grd file for this one in M13. |
1474 dict->SetString("PREVIEW_IMAGE", | 1500 dict->SetString("PREVIEW_IMAGE", |
1475 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1501 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1476 dict->SetString("PLAY_MEDIA", | 1502 dict->SetString("PLAY_MEDIA", |
1477 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1503 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1478 | 1504 |
1479 return true; | 1505 return true; |
1480 } | 1506 } |
OLD | NEW |