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

Side by Side 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: Fix indentation 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 unified diff | Download patch
« no previous file with comments | « AUTHORS ('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/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return BrowserWindow::CreateBrowserWindow(browser); 239 return BrowserWindow::CreateBrowserWindow(browser);
240 } 240 }
241 241
242 #if defined(OS_CHROMEOS) 242 #if defined(OS_CHROMEOS)
243 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH; 243 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH;
244 #else 244 #else
245 chrome::HostDesktopType kDefaultHostDesktopType = 245 chrome::HostDesktopType kDefaultHostDesktopType =
246 chrome::HOST_DESKTOP_TYPE_NATIVE; 246 chrome::HOST_DESKTOP_TYPE_NATIVE;
247 #endif 247 #endif
248 248
249 bool ShouldReloadCrashedTab(WebContents* contents) {
250 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
251 if (!command_line.HasSwitch(switches::kReloadKilledTabs))
252 return false;
253
254 base::TerminationStatus crashed_status = contents->GetCrashedStatus();
255
256 return crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
257 crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
258 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED;
259 }
249 260
250 } // namespace 261 } // namespace
251 262
252 //////////////////////////////////////////////////////////////////////////////// 263 ////////////////////////////////////////////////////////////////////////////////
253 // Browser, CreateParams: 264 // Browser, CreateParams:
254 265
255 Browser::CreateParams::CreateParams() 266 Browser::CreateParams::CreateParams()
256 : type(TYPE_TABBED), 267 : type(TYPE_TABBED),
257 profile(NULL), 268 profile(NULL),
258 host_desktop_type(kDefaultHostDesktopType), 269 host_desktop_type(kDefaultHostDesktopType),
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 content::Source<Browser>(this), 650 content::Source<Browser>(this),
640 content::NotificationService::NoDetails()); 651 content::NotificationService::NoDetails());
641 652
642 chrome::CloseAllTabs(this); 653 chrome::CloseAllTabs(this);
643 } 654 }
644 655
645 void Browser::OnWindowActivated() { 656 void Browser::OnWindowActivated() {
646 // On some platforms we want to automatically reload tabs that are 657 // On some platforms we want to automatically reload tabs that are
647 // killed when the user selects them. 658 // killed when the user selects them.
648 WebContents* contents = chrome::GetActiveWebContents(this); 659 WebContents* contents = chrome::GetActiveWebContents(this);
649 if (contents && contents->GetCrashedStatus() == 660 if (contents && ShouldReloadCrashedTab(contents))
650 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { 661 chrome::Reload(this, CURRENT_TAB);
651 if (CommandLine::ForCurrentProcess()->HasSwitch(
652 switches::kReloadKilledTabs)) {
653 chrome::Reload(this, CURRENT_TAB);
654 }
655 }
656 } 662 }
657 663
658 //////////////////////////////////////////////////////////////////////////////// 664 ////////////////////////////////////////////////////////////////////////////////
659 // In-progress download termination handling: 665 // In-progress download termination handling:
660 666
661 void Browser::InProgressDownloadResponse(bool cancel_downloads) { 667 void Browser::InProgressDownloadResponse(bool cancel_downloads) {
662 if (cancel_downloads) { 668 if (cancel_downloads) {
663 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; 669 cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
664 chrome::CloseWindow(this); 670 chrome::CloseWindow(this);
665 return; 671 return;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); 1076 window_->GetLocationBar()->SaveStateToContents(contents->web_contents());
1071 } 1077 }
1072 1078
1073 void Browser::ActiveTabChanged(TabContents* old_contents, 1079 void Browser::ActiveTabChanged(TabContents* old_contents,
1074 TabContents* new_contents, 1080 TabContents* new_contents,
1075 int index, 1081 int index,
1076 bool user_gesture) { 1082 bool user_gesture) {
1077 // On some platforms we want to automatically reload tabs that are 1083 // On some platforms we want to automatically reload tabs that are
1078 // killed when the user selects them. 1084 // killed when the user selects them.
1079 bool did_reload = false; 1085 bool did_reload = false;
1080 if (user_gesture && new_contents->web_contents()->GetCrashedStatus() == 1086 if (user_gesture && ShouldReloadCrashedTab(new_contents->web_contents())) {
1081 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { 1087 LOG(WARNING) << "Reloading killed tab at " << index;
1082 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 1088 static int reload_count = 0;
1083 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { 1089 UMA_HISTOGRAM_CUSTOM_COUNTS(
1084 LOG(WARNING) << "Reloading killed tab at " << index; 1090 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
1085 static int reload_count = 0; 1091 chrome::Reload(this, CURRENT_TAB);
1086 UMA_HISTOGRAM_CUSTOM_COUNTS( 1092 did_reload = true;
1087 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
1088 chrome::Reload(this, CURRENT_TAB);
1089 did_reload = true;
1090 }
1091 } 1093 }
1092 1094
1093 // Discarded tabs always get reloaded. 1095 // Discarded tabs always get reloaded.
1094 if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) { 1096 if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) {
1095 LOG(WARNING) << "Reloading discarded tab at " << index; 1097 LOG(WARNING) << "Reloading discarded tab at " << index;
1096 static int reload_count = 0; 1098 static int reload_count = 0;
1097 UMA_HISTOGRAM_CUSTOM_COUNTS( 1099 UMA_HISTOGRAM_CUSTOM_COUNTS(
1098 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); 1100 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50);
1099 chrome::Reload(this, CURRENT_TAB); 1101 chrome::Reload(this, CURRENT_TAB);
1100 } 1102 }
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 if (contents && !allow_js_access) { 2350 if (contents && !allow_js_access) {
2349 contents->web_contents()->GetController().LoadURL( 2351 contents->web_contents()->GetController().LoadURL(
2350 target_url, 2352 target_url,
2351 content::Referrer(), 2353 content::Referrer(),
2352 content::PAGE_TRANSITION_LINK, 2354 content::PAGE_TRANSITION_LINK,
2353 std::string()); // No extra headers. 2355 std::string()); // No extra headers.
2354 } 2356 }
2355 2357
2356 return contents != NULL; 2358 return contents != NULL;
2357 } 2359 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698