Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / file_system_provider / file_system_provider_api.cc
blob0d9fc0dd5d06f3c22357c0fa5b50f9d9bbd1d1e1
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"
9 namespace extensions {
11 namespace {
13 // Error names from
14 // http://www.w3.org/TR/file-system-api/#errors-and-exceptions
15 const char kSecurityErrorName[] = "SecurityError";
17 // Error messages.
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);
28 return error;
31 } // namespace
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));
46 SetResult(result);
47 SendResponse(true);
48 return true;
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.
58 SetResult(result);
59 SendResponse(true);
60 return true;
63 } // namespace extensions