| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 14 #include "app/win_util.h" | 14 #include "app/win_util.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/environment.h" | 16 #include "base/environment.h" |
| 17 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
| 18 #include "base/nss_util.h" | 18 #include "base/nss_util.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/win_util.h" | 22 #include "base/win/windows_version.h" |
| 23 #include "chrome/browser/browser_list.h" | 23 #include "chrome/browser/browser_list.h" |
| 24 #include "chrome/browser/first_run/first_run.h" | 24 #include "chrome/browser/first_run/first_run.h" |
| 25 #include "chrome/browser/metrics/metrics_service.h" | 25 #include "chrome/browser/metrics/metrics_service.h" |
| 26 #include "chrome/browser/views/uninstall_view.h" | 26 #include "chrome/browser/views/uninstall_view.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/env_vars.h" | 28 #include "chrome/common/env_vars.h" |
| 29 #include "chrome/common/result_codes.h" | 29 #include "chrome/common/result_codes.h" |
| 30 #include "chrome/installer/util/helper.h" | 30 #include "chrome/installer/util/helper.h" |
| 31 #include "chrome/installer/util/install_util.h" | 31 #include "chrome/installer/util/install_util.h" |
| 32 #include "chrome/installer/util/shell_util.h" | 32 #include "chrome/installer/util/shell_util.h" |
| 33 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 35 #include "net/base/winsock_init.h" | 35 #include "net/base/winsock_init.h" |
| 36 #include "net/socket/ssl_client_socket_nss_factory.h" | 36 #include "net/socket/ssl_client_socket_nss_factory.h" |
| 37 #include "views/focus/accelerator_handler.h" | 37 #include "views/focus/accelerator_handler.h" |
| 38 #include "views/window/window.h" | 38 #include "views/window/window.h" |
| 39 | 39 |
| 40 void DidEndMainMessageLoop() { | 40 void DidEndMainMessageLoop() { |
| 41 OleUninitialize(); | 41 OleUninitialize(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void RecordBreakpadStatusUMA(MetricsService* metrics) { | 44 void RecordBreakpadStatusUMA(MetricsService* metrics) { |
| 45 DWORD len = ::GetEnvironmentVariableW( | 45 DWORD len = ::GetEnvironmentVariableW( |
| 46 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); | 46 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); |
| 47 metrics->RecordBreakpadRegistration((len == 0)); | 47 metrics->RecordBreakpadRegistration((len == 0)); |
| 48 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); | 48 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void WarnAboutMinimumSystemRequirements() { | 51 void WarnAboutMinimumSystemRequirements() { |
| 52 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) { | 52 if (base::win::GetVersion() < base::win::VERSION_XP) { |
| 53 // Display a warning message if the user is running chrome on Windows 2000. | 53 // Display a warning message if the user is running chrome on Windows 2000. |
| 54 const std::wstring text = | 54 const std::wstring text = |
| 55 l10n_util::GetString(IDS_UNSUPPORTED_OS_PRE_WIN_XP); | 55 l10n_util::GetString(IDS_UNSUPPORTED_OS_PRE_WIN_XP); |
| 56 const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); | 56 const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); |
| 57 win_util::MessageBox(NULL, text, caption, | 57 win_util::MessageBox(NULL, text, caption, |
| 58 MB_OK | MB_ICONWARNING | MB_TOPMOST); | 58 MB_OK | MB_ICONWARNING | MB_TOPMOST); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 int AskForUninstallConfirmation() { | 62 int AskForUninstallConfirmation() { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); | 141 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // This method handles the --hide-icons and --show-icons command line options | 144 // This method handles the --hide-icons and --show-icons command line options |
| 145 // for chrome that get triggered by Windows from registry entries | 145 // for chrome that get triggered by Windows from registry entries |
| 146 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons | 146 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons |
| 147 // functionality so we just ask the users if they want to uninstall Chrome. | 147 // functionality so we just ask the users if they want to uninstall Chrome. |
| 148 int HandleIconsCommands(const CommandLine &parsed_command_line) { | 148 int HandleIconsCommands(const CommandLine &parsed_command_line) { |
| 149 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { | 149 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { |
| 150 std::wstring cp_applet; | 150 std::wstring cp_applet; |
| 151 win_util::WinVersion version = win_util::GetWinVersion(); | 151 base::win::Version version = base::win::GetVersion(); |
| 152 if (version >= win_util::WINVERSION_VISTA) { | 152 if (version >= base::win::VERSION_VISTA) { |
| 153 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. | 153 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. |
| 154 } else if (version >= win_util::WINVERSION_XP) { | 154 } else if (version >= base::win::VERSION_XP) { |
| 155 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. | 155 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. |
| 156 } else { | 156 } else { |
| 157 return ResultCodes::UNSUPPORTED_PARAM; // Not supported | 157 return ResultCodes::UNSUPPORTED_PARAM; // Not supported |
| 158 } | 158 } |
| 159 | 159 |
| 160 const std::wstring msg = l10n_util::GetStringF(IDS_HIDE_ICONS_NOT_SUPPORTED, | 160 const std::wstring msg = l10n_util::GetStringF(IDS_HIDE_ICONS_NOT_SUPPORTED, |
| 161 cp_applet); | 161 cp_applet); |
| 162 const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); | 162 const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); |
| 163 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; | 163 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; |
| 164 if (IDOK == win_util::MessageBox(NULL, msg, caption, flags)) | 164 if (IDOK == win_util::MessageBox(NULL, msg, caption, flags)) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 base::EnsureNSPRInit(); | 232 base::EnsureNSPRInit(); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 // static | 237 // static |
| 238 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | 238 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( |
| 239 const MainFunctionParams& parameters) { | 239 const MainFunctionParams& parameters) { |
| 240 return new BrowserMainPartsWin(parameters); | 240 return new BrowserMainPartsWin(parameters); |
| 241 } | 241 } |
| OLD | NEW |