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

Unified Diff: chrome/renderer/renderer_main_platform_delegate_win.cc

Issue 113190: Add support for alternate window station. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | sandbox/sandbox.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/renderer_main_platform_delegate_win.cc
===================================================================
--- chrome/renderer/renderer_main_platform_delegate_win.cc (revision 16307)
+++ chrome/renderer/renderer_main_platform_delegate_win.cc (working copy)
@@ -18,15 +18,46 @@
// can be done with OpenThemeData() but it fails unless you pass a valid
// window at least the first time. Interestingly, the very act of creating a
// window also sets the connection to the theme service.
-void EnableThemeSupportForRenderer() {
+void EnableThemeSupportForRenderer(bool no_sandbox) {
+ HWINSTA current = NULL;
+ HWINSTA winsta0 = NULL;
+
+ if (!no_sandbox) {
+ current = ::GetProcessWindowStation();
+ winsta0 = ::OpenWindowStationW(L"WinSta0", FALSE, GENERIC_READ);
+ if (!winsta0 || !::SetProcessWindowStation(winsta0)) {
+ // Could not set the alternate window station. There is a possibility
+ // that the theme wont be correctly initialized on XP.
+ NOTREACHED();
rvargas (doing something else) 2009/05/20 01:21:01 nit: could add a log message here?
+ }
+ }
+
+ // Create a windows on the WinSta0 to initialize theme support.
cpu_(ooo_6.6-7.5) 2009/05/20 01:51:22 don't need the comment, see lines 16-20.
HWND window = ::CreateWindowExW(0, L"Static", L"", WS_POPUP | WS_DISABLED,
CW_USEDEFAULT, 0, 0, 0, HWND_MESSAGE, NULL,
::GetModuleHandleA(NULL), NULL);
+ ::DestroyWindow(window);
rvargas (doing something else) 2009/05/20 01:21:01 nit: could you move the !window check here?
+
+ if (!no_sandbox) {
+ // Revert the window station.
+ if (!current || !::SetProcessWindowStation(current)) {
+ // We failed to switch back to the secure window station. This might
+ // confuse the renderer enough that we should kill it now.
+ CHECK(false) << "Failed to restore alternate window station";
+ }
+
+ if (!CloseWindowStation(winsta0)) {
cpu_(ooo_6.6-7.5) 2009/05/20 01:51:22 it seems the style here is :: for windows calls
+ // We might be leaking a winsta0 handle. This is a security risk, but
+ // since we allow fail over to no desktop protection in low memory
+ // condition, this is not a big risk.
+ NOTREACHED();
+ }
+ }
+
if (!window) {
DLOG(WARNING) << "failed to enable theme support";
return;
}
- ::DestroyWindow(window);
}
} // namespace
@@ -43,7 +74,9 @@
void RendererMainPlatformDelegate::PlatformInitialize() {
// Be mindful of what resources you acquire here. They can be used by
// malicious code if the renderer gets compromised.
- EnableThemeSupportForRenderer();
+ const CommandLine& command_line = parameters_.command_line_;
+ bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
+ EnableThemeSupportForRenderer(no_sandbox);
}
void RendererMainPlatformDelegate::PlatformUninitialize() {
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | sandbox/sandbox.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698