| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage)); | 112 result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage)); |
| 113 SetResult(result); | 113 SetResult(result); |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 base::ListValue* result = new base::ListValue(); | 117 base::ListValue* result = new base::ListValue(); |
| 118 result->Append(new base::FundamentalValue(file_system_id)); | 118 result->Append(new base::FundamentalValue(file_system_id)); |
| 119 // Don't append an error on success. | 119 // Don't append an error on success. |
| 120 | 120 |
| 121 SetResult(result); | 121 SetResult(result); |
| 122 SendResponse(true); | |
| 123 return true; | 122 return true; |
| 124 } | 123 } |
| 125 | 124 |
| 126 bool FileSystemProviderUnmountFunction::RunImpl() { | 125 bool FileSystemProviderUnmountFunction::RunImpl() { |
| 127 using api::file_system_provider::Unmount::Params; | 126 using api::file_system_provider::Unmount::Params; |
| 128 const scoped_ptr<Params> params(Params::Create(*args_)); | 127 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 129 EXTENSION_FUNCTION_VALIDATE(params); | 128 EXTENSION_FUNCTION_VALIDATE(params); |
| 130 | 129 |
| 131 chromeos::file_system_provider::Service* service = | 130 chromeos::file_system_provider::Service* service = |
| 132 chromeos::file_system_provider::Service::Get(GetProfile()); | 131 chromeos::file_system_provider::Service::Get(GetProfile()); |
| 133 DCHECK(service); | 132 DCHECK(service); |
| 134 | 133 |
| 135 if (!service->UnmountFileSystem(extension_id(), params->file_system_id)) { | 134 if (!service->UnmountFileSystem(extension_id(), params->file_system_id)) { |
| 136 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 135 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
| 137 base::ListValue* result = new base::ListValue(); | 136 base::ListValue* result = new base::ListValue(); |
| 138 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage)); | 137 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage)); |
| 139 SetResult(result); | 138 SetResult(result); |
| 140 return false; | 139 return false; |
| 141 } | 140 } |
| 142 | 141 |
| 143 base::ListValue* result = new base::ListValue(); | 142 base::ListValue* result = new base::ListValue(); |
| 144 SetResult(result); | 143 SetResult(result); |
| 145 SendResponse(true); | |
| 146 return true; | 144 return true; |
| 147 } | 145 } |
| 148 | 146 |
| 149 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunImpl() { | 147 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunImpl() { |
| 150 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; | 148 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; |
| 151 const scoped_ptr<Params> params(Params::Create(*args_)); | 149 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 152 EXTENSION_FUNCTION_VALIDATE(params); | 150 EXTENSION_FUNCTION_VALIDATE(params); |
| 153 | 151 |
| 154 chromeos::file_system_provider::Service* service = | 152 chromeos::file_system_provider::Service* service = |
| 155 chromeos::file_system_provider::Service::Get(GetProfile()); | 153 chromeos::file_system_provider::Service::Get(GetProfile()); |
| 156 DCHECK(service); | 154 DCHECK(service); |
| 157 | 155 |
| 158 if (!service->FulfillRequest(extension_id(), | 156 if (!service->request_manager()->FulfillRequest( |
| 159 params->file_system_id, | 157 extension_id(), |
| 160 params->request_id, | 158 params->file_system_id, |
| 161 scoped_ptr<base::DictionaryValue>(), | 159 params->request_id, |
| 162 false /* has_more */)) { | 160 scoped_ptr<base::DictionaryValue>(), |
| 161 false /* has_more */)) { |
| 163 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 162 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
| 164 base::ListValue* result = new base::ListValue(); | 163 base::ListValue* result = new base::ListValue(); |
| 165 result->Append( | 164 result->Append( |
| 166 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); | 165 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); |
| 167 SetResult(result); | 166 SetResult(result); |
| 168 return false; | 167 return false; |
| 169 } | 168 } |
| 170 | 169 |
| 171 base::ListValue* result = new base::ListValue(); | 170 base::ListValue* result = new base::ListValue(); |
| 172 SetResult(result); | 171 SetResult(result); |
| 173 SendResponse(true); | |
| 174 return true; | 172 return true; |
| 175 } | 173 } |
| 176 | 174 |
| 177 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunImpl() { | 175 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunImpl() { |
| 178 using api::file_system_provider_internal::UnmountRequestedError::Params; | 176 using api::file_system_provider_internal::UnmountRequestedError::Params; |
| 179 const scoped_ptr<Params> params(Params::Create(*args_)); | 177 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 180 EXTENSION_FUNCTION_VALIDATE(params); | 178 EXTENSION_FUNCTION_VALIDATE(params); |
| 181 | 179 |
| 182 chromeos::file_system_provider::Service* service = | 180 chromeos::file_system_provider::Service* service = |
| 183 chromeos::file_system_provider::Service::Get(GetProfile()); | 181 chromeos::file_system_provider::Service::Get(GetProfile()); |
| 184 DCHECK(service); | 182 DCHECK(service); |
| 185 | 183 |
| 186 // Currently it is not possible to refer to types/enums defined in a different | 184 // 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 | 185 // IDL file. Therefore we need to convert DOMString to ProviderError, since |
| 188 // UnmountRequestedErrorFunction() is defined in a different namespace than | 186 // UnmountRequestedErrorFunction() is defined in a different namespace than |
| 189 // ProvidedError. | 187 // ProvidedError. |
| 190 // TODO(mtomasz): Remove this trick, once IDL supports namespaces correctly. | 188 // TODO(mtomasz): Remove this trick, once IDL supports namespaces correctly. |
| 191 const api::file_system_provider::ProviderError provider_error = | 189 const api::file_system_provider::ProviderError provider_error = |
| 192 api::file_system_provider::ParseProviderError(params->error); | 190 api::file_system_provider::ParseProviderError(params->error); |
| 193 | 191 |
| 194 if (!service->RejectRequest(extension_id(), | 192 if (!service->request_manager()->RejectRequest( |
| 195 params->file_system_id, | 193 extension_id(), |
| 196 params->request_id, | 194 params->file_system_id, |
| 197 ProviderErrorToFileError(provider_error))) { | 195 params->request_id, |
| 196 ProviderErrorToFileError(provider_error))) { |
| 198 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 197 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
| 199 base::ListValue* result = new base::ListValue(); | 198 base::ListValue* result = new base::ListValue(); |
| 200 result->Append( | 199 result->Append( |
| 201 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); | 200 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); |
| 202 SetResult(result); | 201 SetResult(result); |
| 203 return false; | 202 return false; |
| 204 } | 203 } |
| 205 | 204 |
| 206 base::ListValue* result = new base::ListValue(); | 205 base::ListValue* result = new base::ListValue(); |
| 207 SetResult(result); | 206 SetResult(result); |
| 208 SendResponse(true); | |
| 209 return true; | 207 return true; |
| 210 } | 208 } |
| 211 | 209 |
| 212 } // namespace extensions | 210 } // namespace extensions |
| OLD | NEW |