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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
44 #include "webkit/fileapi/file_system_context.h" | 44 #include "webkit/fileapi/file_system_context.h" |
45 #include "webkit/fileapi/file_system_file_util.h" | 45 #include "webkit/fileapi/file_system_file_util.h" |
46 #include "webkit/fileapi/file_system_mount_point_provider.h" | 46 #include "webkit/fileapi/file_system_mount_point_provider.h" |
47 #include "webkit/fileapi/file_system_operation.h" | 47 #include "webkit/fileapi/file_system_operation.h" |
48 #include "webkit/fileapi/file_system_operation_context.h" | 48 #include "webkit/fileapi/file_system_operation_context.h" |
49 #include "webkit/fileapi/file_system_path_manager.h" | 49 #include "webkit/fileapi/file_system_path_manager.h" |
50 #include "webkit/fileapi/file_system_types.h" | 50 #include "webkit/fileapi/file_system_types.h" |
51 #include "webkit/fileapi/file_system_util.h" | 51 #include "webkit/fileapi/file_system_util.h" |
52 | 52 |
53 #ifdef OS_CHROMEOS | |
54 #include "chrome/browser/chromeos/cros/cros_library.h" | |
55 #endif | |
56 | |
57 using content::BrowserThread; | 53 using content::BrowserThread; |
58 | 54 |
59 // Error messages. | 55 // Error messages. |
60 const char kFileError[] = "File error %d"; | 56 const char kFileError[] = "File error %d"; |
61 const char kInvalidFileUrl[] = "Invalid file URL"; | 57 const char kInvalidFileUrl[] = "Invalid file URL"; |
62 const char kVolumeDevicePathNotFound[] = "Device path not found"; | 58 const char kVolumeDevicePathNotFound[] = "Device path not found"; |
63 | 59 |
64 #ifdef OS_CHROMEOS | 60 #ifdef OS_CHROMEOS |
65 // Volume type strings. | 61 // Volume type strings. |
66 const std::string kVolumeTypeFlash = "flash"; | 62 const std::string kVolumeTypeFlash = "flash"; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 DictionaryPrefUpdate prefs_usage_update(profile->GetPrefs(), | 256 DictionaryPrefUpdate prefs_usage_update(profile->GetPrefs(), |
261 prefs::kLastUsedFileBrowserHandlers); | 257 prefs::kLastUsedFileBrowserHandlers); |
262 prefs_usage_update->SetWithoutPathExpansion(task_id, | 258 prefs_usage_update->SetWithoutPathExpansion(task_id, |
263 new base::FundamentalValue( | 259 new base::FundamentalValue( |
264 static_cast<int>(base::Time::Now().ToInternalValue()/ | 260 static_cast<int>(base::Time::Now().ToInternalValue()/ |
265 base::Time::kMicrosecondsPerSecond))); | 261 base::Time::kMicrosecondsPerSecond))); |
266 } | 262 } |
267 | 263 |
268 #ifdef OS_CHROMEOS | 264 #ifdef OS_CHROMEOS |
269 base::DictionaryValue* MountPointToValue(Profile* profile, | 265 base::DictionaryValue* MountPointToValue(Profile* profile, |
270 const chromeos::MountLibrary::MountPointInfo& mount_point_info) { | 266 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point_info) { |
271 | 267 |
272 base::DictionaryValue *mount_info = new base::DictionaryValue(); | 268 base::DictionaryValue *mount_info = new base::DictionaryValue(); |
273 | 269 |
274 mount_info->SetString("mountType", | 270 mount_info->SetString("mountType", |
275 chromeos::MountLibrary::MountTypeToString(mount_point_info.mount_type)); | 271 chromeos::disks::DiskMountManager::MountTypeToString( |
272 mount_point_info.mount_type)); | |
276 | 273 |
277 if (mount_point_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { | 274 if (mount_point_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
278 GURL source_url; | 275 GURL source_url; |
279 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile, | 276 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile, |
280 FilePath(mount_point_info.source_path), | 277 FilePath(mount_point_info.source_path), |
281 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), | 278 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), |
282 &source_url)) { | 279 &source_url)) { |
283 mount_info->SetString("sourceUrl", source_url.spec()); | 280 mount_info->SetString("sourceUrl", source_url.spec()); |
284 } | 281 } |
285 } else { | 282 } else { |
286 mount_info->SetString("sourceUrl", mount_point_info.source_path); | 283 mount_info->SetString("sourceUrl", mount_point_info.source_path); |
287 } | 284 } |
288 | 285 |
289 FilePath relative_mount_path; | 286 FilePath relative_mount_path; |
290 // Convert mount point path to relative path with the external file system | 287 // Convert mount point path to relative path with the external file system |
291 // exposed within File API. | 288 // exposed within File API. |
292 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile, | 289 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile, |
293 FilePath(mount_point_info.mount_path), | 290 FilePath(mount_point_info.mount_path), |
294 &relative_mount_path)) { | 291 &relative_mount_path)) { |
295 mount_info->SetString("mountPath", relative_mount_path.value()); | 292 mount_info->SetString("mountPath", relative_mount_path.value()); |
296 } | 293 } |
297 | 294 |
298 mount_info->SetString("mountCondition", | 295 mount_info->SetString("mountCondition", |
299 chromeos::MountLibrary::MountConditionToString( | 296 chromeos::disks::DiskMountManager::MountConditionToString( |
300 mount_point_info.mount_condition)); | 297 mount_point_info.mount_condition)); |
301 | 298 |
302 return mount_info; | 299 return mount_info; |
303 } | 300 } |
304 #endif | 301 #endif |
305 | 302 |
306 | 303 |
307 class LocalFileSystemCallbackDispatcher | 304 class LocalFileSystemCallbackDispatcher |
308 : public fileapi::FileSystemCallbackDispatcher { | 305 : public fileapi::FileSystemCallbackDispatcher { |
309 public: | 306 public: |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
990 return 0; | 987 return 0; |
991 } | 988 } |
992 return ExtensionTabUtil::GetTabId(tab_contents); | 989 return ExtensionTabUtil::GetTabId(tab_contents); |
993 } | 990 } |
994 | 991 |
995 // GetFileSystemRootPathOnFileThread can only be called from the file thread, | 992 // GetFileSystemRootPathOnFileThread can only be called from the file thread, |
996 // so here we are. This function takes a vector of virtual paths, converts | 993 // so here we are. This function takes a vector of virtual paths, converts |
997 // them to local paths and calls GetLocalPathsResponseOnUIThread with the | 994 // them to local paths and calls GetLocalPathsResponseOnUIThread with the |
998 // result vector, on the UI thread. | 995 // result vector, on the UI thread. |
999 void FileBrowserFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, | 996 void FileBrowserFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, |
1000 void* context) { | 997 void* context) { |
satorux1
2011/11/15 21:20:24
can you change this: void* -> std::string
hashimoto
2011/11/16 04:28:15
Instead of replacing void* with std::string, I int
| |
1001 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
1002 FilePathList selected_files; | 999 FilePathList selected_files; |
1003 | 1000 |
1004 // FilePath(virtual_path) doesn't work on win, so limit this to ChromeOS. | 1001 // FilePath(virtual_path) doesn't work on win, so limit this to ChromeOS. |
1005 #if defined(OS_CHROMEOS) | 1002 #if defined(OS_CHROMEOS) |
1006 GURL origin_url = source_url().GetOrigin(); | 1003 GURL origin_url = source_url().GetOrigin(); |
1007 fileapi::FileSystemPathManager* path_manager = | 1004 fileapi::FileSystemPathManager* path_manager = |
1008 profile()->GetFileSystemContext()->path_manager(); | 1005 profile()->GetFileSystemContext()->path_manager(); |
1009 | 1006 |
1010 size_t len = file_urls.size(); | 1007 size_t len = file_urls.size(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1057 BrowserThread::FILE, FROM_HERE, | 1054 BrowserThread::FILE, FROM_HERE, |
1058 base::Bind( | 1055 base::Bind( |
1059 &SelectFileFunction::GetLocalPathsOnFileThread, | 1056 &SelectFileFunction::GetLocalPathsOnFileThread, |
1060 this, | 1057 this, |
1061 file_paths, reinterpret_cast<void*>(NULL))); | 1058 file_paths, reinterpret_cast<void*>(NULL))); |
1062 | 1059 |
1063 return true; | 1060 return true; |
1064 } | 1061 } |
1065 | 1062 |
1066 void SelectFileFunction::GetLocalPathsResponseOnUIThread( | 1063 void SelectFileFunction::GetLocalPathsResponseOnUIThread( |
1067 const FilePathList& files, void* context) { | 1064 const FilePathList& files, void* context) { |
satorux1
2011/11/15 21:20:24
context is unused. can you remove?
hashimoto
2011/11/16 04:28:15
Done.
| |
1068 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1065 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1069 DCHECK(!context); | 1066 DCHECK(!context); |
1070 if (files.size() != 1) { | 1067 if (files.size() != 1) { |
1071 SendResponse(false); | 1068 SendResponse(false); |
1072 return; | 1069 return; |
1073 } | 1070 } |
1074 int index; | 1071 int index; |
1075 args_->GetInteger(1, &index); | 1072 args_->GetInteger(1, &index); |
1076 int32 tab_id = GetTabId(); | 1073 int32 tab_id = GetTabId(); |
1077 FileManagerDialog::OnFileSelected(tab_id, files[0], index); | 1074 FileManagerDialog::OnFileSelected(tab_id, files[0], index); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 return true; | 1181 return true; |
1185 } | 1182 } |
1186 | 1183 |
1187 AddMountFunction::AddMountFunction() { | 1184 AddMountFunction::AddMountFunction() { |
1188 } | 1185 } |
1189 | 1186 |
1190 AddMountFunction::~AddMountFunction() { | 1187 AddMountFunction::~AddMountFunction() { |
1191 } | 1188 } |
1192 | 1189 |
1193 bool AddMountFunction::RunImpl() { | 1190 bool AddMountFunction::RunImpl() { |
1191 // The third argument is simply ignored. | |
hashimoto
2011/11/15 12:39:25
MountPathOptions declared in chromeos_mount.h is n
tbarzic
2011/11/15 19:52:38
it's not yet used (this will be needed for network
satorux1
2011/11/15 21:20:24
Let's add it back when needed. :) Hopefully this c
| |
1194 if (args_->GetSize() != 2 && args_->GetSize() != 3) { | 1192 if (args_->GetSize() != 2 && args_->GetSize() != 3) { |
1195 error_ = "Invalid argument count"; | 1193 error_ = "Invalid argument count"; |
1196 return false; | 1194 return false; |
1197 } | 1195 } |
1198 | 1196 |
1199 std::string file_url; | 1197 std::string file_url; |
1200 if (!args_->GetString(0, &file_url)) { | 1198 if (!args_->GetString(0, &file_url)) { |
1201 return false; | 1199 return false; |
1202 } | 1200 } |
1203 | 1201 |
1204 std::string mount_type_str; | 1202 std::string mount_type_str; |
1205 if (!args_->GetString(1, &mount_type_str)) { | 1203 if (!args_->GetString(1, &mount_type_str)) { |
1206 return false; | 1204 return false; |
1207 } | 1205 } |
1208 | 1206 |
1209 UrlList file_paths; | 1207 UrlList file_paths; |
1210 file_paths.push_back(GURL(file_url)); | 1208 file_paths.push_back(GURL(file_url)); |
1211 | 1209 |
1212 #if defined(OS_CHROMEOS) | 1210 #if defined(OS_CHROMEOS) |
1213 chromeos::MountPathOptions options; | 1211 // |context| is deleted in GetLocalPathsResponseOnUIThread |
1214 if (args_->GetSize() == 3) { | 1212 std::string* context = new std::string(mount_type_str); |
satorux1
2011/11/15 21:20:24
This void* context hack is ugly. I think you can r
hashimoto
2011/11/16 04:28:15
Done.
| |
1215 DictionaryValue *dict; | |
1216 if (!args_->GetDictionary(2, &dict)) { | |
1217 NOTREACHED(); | |
1218 } | |
1219 | |
1220 for (base::DictionaryValue::key_iterator it = dict->begin_keys(); | |
1221 it != dict->end_keys(); | |
1222 ++it) { | |
1223 std::string value; | |
1224 if (!dict->GetString(*it, &value)) { | |
1225 NOTREACHED(); | |
1226 } | |
1227 | |
1228 options.push_back(chromeos::MountPathOptions::value_type((*it).c_str(), | |
1229 value.c_str())); | |
1230 } | |
1231 } | |
1232 | |
1233 MountParamaters* params = new MountParamaters(mount_type_str, options); | |
1234 BrowserThread::PostTask( | 1213 BrowserThread::PostTask( |
1235 BrowserThread::FILE, FROM_HERE, | 1214 BrowserThread::FILE, FROM_HERE, |
1236 base::Bind( | 1215 base::Bind(&AddMountFunction::GetLocalPathsOnFileThread, this, file_paths, |
1237 &AddMountFunction::GetLocalPathsOnFileThread, | 1216 context)); |
satorux1
2011/11/15 21:20:24
can you pass mount_type_str directly?
hashimoto
2011/11/16 04:28:15
Done.
| |
1238 this, | |
1239 file_paths, reinterpret_cast<void*>(params))); | |
1240 #endif // OS_CHROMEOS | 1217 #endif // OS_CHROMEOS |
1241 | 1218 |
1242 return true; | 1219 return true; |
1243 } | 1220 } |
1244 | 1221 |
1245 void AddMountFunction::GetLocalPathsResponseOnUIThread( | 1222 void AddMountFunction::GetLocalPathsResponseOnUIThread( |
1246 const FilePathList& files, void* context) { | 1223 const FilePathList& files, void* context) { |
satorux1
2011/11/15 21:20:24
can you change this: void* -> const std::string&
hashimoto
2011/11/16 04:28:15
Done.
| |
1247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1248 DCHECK(context); | 1225 DCHECK(context); |
1249 | 1226 |
1250 if (!files.size()) { | 1227 if (!files.size()) { |
1251 SendResponse(false); | 1228 SendResponse(false); |
1252 return; | 1229 return; |
1253 } | 1230 } |
1254 | 1231 |
1255 #ifdef OS_CHROMEOS | 1232 #ifdef OS_CHROMEOS |
1256 scoped_ptr<MountParamaters> params( | 1233 scoped_ptr<std::string> mount_type_str( |
1257 reinterpret_cast<MountParamaters*>(context)); | 1234 reinterpret_cast<std::string*>(context)); |
1258 const std::string& mount_type_str = params->mount_type; | |
1259 const chromeos::MountPathOptions& options = params->mount_options; | |
1260 FilePath::StringType source_file = files[0].value(); | 1235 FilePath::StringType source_file = files[0].value(); |
1261 | 1236 |
1262 chromeos::MountLibrary *mount_lib = | 1237 chromeos::disks::DiskMountManager* disk_mount_manager = |
1263 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 1238 chromeos::disks::DiskMountManager::GetInstance(); |
1264 | 1239 |
1265 chromeos::MountType mount_type = | 1240 chromeos::MountType mount_type = |
1266 mount_lib->MountTypeFromString(mount_type_str); | 1241 disk_mount_manager->MountTypeFromString(*mount_type_str); |
1267 if (mount_type == chromeos::MOUNT_TYPE_INVALID) { | 1242 if (mount_type == chromeos::MOUNT_TYPE_INVALID) { |
1268 error_ = "Invalid mount type"; | 1243 error_ = "Invalid mount type"; |
1269 SendResponse(false); | 1244 SendResponse(false); |
1270 return; | 1245 return; |
1271 } | 1246 } |
1272 | 1247 |
1273 mount_lib->MountPath(source_file.data(), mount_type, options); | 1248 disk_mount_manager->MountPath(source_file.data(), mount_type); |
1274 #endif | 1249 #endif |
1275 | 1250 |
1276 SendResponse(true); | 1251 SendResponse(true); |
1277 } | 1252 } |
1278 | 1253 |
1279 RemoveMountFunction::RemoveMountFunction() { | 1254 RemoveMountFunction::RemoveMountFunction() { |
1280 } | 1255 } |
1281 | 1256 |
1282 RemoveMountFunction::~RemoveMountFunction() { | 1257 RemoveMountFunction::~RemoveMountFunction() { |
1283 } | 1258 } |
(...skipping 22 matching lines...) Expand all Loading... | |
1306 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( | 1281 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
1307 const FilePathList& files, void* context) { | 1282 const FilePathList& files, void* context) { |
1308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1309 DCHECK(!context); | 1284 DCHECK(!context); |
1310 | 1285 |
1311 if (files.size() != 1) { | 1286 if (files.size() != 1) { |
1312 SendResponse(false); | 1287 SendResponse(false); |
1313 return; | 1288 return; |
1314 } | 1289 } |
1315 #ifdef OS_CHROMEOS | 1290 #ifdef OS_CHROMEOS |
1316 chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( | 1291 chromeos::disks::DiskMountManager::GetInstance()->UnmountPath( |
1317 files[0].value().c_str()); | 1292 files[0].value()); |
1318 #endif | 1293 #endif |
1319 | 1294 |
1320 SendResponse(true); | 1295 SendResponse(true); |
1321 } | 1296 } |
1322 | 1297 |
1323 GetMountPointsFunction::GetMountPointsFunction() { | 1298 GetMountPointsFunction::GetMountPointsFunction() { |
1324 } | 1299 } |
1325 | 1300 |
1326 GetMountPointsFunction::~GetMountPointsFunction() { | 1301 GetMountPointsFunction::~GetMountPointsFunction() { |
1327 } | 1302 } |
1328 | 1303 |
1329 bool GetMountPointsFunction::RunImpl() { | 1304 bool GetMountPointsFunction::RunImpl() { |
1330 if (args_->GetSize()) | 1305 if (args_->GetSize()) |
1331 return false; | 1306 return false; |
1332 | 1307 |
1333 base::ListValue *mounts = new base::ListValue(); | 1308 base::ListValue *mounts = new base::ListValue(); |
1334 result_.reset(mounts); | 1309 result_.reset(mounts); |
1335 | 1310 |
1336 #ifdef OS_CHROMEOS | 1311 #ifdef OS_CHROMEOS |
1337 chromeos::MountLibrary *mount_lib = | 1312 chromeos::disks::DiskMountManager* disk_mount_manager = |
1338 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 1313 chromeos::disks::DiskMountManager::GetInstance(); |
1339 chromeos::MountLibrary::MountPointMap mount_points = | 1314 chromeos::disks::DiskMountManager::MountPointMap mount_points = |
1340 mount_lib->mount_points(); | 1315 disk_mount_manager->mount_points(); |
1341 | 1316 |
1342 for (chromeos::MountLibrary::MountPointMap::const_iterator it = | 1317 for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it = |
1343 mount_points.begin(); | 1318 mount_points.begin(); |
1344 it != mount_points.end(); | 1319 it != mount_points.end(); |
1345 ++it) { | 1320 ++it) { |
1346 mounts->Append(MountPointToValue(profile_, it->second)); | 1321 mounts->Append(MountPointToValue(profile_, it->second)); |
1347 } | 1322 } |
1348 #endif | 1323 #endif |
1349 | 1324 |
1350 SendResponse(true); | 1325 SendResponse(true); |
1351 return true; | 1326 return true; |
1352 } | 1327 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 if (files.size() != 1) { | 1360 if (files.size() != 1) { |
1386 SendResponse(false); | 1361 SendResponse(false); |
1387 return; | 1362 return; |
1388 } | 1363 } |
1389 | 1364 |
1390 BrowserThread::PostTask( | 1365 BrowserThread::PostTask( |
1391 BrowserThread::FILE, FROM_HERE, | 1366 BrowserThread::FILE, FROM_HERE, |
1392 base::Bind( | 1367 base::Bind( |
1393 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, | 1368 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, |
1394 this, | 1369 this, |
1395 files[0].value().c_str())); | 1370 files[0].value())); |
1396 } | 1371 } |
1397 | 1372 |
1398 void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( | 1373 void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( |
1399 const char* mount_path) { | 1374 const std::string& mount_path) { |
1400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 1375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
1401 | 1376 |
1402 size_t total_size_kb = 0; | 1377 size_t total_size_kb = 0; |
1403 size_t remaining_size_kb = 0; | 1378 size_t remaining_size_kb = 0; |
1404 #ifdef OS_CHROMEOS | 1379 #ifdef OS_CHROMEOS |
1405 chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStatsOnFileThread( | 1380 chromeos::disks::DiskMountManager::GetInstance()-> |
1406 mount_path, &total_size_kb, &remaining_size_kb); | 1381 GetSizeStatsOnFileThread(mount_path, &total_size_kb, &remaining_size_kb); |
1407 #endif | 1382 #endif |
1408 | 1383 |
1409 BrowserThread::PostTask( | 1384 BrowserThread::PostTask( |
1410 BrowserThread::UI, FROM_HERE, | 1385 BrowserThread::UI, FROM_HERE, |
1411 base::Bind( | 1386 base::Bind( |
1412 &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread, | 1387 &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread, |
1413 this, | 1388 this, |
1414 mount_path, total_size_kb, remaining_size_kb)); | 1389 mount_path, total_size_kb, remaining_size_kb)); |
1415 } | 1390 } |
1416 | 1391 |
1417 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( | 1392 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( |
1418 const char* mount_path, size_t total_size_kb, size_t remaining_size_kb) { | 1393 const std::string& mount_path, |
1394 size_t total_size_kb, | |
1395 size_t remaining_size_kb) { | |
1419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1420 | 1397 |
1421 base::DictionaryValue* sizes = new base::DictionaryValue(); | 1398 base::DictionaryValue* sizes = new base::DictionaryValue(); |
1422 result_.reset(sizes); | 1399 result_.reset(sizes); |
1423 | 1400 |
1424 sizes->SetInteger("totalSizeKB", total_size_kb); | 1401 sizes->SetInteger("totalSizeKB", total_size_kb); |
1425 sizes->SetInteger("remainingSizeKB", remaining_size_kb); | 1402 sizes->SetInteger("remainingSizeKB", remaining_size_kb); |
1426 | 1403 |
1427 SendResponse(true); | 1404 SendResponse(true); |
1428 } | 1405 } |
(...skipping 30 matching lines...) Expand all Loading... | |
1459 void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( | 1436 void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( |
1460 const FilePathList& files, void* context) { | 1437 const FilePathList& files, void* context) { |
1461 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1462 | 1439 |
1463 if (files.size() != 1) { | 1440 if (files.size() != 1) { |
1464 SendResponse(false); | 1441 SendResponse(false); |
1465 return; | 1442 return; |
1466 } | 1443 } |
1467 | 1444 |
1468 #ifdef OS_CHROMEOS | 1445 #ifdef OS_CHROMEOS |
1469 chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( | 1446 chromeos::disks::DiskMountManager::GetInstance()->FormatMountedDevice( |
1470 files[0].value().c_str()); | 1447 files[0].value()); |
1471 #endif | 1448 #endif |
1472 | 1449 |
1473 SendResponse(true); | 1450 SendResponse(true); |
1474 } | 1451 } |
1475 | 1452 |
1476 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { | 1453 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { |
1477 } | 1454 } |
1478 | 1455 |
1479 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { | 1456 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { |
1480 } | 1457 } |
1481 | 1458 |
1482 bool GetVolumeMetadataFunction::RunImpl() { | 1459 bool GetVolumeMetadataFunction::RunImpl() { |
1483 if (args_->GetSize() != 1) { | 1460 if (args_->GetSize() != 1) { |
1484 error_ = "Invalid argument count"; | 1461 error_ = "Invalid argument count"; |
1485 return false; | 1462 return false; |
1486 } | 1463 } |
1487 | 1464 |
1488 std::string volume_device_path; | 1465 std::string volume_device_path; |
1489 if (!args_->GetString(0, &volume_device_path)) { | 1466 if (!args_->GetString(0, &volume_device_path)) { |
1490 NOTREACHED(); | 1467 NOTREACHED(); |
1491 } | 1468 } |
1492 | 1469 |
1493 #ifdef OS_CHROMEOS | 1470 #ifdef OS_CHROMEOS |
1494 chromeos::MountLibrary* mount_lib = | 1471 chromeos::disks::DiskMountManager* disk_mount_manager = |
1495 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 1472 chromeos::disks::DiskMountManager::GetInstance(); |
1496 chromeos::MountLibrary::DiskMap::const_iterator volume_it = | 1473 chromeos::disks::DiskMountManager::DiskMap::const_iterator volume_it = |
1497 mount_lib->disks().find(volume_device_path); | 1474 disk_mount_manager->disks().find(volume_device_path); |
1498 | 1475 |
1499 if (volume_it != mount_lib->disks().end() && | 1476 if (volume_it != disk_mount_manager->disks().end() && |
1500 !volume_it->second->is_hidden()) { | 1477 !volume_it->second->is_hidden()) { |
1501 chromeos::MountLibrary::Disk* volume = volume_it->second; | 1478 chromeos::disks::DiskMountManager::Disk* volume = volume_it->second; |
1502 DictionaryValue* volume_info = new DictionaryValue(); | 1479 DictionaryValue* volume_info = new DictionaryValue(); |
1503 result_.reset(volume_info); | 1480 result_.reset(volume_info); |
1504 // Localising mount path. | 1481 // Localising mount path. |
1505 std::string mount_path; | 1482 std::string mount_path; |
1506 if (!volume->mount_path().empty()) { | 1483 if (!volume->mount_path().empty()) { |
1507 FilePath relative_mount_path; | 1484 FilePath relative_mount_path; |
1508 FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, | 1485 FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, |
1509 FilePath(volume->mount_path()), &relative_mount_path); | 1486 FilePath(volume->mount_path()), &relative_mount_path); |
1510 mount_path = relative_mount_path.value(); | 1487 mount_path = relative_mount_path.value(); |
1511 } | 1488 } |
1512 volume_info->SetString("devicePath", volume->device_path()); | 1489 volume_info->SetString("devicePath", volume->device_path()); |
1513 volume_info->SetString("mountPath", mount_path); | 1490 volume_info->SetString("mountPath", mount_path); |
1514 volume_info->SetString("systemPath", volume->system_path()); | 1491 volume_info->SetString("systemPath", volume->system_path()); |
1515 volume_info->SetString("filePath", volume->file_path()); | 1492 volume_info->SetString("filePath", volume->file_path()); |
1516 volume_info->SetString("deviceLabel", volume->device_label()); | 1493 volume_info->SetString("deviceLabel", volume->device_label()); |
1517 volume_info->SetString("driveLabel", volume->drive_label()); | 1494 volume_info->SetString("driveLabel", volume->drive_label()); |
1518 volume_info->SetString("deviceType", | 1495 volume_info->SetString("deviceType", |
1519 DeviceTypeToString(volume->device_type())); | 1496 DeviceTypeToString(volume->device_type())); |
1520 volume_info->SetInteger("totalSize", volume->total_size()); | 1497 volume_info->SetInteger("totalSize", volume->total_size_in_bytes()); |
1521 volume_info->SetBoolean("isParent", volume->is_parent()); | 1498 volume_info->SetBoolean("isParent", volume->is_parent()); |
1522 volume_info->SetBoolean("isReadOnly", volume->is_read_only()); | 1499 volume_info->SetBoolean("isReadOnly", volume->is_read_only()); |
1523 volume_info->SetBoolean("hasMedia", volume->has_media()); | 1500 volume_info->SetBoolean("hasMedia", volume->has_media()); |
1524 volume_info->SetBoolean("isOnBootDevice", volume->on_boot_device()); | 1501 volume_info->SetBoolean("isOnBootDevice", volume->on_boot_device()); |
1525 | 1502 |
1526 return true; | 1503 return true; |
1527 } | 1504 } |
1528 #endif | 1505 #endif |
1529 error_ = kVolumeDevicePathNotFound; | 1506 error_ = kVolumeDevicePathNotFound; |
1530 return false; | 1507 return false; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1715 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1692 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1716 dict->SetString("PLAY_MEDIA", | 1693 dict->SetString("PLAY_MEDIA", |
1717 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1694 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1718 #if defined(OS_CHROMEOS) | 1695 #if defined(OS_CHROMEOS) |
1719 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePhotoEditor)) | 1696 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePhotoEditor)) |
1720 dict->SetString("ENABLE_PHOTO_EDITOR", "true"); | 1697 dict->SetString("ENABLE_PHOTO_EDITOR", "true"); |
1721 #endif | 1698 #endif |
1722 | 1699 |
1723 return true; | 1700 return true; |
1724 } | 1701 } |
OLD | NEW |