Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: content/browser/renderer_host/sandbox_ipc_linux.cc

Issue 2833973003: Initialize FontConfigIPC when zygote is disabled so font fallback works. (Closed)
Patch Set: Add browser test. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/sandbox_ipc_linux.h" 5 #include "content/browser/renderer_host/sandbox_ipc_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 17 matching lines...) Expand all
28 #include "skia/ext/skia_utils_base.h" 28 #include "skia/ext/skia_utils_base.h"
29 #include "third_party/skia/include/ports/SkFontConfigInterface.h" 29 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
30 #include "ui/gfx/font.h" 30 #include "ui/gfx/font.h"
31 #include "ui/gfx/font_fallback_linux.h" 31 #include "ui/gfx/font_fallback_linux.h"
32 #include "ui/gfx/font_render_params.h" 32 #include "ui/gfx/font_render_params.h"
33 33
34 namespace content { 34 namespace content {
35 35
36 namespace { 36 namespace {
37 37
38 SandboxIPCHandler::TestObserver* g_test_observer = nullptr;
39
38 // Converts gfx::FontRenderParams::Hinting to WebFontRenderStyle::hintStyle. 40 // Converts gfx::FontRenderParams::Hinting to WebFontRenderStyle::hintStyle.
39 // Returns an int for serialization, but the underlying Blink type is a char. 41 // Returns an int for serialization, but the underlying Blink type is a char.
40 int ConvertHinting(gfx::FontRenderParams::Hinting hinting) { 42 int ConvertHinting(gfx::FontRenderParams::Hinting hinting) {
41 switch (hinting) { 43 switch (hinting) {
42 case gfx::FontRenderParams::HINTING_NONE: return 0; 44 case gfx::FontRenderParams::HINTING_NONE: return 0;
43 case gfx::FontRenderParams::HINTING_SLIGHT: return 1; 45 case gfx::FontRenderParams::HINTING_SLIGHT: return 1;
44 case gfx::FontRenderParams::HINTING_MEDIUM: return 2; 46 case gfx::FontRenderParams::HINTING_MEDIUM: return 2;
45 case gfx::FontRenderParams::HINTING_FULL: return 3; 47 case gfx::FontRenderParams::HINTING_FULL: return 3;
46 } 48 }
47 NOTREACHED() << "Unexpected hinting value " << hinting; 49 NOTREACHED() << "Unexpected hinting value " << hinting;
(...skipping 11 matching lines...) Expand all
59 case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR: return 1; 61 case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR: return 1;
60 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB: return 1; 62 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB: return 1;
61 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR: return 1; 63 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR: return 1;
62 } 64 }
63 NOTREACHED() << "Unexpected subpixel rendering value " << rendering; 65 NOTREACHED() << "Unexpected subpixel rendering value " << rendering;
64 return 0; 66 return 0;
65 } 67 }
66 68
67 } // namespace 69 } // namespace
68 70
71 // static
72 void SandboxIPCHandler::SetObserverForTests(
73 SandboxIPCHandler::TestObserver* observer) {
74 g_test_observer = observer;
75 }
76
69 SandboxIPCHandler::SandboxIPCHandler(int lifeline_fd, int browser_socket) 77 SandboxIPCHandler::SandboxIPCHandler(int lifeline_fd, int browser_socket)
70 : lifeline_fd_(lifeline_fd), 78 : lifeline_fd_(lifeline_fd),
71 browser_socket_(browser_socket) { 79 browser_socket_(browser_socket) {
72 } 80 }
73 81
74 void SandboxIPCHandler::Run() { 82 void SandboxIPCHandler::Run() {
75 struct pollfd pfds[2]; 83 struct pollfd pfds[2];
76 pfds[0].fd = lifeline_fd_; 84 pfds[0].fd = lifeline_fd_;
77 pfds[0].events = POLLIN; 85 pfds[0].events = POLLIN;
78 pfds[1].fd = browser_socket_; 86 pfds[1].fd = browser_socket_;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 217
210 void SandboxIPCHandler::HandleFontOpenRequest( 218 void SandboxIPCHandler::HandleFontOpenRequest(
211 int fd, 219 int fd,
212 base::PickleIterator iter, 220 base::PickleIterator iter,
213 const std::vector<base::ScopedFD>& fds) { 221 const std::vector<base::ScopedFD>& fds) {
214 uint32_t index; 222 uint32_t index;
215 if (!iter.ReadUInt32(&index)) 223 if (!iter.ReadUInt32(&index))
216 return; 224 return;
217 if (index >= static_cast<uint32_t>(paths_.size())) 225 if (index >= static_cast<uint32_t>(paths_.size()))
218 return; 226 return;
227 if (g_test_observer)
228 g_test_observer->OnFontOpen(index);
219 const int result_fd = open(paths_[index].c_str(), O_RDONLY); 229 const int result_fd = open(paths_[index].c_str(), O_RDONLY);
220 230
221 base::Pickle reply; 231 base::Pickle reply;
222 reply.WriteBool(result_fd != -1); 232 reply.WriteBool(result_fd != -1);
223 233
224 // The receiver will have its own access to the file, so we will close it 234 // The receiver will have its own access to the file, so we will close it
225 // after this send. 235 // after this send.
226 SendRendererReply(fds, reply, result_fd); 236 SendRendererReply(fds, reply, result_fd);
227 237
228 if (result_fd >= 0) { 238 if (result_fd >= 0) {
(...skipping 14 matching lines...) Expand all
243 return; 253 return;
244 254
245 std::string preferred_locale; 255 std::string preferred_locale;
246 if (!iter.ReadString(&preferred_locale)) 256 if (!iter.ReadString(&preferred_locale))
247 return; 257 return;
248 258
249 auto fallback_font = gfx::GetFallbackFontForChar(c, preferred_locale); 259 auto fallback_font = gfx::GetFallbackFontForChar(c, preferred_locale);
250 int fontconfig_interface_id = 260 int fontconfig_interface_id =
251 FindOrAddPath(SkString(fallback_font.filename.data())); 261 FindOrAddPath(SkString(fallback_font.filename.data()));
252 262
263 if (g_test_observer)
Sami 2017/05/15 11:14:37 nit: Please add curly braces
264 g_test_observer->OnGetFallbackFontForChar(c, fallback_font.name,
265 fontconfig_interface_id);
253 base::Pickle reply; 266 base::Pickle reply;
254 reply.WriteString(fallback_font.name); 267 reply.WriteString(fallback_font.name);
255 reply.WriteString(fallback_font.filename); 268 reply.WriteString(fallback_font.filename);
256 reply.WriteInt(fontconfig_interface_id); 269 reply.WriteInt(fontconfig_interface_id);
257 reply.WriteInt(fallback_font.ttc_index); 270 reply.WriteInt(fallback_font.ttc_index);
258 reply.WriteBool(fallback_font.is_bold); 271 reply.WriteBool(fallback_font.is_bold);
259 reply.WriteBool(fallback_font.is_italic); 272 reply.WriteBool(fallback_font.is_italic);
260 SendRendererReply(fds, reply, -1); 273 SendRendererReply(fds, reply, -1);
261 } 274 }
262 275
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 426 }
414 427
415 SandboxIPCHandler::~SandboxIPCHandler() { 428 SandboxIPCHandler::~SandboxIPCHandler() {
416 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) 429 if (IGNORE_EINTR(close(lifeline_fd_)) < 0)
417 PLOG(ERROR) << "close"; 430 PLOG(ERROR) << "close";
418 if (IGNORE_EINTR(close(browser_socket_)) < 0) 431 if (IGNORE_EINTR(close(browser_socket_)) < 0)
419 PLOG(ERROR) << "close"; 432 PLOG(ERROR) << "close";
420 } 433 }
421 434
422 } // namespace content 435 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698