diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 19:09:38 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 19:09:38 +0000 |
commit | dfe9d1d2de7fd8d244599b79a22898cce8df7c81 (patch) | |
tree | bbc7eadc945e6b217b922f875092fd2ee7a89cba /chrome | |
parent | a9da4c46a446de3912465fb58339f6b16725dc53 (diff) | |
download | chromium_src-dfe9d1d2de7fd8d244599b79a22898cce8df7c81.zip chromium_src-dfe9d1d2de7fd8d244599b79a22898cce8df7c81.tar.gz chromium_src-dfe9d1d2de7fd8d244599b79a22898cce8df7c81.tar.bz2 |
Focus fix for compact navigation bar.
* Make focusable so that focus can be moved to compact navigation bar by tab.
* Ctrl-L should focus the compact navigation bar (and select all texts)
BUG=51 (chrome-os)
TEST=switch to compact navigation bar mode, hit tab or ctrl-L to move focus to compact navigation bar.
Review URL: http://codereview.chromium.org/384079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/browser_extenders.cc | 14 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_navigation_bar.cc | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_navigation_bar.h | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_extender.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/standard_extender.cc | 1 |
8 files changed, 49 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/browser_extenders.cc b/chrome/browser/chromeos/browser_extenders.cc index 0c902c3..0e21d98 100644 --- a/chrome/browser/chromeos/browser_extenders.cc +++ b/chrome/browser/chromeos/browser_extenders.cc @@ -170,8 +170,18 @@ class NormalExtender : public BrowserExtender, return compact_navigation_bar_enabled_; } + virtual bool SetFocusToCompactNavigationBar() { + if (compact_navigation_bar_->IsFocusable()) { + compact_navigation_bar_->FocusLocation(); + return true; + } else { + return false; + } + } + virtual void ToggleCompactNavigationBar() { compact_navigation_bar_enabled_ = !compact_navigation_bar_enabled_; + compact_navigation_bar_->SetFocusable(compact_navigation_bar_enabled_); status_area_->Update(); } @@ -308,6 +318,10 @@ class PopupExtender : public BrowserExtender { return true; } + virtual bool SetFocusToCompactNavigationBar() { + return false; + } + virtual void ToggleCompactNavigationBar() {} virtual void OnMouseEnteredToTab(Tab* tab) {} diff --git a/chrome/browser/chromeos/compact_location_bar.h b/chrome/browser/chromeos/compact_location_bar.h index 599cb44..83c46e6 100644 --- a/chrome/browser/chromeos/compact_location_bar.h +++ b/chrome/browser/chromeos/compact_location_bar.h @@ -112,4 +112,3 @@ class CompactLocationBar : public views::View, } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_H_ - diff --git a/chrome/browser/chromeos/compact_navigation_bar.cc b/chrome/browser/chromeos/compact_navigation_bar.cc index 16a33b9..7d16b86 100644 --- a/chrome/browser/chromeos/compact_navigation_bar.cc +++ b/chrome/browser/chromeos/compact_navigation_bar.cc @@ -49,6 +49,7 @@ static const int kURLPadding = 2; CompactNavigationBar::CompactNavigationBar(Browser* browser) : browser_(browser), initialized_(false) { + SetFocusable(true); } CompactNavigationBar::~CompactNavigationBar() { @@ -114,6 +115,15 @@ void CompactNavigationBar::Init() { location_entry_view_->Attach(location_entry_->widget()); } +void CompactNavigationBar::Focus() { + location_entry_->SetFocus(); +} + +void CompactNavigationBar::FocusLocation() { + location_entry_->SetFocus(); + location_entry_->SelectAll(true); +} + gfx::Size CompactNavigationBar::GetPreferredSize() { int width = 0; diff --git a/chrome/browser/chromeos/compact_navigation_bar.h b/chrome/browser/chromeos/compact_navigation_bar.h index aa4b86a..7a689e9 100644 --- a/chrome/browser/chromeos/compact_navigation_bar.h +++ b/chrome/browser/chromeos/compact_navigation_bar.h @@ -40,10 +40,14 @@ class CompactNavigationBar : public views::View, // widget. void Init(); + // Set focus to the location entry in the compact navigation bar. + void FocusLocation(); + // views::View overrides. virtual gfx::Size GetPreferredSize(); virtual void Layout(); virtual void Paint(gfx::Canvas* canvas); + virtual void Focus(); private: // views::ButtonListener implementation. diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 7ecc76b..1cd3394 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1029,8 +1029,17 @@ LocationBar* BrowserWindowGtk::GetLocationBar() const { } void BrowserWindowGtk::SetFocusToLocationBar() { - if (!IsFullscreen()) + if (!IsFullscreen()) { +#if defined(OS_CHROMEOS) + if (compact_navigation_bar_) { + compact_navigation_bar_->FocusLocation(); + } else { + GetLocationBar()->FocusLocation(); + } +#else GetLocationBar()->FocusLocation(); +#endif + } } void BrowserWindowGtk::UpdateStopGoState(bool is_loading, bool force) { diff --git a/chrome/browser/views/frame/browser_extender.h b/chrome/browser/views/frame/browser_extender.h index a40dad7..b33d173 100644 --- a/chrome/browser/views/frame/browser_extender.h +++ b/chrome/browser/views/frame/browser_extender.h @@ -56,6 +56,10 @@ class BrowserExtender { // to use the regular logic to decide. virtual bool ShouldForceHideToolbar() = 0; + // Returns true if the compact navigation bar is focusable and got + // focus, false otherwise. + virtual bool SetFocusToCompactNavigationBar() = 0; + // Toggles the visibility of CompactNavigationBar. virtual void ToggleCompactNavigationBar() = 0; diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index f50e6a1..dd241d1 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -934,9 +934,14 @@ LocationBar* BrowserView::GetLocationBar() const { void BrowserView::SetFocusToLocationBar() { LocationBarView* location_bar = toolbar_->location_bar(); - if (location_bar->IsFocusable()) { + if (browser_extender_->SetFocusToCompactNavigationBar()) { + // Compact navigation bar got focus. + } else if (location_bar->IsFocusable()) { + // Location bar got focus. location_bar->FocusLocation(); } else { + // If none of location bar/compact navigation bar got focus, + // then clear focus. views::FocusManager* focus_manager = GetFocusManager(); DCHECK(focus_manager); focus_manager->ClearFocus(); diff --git a/chrome/browser/views/frame/standard_extender.cc b/chrome/browser/views/frame/standard_extender.cc index 1fe41d1..b03a572 100644 --- a/chrome/browser/views/frame/standard_extender.cc +++ b/chrome/browser/views/frame/standard_extender.cc @@ -27,6 +27,7 @@ class StandardExtender : public BrowserExtender { virtual void UpdateTitleBar() {} virtual void ActivationChanged() {} virtual bool ShouldForceHideToolbar() { return false; } + virtual bool SetFocusToCompactNavigationBar() { return false; } virtual void ToggleCompactNavigationBar() {} virtual void OnMouseEnteredToTab(Tab* tab) {} virtual void OnMouseMovedOnTab(Tab* tab) {} |