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

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

Issue 1142593002: Generalize volume configuration over all volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the configure test. Created 5 years, 7 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
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_misc.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/frame/frame_util.h" 10 #include "ash/frame/frame_util.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 using chromeos::file_system_provider::Service; 485 using chromeos::file_system_provider::Service;
486 using chromeos::file_system_provider::ProvidingExtensionInfo; 486 using chromeos::file_system_provider::ProvidingExtensionInfo;
487 Service* const service = Service::Get(chrome_details_.GetProfile()); 487 Service* const service = Service::Get(chrome_details_.GetProfile());
488 488
489 if (!service->RequestMount(params->extension_id)) 489 if (!service->RequestMount(params->extension_id))
490 return RespondNow(Error("Failed to request a new mount.")); 490 return RespondNow(Error("Failed to request a new mount."));
491 491
492 return RespondNow(NoArguments()); 492 return RespondNow(NoArguments());
493 } 493 }
494 494
495 FileManagerPrivateConfigureProvidedFileSystemFunction:: 495 FileManagerPrivateConfigureVolumeFunction::
496 FileManagerPrivateConfigureProvidedFileSystemFunction() 496 FileManagerPrivateConfigureVolumeFunction()
497 : chrome_details_(this) { 497 : chrome_details_(this) {
498 } 498 }
499 499
500 ExtensionFunction::ResponseAction 500 ExtensionFunction::ResponseAction
501 FileManagerPrivateConfigureProvidedFileSystemFunction::Run() { 501 FileManagerPrivateConfigureVolumeFunction::Run() {
502 using extensions::api::file_manager_private::ConfigureProvidedFileSystem:: 502 using extensions::api::file_manager_private::ConfigureVolume::Params;
503 Params;
504 const scoped_ptr<Params> params(Params::Create(*args_)); 503 const scoped_ptr<Params> params(Params::Create(*args_));
505 EXTENSION_FUNCTION_VALIDATE(params); 504 EXTENSION_FUNCTION_VALIDATE(params);
506 505
507 using file_manager::VolumeManager; 506 using file_manager::VolumeManager;
508 using file_manager::Volume; 507 using file_manager::Volume;
509 VolumeManager* const volume_manager = 508 VolumeManager* const volume_manager =
510 VolumeManager::Get(chrome_details_.GetProfile()); 509 VolumeManager::Get(chrome_details_.GetProfile());
511 base::WeakPtr<Volume> volume = 510 base::WeakPtr<Volume> volume =
512 volume_manager->FindVolumeById(params->volume_id); 511 volume_manager->FindVolumeById(params->volume_id);
513 if (!volume.get()) 512 if (!volume.get())
514 return RespondNow(Error("Volume not found.")); 513 return RespondNow(Error("Volume not found."));
514 if (!volume->configurable())
515 return RespondNow(Error("Volume not configurable."));
515 516
516 using chromeos::file_system_provider::Service; 517 switch (volume->type()) {
517 Service* const service = Service::Get(chrome_details_.GetProfile()); 518 case file_manager::VOLUME_TYPE_PROVIDED: {
518 DCHECK(service); 519 using chromeos::file_system_provider::Service;
520 Service* const service = Service::Get(chrome_details_.GetProfile());
521 DCHECK(service);
519 522
520 using chromeos::file_system_provider::ProvidedFileSystemInterface; 523 using chromeos::file_system_provider::ProvidedFileSystemInterface;
521 ProvidedFileSystemInterface* const file_system = 524 ProvidedFileSystemInterface* const file_system =
522 service->GetProvidedFileSystem(volume->extension_id(), 525 service->GetProvidedFileSystem(volume->extension_id(),
523 volume->file_system_id()); 526 volume->file_system_id());
524 DCHECK(file_system); 527 if (file_system)
528 file_system->Configure(base::Bind(
529 &FileManagerPrivateConfigureVolumeFunction::OnCompleted, this));
530 break;
531 }
532 default:
533 NOTIMPLEMENTED();
534 }
525 535
526 file_system->Configure(base::Bind(
527 &FileManagerPrivateConfigureProvidedFileSystemFunction::OnCompleted,
528 this));
529 return RespondLater(); 536 return RespondLater();
530 } 537 }
531 538
532 void FileManagerPrivateConfigureProvidedFileSystemFunction::OnCompleted( 539 void FileManagerPrivateConfigureVolumeFunction::OnCompleted(
533 base::File::Error result) { 540 base::File::Error result) {
534 if (result != base::File::FILE_OK) { 541 if (result != base::File::FILE_OK) {
535 Respond(Error("Failed to complete configuration.")); 542 Respond(Error("Failed to complete configuration."));
536 return; 543 return;
537 } 544 }
538 545
539 Respond(NoArguments()); 546 Respond(NoArguments());
540 } 547 }
541 548
542 } // namespace extensions 549 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698