| 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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 LOG(WARNING) << "External provider is not available"; | 852 LOG(WARNING) << "External provider is not available"; |
| 853 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 853 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 854 base::Bind(callback, selected_files)); | 854 base::Bind(callback, selected_files)); |
| 855 return; | 855 return; |
| 856 } | 856 } |
| 857 | 857 |
| 858 GURL origin_url = source_url().GetOrigin(); | 858 GURL origin_url = source_url().GetOrigin(); |
| 859 size_t len = file_urls.size(); | 859 size_t len = file_urls.size(); |
| 860 selected_files.reserve(len); | 860 selected_files.reserve(len); |
| 861 for (size_t i = 0; i < len; ++i) { | 861 for (size_t i = 0; i < len; ++i) { |
| 862 FilePath real_path; | 862 FilePath local_path; |
| 863 const GURL& file_url = file_urls[i]; | 863 const GURL& file_url = file_urls[i]; |
| 864 | 864 |
| 865 // If "localPath" parameter is set, use it as the real path. | 865 // If "localPath" parameter is set, use it as the real path. |
| 866 // TODO(satorux): Eventually, we should be able to get the real path | 866 // TODO(satorux): Eventually, we should be able to get the real path |
| 867 // from GDataFileSystem instead of passing through with filesystem | 867 // from GDataFileSystem instead of passing through with filesystem |
| 868 // URLs. crosbug.com/27510. | 868 // URLs. crosbug.com/27510. |
| 869 // | 869 // |
| 870 // TODO(satorux): GURL::query() is not yet supported for filesystem: | 870 // TODO(satorux): GURL::query() is not yet supported for filesystem: |
| 871 // URLs. For now, use GURL::spec() to get the query portion. Should | 871 // URLs. For now, use GURL::spec() to get the query portion. Should |
| 872 // get rid of the hack once query() is supported: crbug.com/114484. | 872 // get rid of the hack once query() is supported: crbug.com/114484. |
| 873 const std::string::size_type query_start = file_url.spec().find('?'); | 873 const std::string::size_type query_start = file_url.spec().find('?'); |
| 874 if (query_start != std::string::npos) { | 874 if (query_start != std::string::npos) { |
| 875 const std::string query = file_url.spec().substr(query_start + 1); | 875 const std::string query = file_url.spec().substr(query_start + 1); |
| 876 std::vector<std::pair<std::string, std::string> > parameters; | 876 std::vector<std::pair<std::string, std::string> > parameters; |
| 877 if (base::SplitStringIntoKeyValuePairs( | 877 if (base::SplitStringIntoKeyValuePairs( |
| 878 query, '=', '&', ¶meters)) { | 878 query, '=', '&', ¶meters)) { |
| 879 for (size_t i = 0; i < parameters.size(); ++i) { | 879 for (size_t i = 0; i < parameters.size(); ++i) { |
| 880 if (parameters[i].first == "localPath") { | 880 if (parameters[i].first == "localPath") { |
| 881 const std::string unescaped_value = | 881 const std::string unescaped_value = |
| 882 net::UnescapeURLComponent(parameters[i].second, | 882 net::UnescapeURLComponent(parameters[i].second, |
| 883 kUnescapeRuleForQueryParameters); | 883 kUnescapeRuleForQueryParameters); |
| 884 real_path = FilePath::FromUTF8Unsafe(unescaped_value); | 884 local_path = FilePath::FromUTF8Unsafe(unescaped_value); |
| 885 break; | 885 break; |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 | 890 |
| 891 // Extract the path from |file_url|. | 891 // Extract the path from |file_url|. |
| 892 GURL file_origin_url; | 892 GURL file_origin_url; |
| 893 FilePath virtual_path; | 893 FilePath virtual_path; |
| 894 fileapi::FileSystemType type; | 894 fileapi::FileSystemType type; |
| 895 | 895 |
| 896 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, | 896 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, |
| 897 &virtual_path)) { | 897 &virtual_path)) { |
| 898 continue; | 898 continue; |
| 899 } | 899 } |
| 900 if (type != fileapi::kFileSystemTypeExternal) { | 900 if (type != fileapi::kFileSystemTypeExternal) { |
| 901 NOTREACHED(); | 901 NOTREACHED(); |
| 902 continue; | 902 continue; |
| 903 } | 903 } |
| 904 | 904 |
| 905 FilePath::StringType display_name; | |
| 906 FilePath root = provider->GetFileSystemRootPathOnFileThread( | 905 FilePath root = provider->GetFileSystemRootPathOnFileThread( |
| 907 origin_url, | 906 origin_url, |
| 908 fileapi::kFileSystemTypeExternal, | 907 fileapi::kFileSystemTypeExternal, |
| 909 FilePath(virtual_path), | 908 FilePath(virtual_path), |
| 910 false); | 909 false); |
| 910 FilePath file_path; |
| 911 if (!root.empty()) { | 911 if (!root.empty()) { |
| 912 // If we haven't got the real path from "localPath", use it as the | 912 file_path = root.Append(virtual_path); |
| 913 // real path. Otherwise, use it as the display name. | |
| 914 if (real_path.empty()) | |
| 915 real_path = root.Append(virtual_path); | |
| 916 else | |
| 917 display_name = virtual_path.BaseName().value(); | |
| 918 } else { | 913 } else { |
| 919 LOG(WARNING) << "GetLocalPathsOnFileThread failed " | 914 LOG(WARNING) << "GetLocalPathsOnFileThread failed " |
| 920 << file_url.spec(); | 915 << file_url.spec(); |
| 921 } | 916 } |
| 922 | 917 |
| 923 if (!real_path.empty()) { | 918 if (!file_path.empty()) { |
| 924 DVLOG(1) << "Selected: real path: " << real_path.value() | 919 DVLOG(1) << "Selected: file path: " << file_path.value() |
| 925 << " display name: " << display_name; | 920 << " local path: " << local_path.value(); |
| 926 selected_files.push_back( | 921 selected_files.push_back( |
| 927 ui::SelectedFileInfo(real_path, display_name)); | 922 ui::SelectedFileInfo(file_path, local_path)); |
| 928 } | 923 } |
| 929 } | 924 } |
| 930 | 925 |
| 931 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 926 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 932 base::Bind(callback, selected_files)); | 927 base::Bind(callback, selected_files)); |
| 933 } | 928 } |
| 934 | 929 |
| 935 bool SelectFileFunction::RunImpl() { | 930 bool SelectFileFunction::RunImpl() { |
| 936 if (args_->GetSize() != 2) { | 931 if (args_->GetSize() != 2) { |
| 937 return false; | 932 return false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 994 |
| 1000 void ViewFilesFunction::GetLocalPathsResponseOnUIThread( | 995 void ViewFilesFunction::GetLocalPathsResponseOnUIThread( |
| 1001 const std::string& internal_task_id, | 996 const std::string& internal_task_id, |
| 1002 const SelectedFileInfoList& files) { | 997 const SelectedFileInfoList& files) { |
| 1003 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1004 bool success = true; | 999 bool success = true; |
| 1005 for (SelectedFileInfoList::const_iterator iter = files.begin(); | 1000 for (SelectedFileInfoList::const_iterator iter = files.begin(); |
| 1006 iter != files.end(); | 1001 iter != files.end(); |
| 1007 ++iter) { | 1002 ++iter) { |
| 1008 bool handled = file_manager_util::ExecuteBuiltinHandler( | 1003 bool handled = file_manager_util::ExecuteBuiltinHandler( |
| 1009 GetCurrentBrowser(), iter->path, internal_task_id); | 1004 GetCurrentBrowser(), iter->file_path, internal_task_id); |
| 1010 if (!handled && files.size() == 1) | 1005 if (!handled && files.size() == 1) |
| 1011 success = false; | 1006 success = false; |
| 1012 } | 1007 } |
| 1013 SetResult(Value::CreateBooleanValue(success)); | 1008 SetResult(Value::CreateBooleanValue(success)); |
| 1014 SendResponse(true); | 1009 SendResponse(true); |
| 1015 } | 1010 } |
| 1016 | 1011 |
| 1017 SelectFilesFunction::SelectFilesFunction() { | 1012 SelectFilesFunction::SelectFilesFunction() { |
| 1018 } | 1013 } |
| 1019 | 1014 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 void AddMountFunction::GetLocalPathsResponseOnUIThread( | 1144 void AddMountFunction::GetLocalPathsResponseOnUIThread( |
| 1150 const std::string& mount_type_str, | 1145 const std::string& mount_type_str, |
| 1151 const SelectedFileInfoList& files) { | 1146 const SelectedFileInfoList& files) { |
| 1152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1153 | 1148 |
| 1154 if (!files.size()) { | 1149 if (!files.size()) { |
| 1155 SendResponse(false); | 1150 SendResponse(false); |
| 1156 return; | 1151 return; |
| 1157 } | 1152 } |
| 1158 | 1153 |
| 1159 const FilePath& source_path = files[0].path; | 1154 const FilePath& source_path = files[0].local_path; |
| 1160 const FilePath::StringType& display_name = files[0].display_name; | 1155 const FilePath::StringType& display_name = |
| 1156 files[0].file_path.BaseName().value(); |
| 1161 // Check if the source path is under GData cache directory. | 1157 // Check if the source path is under GData cache directory. |
| 1162 gdata::GDataSystemService* system_service = | 1158 gdata::GDataSystemService* system_service = |
| 1163 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1159 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 1164 gdata::GDataCache* cache = system_service ? system_service->cache() : NULL; | 1160 gdata::GDataCache* cache = system_service ? system_service->cache() : NULL; |
| 1165 if (cache && cache->IsUnderGDataCacheDirectory(source_path)) { | 1161 if (cache && cache->IsUnderGDataCacheDirectory(source_path)) { |
| 1166 cache->SetMountedStateOnUIThread( | 1162 cache->SetMountedStateOnUIThread( |
| 1167 source_path, | 1163 source_path, |
| 1168 true, | 1164 true, |
| 1169 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, | 1165 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, |
| 1170 display_name)); | 1166 display_name)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 } | 1211 } |
| 1216 | 1212 |
| 1217 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( | 1213 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
| 1218 const SelectedFileInfoList& files) { | 1214 const SelectedFileInfoList& files) { |
| 1219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1220 | 1216 |
| 1221 if (files.size() != 1) { | 1217 if (files.size() != 1) { |
| 1222 SendResponse(false); | 1218 SendResponse(false); |
| 1223 return; | 1219 return; |
| 1224 } | 1220 } |
| 1225 DiskMountManager::GetInstance()->UnmountPath(files[0].path.value()); | 1221 DiskMountManager::GetInstance()->UnmountPath(files[0].local_path.value()); |
| 1226 SendResponse(true); | 1222 SendResponse(true); |
| 1227 } | 1223 } |
| 1228 | 1224 |
| 1229 GetMountPointsFunction::GetMountPointsFunction() { | 1225 GetMountPointsFunction::GetMountPointsFunction() { |
| 1230 } | 1226 } |
| 1231 | 1227 |
| 1232 GetMountPointsFunction::~GetMountPointsFunction() { | 1228 GetMountPointsFunction::~GetMountPointsFunction() { |
| 1233 } | 1229 } |
| 1234 | 1230 |
| 1235 bool GetMountPointsFunction::RunImpl() { | 1231 bool GetMountPointsFunction::RunImpl() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 | 1277 |
| 1282 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( | 1278 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
| 1283 const SelectedFileInfoList& files) { | 1279 const SelectedFileInfoList& files) { |
| 1284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1285 | 1281 |
| 1286 if (files.size() != 1) { | 1282 if (files.size() != 1) { |
| 1287 SendResponse(false); | 1283 SendResponse(false); |
| 1288 return; | 1284 return; |
| 1289 } | 1285 } |
| 1290 | 1286 |
| 1291 if (files[0].path == gdata::util::GetGDataMountPointPath()) { | 1287 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { |
| 1292 gdata::GDataSystemService* system_service = | 1288 gdata::GDataSystemService* system_service = |
| 1293 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1289 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 1294 | 1290 |
| 1295 gdata::GDataFileSystemInterface* file_system = | 1291 gdata::GDataFileSystemInterface* file_system = |
| 1296 system_service->file_system(); | 1292 system_service->file_system(); |
| 1297 | 1293 |
| 1298 file_system->GetAvailableSpace( | 1294 file_system->GetAvailableSpace( |
| 1299 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, | 1295 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, |
| 1300 this)); | 1296 this)); |
| 1301 | 1297 |
| 1302 } else { | 1298 } else { |
| 1303 BrowserThread::PostTask( | 1299 BrowserThread::PostTask( |
| 1304 BrowserThread::FILE, FROM_HERE, | 1300 BrowserThread::FILE, FROM_HERE, |
| 1305 base::Bind( | 1301 base::Bind( |
| 1306 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, | 1302 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, |
| 1307 this, | 1303 this, |
| 1308 files[0].path.value())); | 1304 files[0].file_path.value())); |
| 1309 } | 1305 } |
| 1310 } | 1306 } |
| 1311 | 1307 |
| 1312 void GetSizeStatsFunction::GetGDataAvailableSpaceCallback( | 1308 void GetSizeStatsFunction::GetGDataAvailableSpaceCallback( |
| 1313 gdata::GDataFileError error, | 1309 gdata::GDataFileError error, |
| 1314 int64 bytes_total, | 1310 int64 bytes_total, |
| 1315 int64 bytes_used) { | 1311 int64 bytes_used) { |
| 1316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1317 | 1313 |
| 1318 if (error == gdata::GDATA_FILE_OK) { | 1314 if (error == gdata::GDATA_FILE_OK) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1380 |
| 1385 void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( | 1381 void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( |
| 1386 const SelectedFileInfoList& files) { | 1382 const SelectedFileInfoList& files) { |
| 1387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1388 | 1384 |
| 1389 if (files.size() != 1) { | 1385 if (files.size() != 1) { |
| 1390 SendResponse(false); | 1386 SendResponse(false); |
| 1391 return; | 1387 return; |
| 1392 } | 1388 } |
| 1393 | 1389 |
| 1394 DiskMountManager::GetInstance()->FormatMountedDevice(files[0].path.value()); | 1390 DiskMountManager::GetInstance()->FormatMountedDevice( |
| 1391 files[0].file_path.value()); |
| 1395 SendResponse(true); | 1392 SendResponse(true); |
| 1396 } | 1393 } |
| 1397 | 1394 |
| 1398 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { | 1395 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { |
| 1399 } | 1396 } |
| 1400 | 1397 |
| 1401 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { | 1398 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { |
| 1402 } | 1399 } |
| 1403 | 1400 |
| 1404 bool GetVolumeMetadataFunction::RunImpl() { | 1401 bool GetVolumeMetadataFunction::RunImpl() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1430 // Should contain volume's mount path. | 1427 // Should contain volume's mount path. |
| 1431 if (files.size() != 1) { | 1428 if (files.size() != 1) { |
| 1432 error_ = "Invalid mount path."; | 1429 error_ = "Invalid mount path."; |
| 1433 SendResponse(false); | 1430 SendResponse(false); |
| 1434 return; | 1431 return; |
| 1435 } | 1432 } |
| 1436 | 1433 |
| 1437 results_.reset(); | 1434 results_.reset(); |
| 1438 | 1435 |
| 1439 const DiskMountManager::Disk* volume = GetVolumeAsDisk( | 1436 const DiskMountManager::Disk* volume = GetVolumeAsDisk( |
| 1440 files[0].path.value()); | 1437 files[0].file_path.value()); |
| 1441 if (volume) { | 1438 if (volume) { |
| 1442 DictionaryValue* volume_info = | 1439 DictionaryValue* volume_info = |
| 1443 CreateValueFromDisk(profile_, volume); | 1440 CreateValueFromDisk(profile_, volume); |
| 1444 SetResult(volume_info); | 1441 SetResult(volume_info); |
| 1445 } | 1442 } |
| 1446 | 1443 |
| 1447 SendResponse(true); | 1444 SendResponse(true); |
| 1448 } | 1445 } |
| 1449 | 1446 |
| 1450 bool ToggleFullscreenFunction::RunImpl() { | 1447 bool ToggleFullscreenFunction::RunImpl() { |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 this)); | 1996 this)); |
| 2000 return true; | 1997 return true; |
| 2001 } | 1998 } |
| 2002 | 1999 |
| 2003 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( | 2000 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( |
| 2004 const SelectedFileInfoList& files) { | 2001 const SelectedFileInfoList& files) { |
| 2005 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2002 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2006 | 2003 |
| 2007 ListValue* locations = new ListValue; | 2004 ListValue* locations = new ListValue; |
| 2008 for (size_t i = 0; i < files.size(); ++i) { | 2005 for (size_t i = 0; i < files.size(); ++i) { |
| 2009 if (gdata::util::IsUnderGDataMountPoint(files[i].path)) { | 2006 if (gdata::util::IsUnderGDataMountPoint(files[i].file_path)) { |
| 2010 locations->Append(Value::CreateStringValue("drive")); | 2007 locations->Append(Value::CreateStringValue("drive")); |
| 2011 } else { | 2008 } else { |
| 2012 locations->Append(Value::CreateStringValue("local")); | 2009 locations->Append(Value::CreateStringValue("local")); |
| 2013 } | 2010 } |
| 2014 } | 2011 } |
| 2015 | 2012 |
| 2016 SetResult(locations); | 2013 SetResult(locations); |
| 2017 SendResponse(true); | 2014 SendResponse(true); |
| 2018 } | 2015 } |
| 2019 | 2016 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2043 base::Bind(&GetGDataFilesFunction::GetLocalPathsResponseOnUIThread, | 2040 base::Bind(&GetGDataFilesFunction::GetLocalPathsResponseOnUIThread, |
| 2044 this)); | 2041 this)); |
| 2045 return true; | 2042 return true; |
| 2046 } | 2043 } |
| 2047 | 2044 |
| 2048 void GetGDataFilesFunction::GetLocalPathsResponseOnUIThread( | 2045 void GetGDataFilesFunction::GetLocalPathsResponseOnUIThread( |
| 2049 const SelectedFileInfoList& files) { | 2046 const SelectedFileInfoList& files) { |
| 2050 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2047 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2051 | 2048 |
| 2052 for (size_t i = 0; i < files.size(); ++i) { | 2049 for (size_t i = 0; i < files.size(); ++i) { |
| 2053 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].path)); | 2050 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); |
| 2054 FilePath gdata_path = gdata::util::ExtractGDataPath(files[i].path); | 2051 FilePath gdata_path = gdata::util::ExtractGDataPath(files[i].file_path); |
| 2055 remaining_gdata_paths_.push(gdata_path); | 2052 remaining_gdata_paths_.push(gdata_path); |
| 2056 } | 2053 } |
| 2057 | 2054 |
| 2058 local_paths_ = new ListValue; | 2055 local_paths_ = new ListValue; |
| 2059 GetFileOrSendResponse(); | 2056 GetFileOrSendResponse(); |
| 2060 } | 2057 } |
| 2061 | 2058 |
| 2062 void GetGDataFilesFunction::GetFileOrSendResponse() { | 2059 void GetGDataFilesFunction::GetFileOrSendResponse() { |
| 2063 // Send the response if all files are obtained. | 2060 // Send the response if all files are obtained. |
| 2064 if (remaining_gdata_paths_.empty()) { | 2061 if (remaining_gdata_paths_.empty()) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 if (!system_service) { | 2170 if (!system_service) { |
| 2174 SendResponse(false); | 2171 SendResponse(false); |
| 2175 return; | 2172 return; |
| 2176 } | 2173 } |
| 2177 | 2174 |
| 2178 gdata::GDataOperationRegistry* operation_registry = | 2175 gdata::GDataOperationRegistry* operation_registry = |
| 2179 system_service->docs_service()->operation_registry(); | 2176 system_service->docs_service()->operation_registry(); |
| 2180 | 2177 |
| 2181 scoped_ptr<ListValue> responses(new ListValue()); | 2178 scoped_ptr<ListValue> responses(new ListValue()); |
| 2182 for (size_t i = 0; i < files.size(); ++i) { | 2179 for (size_t i = 0; i < files.size(); ++i) { |
| 2183 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].path)); | 2180 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); |
| 2184 FilePath file_path = gdata::util::ExtractGDataPath(files[i].path); | 2181 FilePath file_path = gdata::util::ExtractGDataPath(files[i].file_path); |
| 2185 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 2182 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
| 2186 result->SetBoolean( | 2183 result->SetBoolean( |
| 2187 "canceled", | 2184 "canceled", |
| 2188 operation_registry->CancelForFilePath(file_path)); | 2185 operation_registry->CancelForFilePath(file_path)); |
| 2189 GURL file_url; | 2186 GURL file_url; |
| 2190 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, | 2187 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, |
| 2191 gdata::util::GetSpecialRemoteRootPath().Append(file_path), | 2188 gdata::util::GetSpecialRemoteRootPath().Append(file_path), |
| 2192 source_url_.GetOrigin(), | 2189 source_url_.GetOrigin(), |
| 2193 &file_url)) { | 2190 &file_url)) { |
| 2194 result->SetString("fileUrl", file_url.spec()); | 2191 result->SetString("fileUrl", file_url.spec()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 return; | 2228 return; |
| 2232 } | 2229 } |
| 2233 | 2230 |
| 2234 gdata::GDataSystemService* system_service = | 2231 gdata::GDataSystemService* system_service = |
| 2235 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2232 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2236 if (!system_service) { | 2233 if (!system_service) { |
| 2237 SendResponse(false); | 2234 SendResponse(false); |
| 2238 return; | 2235 return; |
| 2239 } | 2236 } |
| 2240 | 2237 |
| 2241 FilePath source_file = files[0].path; | 2238 FilePath source_file = files[0].file_path; |
| 2242 FilePath destination_file = files[1].path; | 2239 FilePath destination_file = files[1].file_path; |
| 2243 | 2240 |
| 2244 bool source_file_under_gdata = | 2241 bool source_file_under_gdata = |
| 2245 gdata::util::IsUnderGDataMountPoint(source_file); | 2242 gdata::util::IsUnderGDataMountPoint(source_file); |
| 2246 bool destination_file_under_gdata = | 2243 bool destination_file_under_gdata = |
| 2247 gdata::util::IsUnderGDataMountPoint(destination_file); | 2244 gdata::util::IsUnderGDataMountPoint(destination_file); |
| 2248 | 2245 |
| 2249 if (source_file_under_gdata && !destination_file_under_gdata) { | 2246 if (source_file_under_gdata && !destination_file_under_gdata) { |
| 2250 // Transfer a file from gdata to local file system. | 2247 // Transfer a file from gdata to local file system. |
| 2251 source_file = gdata::util::ExtractGDataPath(source_file); | 2248 source_file = gdata::util::ExtractGDataPath(source_file); |
| 2252 system_service->file_system()->TransferFileFromRemoteToLocal( | 2249 system_service->file_system()->TransferFileFromRemoteToLocal( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 gdata::GDataSystemService* system_service = | 2414 gdata::GDataSystemService* system_service = |
| 2418 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2415 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2419 if (!system_service || !system_service->file_system()) | 2416 if (!system_service || !system_service->file_system()) |
| 2420 return false; | 2417 return false; |
| 2421 | 2418 |
| 2422 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2419 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
| 2423 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2420 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
| 2424 | 2421 |
| 2425 return true; | 2422 return true; |
| 2426 } | 2423 } |
| OLD | NEW |