Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: chrome/browser/ui/browser.cc

Issue 10409034: Fixing activation problem: Pages which refresh themselves should not get focus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed fourth review Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 987af6c2271b886ff7cef3465471b2785fb1e1a5..3318e54f18c6a60cc19365fc783da0d6664817a2 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -2697,7 +2697,11 @@ void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents,
// navigating away from the new tab page.
ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL);
- if (contents_is_selected)
+ // Focus on the content if the content is active and it is user initated
+ // or if the window is active as well as the tab - or in other words:
+ // Don't focus when the user did not initate the navigation or the window
+ // and tab are not active.
+ if (contents_is_selected && (user_initiated || window()->IsActive()))
contents->web_contents()->Focus();
}
@@ -3409,7 +3413,11 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
nav_params.referrer = params.referrer;
nav_params.disposition = params.disposition;
nav_params.tabstrip_add_types = TabStripModel::ADD_NONE;
- nav_params.window_action = browser::NavigateParams::SHOW_WINDOW;
+
+ // Show the tab if the window and tab was already active.
+ if (GetSelectedWebContents() == source && window()->IsActive())
+ nav_params.window_action = browser::NavigateParams::SHOW_WINDOW;
+
nav_params.user_gesture = true;
nav_params.override_encoding = params.override_encoding;
nav_params.is_renderer_initiated = params.is_renderer_initiated;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698