OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/file_utilities_message_filter.h" | 5 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "content/browser/child_process_security_policy_impl.h" | 8 #include "content/browser/child_process_security_policy_impl.h" |
9 #include "content/common/file_utilities_messages.h" | 9 #include "content/common/file_utilities_messages.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 bool handled = true; | 29 bool handled = true; |
30 IPC_BEGIN_MESSAGE_MAP_EX(FileUtilitiesMessageFilter, message, *message_was_ok) | 30 IPC_BEGIN_MESSAGE_MAP_EX(FileUtilitiesMessageFilter, message, *message_was_ok) |
31 IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileInfo, OnGetFileInfo) | 31 IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileInfo, OnGetFileInfo) |
32 IPC_MESSAGE_UNHANDLED(handled = false) | 32 IPC_MESSAGE_UNHANDLED(handled = false) |
33 IPC_END_MESSAGE_MAP() | 33 IPC_END_MESSAGE_MAP() |
34 return handled; | 34 return handled; |
35 } | 35 } |
36 | 36 |
37 void FileUtilitiesMessageFilter::OnGetFileInfo( | 37 void FileUtilitiesMessageFilter::OnGetFileInfo( |
38 const base::FilePath& path, | 38 const base::FilePath& path, |
39 base::PlatformFileInfo* result, | 39 base::File::Info* result, |
40 base::PlatformFileError* status) { | 40 base::File::Error* status) { |
41 *result = base::PlatformFileInfo(); | 41 *result = base::File::Info(); |
42 *status = base::PLATFORM_FILE_OK; | 42 *status = base::File::FILE_OK; |
43 | 43 |
44 // Get file metadata only when the child process has been granted | 44 // Get file metadata only when the child process has been granted |
45 // permission to read the file. | 45 // permission to read the file. |
46 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | 46 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
47 process_id_, path)) { | 47 process_id_, path)) { |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 // TODO(rvargas): convert this code to use base::File. | 51 if (!base::GetFileInfo(path, result)) |
52 if (!base::GetFileInfo(path, reinterpret_cast<base::File::Info*>(result))) | 52 *status = base::File::FILE_ERROR_FAILED; |
53 *status = base::PLATFORM_FILE_ERROR_FAILED; | |
54 } | 53 } |
55 | 54 |
56 } // namespace content | 55 } // namespace content |
OLD | NEW |