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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
27 #include "base/win/iat_patch_function.h" | 27 #include "base/win/iat_patch_function.h" |
28 #include "base/win/scoped_handle.h" | 28 #include "base/win/scoped_handle.h" |
29 #include "base/win/scoped_process_information.h" | 29 #include "base/win/scoped_process_information.h" |
30 #include "base/win/win_util.h" | 30 #include "base/win/win_util.h" |
31 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
32 #include "content/common/content_switches_internal.h" | 32 #include "content/common/content_switches_internal.h" |
33 #include "content/public/common/content_client.h" | 33 #include "content/public/common/content_client.h" |
34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
35 #include "content/public/common/dwrite_font_platform_win.h" | |
36 #include "content/public/common/sandbox_init.h" | 35 #include "content/public/common/sandbox_init.h" |
37 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 36 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
38 #include "sandbox/win/src/process_mitigations.h" | 37 #include "sandbox/win/src/process_mitigations.h" |
39 #include "sandbox/win/src/sandbox.h" | 38 #include "sandbox/win/src/sandbox.h" |
40 #include "sandbox/win/src/sandbox_nt_util.h" | 39 #include "sandbox/win/src/sandbox_nt_util.h" |
41 #include "sandbox/win/src/sandbox_policy_base.h" | 40 #include "sandbox/win/src/sandbox_policy_base.h" |
42 #include "sandbox/win/src/win_utils.h" | 41 #include "sandbox/win/src/win_utils.h" |
43 | 42 |
44 #if !defined(NACL_WIN64) | 43 #if !defined(NACL_WIN64) |
45 #include "ui/gfx/win/direct_write.h" // nogncheck: unused #ifdef NACL_WIN64 | 44 #include "ui/gfx/win/direct_write.h" // nogncheck: unused #ifdef NACL_WIN64 |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 // process launch. | 749 // process launch. |
751 base::SharedMemory direct_write_font_cache_section; | 750 base::SharedMemory direct_write_font_cache_section; |
752 if (type_str == switches::kRendererProcess || | 751 if (type_str == switches::kRendererProcess || |
753 type_str == switches::kPpapiPluginProcess) { | 752 type_str == switches::kPpapiPluginProcess) { |
754 if (gfx::win::ShouldUseDirectWrite()) { | 753 if (gfx::win::ShouldUseDirectWrite()) { |
755 AddDirectory(base::DIR_WINDOWS_FONTS, | 754 AddDirectory(base::DIR_WINDOWS_FONTS, |
756 NULL, | 755 NULL, |
757 true, | 756 true, |
758 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 757 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
759 policy); | 758 policy); |
760 | |
761 if (!ShouldUseDirectWriteFontProxyFieldTrial()) { | |
762 // If DirectWrite is enabled for font rendering then open the font | |
763 // cache section which is created by the browser and pass the handle to | |
764 // the renderer process. This is needed because renderer processes on | |
765 // Windows 8+ may be running in an AppContainer sandbox and hence their | |
766 // kernel object namespace may be partitioned. | |
767 std::string name(content::kFontCacheSharedSectionName); | |
768 name.append(base::UintToString(base::GetCurrentProcId())); | |
769 | |
770 if (direct_write_font_cache_section.Open(name, true)) { | |
771 HANDLE handle = direct_write_font_cache_section.handle().GetHandle(); | |
772 policy->AddHandleToShare(handle); | |
773 cmd_line->AppendSwitchASCII( | |
774 switches::kFontCacheSharedHandle, | |
775 base::UintToString(base::win::HandleToUint32(handle))); | |
776 } | |
777 } | |
778 } | 759 } |
779 } | 760 } |
780 #endif | 761 #endif |
781 | 762 |
782 if (type_str != switches::kRendererProcess) { | 763 if (type_str != switches::kRendererProcess) { |
783 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into | 764 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into |
784 // this subprocess. See | 765 // this subprocess. See |
785 // http://code.google.com/p/chromium/issues/detail?id=25580 | 766 // http://code.google.com/p/chromium/issues/detail?id=25580 |
786 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); | 767 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); |
787 } | 768 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 } | 859 } |
879 | 860 |
880 return false; | 861 return false; |
881 } | 862 } |
882 | 863 |
883 bool BrokerAddTargetPeer(HANDLE peer_process) { | 864 bool BrokerAddTargetPeer(HANDLE peer_process) { |
884 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 865 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
885 } | 866 } |
886 | 867 |
887 } // namespace content | 868 } // namespace content |
OLD | NEW |