summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrikant@chromium.org <shrikant@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 21:29:56 +0000
committershrikant@chromium.org <shrikant@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 21:29:56 +0000
commit0947506a49369b5864ca92d6452d4ac955424189 (patch)
tree4e9bdcf19e102fba139f93114fecc7edacfb6b14
parent05f43dec21095d9f7af140972bff7bde5bf065ed (diff)
downloadchromium_src-0947506a49369b5864ca92d6452d4ac955424189.zip
chromium_src-0947506a49369b5864ca92d6452d4ac955424189.tar.gz
chromium_src-0947506a49369b5864ca92d6452d4ac955424189.tar.bz2
Fixing focus issue after tab crash.
BUG=276609 R=sky,ananta Review URL: https://codereview.chromium.org/23618033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229919 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/browser_focus_uitest.cc13
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h5
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc16
3 files changed, 27 insertions, 7 deletions
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 869f43d..4a6f59d 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -871,6 +871,19 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
}
+// Tests that focus goes to frame after crashed tab.
+// TODO(shrikant): Find out where the focus should be deterministically.
+// Currently focused_view after crash seem to be non null in debug mode
+// (invalidated pointer 0xcccccc).
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusAfterCrashedTab) {
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ content::CrashTab(browser()->tab_strip_model()->GetActiveWebContents());
+
+ ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
+}
+
// Tests that when a new tab is opened from the omnibox, the focus is moved from
// the omnibox for the current tab.
IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 8d6d6d9..7b0d5bd 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -344,6 +344,11 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
void UpdateConstrainedWindowRects(const std::vector<gfx::Rect>& rects);
#endif
+ // Method to indicate if this instance is shutting down or closing.
+ // TODO(shrikant): Discuss around to see if it makes sense to add this method
+ // as part of RenderWidgetHostView.
+ bool IsClosing() const { return in_shutdown_; };
+
protected:
friend class RenderWidgetHostView;
virtual ~RenderWidgetHostViewAura();
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 2b33dab..079ed23 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -1077,10 +1077,6 @@ void WebContentsViewAura::GetContainerBounds(gfx::Rect *out) const {
void WebContentsViewAura::OnTabCrashed(base::TerminationStatus status,
int error_code) {
- // Set the focus to the parent because neither the view window nor this
- // window can handle key events.
- if (window_->HasFocus() && window_->parent())
- window_->parent()->Focus();
}
void WebContentsViewAura::SizeContents(const gfx::Size& size) {
@@ -1499,9 +1495,15 @@ bool WebContentsViewAura::ShouldDescendIntoChildForEventHandling(
}
bool WebContentsViewAura::CanFocus() {
- // Do not take the focus if the render widget host view is gone because
- // neither the view window nor this window can handle key events.
- return web_contents_->GetRenderWidgetHostView() != NULL;
+ // Do not take the focus if the render widget host view aura is gone or
+ // is in the process of shutting down because neither the view window nor
+ // this window can handle key events.
+ RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura(
+ web_contents_->GetRenderWidgetHostView());
+ if (view != NULL && !view->IsClosing())
+ return true;
+
+ return false;
}
void WebContentsViewAura::OnCaptureLost() {