| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const content::MainFunctionParams& parameters) | 174 const content::MainFunctionParams& parameters) |
| 175 : ChromeBrowserMainParts(parameters) { | 175 : ChromeBrowserMainParts(parameters) { |
| 176 if (base::win::IsMetroProcess()) { | 176 if (base::win::IsMetroProcess()) { |
| 177 typedef const wchar_t* (*GetMetroSwitches)(void); | 177 typedef const wchar_t* (*GetMetroSwitches)(void); |
| 178 GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>( | 178 GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>( |
| 179 GetProcAddress(base::win::GetMetroModule(), | 179 GetProcAddress(base::win::GetMetroModule(), |
| 180 "GetMetroCommandLineSwitches")); | 180 "GetMetroCommandLineSwitches")); |
| 181 if (metro_switches_proc) { | 181 if (metro_switches_proc) { |
| 182 base::string16 metro_switches = (*metro_switches_proc)(); | 182 base::string16 metro_switches = (*metro_switches_proc)(); |
| 183 if (!metro_switches.empty()) { | 183 if (!metro_switches.empty()) { |
| 184 CommandLine extra_switches(CommandLine::NO_PROGRAM); | 184 base::CommandLine extra_switches(base::CommandLine::NO_PROGRAM); |
| 185 extra_switches.ParseFromString(metro_switches); | 185 extra_switches.ParseFromString(metro_switches); |
| 186 CommandLine::ForCurrentProcess()->AppendArguments(extra_switches, | 186 base::CommandLine::ForCurrentProcess()->AppendArguments(extra_switches, |
| 187 false); | 187 false); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 ChromeBrowserMainPartsWin::~ChromeBrowserMainPartsWin() { | 193 ChromeBrowserMainPartsWin::~ChromeBrowserMainPartsWin() { |
| 194 } | 194 } |
| 195 | 195 |
| 196 void ChromeBrowserMainPartsWin::ToolkitInitialized() { | 196 void ChromeBrowserMainPartsWin::ToolkitInitialized() { |
| 197 ChromeBrowserMainParts::ToolkitInitialized(); | 197 ChromeBrowserMainParts::ToolkitInitialized(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // functions in the kernel (win32k.sys). If we are on Windows 8+ and if | 232 // functions in the kernel (win32k.sys). If we are on Windows 8+ and if |
| 233 // we are launched with the kEnableWin32kRendererLockDown switch then we | 233 // we are launched with the kEnableWin32kRendererLockDown switch then we |
| 234 // force the PDF pepper plugin to run out of process. This is because the | 234 // force the PDF pepper plugin to run out of process. This is because the |
| 235 // PDF plugin uses GDI for text rendering which does not work in the | 235 // PDF plugin uses GDI for text rendering which does not work in the |
| 236 // Win32K lockdown mode. Running it out of process ensures that the process | 236 // Win32K lockdown mode. Running it out of process ensures that the process |
| 237 // launched for the plugin does not have the Win32K lockdown mode enabled. | 237 // launched for the plugin does not have the Win32K lockdown mode enabled. |
| 238 // TODO(ananta) | 238 // TODO(ananta) |
| 239 // Revisit this when the pdf plugin uses skia and stops using GDI. | 239 // Revisit this when the pdf plugin uses skia and stops using GDI. |
| 240 if (switches::IsWin32kRendererLockdownEnabled() && | 240 if (switches::IsWin32kRendererLockdownEnabled() && |
| 241 base::win::GetVersion() >= base::win::VERSION_WIN8) { | 241 base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 242 CommandLine::ForCurrentProcess()->AppendSwitch( | 242 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 243 switches::kEnableOutOfProcessPdf); | 243 switches::kEnableOutOfProcessPdf); |
| 244 } | 244 } |
| 245 return rv; | 245 return rv; |
| 246 } | 246 } |
| 247 | 247 |
| 248 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { | 248 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { |
| 249 ui::MessageBox(NULL, | 249 ui::MessageBox(NULL, |
| 250 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), | 250 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), |
| 251 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), | 251 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), |
| 252 MB_OK | MB_ICONERROR | MB_TOPMOST); | 252 MB_OK | MB_ICONERROR | MB_TOPMOST); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // September 2014. | 291 // September 2014. |
| 292 InitializeDisableTerminateOnHeapCorruptionExperiment(); | 292 InitializeDisableTerminateOnHeapCorruptionExperiment(); |
| 293 | 293 |
| 294 #if defined(GOOGLE_CHROME_BUILD) | 294 #if defined(GOOGLE_CHROME_BUILD) |
| 295 did_run_updater_.reset(new DidRunUpdater); | 295 did_run_updater_.reset(new DidRunUpdater); |
| 296 #endif | 296 #endif |
| 297 } | 297 } |
| 298 | 298 |
| 299 // static | 299 // static |
| 300 void ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( | 300 void ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( |
| 301 const CommandLine& parsed_command_line) { | 301 const base::CommandLine& parsed_command_line) { |
| 302 // Clear this var so child processes don't show the dialog by default. | 302 // Clear this var so child processes don't show the dialog by default. |
| 303 scoped_ptr<base::Environment> env(base::Environment::Create()); | 303 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 304 env->UnSetVar(env_vars::kShowRestart); | 304 env->UnSetVar(env_vars::kShowRestart); |
| 305 | 305 |
| 306 // For non-interactive tests we don't restart on crash. | 306 // For non-interactive tests we don't restart on crash. |
| 307 if (env->HasVar(env_vars::kHeadless)) | 307 if (env->HasVar(env_vars::kHeadless)) |
| 308 return; | 308 return; |
| 309 | 309 |
| 310 // If the known command-line test options are used we don't create the | 310 // If the known command-line test options are used we don't create the |
| 311 // environment block which means we don't get the restart dialog. | 311 // environment block which means we don't get the restart dialog. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 325 dlg_strings.append(adjusted_string); | 325 dlg_strings.append(adjusted_string); |
| 326 dlg_strings.push_back('|'); | 326 dlg_strings.push_back('|'); |
| 327 dlg_strings.append(base::ASCIIToUTF16( | 327 dlg_strings.append(base::ASCIIToUTF16( |
| 328 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); | 328 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); |
| 329 | 329 |
| 330 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings)); | 330 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // static | 333 // static |
| 334 void ChromeBrowserMainPartsWin::RegisterApplicationRestart( | 334 void ChromeBrowserMainPartsWin::RegisterApplicationRestart( |
| 335 const CommandLine& parsed_command_line) { | 335 const base::CommandLine& parsed_command_line) { |
| 336 DCHECK(base::win::GetVersion() >= base::win::VERSION_VISTA); | 336 DCHECK(base::win::GetVersion() >= base::win::VERSION_VISTA); |
| 337 base::ScopedNativeLibrary library(base::FilePath(L"kernel32.dll")); | 337 base::ScopedNativeLibrary library(base::FilePath(L"kernel32.dll")); |
| 338 // Get the function pointer for RegisterApplicationRestart. | 338 // Get the function pointer for RegisterApplicationRestart. |
| 339 RegisterApplicationRestartProc register_application_restart = | 339 RegisterApplicationRestartProc register_application_restart = |
| 340 reinterpret_cast<RegisterApplicationRestartProc>( | 340 reinterpret_cast<RegisterApplicationRestartProc>( |
| 341 library.GetFunctionPointer("RegisterApplicationRestart")); | 341 library.GetFunctionPointer("RegisterApplicationRestart")); |
| 342 if (!register_application_restart) { | 342 if (!register_application_restart) { |
| 343 LOG(WARNING) << "Cannot find RegisterApplicationRestart in kernel32.dll"; | 343 LOG(WARNING) << "Cannot find RegisterApplicationRestart in kernel32.dll"; |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 // The Windows Restart Manager expects a string of command line flags only, | 346 // The Windows Restart Manager expects a string of command line flags only, |
| 347 // without the program. | 347 // without the program. |
| 348 CommandLine command_line(CommandLine::NO_PROGRAM); | 348 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 349 command_line.AppendArguments(parsed_command_line, false); | 349 command_line.AppendArguments(parsed_command_line, false); |
| 350 if (!command_line.HasSwitch(switches::kRestoreLastSession)) | 350 if (!command_line.HasSwitch(switches::kRestoreLastSession)) |
| 351 command_line.AppendSwitch(switches::kRestoreLastSession); | 351 command_line.AppendSwitch(switches::kRestoreLastSession); |
| 352 | 352 |
| 353 // Restart Chrome if the computer is restarted as the result of an update. | 353 // Restart Chrome if the computer is restarted as the result of an update. |
| 354 // This could be extended to handle crashes, hangs, and patches. | 354 // This could be extended to handle crashes, hangs, and patches. |
| 355 HRESULT hr = register_application_restart( | 355 HRESULT hr = register_application_restart( |
| 356 command_line.GetCommandLineString().c_str(), | 356 command_line.GetCommandLineString().c_str(), |
| 357 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH); | 357 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH); |
| 358 if (FAILED(hr)) { | 358 if (FAILED(hr)) { |
| 359 if (hr == E_INVALIDARG) { | 359 if (hr == E_INVALIDARG) { |
| 360 LOG(WARNING) << "Command line too long for RegisterApplicationRestart"; | 360 LOG(WARNING) << "Command line too long for RegisterApplicationRestart"; |
| 361 } else { | 361 } else { |
| 362 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr << | 362 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr << |
| 363 ", command_line: " << command_line.GetCommandLineString(); | 363 ", command_line: " << command_line.GetCommandLineString(); |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 // static | 368 // static |
| 369 int ChromeBrowserMainPartsWin::HandleIconsCommands( | 369 int ChromeBrowserMainPartsWin::HandleIconsCommands( |
| 370 const CommandLine& parsed_command_line) { | 370 const base::CommandLine& parsed_command_line) { |
| 371 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { | 371 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { |
| 372 base::string16 cp_applet; | 372 base::string16 cp_applet; |
| 373 base::win::Version version = base::win::GetVersion(); | 373 base::win::Version version = base::win::GetVersion(); |
| 374 if (version >= base::win::VERSION_VISTA) { | 374 if (version >= base::win::VERSION_VISTA) { |
| 375 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. | 375 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. |
| 376 } else if (version >= base::win::VERSION_XP) { | 376 } else if (version >= base::win::VERSION_XP) { |
| 377 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. | 377 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. |
| 378 } else { | 378 } else { |
| 379 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported | 379 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported |
| 380 } | 380 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 411 // The dialog cannot be shown in Win8 Metro as doing so hangs Chrome on | 411 // The dialog cannot be shown in Win8 Metro as doing so hangs Chrome on |
| 412 // an invisible dialog. | 412 // an invisible dialog. |
| 413 // TODO (gab): Get rid of this dialog altogether and auto-launch | 413 // TODO (gab): Get rid of this dialog altogether and auto-launch |
| 414 // system-level Chrome instead. | 414 // system-level Chrome instead. |
| 415 const base::string16 text = | 415 const base::string16 text = |
| 416 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); | 416 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); |
| 417 const base::string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAM
E); | 417 const base::string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAM
E); |
| 418 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; | 418 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; |
| 419 ui::MessageBox(NULL, text, caption, flags); | 419 ui::MessageBox(NULL, text, caption, flags); |
| 420 } | 420 } |
| 421 CommandLine uninstall_cmd( | 421 base::CommandLine uninstall_cmd( |
| 422 InstallUtil::GetChromeUninstallCmd(false, dist->GetType())); | 422 InstallUtil::GetChromeUninstallCmd(false, dist->GetType())); |
| 423 if (!uninstall_cmd.GetProgram().empty()) { | 423 if (!uninstall_cmd.GetProgram().empty()) { |
| 424 uninstall_cmd.AppendSwitch(installer::switches::kSelfDestruct); | 424 uninstall_cmd.AppendSwitch(installer::switches::kSelfDestruct); |
| 425 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); | 425 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); |
| 426 uninstall_cmd.AppendSwitch( | 426 uninstall_cmd.AppendSwitch( |
| 427 installer::switches::kDoNotRemoveSharedItems); | 427 installer::switches::kDoNotRemoveSharedItems); |
| 428 | 428 |
| 429 // Trigger Active Setup for the system-level Chrome to make sure | 429 // Trigger Active Setup for the system-level Chrome to make sure |
| 430 // per-user shortcuts to the system-level Chrome are created. Skip this | 430 // per-user shortcuts to the system-level Chrome are created. Skip this |
| 431 // if the system-level Chrome will undergo first run anyway, as Active | 431 // if the system-level Chrome will undergo first run anyway, as Active |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 if (resource_id) | 476 if (resource_id) |
| 477 return l10n_util::GetStringUTF16(resource_id); | 477 return l10n_util::GetStringUTF16(resource_id); |
| 478 return base::string16(); | 478 return base::string16(); |
| 479 } | 479 } |
| 480 | 480 |
| 481 // static | 481 // static |
| 482 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { | 482 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { |
| 483 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); | 483 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); |
| 484 installer::SetTranslationDelegate(&delegate); | 484 installer::SetTranslationDelegate(&delegate); |
| 485 } | 485 } |
| OLD | NEW |