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" | 5 #include "chrome/browser/browser_main.h" |
6 #include "chrome/browser/browser_main_win.h" | 6 #include "chrome/browser/browser_main_win.h" |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/environment.h" | 14 #include "base/environment.h" |
15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
16 #include "base/nss_util.h" | 16 #include "base/nss_util.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/scoped_native_library.h" | 18 #include "base/scoped_native_library.h" |
19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 #include "base/win/wrapped_window_proc.h" |
22 #include "chrome/browser/browser_list.h" | 23 #include "chrome/browser/browser_list.h" |
23 #include "chrome/browser/first_run/first_run.h" | 24 #include "chrome/browser/first_run/first_run.h" |
24 #include "chrome/browser/metrics/metrics_service.h" | 25 #include "chrome/browser/metrics/metrics_service.h" |
25 #include "chrome/browser/ui/views/uninstall_view.h" | 26 #include "chrome/browser/ui/views/uninstall_view.h" |
| 27 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/env_vars.h" | 29 #include "chrome/common/env_vars.h" |
28 #include "chrome/common/result_codes.h" | 30 #include "chrome/common/result_codes.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 31 #include "chrome/installer/util/browser_distribution.h" |
30 #include "chrome/installer/util/helper.h" | 32 #include "chrome/installer/util/helper.h" |
31 #include "chrome/installer/util/install_util.h" | 33 #include "chrome/installer/util/install_util.h" |
32 #include "chrome/installer/util/shell_util.h" | 34 #include "chrome/installer/util/shell_util.h" |
33 #include "content/common/main_function_params.h" | 35 #include "content/common/main_function_params.h" |
34 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
36 #include "net/base/winsock_init.h" | 38 #include "net/base/winsock_init.h" |
37 #include "net/socket/client_socket_factory.h" | 39 #include "net/socket/client_socket_factory.h" |
38 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/l10n/l10n_util_win.h" | 41 #include "ui/base/l10n/l10n_util_win.h" |
40 #include "ui/base/message_box_win.h" | 42 #include "ui/base/message_box_win.h" |
41 #include "views/focus/accelerator_handler.h" | 43 #include "views/focus/accelerator_handler.h" |
42 #include "views/window/window.h" | 44 #include "views/window/window.h" |
43 | 45 |
44 namespace { | 46 namespace { |
| 47 |
45 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( | 48 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( |
46 const wchar_t* command_line, | 49 const wchar_t* command_line, |
47 DWORD flags); | 50 DWORD flags); |
| 51 |
| 52 void InitializeWindowProcExceptions() { |
| 53 // Get the breakpad pointer from chrome.exe |
| 54 base::win::WinProcExceptionFilter exception_filter = |
| 55 reinterpret_cast<base::win::WinProcExceptionFilter>( |
| 56 ::GetProcAddress(::GetModuleHandle( |
| 57 chrome::kBrowserProcessExecutableName), |
| 58 "CrashForException")); |
| 59 exception_filter = base::win::SetWinProcExceptionFilter(exception_filter); |
| 60 DCHECK(!exception_filter); |
| 61 } |
| 62 |
48 } // namespace | 63 } // namespace |
49 | 64 |
50 void DidEndMainMessageLoop() { | 65 void DidEndMainMessageLoop() { |
51 OleUninitialize(); | 66 OleUninitialize(); |
52 } | 67 } |
53 | 68 |
54 void RecordBreakpadStatusUMA(MetricsService* metrics) { | 69 void RecordBreakpadStatusUMA(MetricsService* metrics) { |
55 DWORD len = ::GetEnvironmentVariableW( | 70 DWORD len = ::GetEnvironmentVariableW( |
56 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); | 71 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); |
57 metrics->RecordBreakpadRegistration((len == 0)); | 72 metrics->RecordBreakpadRegistration((len == 0)); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 272 } |
258 | 273 |
259 virtual void PreMainMessageLoopStart() { | 274 virtual void PreMainMessageLoopStart() { |
260 OleInitialize(NULL); | 275 OleInitialize(NULL); |
261 | 276 |
262 // If we're running tests (ui_task is non-null), then the ResourceBundle | 277 // If we're running tests (ui_task is non-null), then the ResourceBundle |
263 // has already been initialized. | 278 // has already been initialized. |
264 if (!parameters().ui_task) { | 279 if (!parameters().ui_task) { |
265 // Override the configured locale with the user's preferred UI language. | 280 // Override the configured locale with the user's preferred UI language. |
266 l10n_util::OverrideLocaleWithUILanguageList(); | 281 l10n_util::OverrideLocaleWithUILanguageList(); |
| 282 |
| 283 // Make sure that we know how to handle exceptions from the message loop. |
| 284 InitializeWindowProcExceptions(); |
267 } | 285 } |
268 } | 286 } |
269 | 287 |
270 private: | 288 private: |
271 virtual void InitializeSSL() { | 289 virtual void InitializeSSL() { |
272 // Use NSS for SSL by default. | 290 // Use NSS for SSL by default. |
273 // The default client socket factory uses NSS for SSL by default on | 291 // The default client socket factory uses NSS for SSL by default on |
274 // Windows. | 292 // Windows. |
275 if (parsed_command_line().HasSwitch(switches::kUseSystemSSL)) { | 293 if (parsed_command_line().HasSwitch(switches::kUseSystemSSL)) { |
276 net::ClientSocketFactory::UseSystemSSL(); | 294 net::ClientSocketFactory::UseSystemSSL(); |
277 } else { | 295 } else { |
278 // We want to be sure to init NSPR on the main thread. | 296 // We want to be sure to init NSPR on the main thread. |
279 base::EnsureNSPRInit(); | 297 base::EnsureNSPRInit(); |
280 } | 298 } |
281 } | 299 } |
282 }; | 300 }; |
283 | 301 |
284 // static | 302 // static |
285 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | 303 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( |
286 const MainFunctionParams& parameters) { | 304 const MainFunctionParams& parameters) { |
287 return new BrowserMainPartsWin(parameters); | 305 return new BrowserMainPartsWin(parameters); |
288 } | 306 } |
OLD | NEW |