summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 20:40:53 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 20:40:53 +0000
commit6b2ee92785ecfd9a28333190925ea9d6fb5709ea (patch)
treeb3d3ef315a7faa7ccb18528426ae9da2b0f31e61 /chrome
parent9b67a3bafdcf549a9a28f4a0ce63dc165a34b6cd (diff)
downloadchromium_src-6b2ee92785ecfd9a28333190925ea9d6fb5709ea.zip
chromium_src-6b2ee92785ecfd9a28333190925ea9d6fb5709ea.tar.gz
chromium_src-6b2ee92785ecfd9a28333190925ea9d6fb5709ea.tar.bz2
Don't show popups before tabs have been added. Instead, prevent the BrowserView from restoring focus to the tab if the window that contains it isn't visible. This prevents blur events from being fired incorrectly.
http://crbug.com/7991 Review URL: http://codereview.chromium.org/99248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc9
-rw-r--r--chrome/browser/views/frame/browser_view.cc11
2 files changed, 7 insertions, 13 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index dc86bcb..6d50e66 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2601,15 +2601,8 @@ void Browser::BuildPopupWindowHelper(TabContents* source,
browser->set_maximized_state(MAXIMIZED_STATE_UNMAXIMIZED);
browser->CreateBrowserWindow();
- // We need to Show before AddNewContents, otherwise AddNewContents will focus
- // it (via BrowserView::TabSelectedAt calling RestoreFocus), triggering any
- // onblur="" handlers.
+ browser->tabstrip_model()->AppendTabContents(new_contents, true);
browser->window()->Show();
-
- // TODO(beng): See if this can be made to use
- // TabStripModel::AppendTabContents.
- browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB,
- gfx::Rect(), true);
}
GURL Browser::GetHomePage() const {
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index aebb183..6f1ce19 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -901,9 +901,8 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// We do not store the focus when closing the tab to work-around bug 4633.
// Some reports seem to show that the focus manager and/or focused view can
// be garbage at that point, it is not clear why.
- if (old_contents && !old_contents->is_being_destroyed() &&
- old_contents->AsWebContents())
- old_contents->AsWebContents()->view()->StoreFocus();
+ if (old_contents && !old_contents->is_being_destroyed())
+ old_contents->view()->StoreFocus();
// Update various elements that are interested in knowing the current
// TabContents.
@@ -916,8 +915,10 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
new_contents->DidBecomeSelected();
if (BrowserList::GetLastActive() == browser_ &&
!browser_->tabstrip_model()->closing_all() &&
- new_contents->AsWebContents()) {
- new_contents->AsWebContents()->view()->RestoreFocus();
+ GetWidget()->GetWindow()->IsVisible()) {
+ // We only restore focus if our window is visible, to avoid invoking blur
+ // handlers when we are eventually shown.
+ new_contents->view()->RestoreFocus();
}
// Update all the UI bits.