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

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: Make anonymous functions 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 | « no previous file | 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 IsTabCrashed(WebContents* contents) {
sky 2012/10/31 21:30:15 Name this ShouldReloadCrashedTab and have it inclu
simonhong_ 2012/10/31 22:06:43 Done.
250 base::TerminationStatus crashed_status = contents->GetCrashedStatus();
251
252 if (crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
sky 2012/10/31 21:30:15 Make this a single return statement, eg: return c
simonhong_ 2012/10/31 22:06:43 Done.
253 crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
254 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED)
255 return true;
256 else
257 return false;
258 }
249 259
250 } // namespace 260 } // namespace
251 261
252 //////////////////////////////////////////////////////////////////////////////// 262 ////////////////////////////////////////////////////////////////////////////////
253 // Browser, CreateParams: 263 // Browser, CreateParams:
254 264
255 Browser::CreateParams::CreateParams() 265 Browser::CreateParams::CreateParams()
256 : type(TYPE_TABBED), 266 : type(TYPE_TABBED),
257 profile(NULL), 267 profile(NULL),
258 host_desktop_type(kDefaultHostDesktopType), 268 host_desktop_type(kDefaultHostDesktopType),
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 content::Source<Browser>(this), 650 content::Source<Browser>(this),
641 content::NotificationService::NoDetails()); 651 content::NotificationService::NoDetails());
642 652
643 chrome::CloseAllTabs(this); 653 chrome::CloseAllTabs(this);
644 } 654 }
645 655
646 void Browser::OnWindowActivated() { 656 void Browser::OnWindowActivated() {
647 // On some platforms we want to automatically reload tabs that are 657 // On some platforms we want to automatically reload tabs that are
648 // killed when the user selects them. 658 // killed when the user selects them.
649 WebContents* contents = chrome::GetActiveWebContents(this); 659 WebContents* contents = chrome::GetActiveWebContents(this);
650 if (contents && contents->GetCrashedStatus() == 660 if (contents) {
651 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
652 if (CommandLine::ForCurrentProcess()->HasSwitch( 661 if (CommandLine::ForCurrentProcess()->HasSwitch(
653 switches::kReloadKilledTabs)) { 662 switches::kReloadKilledTabs) && IsTabCrashed(contents)) {
654 chrome::Reload(this, CURRENT_TAB); 663 chrome::Reload(this, CURRENT_TAB);
655 } 664 }
656 } 665 }
657 } 666 }
658 667
659 //////////////////////////////////////////////////////////////////////////////// 668 ////////////////////////////////////////////////////////////////////////////////
660 // In-progress download termination handling: 669 // In-progress download termination handling:
661 670
662 void Browser::InProgressDownloadResponse(bool cancel_downloads) { 671 void Browser::InProgressDownloadResponse(bool cancel_downloads) {
663 if (cancel_downloads) { 672 if (cancel_downloads) {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); 1080 window_->GetLocationBar()->SaveStateToContents(contents->web_contents());
1072 } 1081 }
1073 1082
1074 void Browser::ActiveTabChanged(TabContents* old_contents, 1083 void Browser::ActiveTabChanged(TabContents* old_contents,
1075 TabContents* new_contents, 1084 TabContents* new_contents,
1076 int index, 1085 int index,
1077 bool user_gesture) { 1086 bool user_gesture) {
1078 // On some platforms we want to automatically reload tabs that are 1087 // On some platforms we want to automatically reload tabs that are
1079 // killed when the user selects them. 1088 // killed when the user selects them.
1080 bool did_reload = false; 1089 bool did_reload = false;
1081 if (user_gesture && new_contents->web_contents()->GetCrashedStatus() == 1090 if (user_gesture) {
1082 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
1083 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 1091 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
1084 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { 1092 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs) &&
1093 IsTabCrashed(new_contents->web_contents())) {
1085 LOG(WARNING) << "Reloading killed tab at " << index; 1094 LOG(WARNING) << "Reloading killed tab at " << index;
1086 static int reload_count = 0; 1095 static int reload_count = 0;
1087 UMA_HISTOGRAM_CUSTOM_COUNTS( 1096 UMA_HISTOGRAM_CUSTOM_COUNTS(
1088 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); 1097 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
1089 chrome::Reload(this, CURRENT_TAB); 1098 chrome::Reload(this, CURRENT_TAB);
1090 did_reload = true; 1099 did_reload = true;
1091 } 1100 }
1092 } 1101 }
1093 1102
1094 // Discarded tabs always get reloaded. 1103 // Discarded tabs always get reloaded.
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 if (contents && !allow_js_access) { 2320 if (contents && !allow_js_access) {
2312 contents->web_contents()->GetController().LoadURL( 2321 contents->web_contents()->GetController().LoadURL(
2313 target_url, 2322 target_url,
2314 content::Referrer(), 2323 content::Referrer(),
2315 content::PAGE_TRANSITION_LINK, 2324 content::PAGE_TRANSITION_LINK,
2316 std::string()); // No extra headers. 2325 std::string()); // No extra headers.
2317 } 2326 }
2318 2327
2319 return contents != NULL; 2328 return contents != NULL;
2320 } 2329 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698