summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 09:08:38 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 09:08:38 +0000
commit00a0fad11302a8a6b5697207ac957c04530ab62e (patch)
tree3ff2fd3b762cbbc88fd350f4a00f92d780404ce6
parentdee2a9dc53b3ba91cd857826c013cb90a732a072 (diff)
downloadchromium_src-00a0fad11302a8a6b5697207ac957c04530ab62e.zip
chromium_src-00a0fad11302a8a6b5697207ac957c04530ab62e.tar.gz
chromium_src-00a0fad11302a8a6b5697207ac957c04530ab62e.tar.bz2
cros: Don't automatically reload crashed or killed tabs
We never wanted to do this for crashed tabs. Now that we have zram and the tab discarder killed tabs are quite rare and may be indicative of an important problem, so don't reload them either. BUG=232323 TEST=added to browser_tests BrowserTest.ReloadCrashedTabs R=gspencer@chromium.org Review URL: https://chromiumcodereview.appspot.com/15131005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200213 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/browser.cc39
-rw-r--r--chrome/browser/ui/browser.h5
-rw-r--r--chrome/browser/ui/browser_unittest.cc67
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/chrome_tests_unit.gypi1
5 files changed, 70 insertions, 46 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 1b60fff..6cd558f 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -235,14 +235,6 @@ BrowserWindow* CreateBrowserWindow(Browser* browser) {
return BrowserWindow::CreateBrowserWindow(browser);
}
-bool ShouldReloadCrashedTab(WebContents* contents) {
-#if defined(OS_CHROMEOS)
- return contents->IsCrashed();
-#else
- return false;
-#endif
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -633,22 +625,6 @@ void Browser::OnWindowClosing() {
tab_strip_model_->CloseAllTabs();
}
-void Browser::OnWindowActivated() {
- // On some platforms we want to automatically reload tabs that are
- // killed when the user selects them.
- WebContents* contents = tab_strip_model_->GetActiveWebContents();
- if (contents && ShouldReloadCrashedTab(contents)) {
- chrome::Reload(this, CURRENT_TAB);
- // The reload above will change the toolbar reload button into a stop
- // button. If the user activated the window with a mouse press on the
- // reload button itself, the reload will stop on mouse release and the page
- // will be blank. Disable the stop command temporarily. It will be
- // re-enabled as the page loads.
- command_controller_->command_updater()->UpdateCommandEnabled(IDC_STOP,
- false);
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
// In-progress download termination handling:
@@ -1025,21 +1001,8 @@ void Browser::ActiveTabChanged(WebContents* old_contents,
int reason) {
content::RecordAction(UserMetricsAction("ActiveTabChanged"));
- // On some platforms we want to automatically reload tabs that are
- // killed when the user selects them.
- bool did_reload = false;
- if ((reason & CHANGE_REASON_USER_GESTURE) &&
- ShouldReloadCrashedTab(new_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.
- if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) {
+ if (tab_strip_model_->IsTabDiscarded(index)) {
LOG(WARNING) << "Reloading discarded tab at " << index;
static int reload_count = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index de9d1e1..ec42e1b 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -295,11 +295,6 @@ class Browser : public TabStripModelObserver,
// cleanup.
void OnWindowClosing();
- // OnWindowActivationChanged handling ///////////////////////////////////////
-
- // Invoked when the window containing us is activated.
- void OnWindowActivated();
-
// In-progress download termination handling /////////////////////////////////
// Called when the user has decided whether to proceed or not with the browser
diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc
new file mode 100644
index 0000000..27cb23f
--- /dev/null
+++ b/chrome/browser/ui/browser_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/browser.h"
+
+#include "base/process_util.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "content/public/browser/site_instance.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/web_contents_tester.h"
+
+using content::SiteInstance;
+using content::WebContents;
+using content::WebContentsTester;
+
+class BrowserUnitTest : public BrowserWithTestWindowTest {
+ public:
+ BrowserUnitTest() {}
+ virtual ~BrowserUnitTest() {}
+
+ // Caller owns the memory.
+ WebContents* CreateTestWebContents() {
+ return WebContentsTester::CreateTestWebContents(
+ profile(), SiteInstance::Create(profile()));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserUnitTest);
+};
+
+// Don't build on platforms without a tab strip.
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+// Ensure crashed tabs are not reloaded when selected. crbug.com/232323
+TEST_F(BrowserUnitTest, ReloadCrashedTab) {
+ TabStripModel* tab_strip_model = browser()->tab_strip_model();
+
+ // Start with a single foreground tab. |tab_strip_model| owns the memory.
+ WebContents* contents1 = CreateTestWebContents();
+ tab_strip_model->AppendWebContents(contents1, true);
+ WebContentsTester::For(contents1)->NavigateAndCommit(GURL("about:blank"));
+ WebContentsTester::For(contents1)->TestSetIsLoading(false);
+ EXPECT_TRUE(tab_strip_model->IsTabSelected(0));
+ EXPECT_FALSE(contents1->IsLoading());
+
+ // Add a second tab in the background.
+ WebContents* contents2 = CreateTestWebContents();
+ tab_strip_model->AppendWebContents(contents2, false);
+ WebContentsTester::For(contents2)->NavigateAndCommit(GURL("about:blank"));
+ WebContentsTester::For(contents2)->TestSetIsLoading(false);
+ EXPECT_EQ(2, browser()->tab_strip_model()->count());
+ EXPECT_TRUE(tab_strip_model->IsTabSelected(0));
+ EXPECT_FALSE(contents2->IsLoading());
+
+ // Simulate the second tab crashing.
+ contents2->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
+ EXPECT_TRUE(contents2->IsCrashed());
+
+ // Selecting the second tab does not cause a load or clear the crash.
+ tab_strip_model->ActivateTabAt(1, true);
+ EXPECT_TRUE(tab_strip_model->IsTabSelected(1));
+ EXPECT_FALSE(contents2->IsLoading());
+ EXPECT_TRUE(contents2->IsCrashed());
+}
+
+#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index c069ae9..4d87666 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1705,10 +1705,8 @@ void BrowserView::OnWidgetActivationChanged(views::Widget* widget,
launcher_item_controller_->BrowserActivationStateChanged();
#endif
- if (active) {
+ if (active)
BrowserList::SetLastActive(browser_.get());
- browser_->OnWindowActivated();
- }
}
void BrowserView::OnWindowBeginUserBoundsChange() {
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 40bbe72..b5bac1c 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1269,6 +1269,7 @@
'browser/ui/bookmarks/recently_used_folders_combo_model_unittest.cc',
'browser/ui/browser_command_controller_unittest.cc',
'browser/ui/browser_iterator_unittest.cc',
+ 'browser/ui/browser_unittest.cc',
'browser/ui/chrome_select_file_policy_unittest.cc',
# It is safe to list */cocoa/* files in the "common" file list
# without an explicit exclusion since gyp is smart enough to