| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_pr
ovider_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_pr
ovider_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 7 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
| 8 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 8 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 9 #include "chrome/browser/chromeos/file_system_provider/request_value.h" | 9 #include "chrome/browser/chromeos/file_system_provider/request_value.h" |
| 10 #include "chrome/browser/chromeos/file_system_provider/service.h" | 10 #include "chrome/browser/chromeos/file_system_provider/service.h" |
| 11 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 11 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| 12 | 12 |
| 13 using chromeos::file_system_provider::ProvidedFileSystemInterface; | 13 using chromeos::file_system_provider::ProvidedFileSystemInterface; |
| 14 using chromeos::file_system_provider::RequestManager; | 14 using chromeos::file_system_provider::RequestManager; |
| 15 using chromeos::file_system_provider::RequestValue; | 15 using chromeos::file_system_provider::RequestValue; |
| 16 using chromeos::file_system_provider::Service; | 16 using chromeos::file_system_provider::Service; |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 const char kNotFoundErrorName[] = "NotFoundError"; | 20 const char kNotFoundErrorName[] = "NotFoundError"; |
| 21 const char kSecurityErrorName[] = "SecurityError"; | 21 const char kSecurityErrorName[] = "SecurityError"; |
| 22 | 22 |
| 23 const char kEmptyNameErrorMessage[] = "Empty display name is not allowed."; | 23 const char kEmptyNameErrorMessage[] = "Empty display name is not allowed."; |
| 24 const char kEmptyIdErrorMessage[] = "Empty file system Id s not allowed."; |
| 24 const char kMountFailedErrorMessage[] = "Mounting the file system failed."; | 25 const char kMountFailedErrorMessage[] = "Mounting the file system failed."; |
| 25 const char kUnmountFailedErrorMessage[] = "Unmounting the file system failed."; | 26 const char kUnmountFailedErrorMessage[] = "Unmounting the file system failed."; |
| 26 const char kResponseFailedErrorMessage[] = | 27 const char kResponseFailedErrorMessage[] = |
| 27 "Sending a response for the request failed."; | 28 "Sending a response for the request failed."; |
| 28 | 29 |
| 29 base::DictionaryValue* CreateError(const std::string& name, | 30 base::DictionaryValue* CreateError(const std::string& name, |
| 30 const std::string& message) { | 31 const std::string& message) { |
| 31 base::DictionaryValue* error = new base::DictionaryValue(); | 32 base::DictionaryValue* error = new base::DictionaryValue(); |
| 32 error->SetString("name", name); | 33 error->SetString("name", name); |
| 33 error->SetString("message", message); | 34 error->SetString("message", message); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool FileSystemProviderInternalFunction::RunSync() { | 98 bool FileSystemProviderInternalFunction::RunSync() { |
| 98 DCHECK(args_); | 99 DCHECK(args_); |
| 99 if (!Parse()) | 100 if (!Parse()) |
| 100 return true; | 101 return true; |
| 101 | 102 |
| 102 SendResponse(RunWhenValid()); | 103 SendResponse(RunWhenValid()); |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 bool FileSystemProviderInternalFunction::Parse() { | 107 bool FileSystemProviderInternalFunction::Parse() { |
| 107 int file_system_id = 0; | 108 std::string file_system_id; |
| 108 | 109 |
| 109 if (!args_->GetInteger(0, &file_system_id) || | 110 if (!args_->GetString(0, &file_system_id) || |
| 110 !args_->GetInteger(1, &request_id_)) { | 111 !args_->GetInteger(1, &request_id_)) { |
| 111 bad_message_ = true; | 112 bad_message_ = true; |
| 112 SendResponse(false); | 113 SendResponse(false); |
| 113 return false; | 114 return false; |
| 114 } | 115 } |
| 115 | 116 |
| 116 Service* service = Service::Get(GetProfile()); | 117 Service* service = Service::Get(GetProfile()); |
| 117 if (!service) { | 118 if (!service) { |
| 118 SendResponse(false); | 119 SendResponse(false); |
| 119 return false; | 120 return false; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 133 | 134 |
| 134 void FileSystemProviderInternalFunction::SetErrorResponse( | 135 void FileSystemProviderInternalFunction::SetErrorResponse( |
| 135 const std::string& name, | 136 const std::string& name, |
| 136 const std::string& message) { | 137 const std::string& message) { |
| 137 base::ListValue* result = new base::ListValue(); | 138 base::ListValue* result = new base::ListValue(); |
| 138 result->Append(CreateError(name, message)); | 139 result->Append(CreateError(name, message)); |
| 139 SetResult(result); | 140 SetResult(result); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace extensions | 143 } // namespace extensions |
| OLD | NEW |