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/provided_file_system_inte
rface.h" | 10 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 case api::file_system_provider::PROVIDER_ERROR_IO: | 83 case api::file_system_provider::PROVIDER_ERROR_IO: |
84 return base::File::FILE_ERROR_IO; | 84 return base::File::FILE_ERROR_IO; |
85 default: | 85 default: |
86 NOTREACHED(); | 86 NOTREACHED(); |
87 } | 87 } |
88 return base::File::FILE_ERROR_FAILED; | 88 return base::File::FILE_ERROR_FAILED; |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 bool FileSystemProviderMountFunction::RunImpl() { | 93 bool FileSystemProviderMountFunction::RunSync() { |
94 using api::file_system_provider::Mount::Params; | 94 using api::file_system_provider::Mount::Params; |
95 const scoped_ptr<Params> params(Params::Create(*args_)); | 95 const scoped_ptr<Params> params(Params::Create(*args_)); |
96 EXTENSION_FUNCTION_VALIDATE(params); | 96 EXTENSION_FUNCTION_VALIDATE(params); |
97 | 97 |
98 // It's an error if the display name is empty. | 98 // It's an error if the display name is empty. |
99 if (params->display_name.empty()) { | 99 if (params->display_name.empty()) { |
100 base::ListValue* result = new base::ListValue(); | 100 base::ListValue* result = new base::ListValue(); |
101 result->Append(new base::StringValue("")); | 101 result->Append(new base::StringValue("")); |
102 result->Append(CreateError(kSecurityErrorName, | 102 result->Append(CreateError(kSecurityErrorName, |
103 kEmptyNameErrorMessage)); | 103 kEmptyNameErrorMessage)); |
(...skipping 19 matching lines...) Expand all Loading... |
123 } | 123 } |
124 | 124 |
125 base::ListValue* result = new base::ListValue(); | 125 base::ListValue* result = new base::ListValue(); |
126 result->Append(new base::FundamentalValue(file_system_id)); | 126 result->Append(new base::FundamentalValue(file_system_id)); |
127 // Don't append an error on success. | 127 // Don't append an error on success. |
128 | 128 |
129 SetResult(result); | 129 SetResult(result); |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 bool FileSystemProviderUnmountFunction::RunImpl() { | 133 bool FileSystemProviderUnmountFunction::RunSync() { |
134 using api::file_system_provider::Unmount::Params; | 134 using api::file_system_provider::Unmount::Params; |
135 const scoped_ptr<Params> params(Params::Create(*args_)); | 135 const scoped_ptr<Params> params(Params::Create(*args_)); |
136 EXTENSION_FUNCTION_VALIDATE(params); | 136 EXTENSION_FUNCTION_VALIDATE(params); |
137 | 137 |
138 Service* service = Service::Get(GetProfile()); | 138 Service* service = Service::Get(GetProfile()); |
139 DCHECK(service); | 139 DCHECK(service); |
140 | 140 |
141 if (!service->UnmountFileSystem(extension_id(), params->file_system_id)) { | 141 if (!service->UnmountFileSystem(extension_id(), params->file_system_id)) { |
142 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. | 142 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. |
143 base::ListValue* result = new base::ListValue(); | 143 base::ListValue* result = new base::ListValue(); |
144 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage)); | 144 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage)); |
145 SetResult(result); | 145 SetResult(result); |
146 return false; | 146 return false; |
147 } | 147 } |
148 | 148 |
149 base::ListValue* result = new base::ListValue(); | 149 base::ListValue* result = new base::ListValue(); |
150 SetResult(result); | 150 SetResult(result); |
151 return true; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunImpl() { | 154 bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunSync() { |
155 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; | 155 using api::file_system_provider_internal::UnmountRequestedSuccess::Params; |
156 scoped_ptr<Params> params(Params::Create(*args_)); | 156 scoped_ptr<Params> params(Params::Create(*args_)); |
157 EXTENSION_FUNCTION_VALIDATE(params); | 157 EXTENSION_FUNCTION_VALIDATE(params); |
158 | 158 |
159 Service* service = Service::Get(GetProfile()); | 159 Service* service = Service::Get(GetProfile()); |
160 DCHECK(service); | 160 DCHECK(service); |
161 | 161 |
162 ProvidedFileSystemInterface* file_system = | 162 ProvidedFileSystemInterface* file_system = |
163 service->GetProvidedFileSystem(extension_id(), params->file_system_id); | 163 service->GetProvidedFileSystem(extension_id(), params->file_system_id); |
164 if (!file_system) { | 164 if (!file_system) { |
(...skipping 18 matching lines...) Expand all Loading... |
183 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); | 183 CreateError(kSecurityErrorName, kResponseFailedErrorMessage)); |
184 SetResult(result); | 184 SetResult(result); |
185 return false; | 185 return false; |
186 } | 186 } |
187 | 187 |
188 base::ListValue* result = new base::ListValue(); | 188 base::ListValue* result = new base::ListValue(); |
189 SetResult(result); | 189 SetResult(result); |
190 return true; | 190 return true; |
191 } | 191 } |
192 | 192 |
193 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunImpl() { | 193 bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunSync() { |
194 using api::file_system_provider_internal::UnmountRequestedError::Params; | 194 using api::file_system_provider_internal::UnmountRequestedError::Params; |
195 const scoped_ptr<Params> params(Params::Create(*args_)); | 195 const scoped_ptr<Params> params(Params::Create(*args_)); |
196 EXTENSION_FUNCTION_VALIDATE(params); | 196 EXTENSION_FUNCTION_VALIDATE(params); |
197 | 197 |
198 Service* service = Service::Get(GetProfile()); | 198 Service* service = Service::Get(GetProfile()); |
199 DCHECK(service); | 199 DCHECK(service); |
200 | 200 |
201 ProvidedFileSystemInterface* file_system = | 201 ProvidedFileSystemInterface* file_system = |
202 service->GetProvidedFileSystem(extension_id(), params->file_system_id); | 202 service->GetProvidedFileSystem(extension_id(), params->file_system_id); |
203 if (!file_system) { | 203 if (!file_system) { |
(...skipping 16 matching lines...) Expand all Loading... |
220 SetResult(result); | 220 SetResult(result); |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 base::ListValue* result = new base::ListValue(); | 224 base::ListValue* result = new base::ListValue(); |
225 SetResult(result); | 225 SetResult(result); |
226 return true; | 226 return true; |
227 } | 227 } |
228 | 228 |
229 } // namespace extensions | 229 } // namespace extensions |
OLD | NEW |