OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browser_main.h" | |
6 #include "chrome/browser/browser_main_win.h" | 5 #include "chrome/browser/browser_main_win.h" |
7 | 6 |
8 #include <windows.h> | 7 #include <windows.h> |
9 #include <shellapi.h> | 8 #include <shellapi.h> |
10 | 9 |
11 #include <algorithm> | 10 #include <algorithm> |
12 | 11 |
13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
14 #include "base/environment.h" | 13 #include "base/environment.h" |
15 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 base::win::WinProcExceptionFilter exception_filter = | 54 base::win::WinProcExceptionFilter exception_filter = |
56 reinterpret_cast<base::win::WinProcExceptionFilter>( | 55 reinterpret_cast<base::win::WinProcExceptionFilter>( |
57 ::GetProcAddress(::GetModuleHandle( | 56 ::GetProcAddress(::GetModuleHandle( |
58 chrome::kBrowserProcessExecutableName), | 57 chrome::kBrowserProcessExecutableName), |
59 "CrashForException")); | 58 "CrashForException")); |
60 exception_filter = base::win::SetWinProcExceptionFilter(exception_filter); | 59 exception_filter = base::win::SetWinProcExceptionFilter(exception_filter); |
61 DCHECK(!exception_filter); | 60 DCHECK(!exception_filter); |
62 } | 61 } |
63 } // namespace | 62 } // namespace |
64 | 63 |
| 64 namespace content { |
| 65 |
65 void DidEndMainMessageLoop() { | 66 void DidEndMainMessageLoop() { |
66 OleUninitialize(); | 67 OleUninitialize(); |
67 } | 68 } |
68 | 69 |
| 70 } |
| 71 |
69 void RecordBreakpadStatusUMA(MetricsService* metrics) { | 72 void RecordBreakpadStatusUMA(MetricsService* metrics) { |
70 DWORD len = ::GetEnvironmentVariableW( | 73 DWORD len = ::GetEnvironmentVariableW( |
71 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); | 74 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); |
72 metrics->RecordBreakpadRegistration((len == 0)); | 75 metrics->RecordBreakpadRegistration((len == 0)); |
73 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); | 76 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); |
74 } | 77 } |
75 | 78 |
76 void WarnAboutMinimumSystemRequirements() { | 79 void WarnAboutMinimumSystemRequirements() { |
77 if (base::win::GetVersion() < base::win::VERSION_XP) { | 80 if (base::win::GetVersion() < base::win::VERSION_XP) { |
78 // Display a warning message if the user is running chrome on Windows 2000. | 81 // Display a warning message if the user is running chrome on Windows 2000. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); | 276 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); |
274 } | 277 } |
275 return true; | 278 return true; |
276 } | 279 } |
277 } | 280 } |
278 return false; | 281 return false; |
279 } | 282 } |
280 | 283 |
281 // BrowserMainPartsWin --------------------------------------------------------- | 284 // BrowserMainPartsWin --------------------------------------------------------- |
282 | 285 |
283 class BrowserMainPartsWin : public BrowserMainParts { | 286 BrowserMainPartsWin::BrowserMainPartsWin(const MainFunctionParams& parameters) |
284 public: | 287 : ChromeBrowserMainParts(parameters) { |
285 explicit BrowserMainPartsWin(const MainFunctionParams& parameters) | 288 } |
286 : BrowserMainParts(parameters) {} | |
287 | 289 |
288 protected: | 290 void BrowserMainPartsWin::PreEarlyInitialization() { |
289 virtual void PreEarlyInitialization() { | 291 // Initialize Winsock. |
290 // Initialize Winsock. | 292 net::EnsureWinsockInit(); |
291 net::EnsureWinsockInit(); | 293 } |
| 294 |
| 295 void BrowserMainPartsWin::PreMainMessageLoopStart() { |
| 296 OleInitialize(NULL); |
| 297 |
| 298 // If we're running tests (ui_task is non-null), then the ResourceBundle |
| 299 // has already been initialized. |
| 300 if (!parameters().ui_task) { |
| 301 // Override the configured locale with the user's preferred UI language. |
| 302 l10n_util::OverrideLocaleWithUILanguageList(); |
| 303 |
| 304 // Make sure that we know how to handle exceptions from the message loop. |
| 305 InitializeWindowProcExceptions(); |
292 } | 306 } |
| 307 } |
293 | 308 |
294 virtual void PreMainMessageLoopStart() { | 309 void BrowserMainPartsWin::InitializeSSL() { |
295 OleInitialize(NULL); | 310 // Use NSS for SSL by default. |
296 | 311 // The default client socket factory uses NSS for SSL by default on |
297 // If we're running tests (ui_task is non-null), then the ResourceBundle | 312 // Windows. |
298 // has already been initialized. | 313 if (parsed_command_line().HasSwitch(switches::kUseSystemSSL)) { |
299 if (!parameters().ui_task) { | 314 net::ClientSocketFactory::UseSystemSSL(); |
300 // Override the configured locale with the user's preferred UI language. | 315 } else { |
301 l10n_util::OverrideLocaleWithUILanguageList(); | 316 // We want to be sure to init NSPR on the main thread. |
302 | 317 crypto::EnsureNSPRInit(); |
303 // Make sure that we know how to handle exceptions from the message loop. | |
304 InitializeWindowProcExceptions(); | |
305 } | |
306 } | 318 } |
307 | |
308 private: | |
309 virtual void InitializeSSL() { | |
310 // Use NSS for SSL by default. | |
311 // The default client socket factory uses NSS for SSL by default on | |
312 // Windows. | |
313 if (parsed_command_line().HasSwitch(switches::kUseSystemSSL)) { | |
314 net::ClientSocketFactory::UseSystemSSL(); | |
315 } else { | |
316 // We want to be sure to init NSPR on the main thread. | |
317 crypto::EnsureNSPRInit(); | |
318 } | |
319 } | |
320 }; | |
321 | |
322 // static | |
323 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | |
324 const MainFunctionParams& parameters) { | |
325 return new BrowserMainPartsWin(parameters); | |
326 } | 319 } |
OLD | NEW |