Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 23715003: Files.app: Rename the FileBrowserPrivateAPI's functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_manager/private_api_file_syste m.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste m.h"
6 6
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 #include <sys/statvfs.h> 8 #include <sys/statvfs.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <utime.h> 10 #include <utime.h>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return false; 171 return false;
172 172
173 struct utimbuf times; 173 struct utimbuf times;
174 times.actime = stat_buffer.st_atime; 174 times.actime = stat_buffer.st_atime;
175 times.modtime = timestamp; 175 times.modtime = timestamp;
176 return utime(local_path.value().c_str(), &times) == 0; 176 return utime(local_path.value().c_str(), &times) == 0;
177 } 177 }
178 178
179 } // namespace 179 } // namespace
180 180
181 RequestFileSystemFunction::RequestFileSystemFunction() { 181 FileBrowserPrivateRequestFileSystemFunction::
182 FileBrowserPrivateRequestFileSystemFunction() {
hashimoto 2013/08/30 06:03:14 nit: Better indented by 4 spaces? (cf. https://cod
hirono 2013/08/30 06:26:46 Done.
182 } 183 }
183 184
184 RequestFileSystemFunction::~RequestFileSystemFunction() { 185 FileBrowserPrivateRequestFileSystemFunction::
186 ~FileBrowserPrivateRequestFileSystemFunction() {
185 } 187 }
186 188
187 void RequestFileSystemFunction::DidOpenFileSystem( 189 void FileBrowserPrivateRequestFileSystemFunction::DidOpenFileSystem(
188 scoped_refptr<fileapi::FileSystemContext> file_system_context, 190 scoped_refptr<fileapi::FileSystemContext> file_system_context,
189 base::PlatformFileError result, 191 base::PlatformFileError result,
190 const std::string& name, 192 const std::string& name,
191 const GURL& root_path) { 193 const GURL& root_path) {
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
193 195
194 if (result != base::PLATFORM_FILE_OK) { 196 if (result != base::PLATFORM_FILE_OK) {
195 DidFail(result); 197 DidFail(result);
196 return; 198 return;
197 } 199 }
(...skipping 23 matching lines...) Expand all
221 SetDriveMountPointPermissions(profile_, extension_id(), render_view_host()); 223 SetDriveMountPointPermissions(profile_, extension_id(), render_view_host());
222 224
223 DictionaryValue* dict = new DictionaryValue(); 225 DictionaryValue* dict = new DictionaryValue();
224 SetResult(dict); 226 SetResult(dict);
225 dict->SetString("name", name); 227 dict->SetString("name", name);
226 dict->SetString("path", root_path.spec()); 228 dict->SetString("path", root_path.spec());
227 dict->SetInteger("error", drive::FILE_ERROR_OK); 229 dict->SetInteger("error", drive::FILE_ERROR_OK);
228 SendResponse(true); 230 SendResponse(true);
229 } 231 }
230 232
231 void RequestFileSystemFunction::DidFail( 233 void FileBrowserPrivateRequestFileSystemFunction::DidFail(
232 base::PlatformFileError error_code) { 234 base::PlatformFileError error_code) {
233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
234 236
235 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code)); 237 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code));
236 SendResponse(false); 238 SendResponse(false);
237 } 239 }
238 240
239 bool RequestFileSystemFunction::SetupFileSystemAccessPermissions( 241 bool FileBrowserPrivateRequestFileSystemFunction::
242 SetupFileSystemAccessPermissions(
240 scoped_refptr<fileapi::FileSystemContext> file_system_context, 243 scoped_refptr<fileapi::FileSystemContext> file_system_context,
241 int child_id, 244 int child_id,
242 scoped_refptr<const extensions::Extension> extension) { 245 scoped_refptr<const extensions::Extension> extension) {
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
244 247
245 if (!extension.get()) 248 if (!extension.get())
246 return false; 249 return false;
247 250
248 // Make sure that only component extension can access the entire 251 // Make sure that only component extension can access the entire
249 // local file system. 252 // local file system.
(...skipping 14 matching lines...) Expand all
264 // Grant R/W file permissions to the renderer hosting component 267 // Grant R/W file permissions to the renderer hosting component
265 // extension for all paths exposed by our local file system backend. 268 // extension for all paths exposed by our local file system backend.
266 std::vector<base::FilePath> root_dirs = backend->GetRootDirectories(); 269 std::vector<base::FilePath> root_dirs = backend->GetRootDirectories();
267 for (size_t i = 0; i < root_dirs.size(); ++i) { 270 for (size_t i = 0; i < root_dirs.size(); ++i) {
268 ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile( 271 ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile(
269 child_id, root_dirs[i]); 272 child_id, root_dirs[i]);
270 } 273 }
271 return true; 274 return true;
272 } 275 }
273 276
274 bool RequestFileSystemFunction::RunImpl() { 277 bool FileBrowserPrivateRequestFileSystemFunction::RunImpl() {
275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
276 279
277 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) 280 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess())
278 return false; 281 return false;
279 282
280 set_log_on_completion(true); 283 set_log_on_completion(true);
281 284
282 scoped_refptr<fileapi::FileSystemContext> file_system_context = 285 scoped_refptr<fileapi::FileSystemContext> file_system_context =
283 file_manager::util::GetFileSystemContextForRenderViewHost( 286 file_manager::util::GetFileSystemContextForRenderViewHost(
284 profile(), render_view_host()); 287 profile(), render_view_host());
285 288
286 const GURL origin_url = source_url_.GetOrigin(); 289 const GURL origin_url = source_url_.GetOrigin();
287 file_system_context->OpenFileSystem( 290 file_system_context->OpenFileSystem(
288 origin_url, 291 origin_url,
289 fileapi::kFileSystemTypeExternal, 292 fileapi::kFileSystemTypeExternal,
290 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, 293 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
291 base::Bind(&RequestFileSystemFunction::DidOpenFileSystem, 294 base::Bind(&FileBrowserPrivateRequestFileSystemFunction::
295 DidOpenFileSystem,
292 this, 296 this,
293 file_system_context)); 297 file_system_context));
294 return true; 298 return true;
295 } 299 }
296 300
297 FileWatchFunctionBase::FileWatchFunctionBase() { 301 FileWatchFunctionBase::FileWatchFunctionBase() {
298 } 302 }
299 303
300 FileWatchFunctionBase::~FileWatchFunctionBase() { 304 FileWatchFunctionBase::~FileWatchFunctionBase() {
301 } 305 }
(...skipping 25 matching lines...) Expand all
327 base::FilePath virtual_path = file_watch_url.virtual_path(); 331 base::FilePath virtual_path = file_watch_url.virtual_path();
328 if (local_path.empty()) { 332 if (local_path.empty()) {
329 Respond(false); 333 Respond(false);
330 return true; 334 return true;
331 } 335 }
332 PerformFileWatchOperation(local_path, virtual_path, extension_id()); 336 PerformFileWatchOperation(local_path, virtual_path, extension_id());
333 337
334 return true; 338 return true;
335 } 339 }
336 340
337 AddFileWatchFunction::AddFileWatchFunction() { 341 FileBrowserPrivateAddFileWatchFunction::
342 FileBrowserPrivateAddFileWatchFunction() {
338 } 343 }
339 344
340 AddFileWatchFunction::~AddFileWatchFunction() { 345 FileBrowserPrivateAddFileWatchFunction::
346 ~FileBrowserPrivateAddFileWatchFunction() {
341 } 347 }
342 348
343 void AddFileWatchFunction::PerformFileWatchOperation( 349 void FileBrowserPrivateAddFileWatchFunction::PerformFileWatchOperation(
344 const base::FilePath& local_path, 350 const base::FilePath& local_path,
345 const base::FilePath& virtual_path, 351 const base::FilePath& virtual_path,
346 const std::string& extension_id) { 352 const std::string& extension_id) {
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
348 354
349 file_manager::EventRouter* event_router = 355 file_manager::EventRouter* event_router =
350 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); 356 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router();
351 event_router->AddFileWatch( 357 event_router->AddFileWatch(
352 local_path, 358 local_path,
353 virtual_path, 359 virtual_path,
354 extension_id, 360 extension_id,
355 base::Bind(&AddFileWatchFunction::Respond, this)); 361 base::Bind(&FileBrowserPrivateAddFileWatchFunction::Respond, this));
356 } 362 }
357 363
358 RemoveFileWatchFunction::RemoveFileWatchFunction() { 364 FileBrowserPrivateRemoveFileWatchFunction::
365 FileBrowserPrivateRemoveFileWatchFunction() {
359 } 366 }
360 367
361 RemoveFileWatchFunction::~RemoveFileWatchFunction() { 368 FileBrowserPrivateRemoveFileWatchFunction::
369 ~FileBrowserPrivateRemoveFileWatchFunction() {
362 } 370 }
363 371
364 void RemoveFileWatchFunction::PerformFileWatchOperation( 372 void FileBrowserPrivateRemoveFileWatchFunction::PerformFileWatchOperation(
365 const base::FilePath& local_path, 373 const base::FilePath& local_path,
366 const base::FilePath& unused, 374 const base::FilePath& unused,
367 const std::string& extension_id) { 375 const std::string& extension_id) {
368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
369 377
370 file_manager::EventRouter* event_router = 378 file_manager::EventRouter* event_router =
371 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); 379 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router();
372 event_router->RemoveFileWatch(local_path, extension_id); 380 event_router->RemoveFileWatch(local_path, extension_id);
373 Respond(true); 381 Respond(true);
374 } 382 }
375 383
376 SetLastModifiedFunction::SetLastModifiedFunction() { 384 FileBrowserPrivateSetLastModifiedFunction::
385 FileBrowserPrivateSetLastModifiedFunction() {
377 } 386 }
378 387
379 SetLastModifiedFunction::~SetLastModifiedFunction() { 388 FileBrowserPrivateSetLastModifiedFunction::
389 ~FileBrowserPrivateSetLastModifiedFunction() {
380 } 390 }
381 391
382 bool SetLastModifiedFunction::RunImpl() { 392 bool FileBrowserPrivateSetLastModifiedFunction::RunImpl() {
383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
384 394
385 if (args_->GetSize() != 2) { 395 if (args_->GetSize() != 2) {
386 return false; 396 return false;
387 } 397 }
388 398
389 std::string file_url; 399 std::string file_url;
390 if (!args_->GetString(0, &file_url)) 400 if (!args_->GetString(0, &file_url))
391 return false; 401 return false;
392 402
393 std::string timestamp; 403 std::string timestamp;
394 if (!args_->GetString(1, &timestamp)) 404 if (!args_->GetString(1, &timestamp))
395 return false; 405 return false;
396 406
397 base::FilePath local_path = file_manager::util::GetLocalPathFromURL( 407 base::FilePath local_path = file_manager::util::GetLocalPathFromURL(
398 render_view_host(), profile(), GURL(file_url)); 408 render_view_host(), profile(), GURL(file_url));
399 409
400 base::PostTaskAndReplyWithResult( 410 base::PostTaskAndReplyWithResult(
401 BrowserThread::GetBlockingPool(), 411 BrowserThread::GetBlockingPool(),
402 FROM_HERE, 412 FROM_HERE,
403 base::Bind(&SetLastModifiedOnBlockingPool, 413 base::Bind(&SetLastModifiedOnBlockingPool,
404 local_path, 414 local_path,
405 strtoul(timestamp.c_str(), NULL, 0)), 415 strtoul(timestamp.c_str(), NULL, 0)),
406 base::Bind(&SetLastModifiedFunction::SendResponse, 416 base::Bind(&FileBrowserPrivateSetLastModifiedFunction::SendResponse,
407 this)); 417 this));
408 return true; 418 return true;
409 } 419 }
410 420
411 GetSizeStatsFunction::GetSizeStatsFunction() { 421 FileBrowserPrivateGetSizeStatsFunction::
422 FileBrowserPrivateGetSizeStatsFunction() {
412 } 423 }
413 424
414 GetSizeStatsFunction::~GetSizeStatsFunction() { 425 FileBrowserPrivateGetSizeStatsFunction::
426 ~FileBrowserPrivateGetSizeStatsFunction() {
415 } 427 }
416 428
417 bool GetSizeStatsFunction::RunImpl() { 429 bool FileBrowserPrivateGetSizeStatsFunction::RunImpl() {
418 if (args_->GetSize() != 1) { 430 if (args_->GetSize() != 1) {
419 return false; 431 return false;
420 } 432 }
421 433
422 std::string mount_url; 434 std::string mount_url;
423 if (!args_->GetString(0, &mount_url)) 435 if (!args_->GetString(0, &mount_url))
424 return false; 436 return false;
425 437
426 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( 438 base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
427 render_view_host(), profile(), GURL(mount_url)); 439 render_view_host(), profile(), GURL(mount_url));
428 if (file_path.empty()) 440 if (file_path.empty())
429 return false; 441 return false;
430 442
431 if (file_path == drive::util::GetDriveMountPointPath()) { 443 if (file_path == drive::util::GetDriveMountPointPath()) {
432 drive::DriveIntegrationService* integration_service = 444 drive::DriveIntegrationService* integration_service =
433 drive::DriveIntegrationServiceFactory::GetForProfile(profile_); 445 drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
434 // |integration_service| is NULL if Drive is disabled. 446 // |integration_service| is NULL if Drive is disabled.
435 if (!integration_service) { 447 if (!integration_service) {
436 // If stats couldn't be gotten for drive, result should be left 448 // If stats couldn't be gotten for drive, result should be left
437 // undefined. See comments in GetDriveAvailableSpaceCallback(). 449 // undefined. See comments in GetDriveAvailableSpaceCallback().
438 SendResponse(true); 450 SendResponse(true);
439 return true; 451 return true;
440 } 452 }
441 453
442 drive::FileSystemInterface* file_system = 454 drive::FileSystemInterface* file_system =
443 integration_service->file_system(); 455 integration_service->file_system();
444 456
445 file_system->GetAvailableSpace( 457 file_system->GetAvailableSpace(
446 base::Bind(&GetSizeStatsFunction::GetDriveAvailableSpaceCallback, 458 base::Bind(&FileBrowserPrivateGetSizeStatsFunction::
459 GetDriveAvailableSpaceCallback,
447 this)); 460 this));
448 461
449 } else { 462 } else {
450 uint64* total_size = new uint64(0); 463 uint64* total_size = new uint64(0);
451 uint64* remaining_size = new uint64(0); 464 uint64* remaining_size = new uint64(0);
452 BrowserThread::PostBlockingPoolTaskAndReply( 465 BrowserThread::PostBlockingPoolTaskAndReply(
453 FROM_HERE, 466 FROM_HERE,
454 base::Bind(&GetSizeStatsOnBlockingPool, 467 base::Bind(&GetSizeStatsOnBlockingPool,
455 file_path.value(), 468 file_path.value(),
456 total_size, 469 total_size,
457 remaining_size), 470 remaining_size),
458 base::Bind(&GetSizeStatsFunction::GetSizeStatsCallback, 471 base::Bind(&FileBrowserPrivateGetSizeStatsFunction::
472 GetSizeStatsCallback,
459 this, 473 this,
460 base::Owned(total_size), 474 base::Owned(total_size),
461 base::Owned(remaining_size))); 475 base::Owned(remaining_size)));
462 } 476 }
463 return true; 477 return true;
464 } 478 }
465 479
466 void GetSizeStatsFunction::GetDriveAvailableSpaceCallback( 480 void FileBrowserPrivateGetSizeStatsFunction::GetDriveAvailableSpaceCallback(
467 drive::FileError error, 481 drive::FileError error,
468 int64 bytes_total, 482 int64 bytes_total,
469 int64 bytes_used) { 483 int64 bytes_used) {
470 if (error == drive::FILE_ERROR_OK) { 484 if (error == drive::FILE_ERROR_OK) {
471 const uint64 bytes_total_unsigned = bytes_total; 485 const uint64 bytes_total_unsigned = bytes_total;
472 const uint64 bytes_remaining_unsigned = bytes_total - bytes_used; 486 const uint64 bytes_remaining_unsigned = bytes_total - bytes_used;
473 GetSizeStatsCallback(&bytes_total_unsigned, 487 GetSizeStatsCallback(&bytes_total_unsigned,
474 &bytes_remaining_unsigned); 488 &bytes_remaining_unsigned);
475 } else { 489 } else {
476 // If stats couldn't be gotten for drive, result should be left undefined. 490 // If stats couldn't be gotten for drive, result should be left undefined.
477 SendResponse(true); 491 SendResponse(true);
478 } 492 }
479 } 493 }
480 494
481 void GetSizeStatsFunction::GetSizeStatsCallback( 495 void FileBrowserPrivateGetSizeStatsFunction::GetSizeStatsCallback(
482 const uint64* total_size, 496 const uint64* total_size,
483 const uint64* remaining_size) { 497 const uint64* remaining_size) {
484 base::DictionaryValue* sizes = new base::DictionaryValue(); 498 base::DictionaryValue* sizes = new base::DictionaryValue();
485 SetResult(sizes); 499 SetResult(sizes);
486 500
487 sizes->SetDouble("totalSize", static_cast<double>(*total_size)); 501 sizes->SetDouble("totalSize", static_cast<double>(*total_size));
488 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size)); 502 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size));
489 503
490 SendResponse(true); 504 SendResponse(true);
491 } 505 }
492 506
493 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { 507 FileBrowserPrivateGetVolumeMetadataFunction::
508 FileBrowserPrivateGetVolumeMetadataFunction() {
494 } 509 }
495 510
496 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { 511 FileBrowserPrivateGetVolumeMetadataFunction::
512 ~FileBrowserPrivateGetVolumeMetadataFunction() {
497 } 513 }
498 514
499 bool GetVolumeMetadataFunction::RunImpl() { 515 bool FileBrowserPrivateGetVolumeMetadataFunction::RunImpl() {
500 if (args_->GetSize() != 1) { 516 if (args_->GetSize() != 1) {
501 error_ = "Invalid argument count"; 517 error_ = "Invalid argument count";
502 return false; 518 return false;
503 } 519 }
504 520
505 std::string volume_mount_url; 521 std::string volume_mount_url;
506 if (!args_->GetString(0, &volume_mount_url)) { 522 if (!args_->GetString(0, &volume_mount_url)) {
507 NOTREACHED(); 523 NOTREACHED();
508 return false; 524 return false;
509 } 525 }
(...skipping 16 matching lines...) Expand all
526 } else { 542 } else {
527 const DiskMountManager::Disk* volume = GetVolumeAsDisk(file_path.value()); 543 const DiskMountManager::Disk* volume = GetVolumeAsDisk(file_path.value());
528 if (volume) 544 if (volume)
529 SetResult(CreateValueFromDisk(profile_, extension_->id(), volume)); 545 SetResult(CreateValueFromDisk(profile_, extension_->id(), volume));
530 } 546 }
531 547
532 SendResponse(true); 548 SendResponse(true);
533 return true; 549 return true;
534 } 550 }
535 551
536 ValidatePathNameLengthFunction::ValidatePathNameLengthFunction() { 552 FileBrowserPrivateValidatePathNameLengthFunction::
553 FileBrowserPrivateValidatePathNameLengthFunction() {
537 } 554 }
538 555
539 ValidatePathNameLengthFunction::~ValidatePathNameLengthFunction() { 556 FileBrowserPrivateValidatePathNameLengthFunction::
557 ~FileBrowserPrivateValidatePathNameLengthFunction() {
540 } 558 }
541 559
542 bool ValidatePathNameLengthFunction::RunImpl() { 560 bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() {
543 std::string parent_url; 561 std::string parent_url;
544 if (!args_->GetString(0, &parent_url)) 562 if (!args_->GetString(0, &parent_url))
545 return false; 563 return false;
546 564
547 std::string name; 565 std::string name;
548 if (!args_->GetString(1, &name)) 566 if (!args_->GetString(1, &name))
549 return false; 567 return false;
550 568
551 scoped_refptr<fileapi::FileSystemContext> file_system_context = 569 scoped_refptr<fileapi::FileSystemContext> file_system_context =
552 file_manager::util::GetFileSystemContextForRenderViewHost( 570 file_manager::util::GetFileSystemContextForRenderViewHost(
553 profile(), render_view_host()); 571 profile(), render_view_host());
554 572
555 fileapi::FileSystemURL filesystem_url( 573 fileapi::FileSystemURL filesystem_url(
556 file_system_context->CrackURL(GURL(parent_url))); 574 file_system_context->CrackURL(GURL(parent_url)));
557 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url)) 575 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url))
558 return false; 576 return false;
559 577
560 // No explicit limit on the length of Drive file names. 578 // No explicit limit on the length of Drive file names.
561 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) { 579 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) {
562 SetResult(new base::FundamentalValue(true)); 580 SetResult(new base::FundamentalValue(true));
563 SendResponse(true); 581 SendResponse(true);
564 return true; 582 return true;
565 } 583 }
566 584
567 base::PostTaskAndReplyWithResult( 585 base::PostTaskAndReplyWithResult(
568 BrowserThread::GetBlockingPool(), 586 BrowserThread::GetBlockingPool(),
569 FROM_HERE, 587 FROM_HERE,
570 base::Bind(&GetFileNameMaxLengthOnBlockingPool, 588 base::Bind(&GetFileNameMaxLengthOnBlockingPool,
571 filesystem_url.path().AsUTF8Unsafe()), 589 filesystem_url.path().AsUTF8Unsafe()),
572 base::Bind(&ValidatePathNameLengthFunction::OnFilePathLimitRetrieved, 590 base::Bind(&FileBrowserPrivateValidatePathNameLengthFunction::
591 OnFilePathLimitRetrieved,
573 this, name.size())); 592 this, name.size()));
574 return true; 593 return true;
575 } 594 }
576 595
577 void ValidatePathNameLengthFunction::OnFilePathLimitRetrieved( 596 void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved(
578 size_t current_length, 597 size_t current_length,
579 size_t max_length) { 598 size_t max_length) {
580 SetResult(new base::FundamentalValue(current_length <= max_length)); 599 SetResult(new base::FundamentalValue(current_length <= max_length));
581 SendResponse(true); 600 SendResponse(true);
582 } 601 }
583 602
584 FormatDeviceFunction::FormatDeviceFunction() { 603 FileBrowserPrivateFormatDeviceFunction::
604 FileBrowserPrivateFormatDeviceFunction() {
585 } 605 }
586 606
587 FormatDeviceFunction::~FormatDeviceFunction() { 607 FileBrowserPrivateFormatDeviceFunction::
608 ~FileBrowserPrivateFormatDeviceFunction() {
588 } 609 }
589 610
590 bool FormatDeviceFunction::RunImpl() { 611 bool FileBrowserPrivateFormatDeviceFunction::RunImpl() {
591 if (args_->GetSize() != 1) { 612 if (args_->GetSize() != 1) {
592 return false; 613 return false;
593 } 614 }
594 615
595 std::string volume_file_url; 616 std::string volume_file_url;
596 if (!args_->GetString(0, &volume_file_url)) { 617 if (!args_->GetString(0, &volume_file_url)) {
597 NOTREACHED(); 618 NOTREACHED();
598 return false; 619 return false;
599 } 620 }
600 621
601 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( 622 base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
602 render_view_host(), profile(), GURL(volume_file_url)); 623 render_view_host(), profile(), GURL(volume_file_url));
603 if (file_path.empty()) 624 if (file_path.empty())
604 return false; 625 return false;
605 626
606 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value()); 627 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value());
607 SendResponse(true); 628 SendResponse(true);
608 return true; 629 return true;
609 } 630 }
610 631
611 } // namespace extensions 632 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698