Commit 5ae566d6 authored by jcampan@chromium.org's avatar jcampan@chromium.org

Relanding the following:

When restoring a session, the browser is shown after a tab is selected causing
the focus to be on the location bar (not tab contents for web pages).
This CL ensures the tab decides where the focus should be after the browser is
shown.

BUG=6000
TEST=See bug
R=sky
Review URL: http://codereview.chromium.org/28156

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10488 0039d316-1c4b-4281-b951-d872f2087c98
parent 3f8cb62b
...@@ -359,6 +359,9 @@ class SessionRestoreImpl : public NotificationObserver { ...@@ -359,6 +359,9 @@ class SessionRestoreImpl : public NotificationObserver {
std::min(initial_tab_count + std::max(0, selected_session_index), std::min(initial_tab_count + std::max(0, selected_session_index),
browser->tab_count() - 1), true); browser->tab_count() - 1), true);
browser->window()->Show(); browser->window()->Show();
// Showing the browser focuses the location bar, let the tab decide where
// it wants the focus to be.
browser->GetSelectedTabContents()->SetInitialFocus();
} }
void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) {
......
...@@ -446,6 +446,12 @@ class TabContents : public PageNavigator, ...@@ -446,6 +446,12 @@ class TabContents : public PageNavigator,
// Called when a ConstrainedWindow we own is moved or resized. // Called when a ConstrainedWindow we own is moved or resized.
void DidMoveOrResize(ConstrainedWindow* window); void DidMoveOrResize(ConstrainedWindow* window);
// Sets focus to the tab contents window, but doesn't actually set focus to
// a particular element in it (see also SetInitialFocus(bool) which does
// that in different circumstances).
// FIXME(brettw) having two SetInitialFocus that do different things is silly.
virtual void SetInitialFocus();
protected: protected:
// NotificationObserver implementation: // NotificationObserver implementation:
virtual void Observe(NotificationType type, virtual void Observe(NotificationType type,
...@@ -470,12 +476,6 @@ class TabContents : public PageNavigator, ...@@ -470,12 +476,6 @@ class TabContents : public PageNavigator,
// Protected so that others don't try to delete this directly. // Protected so that others don't try to delete this directly.
virtual ~TabContents(); virtual ~TabContents();
// Sets focus to the tab contents window, but doesn't actuall set focus to
// a particular element in it (see also SetInitialFocus(bool) which does
// that in different circumstances).
// FIXME(brettw) having two SetInitialFocus that do different things is silly.
virtual void SetInitialFocus();
// Changes the IsLoading state and notifies delegate as needed // Changes the IsLoading state and notifies delegate as needed
// |details| is used to provide details on the load that just finished // |details| is used to provide details on the load that just finished
// (but can be null if not applicable). Can be overridden. // (but can be null if not applicable). Can be overridden.
......
...@@ -445,6 +445,7 @@ class TabContents : public PageNavigator, public NotificationObserver { ...@@ -445,6 +445,7 @@ class TabContents : public PageNavigator, public NotificationObserver {
virtual void WasHidden() { virtual void WasHidden() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
virtual void SetInitialFocus() { NOTIMPLEMENTED(); }
virtual void RestoreFocus() { NOTIMPLEMENTED(); } virtual void RestoreFocus() { NOTIMPLEMENTED(); }
static TabContentsType TypeForURL(GURL* url); static TabContentsType TypeForURL(GURL* url);
static TabContents* CreateWithType(TabContentsType type, static TabContents* CreateWithType(TabContentsType type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment