| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 SetJobLevel(*cmd_line, sandbox::JOB_LOCKDOWN, 0, policy); | 702 SetJobLevel(*cmd_line, sandbox::JOB_LOCKDOWN, 0, policy); |
| 703 | 703 |
| 704 bool disable_default_policy = false; | 704 bool disable_default_policy = false; |
| 705 base::FilePath exposed_dir; | 705 base::FilePath exposed_dir; |
| 706 if (delegate) | 706 if (delegate) |
| 707 delegate->PreSandbox(&disable_default_policy, &exposed_dir); | 707 delegate->PreSandbox(&disable_default_policy, &exposed_dir); |
| 708 | 708 |
| 709 if (!disable_default_policy && !AddPolicyForSandboxedProcess(policy)) | 709 if (!disable_default_policy && !AddPolicyForSandboxedProcess(policy)) |
| 710 return base::Process(); | 710 return base::Process(); |
| 711 | 711 |
| 712 if (type_str == switches::kRendererProcess) { | |
| 713 #if !defined(NACL_WIN64) | 712 #if !defined(NACL_WIN64) |
| 713 if (type_str == switches::kRendererProcess || |
| 714 type_str == switches::kPpapiPluginProcess) { |
| 714 if (gfx::win::ShouldUseDirectWrite()) { | 715 if (gfx::win::ShouldUseDirectWrite()) { |
| 715 AddDirectory(base::DIR_WINDOWS_FONTS, | 716 AddDirectory(base::DIR_WINDOWS_FONTS, |
| 716 NULL, | 717 NULL, |
| 717 true, | 718 true, |
| 718 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 719 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
| 719 policy); | 720 policy); |
| 720 | 721 |
| 721 // If DirectWrite is enabled for font rendering then open the font cache | 722 // If DirectWrite is enabled for font rendering then open the font cache |
| 722 // section which is created by the browser and pass the handle to the | 723 // section which is created by the browser and pass the handle to the |
| 723 // renderer process. This is needed because renderer processes on | 724 // renderer process. This is needed because renderer processes on |
| 724 // Windows 8+ may be running in an AppContainer sandbox and hence their | 725 // Windows 8+ may be running in an AppContainer sandbox and hence their |
| 725 // kernel object namespace may be partitioned. | 726 // kernel object namespace may be partitioned. |
| 726 std::string name(content::kFontCacheSharedSectionName); | 727 std::string name(content::kFontCacheSharedSectionName); |
| 727 name.append(base::UintToString(base::GetCurrentProcId())); | 728 name.append(base::UintToString(base::GetCurrentProcId())); |
| 728 | 729 |
| 729 base::SharedMemory direct_write_font_cache_section; | 730 base::SharedMemory direct_write_font_cache_section; |
| 730 if (direct_write_font_cache_section.Open(name, true)) { | 731 if (direct_write_font_cache_section.Open(name, true)) { |
| 731 void* shared_handle = | 732 void* shared_handle = |
| 732 policy->AddHandleToShare(direct_write_font_cache_section.handle()); | 733 policy->AddHandleToShare(direct_write_font_cache_section.handle()); |
| 733 cmd_line->AppendSwitchASCII(switches::kFontCacheSharedHandle, | 734 cmd_line->AppendSwitchASCII(switches::kFontCacheSharedHandle, |
| 734 base::UintToString(reinterpret_cast<unsigned int>(shared_handle))); | 735 base::UintToString(reinterpret_cast<unsigned int>(shared_handle))); |
| 735 } | 736 } |
| 736 } | 737 } |
| 738 } |
| 737 #endif | 739 #endif |
| 738 } else { | 740 |
| 741 if (type_str != switches::kRendererProcess) { |
| 739 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into | 742 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into |
| 740 // this subprocess. See | 743 // this subprocess. See |
| 741 // http://code.google.com/p/chromium/issues/detail?id=25580 | 744 // http://code.google.com/p/chromium/issues/detail?id=25580 |
| 742 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); | 745 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); |
| 743 } | 746 } |
| 744 | 747 |
| 745 sandbox::ResultCode result; | 748 sandbox::ResultCode result; |
| 746 if (!exposed_dir.empty()) { | 749 if (!exposed_dir.empty()) { |
| 747 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 750 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 748 sandbox::TargetPolicy::FILES_ALLOW_ANY, | 751 sandbox::TargetPolicy::FILES_ALLOW_ANY, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 } | 863 } |
| 861 | 864 |
| 862 return false; | 865 return false; |
| 863 } | 866 } |
| 864 | 867 |
| 865 bool BrokerAddTargetPeer(HANDLE peer_process) { | 868 bool BrokerAddTargetPeer(HANDLE peer_process) { |
| 866 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 869 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
| 867 } | 870 } |
| 868 | 871 |
| 869 } // namespace content | 872 } // namespace content |
| OLD | NEW |