[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
mostynb | df175a8 | 2016-02-08 23:27:20 | [diff] [blame] | 5 | // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 6 | |
Vladimir Levin | 11a23b1 | 2017-09-11 23:13:30 | [diff] [blame] | 7 | #ifndef CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_ |
| 8 | #define CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_ |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 9 | |
dcheng | 92ae1414 | 2016-04-09 02:52:24 | [diff] [blame] | 10 | #include <memory> |
zoeclifford | 525974c | 2017-05-17 20:31:06 | [diff] [blame] | 11 | #include <string> |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 14 | #include "base/files/scoped_file.h" |
avi | b533f5d | 2015-12-25 03:11:15 | [diff] [blame] | 15 | #include "base/macros.h" |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 16 | #include "base/pickle.h" |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 17 | #include "base/threading/simple_thread.h" |
zoeclifford | 525974c | 2017-05-17 20:31:06 | [diff] [blame] | 18 | #include "content/common/content_export.h" |
| 19 | #include "third_party/icu/source/common/unicode/uchar.h" |
tomhudson | 55241b6 | 2016-05-27 14:03:18 | [diff] [blame] | 20 | |
| 21 | class SkString; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 22 | |
| 23 | namespace content { |
| 24 | |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 25 | class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate { |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 26 | public: |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 27 | // lifeline_fd: the read end of a pipe which the main thread holds |
| 28 | // the other end of. |
| 29 | // browser_socket: the browser's end of the sandbox IPC socketpair. |
| 30 | SandboxIPCHandler(int lifeline_fd, int browser_socket); |
dcheng | 4c112747 | 2014-10-28 00:01:20 | [diff] [blame] | 31 | ~SandboxIPCHandler() override; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 32 | |
dcheng | 4c112747 | 2014-10-28 00:01:20 | [diff] [blame] | 33 | void Run() override; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 34 | |
zoeclifford | 525974c | 2017-05-17 20:31:06 | [diff] [blame] | 35 | class TestObserver { |
| 36 | public: |
| 37 | virtual void OnGetFallbackFontForChar(UChar32 c, |
| 38 | std::string name, |
| 39 | int id) = 0; |
| 40 | virtual void OnFontOpen(int id) = 0; |
| 41 | }; |
| 42 | CONTENT_EXPORT static void SetObserverForTests(TestObserver* observer); |
| 43 | |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 44 | private: |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 45 | int FindOrAddPath(const SkString& path); |
| 46 | |
Vladimir Levin | 11a23b1 | 2017-09-11 23:13:30 | [diff] [blame] | 47 | void HandleRequestFromChild(int fd); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 48 | |
| 49 | void HandleFontMatchRequest(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 50 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 51 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 52 | |
| 53 | void HandleFontOpenRequest(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 54 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 55 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 56 | |
[email protected] | aee791a6 | 2014-06-12 03:42:40 | [diff] [blame] | 57 | void HandleGetFallbackFontForChar(int fd, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 58 | base::PickleIterator iter, |
| 59 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 60 | |
| 61 | void HandleGetStyleForStrike(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 62 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 63 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 64 | |
| 65 | void HandleLocaltime(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 66 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 67 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 68 | |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 69 | void HandleMakeSharedMemorySegment(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 70 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 71 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 72 | |
| 73 | void HandleMatchWithFallback(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 74 | base::PickleIterator iter, |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 75 | const std::vector<base::ScopedFD>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 76 | |
mdempsky | f12295a | 2015-12-09 22:54:46 | [diff] [blame] | 77 | void SendRendererReply(const std::vector<base::ScopedFD>& fds, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame] | 78 | const base::Pickle& reply, |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 79 | int reply_fd); |
| 80 | |
[email protected] | 972a9995 | 2014-05-01 20:41:22 | [diff] [blame] | 81 | const int lifeline_fd_; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 82 | const int browser_socket_; |
bungeman | e27534c2 | 2016-02-18 15:58:38 | [diff] [blame] | 83 | std::vector<SkString> paths_; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 84 | |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 85 | DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace content |
| 89 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 90 | #endif // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ |