OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/file_system_provider/service.h" | 10 #include "chrome/browser/chromeos/file_system_provider/service.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 | 148 |
149 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunImpl() { | 149 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunImpl() { |
150 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; | 150 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; |
151 const scoped_ptr<Params> params(Params::Create(*args_)); | 151 const scoped_ptr<Params> params(Params::Create(*args_)); |
152 EXTENSION_FUNCTION_VALIDATE(params); | 152 EXTENSION_FUNCTION_VALIDATE(params); |
153 | 153 |
154 chromeos::file_system_provider::Service* service = | 154 chromeos::file_system_provider::Service* service = |
155 chromeos::file_system_provider::Service::Get(GetProfile()); | 155 chromeos::file_system_provider::Service::Get(GetProfile()); |
156 DCHECK(service); | 156 DCHECK(service); |
157 | 157 |
158 if (!service->FulfillRequest(extension_id(), | 158 if (!service->request_manager()->FulfillRequest( |
159 params->file_system_id, | 159 extension_id(), |
160 params->request_id, | 160 params->file_system_id, |
161 scoped_ptr<base::DictionaryValue>(), | 161 params->request_id, |
162 false /* has_more */)) { | 162 scoped_ptr<base::DictionaryValue>(), |
163 false /* has_more */)) { | |
163 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 164 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
164 base::ListValue* result = new base::ListValue(); | 165 base::ListValue* result = new base::ListValue(); |
165 result->Append( | 166 result->Append( |
166 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); | 167 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); |
167 SetResult(result); | 168 SetResult(result); |
168 return false; | 169 return false; |
169 } | 170 } |
170 | 171 |
171 base::ListValue* result = new base::ListValue(); | 172 base::ListValue* result = new base::ListValue(); |
172 SetResult(result); | 173 SetResult(result); |
173 SendResponse(true); | 174 SendResponse(true); |
hashimoto
2014/03/26 06:53:04
nit: Just returning false isn't enough?
mtomasz
2014/03/26 08:47:31
If we return false, then we would signal an error.
hashimoto
2014/03/26 09:04:26
oops, I was confusing this with a SyncExtensionFun
mtomasz
2014/03/26 10:53:58
Good catch. Converted to SyncExtensionFunctions! D
| |
174 return true; | 175 return true; |
175 } | 176 } |
176 | 177 |
177 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunImpl() { | 178 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunImpl() { |
178 using api::file_system_provider_internal::UnmountRequestedError::Params; | 179 using api::file_system_provider_internal::UnmountRequestedError::Params; |
179 const scoped_ptr<Params> params(Params::Create(*args_)); | 180 const scoped_ptr<Params> params(Params::Create(*args_)); |
180 EXTENSION_FUNCTION_VALIDATE(params); | 181 EXTENSION_FUNCTION_VALIDATE(params); |
181 | 182 |
182 chromeos::file_system_provider::Service* service = | 183 chromeos::file_system_provider::Service* service = |
183 chromeos::file_system_provider::Service::Get(GetProfile()); | 184 chromeos::file_system_provider::Service::Get(GetProfile()); |
184 DCHECK(service); | 185 DCHECK(service); |
185 | 186 |
186 // Currently it is not possible to refer to types/enums defined in a different | 187 // Currently it is not possible to refer to types/enums defined in a different |
187 // IDL file. Therefore we need to convert DOMString to ProviderError, since | 188 // IDL file. Therefore we need to convert DOMString to ProviderError, since |
188 // UnmountRequestedErrorFunction() is defined in a different namespace than | 189 // UnmountRequestedErrorFunction() is defined in a different namespace than |
189 // ProvidedError. | 190 // ProvidedError. |
190 // TODO(mtomasz): Remove this trick, once IDL supports namespaces correctly. | 191 // TODO(mtomasz): Remove this trick, once IDL supports namespaces correctly. |
191 const api::file_system_provider::ProviderError provider_error = | 192 const api::file_system_provider::ProviderError provider_error = |
192 api::file_system_provider::ParseProviderError(params->error); | 193 api::file_system_provider::ParseProviderError(params->error); |
193 | 194 |
194 if (!service->RejectRequest(extension_id(), | 195 if (!service->request_manager()->RejectRequest( |
195 params->file_system_id, | 196 extension_id(), |
196 params->request_id, | 197 params->file_system_id, |
197 ProviderErrorToFileError(provider_error))) { | 198 params->request_id, |
199 ProviderErrorToFileError(provider_error))) { | |
198 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 200 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
199 base::ListValue* result = new base::ListValue(); | 201 base::ListValue* result = new base::ListValue(); |
200 result->Append( | 202 result->Append( |
201 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); | 203 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); |
202 SetResult(result); | 204 SetResult(result); |
203 return false; | 205 return false; |
204 } | 206 } |
205 | 207 |
206 base::ListValue* result = new base::ListValue(); | 208 base::ListValue* result = new base::ListValue(); |
207 SetResult(result); | 209 SetResult(result); |
208 SendResponse(true); | 210 SendResponse(true); |
209 return true; | 211 return true; |
210 } | 212 } |
211 | 213 |
212 } // namespace extensions | 214 } // namespace extensions |
OLD | NEW |