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

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

Issue 1122163002: Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with AppContainer prote… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to tip Created 5 years, 7 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
« no previous file with comments | « content/common/dwrite_font_platform_win.cc ('k') | content/public/common/content_switches.h » ('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/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/hash.h" 13 #include "base/hash.h"
14 #include "base/memory/shared_memory.h"
14 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.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"
18 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
19 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
20 #include "base/win/iat_patch_function.h" 22 #include "base/win/iat_patch_function.h"
21 #include "base/win/scoped_handle.h" 23 #include "base/win/scoped_handle.h"
22 #include "base/win/scoped_process_information.h" 24 #include "base/win/scoped_process_information.h"
23 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
24 #include "content/common/content_switches_internal.h" 26 #include "content/common/content_switches_internal.h"
25 #include "content/public/common/content_client.h" 27 #include "content/public/common/content_client.h"
26 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
29 #include "content/public/common/dwrite_font_platform_win.h"
27 #include "content/public/common/sandbox_init.h" 30 #include "content/public/common/sandbox_init.h"
28 #include "content/public/common/sandboxed_process_launcher_delegate.h" 31 #include "content/public/common/sandboxed_process_launcher_delegate.h"
29 #include "sandbox/win/src/process_mitigations.h" 32 #include "sandbox/win/src/process_mitigations.h"
30 #include "sandbox/win/src/sandbox.h" 33 #include "sandbox/win/src/sandbox.h"
31 #include "sandbox/win/src/sandbox_nt_util.h" 34 #include "sandbox/win/src/sandbox_nt_util.h"
32 #include "sandbox/win/src/sandbox_policy_base.h" 35 #include "sandbox/win/src/sandbox_policy_base.h"
33 #include "sandbox/win/src/win_utils.h" 36 #include "sandbox/win/src/win_utils.h"
34 #include "ui/gfx/win/direct_write.h" 37 #include "ui/gfx/win/direct_write.h"
35 38
36 static sandbox::BrokerServices* g_broker_services = NULL; 39 static sandbox::BrokerServices* g_broker_services = NULL;
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 return base::Process(); 673 return base::Process();
671 674
672 if (type_str == switches::kRendererProcess) { 675 if (type_str == switches::kRendererProcess) {
673 #if !defined(NACL_WIN64) 676 #if !defined(NACL_WIN64)
674 if (gfx::win::ShouldUseDirectWrite()) { 677 if (gfx::win::ShouldUseDirectWrite()) {
675 AddDirectory(base::DIR_WINDOWS_FONTS, 678 AddDirectory(base::DIR_WINDOWS_FONTS,
676 NULL, 679 NULL,
677 true, 680 true,
678 sandbox::TargetPolicy::FILES_ALLOW_READONLY, 681 sandbox::TargetPolicy::FILES_ALLOW_READONLY,
679 policy); 682 policy);
683
684 // If DirectWrite is enabled for font rendering then open the font cache
685 // section which is created by the browser and pass the handle to the
686 // renderer process. This is needed because renderer processes on
687 // Windows 8+ may be running in an AppContainer sandbox and hence their
688 // kernel object namespace may be partitioned.
689 std::string name(content::kFontCacheSharedSectionName);
690 name.append(base::UintToString(base::GetCurrentProcId()));
691
692 base::SharedMemory direct_write_font_cache_section;
693 if (direct_write_font_cache_section.Open(name, true)) {
694 void* shared_handle =
695 policy->AddHandleToShare(direct_write_font_cache_section.handle());
696 cmd_line->AppendSwitchASCII(switches::kFontCacheSharedHandle,
697 base::UintToString(reinterpret_cast<unsigned int>(shared_handle)));
698 }
680 } 699 }
681 #endif 700 #endif
682 } else { 701 } else {
683 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into 702 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into
684 // this subprocess. See 703 // this subprocess. See
685 // http://code.google.com/p/chromium/issues/detail?id=25580 704 // http://code.google.com/p/chromium/issues/detail?id=25580
686 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); 705 cmd_line->AppendSwitchASCII("ignored", " --type=renderer ");
687 } 706 }
688 707
689 sandbox::ResultCode result; 708 sandbox::ResultCode result;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 812 }
794 813
795 return false; 814 return false;
796 } 815 }
797 816
798 bool BrokerAddTargetPeer(HANDLE peer_process) { 817 bool BrokerAddTargetPeer(HANDLE peer_process) {
799 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 818 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
800 } 819 }
801 820
802 } // namespace content 821 } // namespace content
OLDNEW
« no previous file with comments | « content/common/dwrite_font_platform_win.cc ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698