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

Side by Side Diff: content/app/content_main_runner.cc

Issue 10914119: Prime the Windows theme DLL earlier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using InputDesktop instead Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/renderer_main_platform_delegate_win.cc » ('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/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/debugger.h" 12 #include "base/debug/debugger.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/i18n/icu_util.h" 15 #include "base/i18n/icu_util.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/metrics/stats_table.h" 19 #include "base/metrics/stats_table.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/profiler/alternate_timer.h" 22 #include "base/profiler/alternate_timer.h"
23 #include "base/string_util.h"
23 #include "base/stringprintf.h" 24 #include "base/stringprintf.h"
24 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
25 #include "content/browser/browser_main.h" 26 #include "content/browser/browser_main.h"
26 #include "content/common/set_process_title.h" 27 #include "content/common/set_process_title.h"
27 #include "content/common/url_schemes.h" 28 #include "content/common/url_schemes.h"
28 #include "content/public/app/content_main_delegate.h" 29 #include "content/public/app/content_main_delegate.h"
29 #include "content/public/app/startup_helper_win.h" 30 #include "content/public/app/startup_helper_win.h"
30 #include "content/public/browser/content_browser_client.h" 31 #include "content/public/browser/content_browser_client.h"
31 #include "content/public/common/content_client.h" 32 #include "content/public/common/content_client.h"
32 #include "content/public/common/content_constants.h" 33 #include "content/public/common/content_constants.h"
(...skipping 15 matching lines...) Expand all
48 49
49 #if defined(USE_TCMALLOC) 50 #if defined(USE_TCMALLOC)
50 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" 51 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
51 #endif 52 #endif
52 53
53 #if defined(OS_WIN) 54 #if defined(OS_WIN)
54 #include <cstring> 55 #include <cstring>
55 #include <atlbase.h> 56 #include <atlbase.h>
56 #include <atlapp.h> 57 #include <atlapp.h>
57 #include <malloc.h> 58 #include <malloc.h>
59 #include <string>
jam 2012/09/12 00:36:05 nit: this is very redundant, no need to add
MAD 2012/09/12 02:10:02 Done.
58 #elif defined(OS_MACOSX) 60 #elif defined(OS_MACOSX)
59 #include "base/mac/scoped_nsautorelease_pool.h" 61 #include "base/mac/scoped_nsautorelease_pool.h"
60 #include "base/mach_ipc_mac.h" 62 #include "base/mach_ipc_mac.h"
61 #include "base/system_monitor/system_monitor.h" 63 #include "base/system_monitor/system_monitor.h"
62 #include "content/browser/mach_broker_mac.h" 64 #include "content/browser/mach_broker_mac.h"
63 #include "content/common/sandbox_init_mac.h" 65 #include "content/common/sandbox_init_mac.h"
64 #endif // OS_WIN 66 #endif // OS_WIN
65 67
66 #if defined(OS_POSIX) 68 #if defined(OS_POSIX)
67 #include <signal.h> 69 #include <signal.h>
(...skipping 20 matching lines...) Expand all
88 extern int RendererMain(const content::MainFunctionParams&); 90 extern int RendererMain(const content::MainFunctionParams&);
89 extern int WorkerMain(const content::MainFunctionParams&); 91 extern int WorkerMain(const content::MainFunctionParams&);
90 extern int UtilityMain(const content::MainFunctionParams&); 92 extern int UtilityMain(const content::MainFunctionParams&);
91 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 93 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
92 namespace content { 94 namespace content {
93 extern int ZygoteMain(const MainFunctionParams&, 95 extern int ZygoteMain(const MainFunctionParams&,
94 ZygoteForkDelegate* forkdelegate); 96 ZygoteForkDelegate* forkdelegate);
95 } // namespace content 97 } // namespace content
96 #endif 98 #endif
97 99
100 namespace {
101 #if defined(OS_WIN)
102 // In order to have Theme support, we need to connect to the theme service.
103 // This needs to be done before we lock down the renderer. Officially this
jam 2012/09/12 00:36:05 renderer->process to make it generic, now that thi
MAD 2012/09/12 02:10:02 Done.
104 // can be done with OpenThemeData() but it fails unless you pass a valid
105 // window at least the first time. Interestingly, the very act of creating a
106 // window also sets the connection to the theme service.
107 void EnableThemeSupportOnAllWindowStations() {
108 HDESK desktop_handle = ::OpenInputDesktop(0, FALSE, READ_CONTROL);
109 if (desktop_handle) {
110 // This means we are running in an input desktop, which implies WinSta0.
111 ::CloseDesktop(desktop_handle);
112 return;
113 }
114
115 HWINSTA current_station = ::GetProcessWindowStation();
116 DCHECK(current_station);
117
118 HWINSTA winsta0 = ::OpenWindowStationA("WinSta0", FALSE, GENERIC_READ);
119 if (!winsta0 || !::SetProcessWindowStation(winsta0)) {
120 // Could not set the alternate window station. There is a possibility
121 // that the theme wont be correctly initialized.
122 NOTREACHED() << "Unable to switch to WinSta0, we: "<< ::GetLastError();
123 }
124
125 HWND window = ::CreateWindowExW(0, L"Static", L"", WS_POPUP | WS_DISABLED,
126 CW_USEDEFAULT, 0, 0, 0, HWND_MESSAGE, NULL,
127 ::GetModuleHandleA(NULL), NULL);
128 if (!window) {
129 DLOG(WARNING) << "failed to enable theme support";
130 } else {
131 ::DestroyWindow(window);
132 window = NULL;
133 }
134
135 // Revert the window station.
136 if (!::SetProcessWindowStation(current_station)) {
137 // We failed to switch back to the secure window station. This might
138 // confuse the renderer enough that we should kill it now.
jam 2012/09/12 00:36:05 ditto
MAD 2012/09/12 02:10:02 Done.
139 LOG(FATAL) << "Failed to restore alternate window station";
140 }
141
142 if (!::CloseWindowStation(winsta0)) {
143 // We might be leaking a winsta0 handle. This is a security risk, but
144 // since we allow fail over to no desktop protection in low memory
145 // condition, this is not a big risk.
146 NOTREACHED();
147 }
148 }
149 #endif // defined(OS_WIN)
150 } // namespace
151
98 namespace content { 152 namespace content {
99 153
100 base::LazyInstance<ContentBrowserClient> 154 base::LazyInstance<ContentBrowserClient>
101 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 155 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
102 base::LazyInstance<ContentPluginClient> 156 base::LazyInstance<ContentPluginClient>
103 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; 157 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER;
104 base::LazyInstance<ContentRendererClient> 158 base::LazyInstance<ContentRendererClient>
105 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; 159 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
106 base::LazyInstance<ContentUtilityClient> 160 base::LazyInstance<ContentUtilityClient>
107 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; 161 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 (delegate && 610 (delegate &&
557 delegate->ProcessRegistersWithSystemProcess(process_type))) { 611 delegate->ProcessRegistersWithSystemProcess(process_type))) {
558 base::SystemMonitor::AllocateSystemIOPorts(); 612 base::SystemMonitor::AllocateSystemIOPorts();
559 } 613 }
560 614
561 if (!process_type.empty() && 615 if (!process_type.empty() &&
562 (!delegate || delegate->ShouldSendMachPort(process_type))) { 616 (!delegate || delegate->ShouldSendMachPort(process_type))) {
563 SendTaskPortToParentProcess(); 617 SendTaskPortToParentProcess();
564 } 618 }
565 #elif defined(OS_WIN) 619 #elif defined(OS_WIN)
620 // This must be done early enough since some helper functions like
621 // IsTouchEnanbled, needed to load resources, may call into the theme dll.
622 EnableThemeSupportOnAllWindowStations();
566 #if defined(ENABLE_HIDPI) 623 #if defined(ENABLE_HIDPI)
567 ui::EnableHighDPISupport(); 624 ui::EnableHighDPISupport();
568 #endif 625 #endif
569 SetupCRT(command_line); 626 SetupCRT(command_line);
570 #endif 627 #endif
571 628
572 #if defined(OS_POSIX) 629 #if defined(OS_POSIX)
573 if (!process_type.empty()) { 630 if (!process_type.empty()) {
574 // When you hit Ctrl-C in a terminal running the browser 631 // When you hit Ctrl-C in a terminal running the browser
575 // process, a SIGINT is delivered to the entire process group. 632 // process, a SIGINT is delivered to the entire process group.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 766
710 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 767 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
711 }; 768 };
712 769
713 // static 770 // static
714 ContentMainRunner* ContentMainRunner::Create() { 771 ContentMainRunner* ContentMainRunner::Create() {
715 return new ContentMainRunnerImpl(); 772 return new ContentMainRunnerImpl();
716 } 773 }
717 774
718 } // namespace content 775 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/renderer_main_platform_delegate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698