| Index: chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
|
| diff --git a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
|
| index f8753a9724a77df1a84d17b90206e3c4ca01f69f..e8fafd7a408e200fda0571cb05feca3f1e2da6da 100644
|
| --- a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
|
| +++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
|
| @@ -5,8 +5,10 @@
|
| #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h"
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/debug/trace_event.h"
|
| +#include "base/memory/linked_ptr.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
|
| @@ -16,6 +18,7 @@
|
| #include "chrome/common/extensions/api/file_system_provider.h"
|
| #include "chrome/common/extensions/api/file_system_provider_internal.h"
|
|
|
| +using chromeos::file_system_provider::ProvidedFileSystemInfo;
|
| using chromeos::file_system_provider::ProvidedFileSystemInterface;
|
| using chromeos::file_system_provider::RequestValue;
|
| using chromeos::file_system_provider::Service;
|
| @@ -29,7 +32,7 @@ bool FileSystemProviderMountFunction::RunSync() {
|
|
|
| // It's an error if the file system Id is empty.
|
| if (params->options.file_system_id.empty()) {
|
| - base::ListValue* result = new base::ListValue();
|
| + base::ListValue* const result = new base::ListValue();
|
| result->Append(CreateError(kSecurityErrorName, kEmptyIdErrorMessage));
|
| SetResult(result);
|
| return true;
|
| @@ -37,14 +40,14 @@ bool FileSystemProviderMountFunction::RunSync() {
|
|
|
| // It's an error if the display name is empty.
|
| if (params->options.display_name.empty()) {
|
| - base::ListValue* result = new base::ListValue();
|
| + base::ListValue* const result = new base::ListValue();
|
| result->Append(CreateError(kSecurityErrorName,
|
| kEmptyNameErrorMessage));
|
| SetResult(result);
|
| return true;
|
| }
|
|
|
| - Service* service = Service::Get(GetProfile());
|
| + Service* const service = Service::Get(GetProfile());
|
| DCHECK(service);
|
| if (!service)
|
| return false;
|
| @@ -54,7 +57,7 @@ bool FileSystemProviderMountFunction::RunSync() {
|
| params->options.file_system_id,
|
| params->options.display_name,
|
| params->options.writable)) {
|
| - base::ListValue* result = new base::ListValue();
|
| + base::ListValue* const result = new base::ListValue();
|
| result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage));
|
| SetResult(result);
|
| return true;
|
| @@ -70,7 +73,7 @@ bool FileSystemProviderUnmountFunction::RunSync() {
|
| scoped_ptr<Params> params(Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params);
|
|
|
| - Service* service = Service::Get(GetProfile());
|
| + Service* const service = Service::Get(GetProfile());
|
| DCHECK(service);
|
| if (!service)
|
| return false;
|
| @@ -85,11 +88,34 @@ bool FileSystemProviderUnmountFunction::RunSync() {
|
| return true;
|
| }
|
|
|
| - base::ListValue* result = new base::ListValue();
|
| + base::ListValue* const result = new base::ListValue();
|
| SetResult(result);
|
| return true;
|
| }
|
|
|
| +bool FileSystemProviderGetAllFunction::RunSync() {
|
| + using api::file_system_provider::FileSystemInfo;
|
| + Service* const service = Service::Get(GetProfile());
|
| + DCHECK(service);
|
| + if (!service)
|
| + return false;
|
| +
|
| + const std::vector<ProvidedFileSystemInfo> file_systems =
|
| + service->GetProvidedFileSystemInfoList();
|
| + std::vector<linked_ptr<FileSystemInfo> > items;
|
| +
|
| + for (size_t i = 0; i < file_systems.size(); ++i) {
|
| + linked_ptr<FileSystemInfo> item(new FileSystemInfo);
|
| + item->file_system_id = file_systems[i].file_system_id();
|
| + item->display_name = file_systems[i].display_name();
|
| + item->writable = file_systems[i].writable();
|
| + items.push_back(item);
|
| + }
|
| +
|
| + SetResultList(api::file_system_provider::GetAll::Results::Create(items));
|
| + return true;
|
| +}
|
| +
|
| bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunWhenValid() {
|
| using api::file_system_provider_internal::UnmountRequestedSuccess::Params;
|
| scoped_ptr<Params> params(Params::Create(*args_));
|
|
|