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

Side by Side Diff: content/zygote/zygote_main_linux.cc

Issue 1685053002: blink fonts: Load Android SkFontMgr on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@windows_change
Patch Set: Rebase. Created 4 years, 9 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/public/common/content_switches.cc ('k') | skia/BUILD.gn » ('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 (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/zygote/zygote_main.h" 5 #include "content/zygote/zygote_main.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <openssl/rand.h> 9 #include <openssl/rand.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 28 matching lines...) Expand all
39 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
40 #include "content/public/common/main_function_params.h" 40 #include "content/public/common/main_function_params.h"
41 #include "content/public/common/sandbox_linux.h" 41 #include "content/public/common/sandbox_linux.h"
42 #include "content/public/common/zygote_fork_delegate_linux.h" 42 #include "content/public/common/zygote_fork_delegate_linux.h"
43 #include "content/zygote/zygote_linux.h" 43 #include "content/zygote/zygote_linux.h"
44 #include "sandbox/linux/services/credentials.h" 44 #include "sandbox/linux/services/credentials.h"
45 #include "sandbox/linux/services/init_process_reaper.h" 45 #include "sandbox/linux/services/init_process_reaper.h"
46 #include "sandbox/linux/services/namespace_sandbox.h" 46 #include "sandbox/linux/services/namespace_sandbox.h"
47 #include "sandbox/linux/services/thread_helpers.h" 47 #include "sandbox/linux/services/thread_helpers.h"
48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" 48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h"
49 #include "third_party/WebKit/public/web/linux/WebFontRendering.h"
49 #include "third_party/icu/source/i18n/unicode/timezone.h" 50 #include "third_party/icu/source/i18n/unicode/timezone.h"
50 #include "third_party/skia/include/ports/SkFontConfigInterface.h" 51 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
52 #include "third_party/skia/include/ports/SkFontMgr_android.h"
51 53
52 #if defined(OS_LINUX) 54 #if defined(OS_LINUX)
53 #include <sys/prctl.h> 55 #include <sys/prctl.h>
54 #endif 56 #endif
55 57
56 #if defined(ENABLE_PLUGINS) 58 #if defined(ENABLE_PLUGINS)
57 #include "content/common/pepper_plugin_list.h" 59 #include "content/common/pepper_plugin_list.h"
58 #include "content/public/common/pepper_plugin_info.h" 60 #include "content/public/common/pepper_plugin_info.h"
59 #endif 61 #endif
60 62
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // will work inside the sandbox. 339 // will work inside the sandbox.
338 RAND_set_urandom_fd(base::GetUrandomFD()); 340 RAND_set_urandom_fd(base::GetUrandomFD());
339 341
340 #if defined(ENABLE_PLUGINS) 342 #if defined(ENABLE_PLUGINS)
341 // Ensure access to the Pepper plugins before the sandbox is turned on. 343 // Ensure access to the Pepper plugins before the sandbox is turned on.
342 PreloadPepperPlugins(); 344 PreloadPepperPlugins();
343 #endif 345 #endif
344 #if defined(ENABLE_WEBRTC) 346 #if defined(ENABLE_WEBRTC)
345 InitializeWebRtcModule(); 347 InitializeWebRtcModule();
346 #endif 348 #endif
349
347 SkFontConfigInterface::SetGlobal( 350 SkFontConfigInterface::SetGlobal(
348 new FontConfigIPC(GetSandboxFD()))->unref(); 351 new FontConfigIPC(GetSandboxFD()))->unref();
352
353 // Set the android SkFontMgr for blink. We need to ensure this is done
354 // before the sandbox is initialized to allow the font manager to access
355 // font configuration files on disk.
356 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
357 switches::kAndroidFontsPath)) {
358 std::string android_fonts_dir =
359 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
360 switches::kAndroidFontsPath);
361
362 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/')
363 android_fonts_dir += '/';
364 std::string font_config = android_fonts_dir + "fonts.xml";
365 SkFontMgr_Android_CustomFonts custom;
366 custom.fSystemFontUse =
367 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom;
368 custom.fBasePath = android_fonts_dir.c_str();
369 custom.fFontsXml = font_config.c_str();
370 custom.fFallbackFontsXml = nullptr;
371 custom.fIsolated = true;
372
373 blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom));
374 }
349 } 375 }
350 376
351 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { 377 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) {
352 // The current process becomes init(1), this function returns from a 378 // The current process becomes init(1), this function returns from a
353 // newly created process. 379 // newly created process.
354 const bool init_created = 380 const bool init_created =
355 sandbox::CreateInitProcessReaper(post_fork_parent_callback); 381 sandbox::CreateInitProcessReaper(post_fork_parent_callback);
356 if (!init_created) { 382 if (!init_created) {
357 LOG(ERROR) << "Error creating an init process to reap zombies"; 383 LOG(ERROR) << "Error creating an init process to reap zombies";
358 return false; 384 return false;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; 635 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS;
610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); 636 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged);
611 637
612 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, 638 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children,
613 extra_fds); 639 extra_fds);
614 // This function call can return multiple times, once per fork(). 640 // This function call can return multiple times, once per fork().
615 return zygote.ProcessRequests(); 641 return zygote.ProcessRequests();
616 } 642 }
617 643
618 } // namespace content 644 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | skia/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698