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/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/crypto.h> | 9 #include <openssl/crypto.h> |
10 #include <openssl/rand.h> | 10 #include <openssl/rand.h> |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // before the sandbox is initialized to allow the font manager to access | 362 // before the sandbox is initialized to allow the font manager to access |
363 // font configuration files on disk. | 363 // font configuration files on disk. |
364 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 364 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
365 switches::kAndroidFontsPath)) { | 365 switches::kAndroidFontsPath)) { |
366 std::string android_fonts_dir = | 366 std::string android_fonts_dir = |
367 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 367 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
368 switches::kAndroidFontsPath); | 368 switches::kAndroidFontsPath); |
369 | 369 |
370 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/') | 370 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/') |
371 android_fonts_dir += '/'; | 371 android_fonts_dir += '/'; |
372 std::string font_config = android_fonts_dir + "fonts.xml"; | 372 |
373 SkFontMgr_Android_CustomFonts custom; | 373 SkFontMgr_Android_CustomFonts custom; |
374 custom.fSystemFontUse = | 374 custom.fSystemFontUse = |
375 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom; | 375 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom; |
376 custom.fBasePath = android_fonts_dir.c_str(); | 376 custom.fBasePath = android_fonts_dir.c_str(); |
| 377 |
| 378 std::string font_config; |
| 379 std::string fallback_font_config; |
| 380 if (android_fonts_dir.find("kitkat") != std::string::npos) { |
| 381 font_config = android_fonts_dir + "system_fonts.xml"; |
| 382 fallback_font_config = android_fonts_dir + "fallback_fonts.xml"; |
| 383 custom.fFallbackFontsXml = fallback_font_config.c_str(); |
| 384 } else { |
| 385 font_config = android_fonts_dir + "fonts.xml"; |
| 386 custom.fFallbackFontsXml = nullptr; |
| 387 } |
377 custom.fFontsXml = font_config.c_str(); | 388 custom.fFontsXml = font_config.c_str(); |
378 custom.fFallbackFontsXml = nullptr; | |
379 custom.fIsolated = true; | 389 custom.fIsolated = true; |
380 | 390 |
381 blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom)); | 391 blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom)); |
382 } | 392 } |
383 } | 393 } |
384 | 394 |
385 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { | 395 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { |
386 // The current process becomes init(1), this function returns from a | 396 // The current process becomes init(1), this function returns from a |
387 // newly created process. | 397 // newly created process. |
388 const bool init_created = | 398 const bool init_created = |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 653 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
644 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 654 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
645 | 655 |
646 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, | 656 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, |
647 extra_fds); | 657 extra_fds); |
648 // This function call can return multiple times, once per fork(). | 658 // This function call can return multiple times, once per fork(). |
649 return zygote.ProcessRequests(); | 659 return zygote.ProcessRequests(); |
650 } | 660 } |
651 | 661 |
652 } // namespace content | 662 } // namespace content |
OLD | NEW |