| 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/file_system_provider/operations/create_directo
ry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_directo
ry.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/common/extensions/api/file_system_provider.h" | 9 #include "chrome/common/extensions/api/file_system_provider.h" |
| 10 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 10 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 : Operation(event_router, file_system_info), | 22 : Operation(event_router, file_system_info), |
| 23 directory_path_(directory_path), | 23 directory_path_(directory_path), |
| 24 recursive_(recursive), | 24 recursive_(recursive), |
| 25 callback_(callback) { | 25 callback_(callback) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 CreateDirectory::~CreateDirectory() { | 28 CreateDirectory::~CreateDirectory() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool CreateDirectory::Execute(int request_id) { | 31 bool CreateDirectory::Execute(int request_id) { |
| 32 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; |
| 33 |
| 32 if (!file_system_info_.writable()) | 34 if (!file_system_info_.writable()) |
| 33 return false; | 35 return false; |
| 34 | 36 |
| 35 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 37 CreateDirectoryRequestedOptions options; |
| 36 values->SetString("directoryPath", directory_path_.AsUTF8Unsafe()); | 38 options.file_system_id = file_system_info_.file_system_id(); |
| 37 values->SetBoolean("recursive", recursive_); | 39 options.request_id = request_id; |
| 40 options.directory_path = directory_path_.AsUTF8Unsafe(); |
| 41 options.recursive = recursive_; |
| 38 | 42 |
| 39 return SendEvent(request_id, | 43 return SendEvent( |
| 40 extensions::api::file_system_provider:: | 44 request_id, |
| 41 OnCreateDirectoryRequested::kEventName, | 45 extensions::api::file_system_provider::OnCreateDirectoryRequested:: |
| 42 values.Pass()); | 46 kEventName, |
| 47 extensions::api::file_system_provider::OnCreateDirectoryRequested::Create( |
| 48 options)); |
| 43 } | 49 } |
| 44 | 50 |
| 45 void CreateDirectory::OnSuccess(int /* request_id */, | 51 void CreateDirectory::OnSuccess(int /* request_id */, |
| 46 scoped_ptr<RequestValue> /* result */, | 52 scoped_ptr<RequestValue> /* result */, |
| 47 bool has_more) { | 53 bool has_more) { |
| 48 callback_.Run(base::File::FILE_OK); | 54 callback_.Run(base::File::FILE_OK); |
| 49 } | 55 } |
| 50 | 56 |
| 51 void CreateDirectory::OnError(int /* request_id */, | 57 void CreateDirectory::OnError(int /* request_id */, |
| 52 scoped_ptr<RequestValue> /* result */, | 58 scoped_ptr<RequestValue> /* result */, |
| 53 base::File::Error error) { | 59 base::File::Error error) { |
| 54 callback_.Run(error); | 60 callback_.Run(error); |
| 55 } | 61 } |
| 56 | 62 |
| 57 } // namespace operations | 63 } // namespace operations |
| 58 } // namespace file_system_provider | 64 } // namespace file_system_provider |
| 59 } // namespace chromeos | 65 } // namespace chromeos |
| OLD | NEW |