Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
| index a5a5fddc227c379179104ddf9186a828403384b3..9e43d5fdb067bd193c1d2ba77f0970794d9eacfa 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 |
| @@ -647,10 +658,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)) { |
| + if (contents) { |
|
sky
2012/10/31 23:42:38
Combine into a single if, eg:
if (contents && Shou
|
| + if (ShouldReloadCrashedTab(contents)) { |
| chrome::Reload(this, CURRENT_TAB); |
| } |
| } |
| @@ -1078,10 +1087,8 @@ 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)) { |
| + if (user_gesture) { |
| + if (ShouldReloadCrashedTab(new_contents->web_contents())) { |
|
sky
2012/10/31 23:42:38
Same thing here.
|
| LOG(WARNING) << "Reloading killed tab at " << index; |
| static int reload_count = 0; |
| UMA_HISTOGRAM_CUSTOM_COUNTS( |