[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 | |
| 5 | // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
| 6 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 7 | #ifndef CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ |
| 8 | #define CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 9 | |
| 10 | #include <vector> |
| 11 | |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 12 | #include "base/files/scoped_file.h" |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 13 | #include "base/memory/scoped_ptr.h" |
| 14 | #include "base/pickle.h" |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 15 | #include "base/threading/simple_thread.h" |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 16 | #include "content/child/blink_platform_impl.h" |
| 17 | #include "skia/ext/skia_utils_base.h" |
| 18 | |
| 19 | namespace content { |
| 20 | |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 21 | class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate { |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 22 | public: |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 23 | // lifeline_fd: the read end of a pipe which the main thread holds |
| 24 | // the other end of. |
| 25 | // browser_socket: the browser's end of the sandbox IPC socketpair. |
| 26 | SandboxIPCHandler(int lifeline_fd, int browser_socket); |
dcheng | 4c112747 | 2014-10-28 00:01:20 | [diff] [blame] | 27 | ~SandboxIPCHandler() override; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 28 | |
dcheng | 4c112747 | 2014-10-28 00:01:20 | [diff] [blame] | 29 | void Run() override; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 30 | |
| 31 | private: |
| 32 | void EnsureWebKitInitialized(); |
| 33 | |
| 34 | int FindOrAddPath(const SkString& path); |
| 35 | |
| 36 | void HandleRequestFromRenderer(int fd); |
| 37 | |
| 38 | void HandleFontMatchRequest(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 39 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 40 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 41 | |
| 42 | void HandleFontOpenRequest(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 43 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 44 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 45 | |
[email protected] | aee791a6 | 2014-06-12 03:42:40 | [diff] [blame] | 46 | void HandleGetFallbackFontForChar(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 47 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 48 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 49 | |
| 50 | void HandleGetStyleForStrike(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 51 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 52 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 53 | |
| 54 | void HandleLocaltime(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 55 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 56 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 57 | |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 58 | void HandleMakeSharedMemorySegment(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 59 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 60 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 61 | |
| 62 | void HandleMatchWithFallback(int fd, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 63 | base::PickleIterator iter, |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 64 | const std::vector<base::ScopedFD*>& fds); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 65 | |
[email protected] | 8feaa67 | 2014-04-30 21:57:10 | [diff] [blame] | 66 | void SendRendererReply(const std::vector<base::ScopedFD*>& fds, |
brettw | 05cfd8ddb | 2015-06-02 07:02:47 | [diff] [blame^] | 67 | const base::Pickle& reply, |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 68 | int reply_fd); |
| 69 | |
[email protected] | 972a9995 | 2014-05-01 20:41:22 | [diff] [blame] | 70 | const int lifeline_fd_; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 71 | const int browser_socket_; |
tfarina | 556a723 | 2014-10-05 01:02:09 | [diff] [blame] | 72 | scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 73 | SkTDArray<SkString*> paths_; |
| 74 | |
[email protected] | ef0dad53c | 2014-05-23 11:31:19 | [diff] [blame] | 75 | DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler); |
[email protected] | ac0a3f0 | 2014-04-24 03:34:16 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace content |
| 79 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 80 | #endif // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ |