OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/render_sandbox_host_linux.h" | 5 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 #include <sys/uio.h> | 11 #include <sys/uio.h> |
12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
13 #include <sys/socket.h> | 13 #include <sys/socket.h> |
14 #include <sys/poll.h> | 14 #include <sys/poll.h> |
15 #include <time.h> | 15 #include <time.h> |
16 | 16 |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/eintr_wrapper.h" | 20 #include "base/eintr_wrapper.h" |
21 #include "base/linux_util.h" | 21 #include "base/linux_util.h" |
22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
23 #include "base/memory/singleton.h" | 23 #include "base/memory/singleton.h" |
24 #include "base/pickle.h" | 24 #include "base/pickle.h" |
25 #include "base/process_util.h" | 25 #include "base/process_util.h" |
26 #include "base/shared_memory.h" | 26 #include "base/shared_memory.h" |
27 #include "base/string_number_conversions.h" | 27 #include "base/string_number_conversions.h" |
28 #include "base/string_util.h" | 28 #include "base/string_util.h" |
| 29 #include "content/common/content_webkitplatformsupport_impl.h" |
29 #include "content/common/font_config_ipc_linux.h" | 30 #include "content/common/font_config_ipc_linux.h" |
30 #include "content/common/sandbox_methods_linux.h" | 31 #include "content/common/sandbox_methods_linux.h" |
31 #include "content/common/unix_domain_socket_posix.h" | 32 #include "content/common/unix_domain_socket_posix.h" |
32 #include "skia/ext/SkFontHost_fontconfig_direct.h" | 33 #include "skia/ext/SkFontHost_fontconfig_direct.h" |
33 #include "third_party/npapi/bindings/npapi_extensions.h" | 34 #include "third_party/npapi/bindings/npapi_extensions.h" |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h" |
36 #include "webkit/glue/webkitplatformsupport_impl.h" | |
37 | 37 |
38 using WebKit::WebCString; | 38 using WebKit::WebCString; |
39 using WebKit::WebFontInfo; | 39 using WebKit::WebFontInfo; |
40 using WebKit::WebUChar; | 40 using WebKit::WebUChar; |
41 | 41 |
42 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC | 42 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
43 | 43 |
44 // BEWARE: code in this file run across *processes* (not just threads). | 44 // BEWARE: code in this file run across *processes* (not just threads). |
45 | 45 |
46 // This code runs in a child process | 46 // This code runs in a child process |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 if (HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)) < 0) | 638 if (HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)) < 0) |
639 PLOG(ERROR) << "sendmsg"; | 639 PLOG(ERROR) << "sendmsg"; |
640 } | 640 } |
641 | 641 |
642 // --------------------------------------------------------------------------- | 642 // --------------------------------------------------------------------------- |
643 | 643 |
644 const int lifeline_fd_; | 644 const int lifeline_fd_; |
645 const int browser_socket_; | 645 const int browser_socket_; |
646 FontConfigDirect* const font_config_; | 646 FontConfigDirect* const font_config_; |
647 std::vector<std::string> sandbox_cmd_; | 647 std::vector<std::string> sandbox_cmd_; |
648 scoped_ptr<webkit_glue::WebKitPlatformSupportImpl> webkit_platform_support_; | 648 scoped_ptr<ContentWebKitPlatformSupportImpl> webkit_platform_support_; |
649 }; | 649 }; |
650 | 650 |
651 SandboxIPCProcess::~SandboxIPCProcess() { | 651 SandboxIPCProcess::~SandboxIPCProcess() { |
652 if (webkit_platform_support_.get()) | 652 if (webkit_platform_support_.get()) |
653 WebKit::shutdown(); | 653 WebKit::shutdown(); |
654 } | 654 } |
655 | 655 |
656 void SandboxIPCProcess::EnsureWebKitInitialized() { | 656 void SandboxIPCProcess::EnsureWebKitInitialized() { |
657 if (webkit_platform_support_.get()) | 657 if (webkit_platform_support_.get()) |
658 return; | 658 return; |
659 webkit_platform_support_.reset(new webkit_glue::WebKitPlatformSupportImpl); | 659 webkit_platform_support_.reset(new ContentWebKitPlatformSupportImpl); |
660 WebKit::initialize(webkit_platform_support_.get()); | 660 WebKit::initialize(webkit_platform_support_.get()); |
661 } | 661 } |
662 | 662 |
663 // ----------------------------------------------------------------------------- | 663 // ----------------------------------------------------------------------------- |
664 | 664 |
665 // Runs on the main thread at startup. | 665 // Runs on the main thread at startup. |
666 RenderSandboxHostLinux::RenderSandboxHostLinux() | 666 RenderSandboxHostLinux::RenderSandboxHostLinux() |
667 : initialized_(false), | 667 : initialized_(false), |
668 renderer_socket_(0), | 668 renderer_socket_(0), |
669 childs_lifeline_fd_(0), | 669 childs_lifeline_fd_(0), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } | 712 } |
713 | 713 |
714 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 714 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
715 if (initialized_) { | 715 if (initialized_) { |
716 if (HANDLE_EINTR(close(renderer_socket_)) < 0) | 716 if (HANDLE_EINTR(close(renderer_socket_)) < 0) |
717 PLOG(ERROR) << "close"; | 717 PLOG(ERROR) << "close"; |
718 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) | 718 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) |
719 PLOG(ERROR) << "close"; | 719 PLOG(ERROR) << "close"; |
720 } | 720 } |
721 } | 721 } |
OLD | NEW |