summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity <calamity@chromium.org>2015-04-29 23:45:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-30 06:46:07 +0000
commit6160055c44df13ba136c17842107782e359ee663 (patch)
tree9f262dc6c5b02cf0609235010b48f0e0e070f3a5
parent299999051553ce065f4277c809e7291150c26364 (diff)
downloadchromium_src-6160055c44df13ba136c17842107782e359ee663.zip
chromium_src-6160055c44df13ba136c17842107782e359ee663.tar.gz
chromium_src-6160055c44df13ba136c17842107782e359ee663.tar.bz2
Make Ctrl + T from apps focus the new tab's omnibox on Linux and ChromeOS.
This CL fixes an issue where pressing Ctrl + T from a non-tabbed browser would not focus the omnibox if the WebView of the new tab's browser window was not focused. This has been fixed by refocusing the omnibox after the browser Show() on ChromeOS and by re-adding an ifdef that was introduced to Linux as part of a ChromeOS specific fix in r173840. BUG=399133 Review URL: https://codereview.chromium.org/1091953004 Cr-Commit-Position: refs/heads/master@{#327660}
-rw-r--r--chrome/browser/ui/ash/chrome_new_window_delegate.cc13
-rw-r--r--chrome/browser/ui/browser.cc22
-rw-r--r--chrome/browser/ui/browser.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc2
4 files changed, 23 insertions, 16 deletions
diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate.cc b/chrome/browser/ui/ash/chrome_new_window_delegate.cc
index f45ec81..49dc9dc 100644
--- a/chrome/browser/ui/ash/chrome_new_window_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_new_window_delegate.cc
@@ -81,10 +81,15 @@ void ChromeNewWindowDelegate::NewTab() {
return;
}
- chrome::ScopedTabbedBrowserDisplayer displayer(
- ProfileManager::GetActiveUserProfile(),
- chrome::HOST_DESKTOP_TYPE_ASH);
- chrome::NewTab(displayer.browser());
+ // Display a browser, setting the focus to the location bar after it is shown.
+ {
+ chrome::ScopedTabbedBrowserDisplayer displayer(
+ ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
+ browser = displayer.browser();
+ chrome::NewTab(browser);
+ }
+
+ browser->SetFocusToLocationBar(false);
}
void ChromeNewWindowDelegate::NewWindow(bool is_incognito) {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 7bd8596..c1556d9 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1198,6 +1198,17 @@ bool Browser::ShouldPreserveAbortedURLs(WebContents* source) {
return chrome::IsNTPURL(committed_url, profile);
}
+void Browser::SetFocusToLocationBar(bool select_all) {
+ // Two differences between this and FocusLocationBar():
+ // (1) This doesn't get recorded in user metrics, since it's called
+ // internally.
+ // (2) This checks whether the location bar can be focused, and if not, clears
+ // the focus. FocusLocationBar() is only reached when the location bar is
+ // focusable, but this may be reached at other times, e.g. while in
+ // fullscreen mode, where we need to leave focus in a consistent state.
+ window_->SetFocusToLocationBar(select_all);
+}
+
bool Browser::PreHandleKeyboardEvent(content::WebContents* source,
const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
@@ -1555,17 +1566,6 @@ bool Browser::ShouldFocusLocationBarByDefault(WebContents* source) {
return chrome::NavEntryIsInstantNTP(source, entry);
}
-void Browser::SetFocusToLocationBar(bool select_all) {
- // Two differences between this and FocusLocationBar():
- // (1) This doesn't get recorded in user metrics, since it's called
- // internally.
- // (2) This checks whether the location bar can be focused, and if not, clears
- // the focus. FocusLocationBar() is only reached when the location bar is
- // focusable, but this may be reached at other times, e.g. while in
- // fullscreen mode, where we need to leave focus in a consistent state.
- window_->SetFocusToLocationBar(select_all);
-}
-
void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) {
DCHECK(source);
chrome::ViewSource(this, source);
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index f5d2c62..0fee68b 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -443,6 +443,7 @@ class Browser : public TabStripModelObserver,
// Overridden from content::WebContentsDelegate:
bool CanOverscrollContent() const override;
bool ShouldPreserveAbortedURLs(content::WebContents* source) override;
+ void SetFocusToLocationBar(bool select_all) override;
bool PreHandleKeyboardEvent(content::WebContents* source,
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) override;
@@ -575,7 +576,6 @@ class Browser : public TabStripModelObserver,
bool proceed,
bool* proceed_to_fire_unload) override;
bool ShouldFocusLocationBarByDefault(content::WebContents* source) override;
- void SetFocusToLocationBar(bool select_all) override;
void ViewSourceForTab(content::WebContents* source,
const GURL& page_url) override;
void ViewSourceForFrame(content::WebContents* source,
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index b6db916..a401e49 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1046,8 +1046,10 @@ void BrowserView::SetFocusToLocationBar(bool select_all) {
// view believe it has a focus even if the widget doens't have a
// focus. Either cases, we need to ignore this when the browser
// window isn't active.
+#if defined(OS_WIN) || defined(OS_CHROMEOS)
if (!force_location_bar_focus_ && !IsActive())
return;
+#endif
// Temporarily reveal the top-of-window views (if not already revealed) so
// that the location bar view is visible and is considered focusable. If the