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

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

Issue 335223003: Add trial for DirectWrite, and reorder some initialization so it can take effect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nacl_win64 Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (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/path_service.h" 16 #include "base/path_service.h"
16 #include "base/process/launch.h" 17 #include "base/process/launch.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/win/iat_patch_function.h" 20 #include "base/win/iat_patch_function.h"
20 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
21 #include "base/win/scoped_process_information.h" 22 #include "base/win/scoped_process_information.h"
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
25 #include "content/public/common/sandbox_init.h" 26 #include "content/public/common/sandbox_init.h"
26 #include "content/public/common/sandboxed_process_launcher_delegate.h" 27 #include "content/public/common/sandboxed_process_launcher_delegate.h"
27 #include "sandbox/win/src/process_mitigations.h" 28 #include "sandbox/win/src/process_mitigations.h"
28 #include "sandbox/win/src/sandbox.h" 29 #include "sandbox/win/src/sandbox.h"
29 #include "sandbox/win/src/sandbox_nt_util.h" 30 #include "sandbox/win/src/sandbox_nt_util.h"
30 #include "sandbox/win/src/win_utils.h" 31 #include "sandbox/win/src/win_utils.h"
32 #include "ui/gfx/win/dpi.h"
31 33
32 static sandbox::BrokerServices* g_broker_services = NULL; 34 static sandbox::BrokerServices* g_broker_services = NULL;
33 static sandbox::TargetServices* g_target_services = NULL; 35 static sandbox::TargetServices* g_target_services = NULL;
34 36
35 namespace content { 37 namespace content {
36 namespace { 38 namespace {
37 39
38 // The DLLs listed here are known (or under strong suspicion) of causing crashes 40 // The DLLs listed here are known (or under strong suspicion) of causing crashes
39 // when they are loaded in the renderer. Note: at runtime we generate short 41 // when they are loaded in the renderer. Note: at runtime we generate short
40 // versions of the dll name only if the dll has an extension. 42 // versions of the dll name only if the dll has an extension.
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 sandbox::ResultCode result = target_services->Init(); 561 sandbox::ResultCode result = target_services->Init();
560 g_target_services = target_services; 562 g_target_services = target_services;
561 return sandbox::SBOX_ALL_OK == result; 563 return sandbox::SBOX_ALL_OK == result;
562 } 564 }
563 565
564 bool ShouldUseDirectWrite() { 566 bool ShouldUseDirectWrite() {
565 // If the flag is currently on, and we're on Win7 or above, we enable 567 // If the flag is currently on, and we're on Win7 or above, we enable
566 // DirectWrite. Skia does not require the additions to DirectWrite in QFE 568 // DirectWrite. Skia does not require the additions to DirectWrite in QFE
567 // 2670838, so a Win7 check is sufficient. We do not currently attempt to 569 // 2670838, so a Win7 check is sufficient. We do not currently attempt to
568 // support Vista, where SP2 and the Platform Update are required. 570 // support Vista, where SP2 and the Platform Update are required.
571 if (base::win::GetVersion() < base::win::VERSION_WIN7)
572 return false;
573
574 // If forced off, don't use it.
569 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 575 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
570 return !command_line.HasSwitch(switches::kDisableDirectWrite) && 576 if (command_line.HasSwitch(switches::kDisableDirectWrite))
571 base::win::GetVersion() >= base::win::VERSION_WIN7; 577 return false;
578
579 #if !defined(NACL_WIN64)
580 // Can't use GDI on HiDPI.
581 if (gfx::GetDPIScale() > 1.0f)
582 return true;
583 #endif
584
585 // Otherwise, Finch.
Alexei Svitkine (slow) 2014/06/18 17:38:27 Nit: Finch is a codename, change to "Otherwise, ch
scottmg 2014/06/18 17:46:43 Done.
586 const std::string group_name =
587 base::FieldTrialList::FindFullName("DirectWrite");
588 return group_name != "Disabled";
572 } 589 }
573 590
574 base::ProcessHandle StartSandboxedProcess( 591 base::ProcessHandle StartSandboxedProcess(
575 SandboxedProcessLauncherDelegate* delegate, 592 SandboxedProcessLauncherDelegate* delegate,
576 CommandLine* cmd_line) { 593 CommandLine* cmd_line) {
577 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 594 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
578 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); 595 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType);
579 596
580 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess", 0, type_str); 597 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess", 0, type_str);
581 598
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 766 }
750 767
751 return false; 768 return false;
752 } 769 }
753 770
754 bool BrokerAddTargetPeer(HANDLE peer_process) { 771 bool BrokerAddTargetPeer(HANDLE peer_process) {
755 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 772 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
756 } 773 }
757 774
758 } // namespace content 775 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698