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/open_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.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 file_path_(file_path), | 23 file_path_(file_path), |
24 mode_(mode), | 24 mode_(mode), |
25 callback_(callback) { | 25 callback_(callback) { |
26 } | 26 } |
27 | 27 |
28 OpenFile::~OpenFile() { | 28 OpenFile::~OpenFile() { |
29 } | 29 } |
30 | 30 |
31 bool OpenFile::Execute(int request_id) { | 31 bool OpenFile::Execute(int request_id) { |
| 32 if (!file_system_info_.writable() && |
| 33 mode_ == ProvidedFileSystemInterface::OPEN_FILE_MODE_WRITE) { |
| 34 return false; |
| 35 } |
| 36 |
32 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 37 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); |
33 values->SetString("filePath", file_path_.AsUTF8Unsafe()); | 38 values->SetString("filePath", file_path_.AsUTF8Unsafe()); |
34 | 39 |
35 switch (mode_) { | 40 switch (mode_) { |
36 case ProvidedFileSystemInterface::OPEN_FILE_MODE_READ: | 41 case ProvidedFileSystemInterface::OPEN_FILE_MODE_READ: |
37 values->SetString( | 42 values->SetString( |
38 "mode", | 43 "mode", |
39 extensions::api::file_system_provider::ToString( | 44 extensions::api::file_system_provider::ToString( |
40 extensions::api::file_system_provider::OPEN_FILE_MODE_READ)); | 45 extensions::api::file_system_provider::OPEN_FILE_MODE_READ)); |
41 break; | 46 break; |
(...skipping 20 matching lines...) Expand all Loading... |
62 | 67 |
63 void OpenFile::OnError(int /* request_id */, | 68 void OpenFile::OnError(int /* request_id */, |
64 scoped_ptr<RequestValue> /* result */, | 69 scoped_ptr<RequestValue> /* result */, |
65 base::File::Error error) { | 70 base::File::Error error) { |
66 callback_.Run(0 /* file_handle */, error); | 71 callback_.Run(0 /* file_handle */, error); |
67 } | 72 } |
68 | 73 |
69 } // namespace operations | 74 } // namespace operations |
70 } // namespace file_system_provider | 75 } // namespace file_system_provider |
71 } // namespace chromeos | 76 } // namespace chromeos |
OLD | NEW |