| 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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 FileErrorToProviderError(error)); | 119 FileErrorToProviderError(error)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 FileSystemProviderInternalFunction::FileSystemProviderInternalFunction() | 122 FileSystemProviderInternalFunction::FileSystemProviderInternalFunction() |
| 123 : request_id_(0), request_manager_(NULL) { | 123 : request_id_(0), request_manager_(NULL) { |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool FileSystemProviderInternalFunction::RejectRequest( | 126 bool FileSystemProviderInternalFunction::RejectRequest( |
| 127 scoped_ptr<chromeos::file_system_provider::RequestValue> value, | 127 scoped_ptr<chromeos::file_system_provider::RequestValue> value, |
| 128 base::File::Error error) { | 128 base::File::Error error) { |
| 129 if (!request_manager_->RejectRequest(request_id_, value.Pass(), error)) { | 129 const base::File::Error result = |
| 130 SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY)); | 130 request_manager_->RejectRequest(request_id_, value.Pass(), error); |
| 131 SendResponse(false); | 131 if (result != base::File::FILE_OK) { |
| 132 SetError(FileErrorToString(result)); |
| 132 return false; | 133 return false; |
| 133 } | 134 } |
| 134 | 135 |
| 135 return true; | 136 return true; |
| 136 } | 137 } |
| 137 | 138 |
| 138 bool FileSystemProviderInternalFunction::FulfillRequest( | 139 bool FileSystemProviderInternalFunction::FulfillRequest( |
| 139 scoped_ptr<RequestValue> value, | 140 scoped_ptr<RequestValue> value, |
| 140 bool has_more) { | 141 bool has_more) { |
| 141 if (!request_manager_->FulfillRequest(request_id_, value.Pass(), has_more)) { | 142 const base::File::Error result = |
| 142 SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY)); | 143 request_manager_->FulfillRequest(request_id_, value.Pass(), has_more); |
| 143 SendResponse(false); | 144 if (result != base::File::FILE_OK) { |
| 145 SetError(FileErrorToString(result)); |
| 144 return false; | 146 return false; |
| 145 } | 147 } |
| 146 | 148 |
| 147 return true; | 149 return true; |
| 148 } | 150 } |
| 149 | 151 |
| 150 bool FileSystemProviderInternalFunction::RunSync() { | 152 bool FileSystemProviderInternalFunction::RunSync() { |
| 151 DCHECK(args_); | 153 DCHECK(args_); |
| 152 if (!Parse()) | 154 if (!Parse()) |
| 153 return true; | 155 return false; |
| 154 | 156 |
| 155 SendResponse(RunWhenValid()); | 157 return RunWhenValid(); |
| 156 return true; | |
| 157 } | 158 } |
| 158 | 159 |
| 159 bool FileSystemProviderInternalFunction::Parse() { | 160 bool FileSystemProviderInternalFunction::Parse() { |
| 160 std::string file_system_id; | 161 std::string file_system_id; |
| 161 | 162 |
| 162 if (!args_->GetString(0, &file_system_id) || | 163 if (!args_->GetString(0, &file_system_id) || |
| 163 !args_->GetInteger(1, &request_id_)) { | 164 !args_->GetInteger(1, &request_id_)) { |
| 164 bad_message_ = true; | 165 bad_message_ = true; |
| 165 SendResponse(false); | |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 | 168 |
| 169 Service* service = Service::Get(GetProfile()); | 169 Service* service = Service::Get(GetProfile()); |
| 170 if (!service) { | 170 if (!service) { |
| 171 SendResponse(false); | |
| 172 return false; | 171 return false; |
| 173 } | 172 } |
| 174 | 173 |
| 175 ProvidedFileSystemInterface* file_system = | 174 ProvidedFileSystemInterface* file_system = |
| 176 service->GetProvidedFileSystem(extension_id(), file_system_id); | 175 service->GetProvidedFileSystem(extension_id(), file_system_id); |
| 177 if (!file_system) { | 176 if (!file_system) { |
| 178 SetError(FileErrorToString(base::File::FILE_ERROR_NOT_FOUND)); | 177 SetError(FileErrorToString(base::File::FILE_ERROR_NOT_FOUND)); |
| 179 SendResponse(false); | |
| 180 return false; | 178 return false; |
| 181 } | 179 } |
| 182 | 180 |
| 183 request_manager_ = file_system->GetRequestManager(); | 181 request_manager_ = file_system->GetRequestManager(); |
| 184 return true; | 182 return true; |
| 185 } | 183 } |
| 186 | 184 |
| 187 } // namespace extensions | 185 } // namespace extensions |
| OLD | NEW |