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/public/browser/browser_main_runner.h" | 5 #include "content/public/browser/browser_main_runner.h" |
6 | 6 |
7 #include "base/allocator/allocator_shim.h" | 7 #include "base/allocator/allocator_shim.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "content/browser/browser_main_loop.h" | 15 #include "content/browser/browser_main_loop.h" |
16 #include "content/browser/browser_shutdown_profile_dumper.h" | 16 #include "content/browser/browser_shutdown_profile_dumper.h" |
17 #include "content/browser/notification_service_impl.h" | 17 #include "content/browser/notification_service_impl.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "content/public/common/main_function_params.h" | 19 #include "content/public/common/main_function_params.h" |
20 #include "ui/base/ime/input_method_initializer.h" | 20 #include "ui/base/ime/input_method_initializer.h" |
21 | 21 |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include <dwrite.h> | |
24 #include "base/win/scoped_comptr.h" | |
25 #include "base/win/win_util.h" | 23 #include "base/win/win_util.h" |
26 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
27 #include "net/cert/sha256_legacy_support_win.h" | 25 #include "net/cert/sha256_legacy_support_win.h" |
28 #include "sandbox/win/src/sidestep/preamble_patcher.h" | 26 #include "sandbox/win/src/sidestep/preamble_patcher.h" |
29 #include "skia/ext/fontmgr_default_win.h" | |
30 #include "third_party/skia/include/ports/SkFontMgr.h" | |
31 #include "third_party/skia/include/ports/SkTypeface_win.h" | |
32 #include "ui/base/win/scoped_ole_initializer.h" | 27 #include "ui/base/win/scoped_ole_initializer.h" |
33 #include "ui/gfx/platform_font_win.h" | |
34 #include "ui/gfx/switches.h" | 28 #include "ui/gfx/switches.h" |
35 #include "ui/gfx/win/direct_write.h" | 29 #include "ui/gfx/win/direct_write.h" |
36 #endif | 30 #endif |
37 | 31 |
38 bool g_exited_main_message_loop = false; | 32 bool g_exited_main_message_loop = false; |
39 | 33 |
40 namespace content { | 34 namespace content { |
41 | 35 |
42 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
43 namespace { | 37 namespace { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 105 } |
112 | 106 |
113 DWORD dummy = 0; | 107 DWORD dummy = 0; |
114 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy)); | 108 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy)); |
115 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, | 109 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, |
116 sidestep::kMaxPreambleStubSize, old_protect, | 110 sidestep::kMaxPreambleStubSize, old_protect, |
117 &old_protect)); | 111 &old_protect)); |
118 #endif // _WIN64 | 112 #endif // _WIN64 |
119 } | 113 } |
120 | 114 |
121 void MaybeEnableDirectWriteFontRendering() { | |
122 if (gfx::win::ShouldUseDirectWrite() && | |
123 !CommandLine::ForCurrentProcess()->HasSwitch( | |
124 switches::kDisableDirectWriteForUI) && | |
125 !CommandLine::ForCurrentProcess()->HasSwitch( | |
126 switches::kDisableHarfBuzzRenderText)) { | |
127 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; | |
128 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); | |
129 if (!dwrite_dll) | |
130 return; | |
131 | |
132 DWriteCreateFactoryProc dwrite_create_factory_proc = | |
133 reinterpret_cast<DWriteCreateFactoryProc>( | |
134 GetProcAddress(dwrite_dll, "DWriteCreateFactory")); | |
135 // Not finding the DWriteCreateFactory function indicates a corrupt dll. | |
136 CHECK(dwrite_create_factory_proc); | |
137 | |
138 base::win::ScopedComPtr<IDWriteFactory> factory; | |
139 | |
140 CHECK(SUCCEEDED( | |
141 dwrite_create_factory_proc( | |
142 DWRITE_FACTORY_TYPE_SHARED, | |
143 __uuidof(IDWriteFactory), | |
144 reinterpret_cast<IUnknown**>(factory.Receive())))); | |
145 // The skia call to create a new DirectWrite font manager instance can fail | |
146 // if we are unable to get the system font collection from the DirectWrite | |
147 // factory. The GetSystemFontCollection method in the IDWriteFactory | |
148 // interface fails with E_INVALIDARG on certain Windows 7 gold versions | |
149 // (6.1.7600.*). We should just use GDI in these cases. | |
150 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); | |
151 if (direct_write_font_mgr) { | |
152 SetDefaultSkiaFactory(direct_write_font_mgr); | |
153 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); | |
154 } | |
155 } | |
156 } | |
157 | |
158 } // namespace | 115 } // namespace |
159 | 116 |
160 #endif // OS_WIN | 117 #endif // OS_WIN |
161 | 118 |
162 class BrowserMainRunnerImpl : public BrowserMainRunner { | 119 class BrowserMainRunnerImpl : public BrowserMainRunner { |
163 public: | 120 public: |
164 BrowserMainRunnerImpl() | 121 BrowserMainRunnerImpl() |
165 : initialization_started_(false), is_shutdown_(false) {} | 122 : initialization_started_(false), is_shutdown_(false) {} |
166 | 123 |
167 ~BrowserMainRunnerImpl() override { | 124 ~BrowserMainRunnerImpl() override { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 base::StatisticsRecorder::Initialize(); | 158 base::StatisticsRecorder::Initialize(); |
202 | 159 |
203 notification_service_.reset(new NotificationServiceImpl); | 160 notification_service_.reset(new NotificationServiceImpl); |
204 | 161 |
205 #if defined(OS_WIN) | 162 #if defined(OS_WIN) |
206 // Ole must be initialized before starting message pump, so that TSF | 163 // Ole must be initialized before starting message pump, so that TSF |
207 // (Text Services Framework) module can interact with the message pump | 164 // (Text Services Framework) module can interact with the message pump |
208 // on Windows 8 Metro mode. | 165 // on Windows 8 Metro mode. |
209 ole_initializer_.reset(new ui::ScopedOleInitializer); | 166 ole_initializer_.reset(new ui::ScopedOleInitializer); |
210 // Enable DirectWrite font rendering if needed. | 167 // Enable DirectWrite font rendering if needed. |
211 MaybeEnableDirectWriteFontRendering(); | 168 gfx::win::MaybeInitializeDirectWrite(); |
212 #endif // OS_WIN | 169 #endif // OS_WIN |
213 | 170 |
214 main_loop_.reset(new BrowserMainLoop(parameters)); | 171 main_loop_.reset(new BrowserMainLoop(parameters)); |
215 | 172 |
216 main_loop_->Init(); | 173 main_loop_->Init(); |
217 | 174 |
218 main_loop_->EarlyInitialization(); | 175 main_loop_->EarlyInitialization(); |
219 | 176 |
220 // Must happen before we try to use a message loop or display any UI. | 177 // Must happen before we try to use a message loop or display any UI. |
221 if (!main_loop_->InitializeToolkit()) | 178 if (!main_loop_->InitializeToolkit()) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 286 |
330 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); | 287 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); |
331 }; | 288 }; |
332 | 289 |
333 // static | 290 // static |
334 BrowserMainRunner* BrowserMainRunner::Create() { | 291 BrowserMainRunner* BrowserMainRunner::Create() { |
335 return new BrowserMainRunnerImpl(); | 292 return new BrowserMainRunnerImpl(); |
336 } | 293 } |
337 | 294 |
338 } // namespace content | 295 } // namespace content |
OLD | NEW |