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 "chrome/browser/chrome_browser_main_win.h" | 5 #include "chrome/browser/chrome_browser_main_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 int GetMinimumFontSize() { | 78 int GetMinimumFontSize() { |
79 int min_font_size; | 79 int min_font_size; |
80 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), | 80 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), |
81 &min_font_size); | 81 &min_font_size); |
82 return min_font_size; | 82 return min_font_size; |
83 } | 83 } |
84 | 84 |
85 class TranslationDelegate : public installer::TranslationDelegate { | 85 class TranslationDelegate : public installer::TranslationDelegate { |
86 public: | 86 public: |
87 virtual string16 GetLocalizedString(int installer_string_id) OVERRIDE; | 87 virtual base::string16 GetLocalizedString(int installer_string_id) OVERRIDE; |
88 }; | 88 }; |
89 | 89 |
90 bool IsSafeModeStart() { | 90 bool IsSafeModeStart() { |
91 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0; | 91 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0; |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 void ShowCloseBrowserFirstMessageBox() { | 96 void ShowCloseBrowserFirstMessageBox() { |
97 int message_id = IDS_UNINSTALL_CLOSE_APP; | 97 int message_id = IDS_UNINSTALL_CLOSE_APP; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ChromeBrowserMainPartsWin::ChromeBrowserMainPartsWin( | 171 ChromeBrowserMainPartsWin::ChromeBrowserMainPartsWin( |
172 const content::MainFunctionParams& parameters) | 172 const content::MainFunctionParams& parameters) |
173 : ChromeBrowserMainParts(parameters) { | 173 : ChromeBrowserMainParts(parameters) { |
174 MaybeEnableHighResolutionTimeEverywhere(); | 174 MaybeEnableHighResolutionTimeEverywhere(); |
175 if (base::win::IsMetroProcess()) { | 175 if (base::win::IsMetroProcess()) { |
176 typedef const wchar_t* (*GetMetroSwitches)(void); | 176 typedef const wchar_t* (*GetMetroSwitches)(void); |
177 GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>( | 177 GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>( |
178 GetProcAddress(base::win::GetMetroModule(), | 178 GetProcAddress(base::win::GetMetroModule(), |
179 "GetMetroCommandLineSwitches")); | 179 "GetMetroCommandLineSwitches")); |
180 if (metro_switches_proc) { | 180 if (metro_switches_proc) { |
181 string16 metro_switches = (*metro_switches_proc)(); | 181 base::string16 metro_switches = (*metro_switches_proc)(); |
182 if (!metro_switches.empty()) { | 182 if (!metro_switches.empty()) { |
183 CommandLine extra_switches(CommandLine::NO_PROGRAM); | 183 CommandLine extra_switches(CommandLine::NO_PROGRAM); |
184 extra_switches.ParseFromString(metro_switches); | 184 extra_switches.ParseFromString(metro_switches); |
185 CommandLine::ForCurrentProcess()->AppendArguments(extra_switches, | 185 CommandLine::ForCurrentProcess()->AppendArguments(extra_switches, |
186 false); | 186 false); |
187 } | 187 } |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // If the known command-line test options are used we don't create the | 267 // If the known command-line test options are used we don't create the |
268 // environment block which means we don't get the restart dialog. | 268 // environment block which means we don't get the restart dialog. |
269 if (parsed_command_line.HasSwitch(switches::kBrowserCrashTest) || | 269 if (parsed_command_line.HasSwitch(switches::kBrowserCrashTest) || |
270 parsed_command_line.HasSwitch(switches::kBrowserAssertTest) || | 270 parsed_command_line.HasSwitch(switches::kBrowserAssertTest) || |
271 parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) | 271 parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) |
272 return; | 272 return; |
273 | 273 |
274 // The encoding we use for the info is "title|context|direction" where | 274 // The encoding we use for the info is "title|context|direction" where |
275 // direction is either env_vars::kRtlLocale or env_vars::kLtrLocale depending | 275 // direction is either env_vars::kRtlLocale or env_vars::kLtrLocale depending |
276 // on the current locale. | 276 // on the current locale. |
277 string16 dlg_strings(l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_TITLE)); | 277 base::string16 dlg_strings(l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_TITLE)
); |
278 dlg_strings.push_back('|'); | 278 dlg_strings.push_back('|'); |
279 string16 adjusted_string( | 279 base::string16 adjusted_string( |
280 l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_CONTENT)); | 280 l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_CONTENT)); |
281 base::i18n::AdjustStringForLocaleDirection(&adjusted_string); | 281 base::i18n::AdjustStringForLocaleDirection(&adjusted_string); |
282 dlg_strings.append(adjusted_string); | 282 dlg_strings.append(adjusted_string); |
283 dlg_strings.push_back('|'); | 283 dlg_strings.push_back('|'); |
284 dlg_strings.append(ASCIIToUTF16( | 284 dlg_strings.append(ASCIIToUTF16( |
285 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); | 285 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); |
286 | 286 |
287 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); | 287 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); |
288 } | 288 } |
289 | 289 |
(...skipping 29 matching lines...) Expand all Loading... |
319 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr << | 319 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr << |
320 ", command_line: " << command_line.GetCommandLineString(); | 320 ", command_line: " << command_line.GetCommandLineString(); |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 // static | 325 // static |
326 int ChromeBrowserMainPartsWin::HandleIconsCommands( | 326 int ChromeBrowserMainPartsWin::HandleIconsCommands( |
327 const CommandLine& parsed_command_line) { | 327 const CommandLine& parsed_command_line) { |
328 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { | 328 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { |
329 string16 cp_applet; | 329 base::string16 cp_applet; |
330 base::win::Version version = base::win::GetVersion(); | 330 base::win::Version version = base::win::GetVersion(); |
331 if (version >= base::win::VERSION_VISTA) { | 331 if (version >= base::win::VERSION_VISTA) { |
332 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. | 332 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. |
333 } else if (version >= base::win::VERSION_XP) { | 333 } else if (version >= base::win::VERSION_XP) { |
334 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. | 334 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. |
335 } else { | 335 } else { |
336 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported | 336 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported |
337 } | 337 } |
338 | 338 |
339 const string16 msg = | 339 const base::string16 msg = |
340 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet); | 340 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet); |
341 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 341 const base::string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
342 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; | 342 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; |
343 if (IDOK == ui::MessageBox(NULL, msg, caption, flags)) | 343 if (IDOK == ui::MessageBox(NULL, msg, caption, flags)) |
344 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); | 344 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); |
345 | 345 |
346 // Exit as we are not launching the browser. | 346 // Exit as we are not launching the browser. |
347 return content::RESULT_CODE_NORMAL_EXIT; | 347 return content::RESULT_CODE_NORMAL_EXIT; |
348 } | 348 } |
349 // We don't hide icons so we shouldn't do anything special to show them | 349 // We don't hide icons so we shouldn't do anything special to show them |
350 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; | 350 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; |
351 } | 351 } |
(...skipping 10 matching lines...) Expand all Loading... |
362 PathService::Get(base::DIR_EXE, &exe_path); | 362 PathService::Get(base::DIR_EXE, &exe_path); |
363 std::wstring exe = exe_path.value(); | 363 std::wstring exe = exe_path.value(); |
364 base::FilePath user_exe_path(installer::GetChromeInstallPath(false, dist)); | 364 base::FilePath user_exe_path(installer::GetChromeInstallPath(false, dist)); |
365 if (base::FilePath::CompareEqualIgnoreCase(exe, user_exe_path.value())) { | 365 if (base::FilePath::CompareEqualIgnoreCase(exe, user_exe_path.value())) { |
366 bool is_metro = base::win::IsMetroProcess(); | 366 bool is_metro = base::win::IsMetroProcess(); |
367 if (!is_metro) { | 367 if (!is_metro) { |
368 // The dialog cannot be shown in Win8 Metro as doing so hangs Chrome on | 368 // The dialog cannot be shown in Win8 Metro as doing so hangs Chrome on |
369 // an invisible dialog. | 369 // an invisible dialog. |
370 // TODO (gab): Get rid of this dialog altogether and auto-launch | 370 // TODO (gab): Get rid of this dialog altogether and auto-launch |
371 // system-level Chrome instead. | 371 // system-level Chrome instead. |
372 const string16 text = | 372 const base::string16 text = |
373 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); | 373 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); |
374 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 374 const base::string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAM
E); |
375 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; | 375 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; |
376 ui::MessageBox(NULL, text, caption, flags); | 376 ui::MessageBox(NULL, text, caption, flags); |
377 } | 377 } |
378 CommandLine uninstall_cmd( | 378 CommandLine uninstall_cmd( |
379 InstallUtil::GetChromeUninstallCmd(false, dist->GetType())); | 379 InstallUtil::GetChromeUninstallCmd(false, dist->GetType())); |
380 if (!uninstall_cmd.GetProgram().empty()) { | 380 if (!uninstall_cmd.GetProgram().empty()) { |
381 uninstall_cmd.AppendSwitch(installer::switches::kSelfDestruct); | 381 uninstall_cmd.AppendSwitch(installer::switches::kSelfDestruct); |
382 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); | 382 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); |
383 uninstall_cmd.AppendSwitch( | 383 uninstall_cmd.AppendSwitch( |
384 installer::switches::kDoNotRemoveSharedItems); | 384 installer::switches::kDoNotRemoveSharedItems); |
385 | 385 |
386 const base::FilePath setup_exe(uninstall_cmd.GetProgram()); | 386 const base::FilePath setup_exe(uninstall_cmd.GetProgram()); |
387 const string16 params(uninstall_cmd.GetArgumentsString()); | 387 const base::string16 params(uninstall_cmd.GetArgumentsString()); |
388 | 388 |
389 SHELLEXECUTEINFO sei = { sizeof(sei) }; | 389 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
390 sei.fMask = SEE_MASK_NOASYNC; | 390 sei.fMask = SEE_MASK_NOASYNC; |
391 sei.nShow = SW_SHOWNORMAL; | 391 sei.nShow = SW_SHOWNORMAL; |
392 sei.lpFile = setup_exe.value().c_str(); | 392 sei.lpFile = setup_exe.value().c_str(); |
393 sei.lpParameters = params.c_str(); | 393 sei.lpParameters = params.c_str(); |
394 // On Windows 8 SEE_MASK_FLAG_LOG_USAGE is necessary to guarantee we | 394 // On Windows 8 SEE_MASK_FLAG_LOG_USAGE is necessary to guarantee we |
395 // flip to the Desktop when launching. | 395 // flip to the Desktop when launching. |
396 if (is_metro) | 396 if (is_metro) |
397 sei.fMask |= SEE_MASK_FLAG_LOG_USAGE; | 397 sei.fMask |= SEE_MASK_FLAG_LOG_USAGE; |
(...skipping 16 matching lines...) Expand all Loading... |
414 case base_id: \ | 414 case base_id: \ |
415 resource_id = chrome_id; \ | 415 resource_id = chrome_id; \ |
416 break; | 416 break; |
417 DO_INSTALLER_STRING_MAPPING | 417 DO_INSTALLER_STRING_MAPPING |
418 #undef HANDLE_STRING | 418 #undef HANDLE_STRING |
419 default: | 419 default: |
420 NOTREACHED(); | 420 NOTREACHED(); |
421 } | 421 } |
422 if (resource_id) | 422 if (resource_id) |
423 return l10n_util::GetStringUTF16(resource_id); | 423 return l10n_util::GetStringUTF16(resource_id); |
424 return string16(); | 424 return base::string16(); |
425 } | 425 } |
426 | 426 |
427 // static | 427 // static |
428 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { | 428 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { |
429 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); | 429 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); |
430 installer::SetTranslationDelegate(&delegate); | 430 installer::SetTranslationDelegate(&delegate); |
431 } | 431 } |
OLD | NEW |