Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 content::Source<Browser>(this), | 640 content::Source<Browser>(this), |
| 641 content::NotificationService::NoDetails()); | 641 content::NotificationService::NoDetails()); |
| 642 | 642 |
| 643 chrome::CloseAllTabs(this); | 643 chrome::CloseAllTabs(this); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void Browser::OnWindowActivated() { | 646 void Browser::OnWindowActivated() { |
| 647 // On some platforms we want to automatically reload tabs that are | 647 // On some platforms we want to automatically reload tabs that are |
| 648 // killed when the user selects them. | 648 // killed when the user selects them. |
| 649 WebContents* contents = chrome::GetActiveWebContents(this); | 649 WebContents* contents = chrome::GetActiveWebContents(this); |
| 650 if (contents && contents->GetCrashedStatus() == | 650 base::TerminationStatus crashed_status = contents->GetCrashedStatus(); |
| 651 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 651 bool crashed = false; |
| 652 if (crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || | |
|
sky
2012/10/30 22:33:01
Move this into an anonmyous function that does all
simonhong_
2012/10/31 20:48:08
Done.
| |
| 653 crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || | |
| 654 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED) | |
| 655 crashed = true; | |
| 656 if (contents && crashed) { | |
| 652 if (CommandLine::ForCurrentProcess()->HasSwitch( | 657 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 653 switches::kReloadKilledTabs)) { | 658 switches::kReloadKilledTabs)) { |
| 654 chrome::Reload(this, CURRENT_TAB); | 659 chrome::Reload(this, CURRENT_TAB); |
| 655 } | 660 } |
| 656 } | 661 } |
| 657 } | 662 } |
| 658 | 663 |
| 659 //////////////////////////////////////////////////////////////////////////////// | 664 //////////////////////////////////////////////////////////////////////////////// |
| 660 // In-progress download termination handling: | 665 // In-progress download termination handling: |
| 661 | 666 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); | 1076 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); |
| 1072 } | 1077 } |
| 1073 | 1078 |
| 1074 void Browser::ActiveTabChanged(TabContents* old_contents, | 1079 void Browser::ActiveTabChanged(TabContents* old_contents, |
| 1075 TabContents* new_contents, | 1080 TabContents* new_contents, |
| 1076 int index, | 1081 int index, |
| 1077 bool user_gesture) { | 1082 bool user_gesture) { |
| 1078 // On some platforms we want to automatically reload tabs that are | 1083 // On some platforms we want to automatically reload tabs that are |
| 1079 // killed when the user selects them. | 1084 // killed when the user selects them. |
| 1080 bool did_reload = false; | 1085 bool did_reload = false; |
| 1081 if (user_gesture && new_contents->web_contents()->GetCrashedStatus() == | 1086 base::TerminationStatus crashed_status = |
| 1082 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 1087 new_contents->web_contents()->GetCrashedStatus(); |
| 1088 bool crashed = false; | |
| 1089 if (crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || | |
| 1090 crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || | |
| 1091 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED) | |
| 1092 crashed = true; | |
| 1093 if (user_gesture && crashed) { | |
| 1083 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 1094 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 1084 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { | 1095 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { |
| 1085 LOG(WARNING) << "Reloading killed tab at " << index; | 1096 LOG(WARNING) << "Reloading killed tab at " << index; |
| 1086 static int reload_count = 0; | 1097 static int reload_count = 0; |
| 1087 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1098 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1088 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); | 1099 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); |
| 1089 chrome::Reload(this, CURRENT_TAB); | 1100 chrome::Reload(this, CURRENT_TAB); |
| 1090 did_reload = true; | 1101 did_reload = true; |
| 1091 } | 1102 } |
| 1092 } | 1103 } |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2311 if (contents && !allow_js_access) { | 2322 if (contents && !allow_js_access) { |
| 2312 contents->web_contents()->GetController().LoadURL( | 2323 contents->web_contents()->GetController().LoadURL( |
| 2313 target_url, | 2324 target_url, |
| 2314 content::Referrer(), | 2325 content::Referrer(), |
| 2315 content::PAGE_TRANSITION_LINK, | 2326 content::PAGE_TRANSITION_LINK, |
| 2316 std::string()); // No extra headers. | 2327 std::string()); // No extra headers. |
| 2317 } | 2328 } |
| 2318 | 2329 |
| 2319 return contents != NULL; | 2330 return contents != NULL; |
| 2320 } | 2331 } |
| OLD | NEW |