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/chromeos/extensions/file_system_provider/file_system_pr
ovider_api.h" |
| 6 |
| 7 #include "chrome/common/extensions/api/file_system_provider.h" |
| 8 |
| 9 namespace extensions { |
| 10 |
| 11 namespace { |
| 12 |
| 13 // Error names from |
| 14 // http://www.w3.org/TR/file-system-api/#errors-and-exceptions |
| 15 const char kSecurityErrorName[] = "SecurityError"; |
| 16 |
| 17 // Error messages. |
| 18 const char kEmptyNameErrorMessage[] = "Empty display name is not allowed"; |
| 19 |
| 20 // Creates a dictionary, which looks like a DOMError. The returned dictionary |
| 21 // will be converted to a real DOMError object in |
| 22 // file_system_provier_custom_bindings.js. |
| 23 base::DictionaryValue* CreateError(const std::string& name, |
| 24 const std::string& message) { |
| 25 base::DictionaryValue* error = new base::DictionaryValue(); |
| 26 error->SetString("name", name); |
| 27 error->SetString("message", message); |
| 28 return error; |
| 29 } |
| 30 |
| 31 } // namespace |
| 32 |
| 33 bool FileSystemProviderMountFunction::RunImpl() { |
| 34 using extensions::api::file_system_provider::Mount::Params; |
| 35 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 36 EXTENSION_FUNCTION_VALIDATE(params); |
| 37 |
| 38 // It's an error if the display name is empty. |
| 39 if (params->display_name.empty()) { |
| 40 const std::string file_system_id = ""; |
| 41 |
| 42 base::ListValue* result = new base::ListValue(); |
| 43 result->Append(new base::StringValue(file_system_id)); |
| 44 result->Append(CreateError(kSecurityErrorName, |
| 45 kEmptyNameErrorMessage)); |
| 46 SetResult(result); |
| 47 SendResponse(true); |
| 48 return true; |
| 49 } |
| 50 |
| 51 // TODO(satorux): Implement the real logic. |
| 52 const std::string file_system_id = params->display_name; |
| 53 |
| 54 base::ListValue* result = new base::ListValue(); |
| 55 result->Append(new base::StringValue(file_system_id)); |
| 56 // Don't append an error on success. |
| 57 |
| 58 SetResult(result); |
| 59 SendResponse(true); |
| 60 return true; |
| 61 } |
| 62 |
| 63 } // namespace extensions |
OLD | NEW |