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