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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1270 it != mount_points.end(); | 1270 it != mount_points.end(); |
1271 ++it) { | 1271 ++it) { |
1272 mounts->Append(MountPointToValue(profile_, it->second)); | 1272 mounts->Append(MountPointToValue(profile_, it->second)); |
1273 } | 1273 } |
1274 #endif | 1274 #endif |
1275 | 1275 |
1276 SendResponse(true); | 1276 SendResponse(true); |
1277 return true; | 1277 return true; |
1278 } | 1278 } |
1279 | 1279 |
1280 GetSizeStatsFunction::GetSizeStatsFunction() { | |
1281 } | |
1282 | |
1283 GetSizeStatsFunction::~GetSizeStatsFunction() { | |
1284 } | |
1285 | |
1286 void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( | |
1287 const char* mount_path) { | |
1288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
1289 | |
1290 size_t total_size_kb = 0; | |
1291 size_t remaining_size_kb = 0; | |
1292 #ifdef OS_CHROMEOS | |
1293 chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStatsOnFileThread( | |
1294 mount_path, &total_size_kb, &remaining_size_kb); | |
1295 #endif | |
rginda
2011/09/06 21:38:58
Is this supposed to fall through to the PostTask,
tonibarzic
2011/09/06 21:45:32
it's supposed to fall through..
| |
1296 | |
1297 BrowserThread::PostTask( | |
1298 BrowserThread::UI, FROM_HERE, | |
1299 NewRunnableMethod(this, | |
1300 &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread, | |
1301 mount_path, total_size_kb, remaining_size_kb)); | |
1302 } | |
1303 | |
1304 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( | |
1305 const char* mount_path, size_t total_size_kb, size_t remaining_size_kb) { | |
1306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
1307 | |
1308 base::DictionaryValue* sizes = new base::DictionaryValue(); | |
1309 result_.reset(sizes); | |
1310 | |
1311 sizes->SetInteger("totalSizeKB", total_size_kb); | |
1312 sizes->SetInteger("remainingSizeKB", remaining_size_kb); | |
1313 | |
1314 SendResponse(true); | |
1315 } | |
1316 | |
1317 bool GetSizeStatsFunction::RunImpl() { | |
1318 if (args_->GetSize() != 1) { | |
1319 return false; | |
1320 } | |
1321 | |
1322 std::string mount_url; | |
1323 if (!args_->GetString(0, &mount_url)) | |
1324 return false; | |
1325 | |
1326 UrlList mount_paths; | |
1327 mount_paths.push_back(GURL(mount_url)); | |
1328 | |
1329 BrowserThread::PostTask( | |
1330 BrowserThread::FILE, FROM_HERE, | |
1331 NewRunnableMethod(this, | |
1332 &GetSizeStatsFunction::GetLocalPathsOnFileThread, | |
1333 mount_paths, reinterpret_cast<void*>(NULL))); | |
1334 return true; | |
1335 } | |
1336 | |
1337 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( | |
1338 const FilePathList& files, void* context) { | |
1339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
1340 | |
1341 if (files.size() != 1) { | |
1342 SendResponse(false); | |
1343 return; | |
1344 } | |
1345 | |
1346 BrowserThread::PostTask( | |
1347 BrowserThread::FILE, FROM_HERE, | |
1348 NewRunnableMethod(this, | |
1349 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, | |
1350 files[0].value().c_str())); | |
1351 return; | |
1352 } | |
1353 | |
1280 FormatDeviceFunction::FormatDeviceFunction() { | 1354 FormatDeviceFunction::FormatDeviceFunction() { |
1281 } | 1355 } |
1282 | 1356 |
1283 FormatDeviceFunction::~FormatDeviceFunction() { | 1357 FormatDeviceFunction::~FormatDeviceFunction() { |
1284 } | 1358 } |
1285 | 1359 |
1286 bool FormatDeviceFunction::RunImpl() { | 1360 bool FormatDeviceFunction::RunImpl() { |
1287 if (args_->GetSize() != 1) { | 1361 if (args_->GetSize() != 1) { |
1288 return false; | 1362 return false; |
1289 } | 1363 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1534 // TODO(serya): Create a new string in .grd file for this one in M13. | 1608 // TODO(serya): Create a new string in .grd file for this one in M13. |
1535 dict->SetString("PREVIEW_IMAGE", | 1609 dict->SetString("PREVIEW_IMAGE", |
1536 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1610 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1537 dict->SetString("PLAY_MEDIA", | 1611 dict->SetString("PLAY_MEDIA", |
1538 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1612 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1539 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) | 1613 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) |
1540 dict->SetString("ENABLE_ARCHIVES", "true"); | 1614 dict->SetString("ENABLE_ARCHIVES", "true"); |
1541 | 1615 |
1542 return true; | 1616 return true; |
1543 } | 1617 } |
OLD | NEW |