OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/api/file_system_provider/file_system_provide
r_api.h" |
| 6 |
| 7 #include "chrome/common/extensions/api/file_system_provider.h" |
| 8 |
| 9 namespace extensions { |
| 10 |
| 11 namespace { |
| 12 |
| 13 const char kOK[] = "OK"; |
| 14 |
| 15 // Names come from http://www.w3.org/TR/file-system-api/#errors-and-exceptions |
| 16 const char kEncodingError[] = "EncodingError"; |
| 17 const char kInvalidModificationError[] = "InvalidModificationError"; |
| 18 const char kInvalidStateError[] = "InvalidStateError"; |
| 19 const char kNotFoundError[] = "NotFoundError"; |
| 20 const char kNotReadableErr[] = "NotReadableErr"; |
| 21 const char kNoModificationAllowedError[] = "NoModificationAllowedError"; |
| 22 const char kPathExistsError[] = "PathExistsError"; |
| 23 const char kQuotaExceededError[] = "QuotaExceededError"; |
| 24 const char kSecurityError[] = "SecurityError"; |
| 25 const char kTypeMismatchError[] = "TypeMismatchError"; |
| 26 |
| 27 // Creates a dictionary, which looks like a DOMError. The returned dictionary |
| 28 // will be converted to a real DOMError object in |
| 29 // file_system_provier_custom_bindings.js. |
| 30 base::DictionaryValue* CreateError(const std::string& name, |
| 31 const std::string& message) { |
| 32 base::DictionaryValue* error = new base::DictionaryValue(); |
| 33 error->SetString("name", name); |
| 34 error->SetString("message", message); |
| 35 return error; |
| 36 } |
| 37 |
| 38 } // namespace |
| 39 |
| 40 bool FileSystemProviderMountFunction::RunImpl() { |
| 41 using extensions::api::file_system_provider::Mount::Params; |
| 42 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 43 EXTENSION_FUNCTION_VALIDATE(params); |
| 44 |
| 45 // It's an error if the display name is empty. |
| 46 if (params->display_name.empty()) { |
| 47 const std::string file_system_id = ""; |
| 48 |
| 49 base::ListValue* result = new base::ListValue(); |
| 50 result->Append(new base::StringValue(file_system_id)); |
| 51 result->Append(CreateError(kSecurityError, |
| 52 "Empty display name is not allowed")); |
| 53 SetResult(result); |
| 54 SendResponse(true); |
| 55 return true; |
| 56 } |
| 57 |
| 58 // TODO(satorux): Implement the real logic. |
| 59 const std::string file_system_id = params->display_name; |
| 60 |
| 61 base::ListValue* result = new base::ListValue(); |
| 62 result->Append(new base::StringValue(file_system_id)); |
| 63 // Don't append an error on success. |
| 64 |
| 65 SetResult(result); |
| 66 SendResponse(true); |
| 67 return true; |
| 68 } |
| 69 |
| 70 } // namespace extensions |
OLD | NEW |