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.
5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h"
7 #include "chrome/common/extensions/api/file_system_provider.h"
14 // http://www.w3.org/TR/file-system-api/#errors-and-exceptions
15 const char kSecurityErrorName
[] = "SecurityError";
18 const char kEmptyNameErrorMessage
[] = "Empty display name is not allowed";
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
);
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
);
38 // It's an error if the display name is empty.
39 if (params
->display_name
.empty()) {
40 const std::string file_system_id
= "";
42 base::ListValue
* result
= new base::ListValue();
43 result
->Append(new base::StringValue(file_system_id
));
44 result
->Append(CreateError(kSecurityErrorName
,
45 kEmptyNameErrorMessage
));
51 // TODO(satorux): Implement the real logic.
52 const std::string file_system_id
= params
->display_name
;
54 base::ListValue
* result
= new base::ListValue();
55 result
->Append(new base::StringValue(file_system_id
));
56 // Don't append an error on success.
63 } // namespace extensions