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/get_metadata.h " | 5 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.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 15 matching lines...) Expand all Loading... | |
26 return false; | 26 return false; |
27 | 27 |
28 output->name = params->metadata.name; | 28 output->name = params->metadata.name; |
29 output->is_directory = params->metadata.is_directory; | 29 output->is_directory = params->metadata.is_directory; |
30 output->size = static_cast<int64>(params->metadata.size); | 30 output->size = static_cast<int64>(params->metadata.size); |
31 | 31 |
32 if (params->metadata.mime_type.get()) | 32 if (params->metadata.mime_type.get()) |
33 output->mime_type = *params->metadata.mime_type.get(); | 33 output->mime_type = *params->metadata.mime_type.get(); |
34 | 34 |
35 std::string input_modification_time; | 35 std::string input_modification_time; |
36 if (!params->metadata.modification_time.additional_properties.GetString( | 36 if (!params->metadata.modification_time.additional_properties.GetString( |
hirono
2014/08/27 09:20:07
Should update thumbnail here?
mtomasz
2014/08/28 04:57:55
Oops. Fortunately the tests would catch it.
| |
37 "value", &input_modification_time)) { | 37 "value", &input_modification_time)) { |
38 return false; | 38 return false; |
39 } | 39 } |
40 | 40 |
41 // Allow to pass invalid modification time, since there is no way to verify | 41 // Allow to pass invalid modification time, since there is no way to verify |
42 // it easily on any earlier stage. | 42 // it easily on any earlier stage. |
43 base::Time::FromString(input_modification_time.c_str(), | 43 base::Time::FromString(input_modification_time.c_str(), |
44 &output->modification_time); | 44 &output->modification_time); |
45 | 45 |
46 return true; | 46 return true; |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 GetMetadata::GetMetadata( | 51 GetMetadata::GetMetadata( |
52 extensions::EventRouter* event_router, | 52 extensions::EventRouter* event_router, |
53 const ProvidedFileSystemInfo& file_system_info, | 53 const ProvidedFileSystemInfo& file_system_info, |
54 const base::FilePath& entry_path, | 54 const base::FilePath& entry_path, |
55 ProvidedFileSystemInterface::MetadataFieldMask fields, | |
55 const ProvidedFileSystemInterface::GetMetadataCallback& callback) | 56 const ProvidedFileSystemInterface::GetMetadataCallback& callback) |
56 : Operation(event_router, file_system_info), | 57 : Operation(event_router, file_system_info), |
57 entry_path_(entry_path), | 58 entry_path_(entry_path), |
59 fields_(fields), | |
58 callback_(callback) { | 60 callback_(callback) { |
59 } | 61 } |
60 | 62 |
61 GetMetadata::~GetMetadata() { | 63 GetMetadata::~GetMetadata() { |
62 } | 64 } |
63 | 65 |
64 bool GetMetadata::Execute(int request_id) { | 66 bool GetMetadata::Execute(int request_id) { |
65 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 67 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); |
66 values->SetString("entryPath", entry_path_.AsUTF8Unsafe()); | 68 values->SetString("entryPath", entry_path_.AsUTF8Unsafe()); |
69 values->SetBoolean( | |
70 "thumbnail", | |
71 (fields_ & ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL) != 0); | |
72 | |
67 return SendEvent( | 73 return SendEvent( |
68 request_id, | 74 request_id, |
69 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, | 75 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, |
70 values.Pass()); | 76 values.Pass()); |
71 } | 77 } |
72 | 78 |
73 void GetMetadata::OnSuccess(int /* request_id */, | 79 void GetMetadata::OnSuccess(int /* request_id */, |
74 scoped_ptr<RequestValue> result, | 80 scoped_ptr<RequestValue> result, |
75 bool has_more) { | 81 bool has_more) { |
76 EntryMetadata metadata; | 82 EntryMetadata metadata; |
(...skipping 11 matching lines...) Expand all Loading... | |
88 | 94 |
89 void GetMetadata::OnError(int /* request_id */, | 95 void GetMetadata::OnError(int /* request_id */, |
90 scoped_ptr<RequestValue> /* result */, | 96 scoped_ptr<RequestValue> /* result */, |
91 base::File::Error error) { | 97 base::File::Error error) { |
92 callback_.Run(EntryMetadata(), error); | 98 callback_.Run(EntryMetadata(), error); |
93 } | 99 } |
94 | 100 |
95 } // namespace operations | 101 } // namespace operations |
96 } // namespace file_system_provider | 102 } // namespace file_system_provider |
97 } // namespace chromeos | 103 } // namespace chromeos |
OLD | NEW |