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

Unified Diff: chrome/browser/ui/browser.cc

Issue 11342055: Add more conditions to reload when --reload-killed-tab option is used. (Closed) Base URL: http://git.chromium.org/chromium/src.git@new
Patch Set: Combine into a single if, Change my name Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index a5a5fddc227c379179104ddf9186a828403384b3..65133002aedc94f21824db3850d8725ce2f68b13 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,12 +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)) {
- chrome::Reload(this, CURRENT_TAB);
- }
+ if (contents && ShouldReloadCrashedTab(contents)) {
sky 2012/11/01 21:37:36 nit: in general no {} for single line ifs.
simonhong_ 2012/11/01 21:47:52 Done. Thank you! On 2012/11/01 21:37:36, sky wrot
+ chrome::Reload(this, CURRENT_TAB);
}
}
@@ -1078,17 +1085,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)) {
+ 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.
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698