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 <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 if (!args_->GetString(0, &file_url)) { | 1339 if (!args_->GetString(0, &file_url)) { |
1340 return false; | 1340 return false; |
1341 } | 1341 } |
1342 | 1342 |
1343 std::string mount_type_str; | 1343 std::string mount_type_str; |
1344 if (!args_->GetString(1, &mount_type_str)) { | 1344 if (!args_->GetString(1, &mount_type_str)) { |
1345 return false; | 1345 return false; |
1346 } | 1346 } |
1347 | 1347 |
1348 // Set default return source path to the empty string. | 1348 // Set default return source path to the empty string. |
1349 SetResult(new base::StringValue("")); | 1349 SetResult(Value::CreateStringValue("")); |
1350 | 1350 |
1351 chromeos::MountType mount_type = | 1351 chromeos::MountType mount_type = |
1352 DiskMountManager::MountTypeFromString(mount_type_str); | 1352 DiskMountManager::MountTypeFromString(mount_type_str); |
1353 switch (mount_type) { | 1353 switch (mount_type) { |
1354 case chromeos::MOUNT_TYPE_INVALID: { | 1354 case chromeos::MOUNT_TYPE_INVALID: { |
1355 error_ = "Invalid mount type"; | 1355 error_ = "Invalid mount type"; |
1356 SendResponse(false); | 1356 SendResponse(false); |
1357 break; | 1357 break; |
1358 } | 1358 } |
1359 case chromeos::MOUNT_TYPE_GDATA: { | 1359 case chromeos::MOUNT_TYPE_GDATA: { |
1360 const bool success = true; | 1360 const bool success = true; |
1361 // Pass back the drive mount point path as source path. | 1361 // Pass back the drive mount point path as source path. |
1362 const std::string& drive_path = | 1362 const std::string& drive_path = |
1363 drive::util::GetDriveMountPointPathAsString(); | 1363 drive::util::GetDriveMountPointPathAsString(); |
1364 SetResult(new base::StringValue(drive_path)); | 1364 SetResult(Value::CreateStringValue(drive_path)); |
1365 FileBrowserEventRouterFactory::GetForProfile(profile_)-> | 1365 FileBrowserEventRouterFactory::GetForProfile(profile_)-> |
1366 MountDrive(base::Bind(&AddMountFunction::SendResponse, | 1366 MountDrive(base::Bind(&AddMountFunction::SendResponse, |
1367 this, | 1367 this, |
1368 success)); | 1368 success)); |
1369 break; | 1369 break; |
1370 } | 1370 } |
1371 default: { | 1371 default: { |
1372 UrlList file_paths; | 1372 UrlList file_paths; |
1373 file_paths.push_back(GURL(file_url)); | 1373 file_paths.push_back(GURL(file_url)); |
1374 | 1374 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 } | 1412 } |
1413 } | 1413 } |
1414 | 1414 |
1415 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, | 1415 void AddMountFunction::OnMountedStateSet(const std::string& mount_type, |
1416 const FilePath::StringType& file_name, | 1416 const FilePath::StringType& file_name, |
1417 drive::DriveFileError error, | 1417 drive::DriveFileError error, |
1418 const FilePath& file_path) { | 1418 const FilePath& file_path) { |
1419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1420 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 1420 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
1421 // Pass back the actual source path of the mount point. | 1421 // Pass back the actual source path of the mount point. |
1422 SetResult(new base::StringValue(file_path.value())); | 1422 SetResult(Value::CreateStringValue(file_path.value())); |
1423 SendResponse(true); | 1423 SendResponse(true); |
1424 // MountPath() takes a std::string. | 1424 // MountPath() takes a std::string. |
1425 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), | 1425 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), |
1426 FilePath(file_name).Extension(), file_name, | 1426 FilePath(file_name).Extension(), file_name, |
1427 DiskMountManager::MountTypeFromString( | 1427 DiskMountManager::MountTypeFromString( |
1428 mount_type)); | 1428 mount_type)); |
1429 } | 1429 } |
1430 | 1430 |
1431 RemoveMountFunction::RemoveMountFunction() { | 1431 RemoveMountFunction::RemoveMountFunction() { |
1432 } | 1432 } |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 return true; | 2419 return true; |
2420 } | 2420 } |
2421 | 2421 |
2422 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( | 2422 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( |
2423 const SelectedFileInfoList& files) { | 2423 const SelectedFileInfoList& files) { |
2424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2425 | 2425 |
2426 ListValue* locations = new ListValue; | 2426 ListValue* locations = new ListValue; |
2427 for (size_t i = 0; i < files.size(); ++i) { | 2427 for (size_t i = 0; i < files.size(); ++i) { |
2428 if (drive::util::IsUnderDriveMountPoint(files[i].file_path)) { | 2428 if (drive::util::IsUnderDriveMountPoint(files[i].file_path)) { |
2429 locations->Append(new base::StringValue("drive")); | 2429 locations->Append(Value::CreateStringValue("drive")); |
2430 } else { | 2430 } else { |
2431 locations->Append(new base::StringValue("local")); | 2431 locations->Append(Value::CreateStringValue("local")); |
2432 } | 2432 } |
2433 } | 2433 } |
2434 | 2434 |
2435 SetResult(locations); | 2435 SetResult(locations); |
2436 SendResponse(true); | 2436 SendResponse(true); |
2437 } | 2437 } |
2438 | 2438 |
2439 GetDriveFilesFunction::GetDriveFilesFunction() | 2439 GetDriveFilesFunction::GetDriveFilesFunction() |
2440 : local_paths_(NULL) { | 2440 : local_paths_(NULL) { |
2441 } | 2441 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 | 2508 |
2509 | 2509 |
2510 void GetDriveFilesFunction::OnFileReady( | 2510 void GetDriveFilesFunction::OnFileReady( |
2511 drive::DriveFileError error, | 2511 drive::DriveFileError error, |
2512 const FilePath& local_path, | 2512 const FilePath& local_path, |
2513 const std::string& unused_mime_type, | 2513 const std::string& unused_mime_type, |
2514 drive::DriveFileType file_type) { | 2514 drive::DriveFileType file_type) { |
2515 FilePath drive_path = remaining_drive_paths_.front(); | 2515 FilePath drive_path = remaining_drive_paths_.front(); |
2516 | 2516 |
2517 if (error == drive::DRIVE_FILE_OK) { | 2517 if (error == drive::DRIVE_FILE_OK) { |
2518 local_paths_->Append(new base::StringValue(local_path.value())); | 2518 local_paths_->Append(Value::CreateStringValue(local_path.value())); |
2519 DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value(); | 2519 DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value(); |
2520 | 2520 |
2521 // TODO(benchan): If the file is a hosted document, a temporary JSON file | 2521 // TODO(benchan): If the file is a hosted document, a temporary JSON file |
2522 // is created to represent the document. The JSON file is not cached and | 2522 // is created to represent the document. The JSON file is not cached and |
2523 // should be deleted after use. We need to somehow communicate with | 2523 // should be deleted after use. We need to somehow communicate with |
2524 // file_manager.js to manage the lifetime of the temporary file. | 2524 // file_manager.js to manage the lifetime of the temporary file. |
2525 // See crosbug.com/28058. | 2525 // See crosbug.com/28058. |
2526 } else { | 2526 } else { |
2527 local_paths_->Append(new base::StringValue("")); | 2527 local_paths_->Append(Value::CreateStringValue("")); |
2528 DVLOG(1) << "Failed to get " << drive_path.value() | 2528 DVLOG(1) << "Failed to get " << drive_path.value() |
2529 << " with error code: " << error; | 2529 << " with error code: " << error; |
2530 } | 2530 } |
2531 | 2531 |
2532 remaining_drive_paths_.pop(); | 2532 remaining_drive_paths_.pop(); |
2533 | 2533 |
2534 // Start getting the next file. | 2534 // Start getting the next file. |
2535 GetFileOrSendResponse(); | 2535 GetFileOrSendResponse(); |
2536 } | 2536 } |
2537 | 2537 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 drive::DriveSystemServiceFactory::GetForProfile(profile_); | 2889 drive::DriveSystemServiceFactory::GetForProfile(profile_); |
2890 // |system_service| is NULL if Drive is disabled. | 2890 // |system_service| is NULL if Drive is disabled. |
2891 if (!system_service || !system_service->file_system()) | 2891 if (!system_service || !system_service->file_system()) |
2892 return false; | 2892 return false; |
2893 | 2893 |
2894 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2894 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2895 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2895 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2896 | 2896 |
2897 return true; | 2897 return true; |
2898 } | 2898 } |
OLD | NEW |