OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/shell/shell_message_filter.h" | 5 #include "content/shell/shell_message_filter.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "content/public/browser/child_process_security_policy.h" | 8 #include "content/public/browser/child_process_security_policy.h" |
9 #include "content/shell/shell_messages.h" | 9 #include "content/shell/shell_messages.h" |
10 #include "webkit/fileapi/isolated_context.h" | 10 #include "webkit/fileapi/isolated_context.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 IPC_BEGIN_MESSAGE_MAP_EX(ShellMessageFilter, message, *message_was_ok) | 24 IPC_BEGIN_MESSAGE_MAP_EX(ShellMessageFilter, message, *message_was_ok) |
25 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ReadFileToString, OnReadFileToString) | 25 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ReadFileToString, OnReadFileToString) |
26 IPC_MESSAGE_HANDLER(ShellViewHostMsg_RegisterIsolatedFileSystem, | 26 IPC_MESSAGE_HANDLER(ShellViewHostMsg_RegisterIsolatedFileSystem, |
27 OnRegisterIsolatedFileSystem) | 27 OnRegisterIsolatedFileSystem) |
28 IPC_MESSAGE_UNHANDLED(handled = false) | 28 IPC_MESSAGE_UNHANDLED(handled = false) |
29 IPC_END_MESSAGE_MAP() | 29 IPC_END_MESSAGE_MAP() |
30 | 30 |
31 return handled; | 31 return handled; |
32 } | 32 } |
33 | 33 |
34 void ShellMessageFilter::OnReadFileToString(const FilePath& local_file, | 34 void ShellMessageFilter::OnReadFileToString(const base::FilePath& local_file, |
35 std::string* contents) { | 35 std::string* contents) { |
36 file_util::ReadFileToString(local_file, contents); | 36 file_util::ReadFileToString(local_file, contents); |
37 } | 37 } |
38 | 38 |
39 void ShellMessageFilter::OnRegisterIsolatedFileSystem( | 39 void ShellMessageFilter::OnRegisterIsolatedFileSystem( |
40 const std::vector<FilePath>& absolute_filenames, | 40 const std::vector<base::FilePath>& absolute_filenames, |
41 std::string* filesystem_id) { | 41 std::string* filesystem_id) { |
42 fileapi::IsolatedContext::FileInfoSet files; | 42 fileapi::IsolatedContext::FileInfoSet files; |
43 ChildProcessSecurityPolicy* policy = | 43 ChildProcessSecurityPolicy* policy = |
44 ChildProcessSecurityPolicy::GetInstance(); | 44 ChildProcessSecurityPolicy::GetInstance(); |
45 for (size_t i = 0; i < absolute_filenames.size(); ++i) { | 45 for (size_t i = 0; i < absolute_filenames.size(); ++i) { |
46 files.AddPath(absolute_filenames[i], NULL); | 46 files.AddPath(absolute_filenames[i], NULL); |
47 if (!policy->CanReadFile(render_process_id_, absolute_filenames[i])) | 47 if (!policy->CanReadFile(render_process_id_, absolute_filenames[i])) |
48 policy->GrantReadFile(render_process_id_, absolute_filenames[i]); | 48 policy->GrantReadFile(render_process_id_, absolute_filenames[i]); |
49 } | 49 } |
50 *filesystem_id = | 50 *filesystem_id = |
51 fileapi::IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files); | 51 fileapi::IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files); |
52 policy->GrantReadFileSystem(render_process_id_, *filesystem_id); | 52 policy->GrantReadFileSystem(render_process_id_, *filesystem_id); |
53 } | 53 } |
54 | 54 |
55 } // namespace content | 55 } // namespace content |
OLD | NEW |