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/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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
24 #include "base/win/iat_patch_function.h" | 24 #include "base/win/iat_patch_function.h" |
25 #include "base/win/scoped_handle.h" | 25 #include "base/win/scoped_handle.h" |
26 #include "base/win/scoped_process_information.h" | 26 #include "base/win/scoped_process_information.h" |
27 #include "base/win/win_util.h" | 27 #include "base/win/win_util.h" |
28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
29 #include "content/common/content_switches_internal.h" | 29 #include "content/common/content_switches_internal.h" |
30 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
32 #include "content/public/common/dwrite_font_platform_win.h" | |
33 #include "content/public/common/sandbox_init.h" | 32 #include "content/public/common/sandbox_init.h" |
34 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 33 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
35 #include "sandbox/win/src/process_mitigations.h" | 34 #include "sandbox/win/src/process_mitigations.h" |
36 #include "sandbox/win/src/sandbox.h" | 35 #include "sandbox/win/src/sandbox.h" |
37 #include "sandbox/win/src/sandbox_nt_util.h" | 36 #include "sandbox/win/src/sandbox_nt_util.h" |
38 #include "sandbox/win/src/sandbox_policy_base.h" | 37 #include "sandbox/win/src/sandbox_policy_base.h" |
39 #include "sandbox/win/src/win_utils.h" | 38 #include "sandbox/win/src/win_utils.h" |
40 #include "ui/gfx/win/direct_write.h" | 39 #include "ui/gfx/win/direct_write.h" |
41 | 40 |
42 static sandbox::BrokerServices* g_broker_services = NULL; | 41 static sandbox::BrokerServices* g_broker_services = NULL; |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 723 |
725 #if !defined(NACL_WIN64) | 724 #if !defined(NACL_WIN64) |
726 if (type_str == switches::kRendererProcess || | 725 if (type_str == switches::kRendererProcess || |
727 type_str == switches::kPpapiPluginProcess) { | 726 type_str == switches::kPpapiPluginProcess) { |
728 if (gfx::win::ShouldUseDirectWrite()) { | 727 if (gfx::win::ShouldUseDirectWrite()) { |
729 AddDirectory(base::DIR_WINDOWS_FONTS, | 728 AddDirectory(base::DIR_WINDOWS_FONTS, |
730 NULL, | 729 NULL, |
731 true, | 730 true, |
732 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 731 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
733 policy); | 732 policy); |
734 | |
735 // If DirectWrite is enabled for font rendering then open the font cache | |
736 // section which is created by the browser and pass the handle to the | |
737 // renderer process. This is needed because renderer processes on | |
738 // Windows 8+ may be running in an AppContainer sandbox and hence their | |
739 // kernel object namespace may be partitioned. | |
740 std::string name(content::kFontCacheSharedSectionName); | |
741 name.append(base::UintToString(base::GetCurrentProcId())); | |
742 | |
743 base::SharedMemory direct_write_font_cache_section; | |
744 if (direct_write_font_cache_section.Open(name, true)) { | |
745 void* shared_handle = policy->AddHandleToShare( | |
746 direct_write_font_cache_section.handle().GetHandle()); | |
747 cmd_line->AppendSwitchASCII( | |
748 switches::kFontCacheSharedHandle, | |
749 base::UintToString(base::win::HandleToUint32(shared_handle))); | |
750 } | |
751 } | 733 } |
752 } | 734 } |
753 #endif | 735 #endif |
754 | 736 |
755 if (type_str != switches::kRendererProcess) { | 737 if (type_str != switches::kRendererProcess) { |
756 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into | 738 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into |
757 // this subprocess. See | 739 // this subprocess. See |
758 // http://code.google.com/p/chromium/issues/detail?id=25580 | 740 // http://code.google.com/p/chromium/issues/detail?id=25580 |
759 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); | 741 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); |
760 } | 742 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 } | 833 } |
852 | 834 |
853 return false; | 835 return false; |
854 } | 836 } |
855 | 837 |
856 bool BrokerAddTargetPeer(HANDLE peer_process) { | 838 bool BrokerAddTargetPeer(HANDLE peer_process) { |
857 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 839 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
858 } | 840 } |
859 | 841 |
860 } // namespace content | 842 } // namespace content |
OLD | NEW |