From b6975b9f4c1495fded60654aa96b1d544ec22a7b Mon Sep 17 00:00:00 2001 From: "simon.hong81@gmail.com" Date: Sat, 3 Nov 2012 02:37:45 +0000 Subject: [PATCH] Add more conditions to reload when --reload-killed-tab option is used. BUG=NONE TEST=compiles Review URL: https://chromiumcodereview.appspot.com/11342055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165831 0039d316-1c4b-4281-b951-d872f2087c98 --- AUTHORS | 2 +- chrome/browser/ui/browser.cc | 38 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/AUTHORS b/AUTHORS index b69669561ed65b..be9a6d3d92cf90 100644 --- a/AUTHORS +++ b/AUTHORS @@ -157,7 +157,7 @@ Clinton Staley Devlin Cronin Junmin Zhu Cem Kocagil -Simon Hong +YoungKi Hong Lu Guanqun François Beaufort Eriq Augustine diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index ce7a5dc2a49086..8d541fb08b5cee 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -246,6 +246,17 @@ chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_NATIVE; #endif +bool ShouldReloadCrashedTab(WebContents* contents) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (!command_line.HasSwitch(switches::kReloadKilledTabs)) + return false; + + base::TerminationStatus crashed_status = contents->GetCrashedStatus(); + + return crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || + crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || + crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED; +} } // namespace @@ -645,13 +656,8 @@ void Browser::OnWindowActivated() { // On some platforms we want to automatically reload tabs that are // killed when the user selects them. WebContents* contents = chrome::GetActiveWebContents(this); - if (contents && contents->GetCrashedStatus() == - base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kReloadKilledTabs)) { - chrome::Reload(this, CURRENT_TAB); - } - } + if (contents && ShouldReloadCrashedTab(contents)) + chrome::Reload(this, CURRENT_TAB); } //////////////////////////////////////////////////////////////////////////////// @@ -1076,17 +1082,13 @@ void Browser::ActiveTabChanged(TabContents* old_contents, // On some platforms we want to automatically reload tabs that are // killed when the user selects them. bool did_reload = false; - if (user_gesture && new_contents->web_contents()->GetCrashedStatus() == - base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { - LOG(WARNING) << "Reloading killed tab at " << index; - static int reload_count = 0; - UMA_HISTOGRAM_CUSTOM_COUNTS( - "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); - chrome::Reload(this, CURRENT_TAB); - did_reload = true; - } + if (user_gesture && ShouldReloadCrashedTab(new_contents->web_contents())) { + LOG(WARNING) << "Reloading killed tab at " << index; + static int reload_count = 0; + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); + chrome::Reload(this, CURRENT_TAB); + did_reload = true; } // Discarded tabs always get reloaded.