| 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/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 <sys/poll.h> | 10 #include <sys/poll.h> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "content/common/sandbox_linux.h" | 32 #include "content/common/sandbox_linux.h" |
| 33 #include "content/common/set_process_title.h" | 33 #include "content/common/set_process_title.h" |
| 34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
| 35 #include "skia/ext/skia_utils_base.h" | 35 #include "skia/ext/skia_utils_base.h" |
| 36 #include "third_party/WebKit/public/web/WebKit.h" | 36 #include "third_party/WebKit/public/web/WebKit.h" |
| 37 #include "third_party/WebKit/public/web/linux/WebFontInfo.h" | 37 #include "third_party/WebKit/public/web/linux/WebFontInfo.h" |
| 38 #include "third_party/npapi/bindings/npapi_extensions.h" | 38 #include "third_party/npapi/bindings/npapi_extensions.h" |
| 39 #include "third_party/skia/include/ports/SkFontConfigInterface.h" | 39 #include "third_party/skia/include/ports/SkFontConfigInterface.h" |
| 40 #include "ui/gfx/font_render_params_linux.h" | 40 #include "ui/gfx/font_render_params_linux.h" |
| 41 | 41 |
| 42 using WebKit::WebCString; | 42 using blink::WebCString; |
| 43 using WebKit::WebFontInfo; | 43 using blink::WebFontInfo; |
| 44 using WebKit::WebUChar; | 44 using blink::WebUChar; |
| 45 using WebKit::WebUChar32; | 45 using blink::WebUChar32; |
| 46 | 46 |
| 47 namespace content { | 47 namespace content { |
| 48 | 48 |
| 49 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC | 49 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
| 50 | 50 |
| 51 // BEWARE: code in this file run across *processes* (not just threads). | 51 // BEWARE: code in this file run across *processes* (not just threads). |
| 52 | 52 |
| 53 // This code runs in a child process | 53 // This code runs in a child process |
| 54 class SandboxIPCProcess { | 54 class SandboxIPCProcess { |
| 55 public: | 55 public: |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 EnsureWebKitInitialized(); | 254 EnsureWebKitInitialized(); |
| 255 WebUChar32 c; | 255 WebUChar32 c; |
| 256 if (!pickle.ReadInt(&iter, &c)) | 256 if (!pickle.ReadInt(&iter, &c)) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 std::string preferred_locale; | 259 std::string preferred_locale; |
| 260 if (!pickle.ReadString(&iter, &preferred_locale)) | 260 if (!pickle.ReadString(&iter, &preferred_locale)) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 WebKit::WebFontFamily family; | 263 blink::WebFontFamily family; |
| 264 WebFontInfo::familyForChar(c, preferred_locale.c_str(), &family); | 264 WebFontInfo::familyForChar(c, preferred_locale.c_str(), &family); |
| 265 | 265 |
| 266 Pickle reply; | 266 Pickle reply; |
| 267 if (family.name.data()) { | 267 if (family.name.data()) { |
| 268 reply.WriteString(family.name.data()); | 268 reply.WriteString(family.name.data()); |
| 269 } else { | 269 } else { |
| 270 reply.WriteString(std::string()); | 270 reply.WriteString(std::string()); |
| 271 } | 271 } |
| 272 reply.WriteBool(family.isBold); | 272 reply.WriteBool(family.isBold); |
| 273 reply.WriteBool(family.isItalic); | 273 reply.WriteBool(family.isItalic); |
| 274 SendRendererReply(fds, reply, -1); | 274 SendRendererReply(fds, reply, -1); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void HandleGetStyleForStrike(int fd, const Pickle& pickle, | 277 void HandleGetStyleForStrike(int fd, const Pickle& pickle, |
| 278 PickleIterator iter, | 278 PickleIterator iter, |
| 279 std::vector<int>& fds) { | 279 std::vector<int>& fds) { |
| 280 std::string family; | 280 std::string family; |
| 281 int sizeAndStyle; | 281 int sizeAndStyle; |
| 282 | 282 |
| 283 if (!pickle.ReadString(&iter, &family) || | 283 if (!pickle.ReadString(&iter, &family) || |
| 284 !pickle.ReadInt(&iter, &sizeAndStyle)) { | 284 !pickle.ReadInt(&iter, &sizeAndStyle)) { |
| 285 return; | 285 return; |
| 286 } | 286 } |
| 287 | 287 |
| 288 EnsureWebKitInitialized(); | 288 EnsureWebKitInitialized(); |
| 289 WebKit::WebFontRenderStyle style; | 289 blink::WebFontRenderStyle style; |
| 290 WebFontInfo::renderStyleForStrike(family.c_str(), sizeAndStyle, &style); | 290 WebFontInfo::renderStyleForStrike(family.c_str(), sizeAndStyle, &style); |
| 291 | 291 |
| 292 Pickle reply; | 292 Pickle reply; |
| 293 reply.WriteInt(style.useBitmaps); | 293 reply.WriteInt(style.useBitmaps); |
| 294 reply.WriteInt(style.useAutoHint); | 294 reply.WriteInt(style.useAutoHint); |
| 295 reply.WriteInt(style.useHinting); | 295 reply.WriteInt(style.useHinting); |
| 296 reply.WriteInt(style.hintStyle); | 296 reply.WriteInt(style.hintStyle); |
| 297 reply.WriteInt(style.useAntiAlias); | 297 reply.WriteInt(style.useAntiAlias); |
| 298 reply.WriteInt(style.useSubpixelRendering); | 298 reply.WriteInt(style.useSubpixelRendering); |
| 299 reply.WriteInt(style.useSubpixelPositioning); | 299 reply.WriteInt(style.useSubpixelPositioning); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 const int lifeline_fd_; | 647 const int lifeline_fd_; |
| 648 const int browser_socket_; | 648 const int browser_socket_; |
| 649 std::vector<std::string> sandbox_cmd_; | 649 std::vector<std::string> sandbox_cmd_; |
| 650 scoped_ptr<WebKitPlatformSupportImpl> webkit_platform_support_; | 650 scoped_ptr<WebKitPlatformSupportImpl> webkit_platform_support_; |
| 651 SkTDArray<SkString*> paths_; | 651 SkTDArray<SkString*> paths_; |
| 652 }; | 652 }; |
| 653 | 653 |
| 654 SandboxIPCProcess::~SandboxIPCProcess() { | 654 SandboxIPCProcess::~SandboxIPCProcess() { |
| 655 paths_.deleteAll(); | 655 paths_.deleteAll(); |
| 656 if (webkit_platform_support_) | 656 if (webkit_platform_support_) |
| 657 WebKit::shutdownWithoutV8(); | 657 blink::shutdownWithoutV8(); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void SandboxIPCProcess::EnsureWebKitInitialized() { | 660 void SandboxIPCProcess::EnsureWebKitInitialized() { |
| 661 if (webkit_platform_support_) | 661 if (webkit_platform_support_) |
| 662 return; | 662 return; |
| 663 webkit_platform_support_.reset(new WebKitPlatformSupportImpl); | 663 webkit_platform_support_.reset(new WebKitPlatformSupportImpl); |
| 664 WebKit::initializeWithoutV8(webkit_platform_support_.get()); | 664 blink::initializeWithoutV8(webkit_platform_support_.get()); |
| 665 } | 665 } |
| 666 | 666 |
| 667 // ----------------------------------------------------------------------------- | 667 // ----------------------------------------------------------------------------- |
| 668 | 668 |
| 669 // Runs on the main thread at startup. | 669 // Runs on the main thread at startup. |
| 670 RenderSandboxHostLinux::RenderSandboxHostLinux() | 670 RenderSandboxHostLinux::RenderSandboxHostLinux() |
| 671 : initialized_(false), | 671 : initialized_(false), |
| 672 renderer_socket_(0), | 672 renderer_socket_(0), |
| 673 childs_lifeline_fd_(0), | 673 childs_lifeline_fd_(0), |
| 674 pid_(0) { | 674 pid_(0) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 723 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
| 724 if (initialized_) { | 724 if (initialized_) { |
| 725 if (HANDLE_EINTR(close(renderer_socket_)) < 0) | 725 if (HANDLE_EINTR(close(renderer_socket_)) < 0) |
| 726 PLOG(ERROR) << "close"; | 726 PLOG(ERROR) << "close"; |
| 727 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) | 727 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) |
| 728 PLOG(ERROR) << "close"; | 728 PLOG(ERROR) << "close"; |
| 729 } | 729 } |
| 730 } | 730 } |
| 731 | 731 |
| 732 } // namespace content | 732 } // namespace content |
| OLD | NEW |