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

Side by Side Diff: content/common/sandbox_win.cc

Issue 671743002: Disable direct write if font count in registry is greater than or equal to threshold (currently 175… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | 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/common/sandbox_win.h" 5 #include "content/common/sandbox_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/profiler.h" 11 #include "base/debug/profiler.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/hash.h" 14 #include "base/hash.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/process/launch.h" 17 #include "base/process/launch.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/win/iat_patch_function.h" 20 #include "base/win/iat_patch_function.h"
21 #include "base/win/registry.h"
21 #include "base/win/scoped_handle.h" 22 #include "base/win/scoped_handle.h"
22 #include "base/win/scoped_process_information.h" 23 #include "base/win/scoped_process_information.h"
23 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
24 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/common/sandbox_init.h" 27 #include "content/public/common/sandbox_init.h"
27 #include "content/public/common/sandboxed_process_launcher_delegate.h" 28 #include "content/public/common/sandboxed_process_launcher_delegate.h"
28 #include "sandbox/win/src/process_mitigations.h" 29 #include "sandbox/win/src/process_mitigations.h"
29 #include "sandbox/win/src/sandbox.h" 30 #include "sandbox/win/src/sandbox.h"
30 #include "sandbox/win/src/sandbox_nt_util.h" 31 #include "sandbox/win/src/sandbox_nt_util.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 *base::CommandLine::ForCurrentProcess(); 597 *base::CommandLine::ForCurrentProcess();
597 if (command_line.HasSwitch(switches::kDisableDirectWrite)) 598 if (command_line.HasSwitch(switches::kDisableDirectWrite))
598 return false; 599 return false;
599 600
600 #if !defined(NACL_WIN64) 601 #if !defined(NACL_WIN64)
601 // Can't use GDI on HiDPI. 602 // Can't use GDI on HiDPI.
602 if (gfx::GetDPIScale() > 1.0f) 603 if (gfx::GetDPIScale() > 1.0f)
603 return true; 604 return true;
604 #endif 605 #endif
605 606
607 // We have logic in renderer_font_platform_win.cc for falling back to safe
608 // font list if machine has more than 1750 fonts installed. Users have
609 // complained about this as safe font list is usually not sufficient.
610 // We now disable direct write (gdi) if we encounter more number
611 // of fonts than a threshold (currently 1750).
612 // Refer: crbug.com/421305
613 const wchar_t kWindowsFontsRegistryKey[] =
614 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
615 base::win::RegistryValueIterator reg_iterator(HKEY_LOCAL_MACHINE,
616 kWindowsFontsRegistryKey);
617 const DWORD kMaxAllowedFontsBeforeFallbackToGDI = 1750;
618 if (reg_iterator.ValueCount() >= kMaxAllowedFontsBeforeFallbackToGDI)
619 return false;
620
606 // Otherwise, check the field trial. 621 // Otherwise, check the field trial.
607 const std::string group_name = 622 const std::string group_name =
608 base::FieldTrialList::FindFullName("DirectWrite"); 623 base::FieldTrialList::FindFullName("DirectWrite");
609 return group_name != "Disabled"; 624 return group_name != "Disabled";
610 } 625 }
611 626
612 base::ProcessHandle StartSandboxedProcess( 627 base::ProcessHandle StartSandboxedProcess(
613 SandboxedProcessLauncherDelegate* delegate, 628 SandboxedProcessLauncherDelegate* delegate,
614 base::CommandLine* cmd_line) { 629 base::CommandLine* cmd_line) {
615 const base::CommandLine& browser_command_line = 630 const base::CommandLine& browser_command_line =
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 804 }
790 805
791 return false; 806 return false;
792 } 807 }
793 808
794 bool BrokerAddTargetPeer(HANDLE peer_process) { 809 bool BrokerAddTargetPeer(HANDLE peer_process) {
795 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 810 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
796 } 811 }
797 812
798 } // namespace content 813 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698