Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..810334f8c2b0671e22460fd37748d4cff3d0b774 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h" |
| + |
| +#include "chrome/common/extensions/api/file_system_provider.h" |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +const char kOK[] = "OK"; |
| + |
| +// Names come from http://www.w3.org/TR/file-system-api/#errors-and-exceptions |
| +const char kEncodingError[] = "EncodingError"; |
|
benwells
2013/11/08 03:34:31
Do you need to declare all of these? Only one is u
satorux1
2013/11/08 03:57:05
Done. Removed unused errors. Clang raised errors t
|
| +const char kInvalidModificationError[] = "InvalidModificationError"; |
| +const char kInvalidStateError[] = "InvalidStateError"; |
| +const char kNotFoundError[] = "NotFoundError"; |
| +const char kNotReadableErr[] = "NotReadableErr"; |
| +const char kNoModificationAllowedError[] = "NoModificationAllowedError"; |
| +const char kPathExistsError[] = "PathExistsError"; |
| +const char kQuotaExceededError[] = "QuotaExceededError"; |
| +const char kSecurityError[] = "SecurityError"; |
| +const char kTypeMismatchError[] = "TypeMismatchError"; |
| + |
| +// Creates a dictionary, which looks like a DOMError. The returned dictionary |
| +// will be converted to a real DOMError object in |
| +// file_system_provier_custom_bindings.js. |
| +base::DictionaryValue* CreateError(const std::string& name, |
| + const std::string& message) { |
| + base::DictionaryValue* error = new base::DictionaryValue(); |
| + error->SetString("name", name); |
| + error->SetString("message", message); |
| + return error; |
| +} |
| + |
| +} // namespace |
| + |
| +bool FileSystemProviderMountFunction::RunImpl() { |
| + using extensions::api::file_system_provider::Mount::Params; |
| + const scoped_ptr<Params> params(Params::Create(*args_)); |
| + EXTENSION_FUNCTION_VALIDATE(params); |
| + |
| + // It's an error if the display name is empty. |
| + if (params->display_name.empty()) { |
| + const std::string file_system_id = ""; |
| + |
| + base::ListValue* result = new base::ListValue(); |
| + result->Append(new base::StringValue(file_system_id)); |
| + result->Append(CreateError(kSecurityError, |
| + "Empty display name is not allowed")); |
| + SetResult(result); |
| + SendResponse(true); |
| + return true; |
| + } |
| + |
| + // TODO(satorux): Implement the real logic. |
| + const std::string file_system_id = params->display_name; |
| + |
| + base::ListValue* result = new base::ListValue(); |
| + result->Append(new base::StringValue(file_system_id)); |
| + // Don't append an error on success. |
| + |
| + SetResult(result); |
| + SendResponse(true); |
| + return true; |
| +} |
| + |
| +} // namespace extensions |