Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/chrome_browser_main_win.cc

Issue 2756603002: Print too-long command line (Closed)
Patch Set: Remove now unneeded include Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <shellapi.h> 7 #include <shellapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <windows.h> 10 #include <windows.h>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 dlg_strings.push_back('|'); 418 dlg_strings.push_back('|');
419 dlg_strings.append(base::ASCIIToUTF16( 419 dlg_strings.append(base::ASCIIToUTF16(
420 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); 420 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale));
421 421
422 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings)); 422 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings));
423 } 423 }
424 424
425 // static 425 // static
426 void ChromeBrowserMainPartsWin::RegisterApplicationRestart( 426 void ChromeBrowserMainPartsWin::RegisterApplicationRestart(
427 const base::CommandLine& parsed_command_line) { 427 const base::CommandLine& parsed_command_line) {
428 DCHECK(base::win::GetVersion() >= base::win::VERSION_VISTA);
429 base::ScopedNativeLibrary library(base::FilePath(L"kernel32.dll")); 428 base::ScopedNativeLibrary library(base::FilePath(L"kernel32.dll"));
430 // Get the function pointer for RegisterApplicationRestart. 429 // Get the function pointer for RegisterApplicationRestart.
431 RegisterApplicationRestartProc register_application_restart = 430 RegisterApplicationRestartProc register_application_restart =
432 reinterpret_cast<RegisterApplicationRestartProc>( 431 reinterpret_cast<RegisterApplicationRestartProc>(
433 library.GetFunctionPointer("RegisterApplicationRestart")); 432 library.GetFunctionPointer("RegisterApplicationRestart"));
434 if (!register_application_restart) { 433 if (!register_application_restart) {
435 LOG(WARNING) << "Cannot find RegisterApplicationRestart in kernel32.dll"; 434 LOG(WARNING) << "Cannot find RegisterApplicationRestart in kernel32.dll";
436 return; 435 return;
437 } 436 }
438 // The Windows Restart Manager expects a string of command line flags only, 437 // The Windows Restart Manager expects a string of command line flags only,
439 // without the program. 438 // without the program.
440 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 439 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
441 command_line.AppendArguments(parsed_command_line, false); 440 command_line.AppendArguments(parsed_command_line, false);
442 if (!command_line.HasSwitch(switches::kRestoreLastSession)) 441 if (!command_line.HasSwitch(switches::kRestoreLastSession))
443 command_line.AppendSwitch(switches::kRestoreLastSession); 442 command_line.AppendSwitch(switches::kRestoreLastSession);
444 443
445 // Restart Chrome if the computer is restarted as the result of an update. 444 // Restart Chrome if the computer is restarted as the result of an update.
446 // This could be extended to handle crashes, hangs, and patches. 445 // This could be extended to handle crashes, hangs, and patches.
446 const auto& command_line_string = command_line.GetCommandLineString();
447 HRESULT hr = register_application_restart( 447 HRESULT hr = register_application_restart(
448 command_line.GetCommandLineString().c_str(), 448 command_line_string.c_str(),
449 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH); 449 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH);
450 if (FAILED(hr)) { 450 if (FAILED(hr)) {
451 if (hr == E_INVALIDARG) { 451 if (hr == E_INVALIDARG) {
452 LOG(WARNING) << "Command line too long for RegisterApplicationRestart"; 452 LOG(WARNING) << "Command line too long for RegisterApplicationRestart: "
453 << command_line_string;
453 } else { 454 } else {
454 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr << 455 NOTREACHED() << "RegisterApplicationRestart failed. hr: " << hr
455 ", command_line: " << command_line.GetCommandLineString(); 456 << ", command_line: " << command_line_string;
456 } 457 }
457 } 458 }
458 } 459 }
459 460
460 // static 461 // static
461 int ChromeBrowserMainPartsWin::HandleIconsCommands( 462 int ChromeBrowserMainPartsWin::HandleIconsCommands(
462 const base::CommandLine& parsed_command_line) { 463 const base::CommandLine& parsed_command_line) {
463 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { 464 if (parsed_command_line.HasSwitch(switches::kHideIcons)) {
464 base::string16 cp_applet; 465 base::string16 cp_applet;
465 base::win::Version version = base::win::GetVersion(); 466 base::win::Version version = base::win::GetVersion();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (resource_id) 551 if (resource_id)
551 return l10n_util::GetStringUTF16(resource_id); 552 return l10n_util::GetStringUTF16(resource_id);
552 return base::string16(); 553 return base::string16();
553 } 554 }
554 555
555 // static 556 // static
556 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { 557 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() {
557 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); 558 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ());
558 installer::SetTranslationDelegate(&delegate); 559 installer::SetTranslationDelegate(&delegate);
559 } 560 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698