diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 04:22:22 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 04:22:22 +0000 |
commit | f9b1b9aa6717657be56a9f7e72c3cd164a68dfe7 (patch) | |
tree | 39801b3953ceb2bb65c83eb9506dff8c60856bf0 /chrome | |
parent | d54f9acebb3cd422f4a3838f5450c7d74de0cd21 (diff) | |
download | chromium_src-f9b1b9aa6717657be56a9f7e72c3cd164a68dfe7.zip chromium_src-f9b1b9aa6717657be56a9f7e72c3cd164a68dfe7.tar.gz chromium_src-f9b1b9aa6717657be56a9f7e72c3cd164a68dfe7.tar.bz2 |
Make sure the Omnibox is hidden when toolbar is collapsed.
BUG=None
TEST=Visual inspection. The Omnibox should never become visible for tabs with a collapsed toolbar (app tabs). F11 twice should not show the Omnibox.
Review URL: http://codereview.chromium.org/2032015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.h | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 2 | ||||
-rw-r--r-- | chrome/browser/location_bar.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 22 | ||||
-rw-r--r-- | chrome/browser/views/location_bar/location_bar_view.cc | 23 | ||||
-rw-r--r-- | chrome/browser/views/location_bar/location_bar_view.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.h | 2 | ||||
-rw-r--r-- | chrome/test/test_location_bar.h | 2 |
10 files changed, 72 insertions, 17 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index a6ba190..487e94e 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -506,6 +506,13 @@ void AutocompleteEditViewWin::SaveStateToTab(TabContents* tab) { void AutocompleteEditViewWin::Update( const TabContents* tab_for_state_restoring) { + // If we're switching to a tab with a collapsed toolbar, bail + // now, since we won't be showing the Omnibox anyway, and + // executing the code below just results in a flicker before + // the toolbar hides. + if (tab_for_state_restoring && tab_for_state_restoring->is_app()) + return; + const bool visibly_changed_permanent_text = model_->UpdatePermanentText(toolbar_model_->GetText()); diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index 08e1524..3f13bbd 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -68,6 +68,8 @@ class LocationBarViewMac : public AutocompleteEditController, virtual AutocompleteEditView* location_entry() { return edit_view_.get(); } + virtual void PushForceHidden() {} + virtual void PopForceHidden() {} virtual LocationBarTesting* GetLocationBarForTesting() { return this; } // Overridden from LocationBarTesting: diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index 486e5d7..f1bf435 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -115,6 +115,8 @@ class LocationBarViewGtk : public AutocompleteEditController, virtual AutocompleteEditView* location_entry() { return location_entry_.get(); } + virtual void PushForceHidden() {} + virtual void PopForceHidden() {} virtual LocationBarTesting* GetLocationBarForTesting() { return this; } // Implement the LocationBarTesting interface. diff --git a/chrome/browser/location_bar.h b/chrome/browser/location_bar.h index 1d71dd2..0ceee05 100644 --- a/chrome/browser/location_bar.h +++ b/chrome/browser/location_bar.h @@ -72,6 +72,13 @@ class LocationBar { virtual const AutocompleteEditView* location_entry() const = 0; virtual AutocompleteEditView* location_entry() = 0; + // Hides the edit field of the location bar if it hasn't already been + // force-hidden. The force hidden count is tracked, so calling multiple + // times is allowed, you just have to be sure to call PopForceHidden + // the same number of times. Currently, this is only needed for Windows. + virtual void PushForceHidden() = 0; + virtual void PopForceHidden() = 0; + // Returns a pointer to the testing interface. virtual LocationBarTesting* GetLocationBarForTesting() = 0; diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 2dd47f4..db95498 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -659,12 +659,12 @@ void BrowserView::Show() { accessible_view_helper_.reset(new AccessibleViewHelper( this, browser_->profile())); - #if defined(OS_LINUX) +#if defined(OS_LINUX) if (!accessible_widget_helper_.get()) { accessible_widget_helper_.reset(new AccessibleWidgetHelper( GTK_WIDGET(GetWindow()->GetNativeWindow()), browser_->profile())); } - #endif +#endif // If the window is already visible, just activate it. if (frame_->GetWindow()->IsVisible()) { @@ -1242,7 +1242,7 @@ void BrowserView::ToggleTabStripMode() { } void BrowserView::SetToolbarCollapsedMode(bool val) { - toolbar_->set_collapsed(val); + toolbar_->SetCollapsed(val); } /////////////////////////////////////////////////////////////////////////////// @@ -1741,7 +1741,7 @@ void BrowserView::Init() { toolbar_->Init(browser_->profile()); toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); if (browser_->type() == Browser::TYPE_EXTENSION_APP) - toolbar_->set_collapsed(true); + toolbar_->SetCollapsed(true); infobar_container_ = new InfoBarContainer(this); AddChildView(infobar_container_); @@ -1970,10 +1970,6 @@ void BrowserView::ProcessFullscreen(bool fullscreen) { // thus are slow and look ugly ignore_layout_ = true; LocationBarView* location_bar = toolbar_->location_bar(); -#if defined(OS_WIN) - AutocompleteEditViewWin* edit_view = - static_cast<AutocompleteEditViewWin*>(location_bar->location_entry()); -#endif if (!fullscreen) { // Hide the fullscreen bubble as soon as possible, since the mode toggle can // take enough time for the user to notice. @@ -1985,15 +1981,12 @@ void BrowserView::ProcessFullscreen(bool fullscreen) { if (focus_manager->GetFocusedView() == location_bar) focus_manager->ClearFocus(); -#if defined(OS_WIN) // If we don't hide the edit and force it to not show until we come out of // fullscreen, then if the user was on the New Tab Page, the edit contents // will appear atop the web contents once we go into fullscreen mode. This // has something to do with how we move the main window while it's hidden; // if we don't hide the main window below, we don't get this problem. - edit_view->set_force_hidden(true); - ShowWindow(edit_view->m_hWnd, SW_HIDE); -#endif + location_bar->PushForceHidden(); } #if defined(OS_WIN) frame_->GetWindow()->PushForceHidden(); @@ -2030,11 +2023,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen) { browser_.get())); } } else { -#if defined(OS_WIN) // Show the edit again since we're no longer in fullscreen mode. - edit_view->set_force_hidden(false); - ShowWindow(edit_view->m_hWnd, SW_SHOW); -#endif + location_bar->PopForceHidden(); } // Undo our anti-jankiness hacks and force the window to relayout now that diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index ec9ed67..7f9cde9 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -84,6 +84,7 @@ LocationBarView::LocationBarView(Profile* profile, keyword_hint_view_(NULL), star_view_(NULL), mode_(mode), + force_hidden_count_(0), ALLOW_THIS_IN_INITIALIZER_LIST(first_run_bubble_(this)) { DCHECK(profile_); SetID(VIEW_ID_LOCATION_BAR); @@ -894,6 +895,28 @@ void LocationBarView::Revert() { location_entry_->RevertAll(); } +void LocationBarView::PushForceHidden() { +#if defined(OS_WIN) + if (force_hidden_count_++ == 0) { + location_entry_->set_force_hidden(true); + ShowWindow(location_entry_->m_hWnd, SW_HIDE); + } +#endif +} + +void LocationBarView::PopForceHidden() { +#if defined(OS_WIN) + if (force_hidden_count_ == 0) { + NOTREACHED() << "Unmatched PopForceHidden() call!"; + return; + } + if (--force_hidden_count_ == 0) { + location_entry_->set_force_hidden(false); + ShowWindow(location_entry_->m_hWnd, SW_SHOW); + } +#endif +} + int LocationBarView::PageActionVisibleCount() { int result = 0; for (size_t i = 0; i < page_action_views_.size(); i++) { diff --git a/chrome/browser/views/location_bar/location_bar_view.h b/chrome/browser/views/location_bar/location_bar_view.h index 1f9c62b..51fa80e 100644 --- a/chrome/browser/views/location_bar/location_bar_view.h +++ b/chrome/browser/views/location_bar/location_bar_view.h @@ -198,6 +198,8 @@ class LocationBarView : public LocationBar, virtual AutocompleteEditView* location_entry() { return location_entry_.get(); } + virtual void PushForceHidden(); + virtual void PopForceHidden(); virtual LocationBarTesting* GetLocationBarForTesting() { return this; } // Overridden from LocationBarTesting: @@ -329,6 +331,10 @@ class LocationBarView : public LocationBar, // The mode that dictates how the bar shows. Mode mode_; + // Counts the number of times consumers have asked us to be hidden. + // We should actually be hidden iff this is greater than zero. + int force_hidden_count_; + // Used schedule a task for the first run info bubble. ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 9097b3c..cc00ba5 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -198,6 +198,22 @@ void ToolbarView::RemoveMenuListener(views::MenuListener* listener) { } } +void ToolbarView::SetCollapsed(bool val) { + if (collapsed_ == val) + return; + + collapsed_ = val; + + // When switching to and from collapsed view, we need to force hide/show the + // location bar entry view, like we do when we switch to full screen mode in + // BrowserView::ProcessFullscreen. Otherwise the text view can appear floating + // on top of web content. + if (collapsed_) + location_bar_->PushForceHidden(); + else + location_bar_->PopForceHidden(); +} + //////////////////////////////////////////////////////////////////////////////// // ToolbarView, FocusChangeListener overrides: diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h index 73d0294..9c7b472 100644 --- a/chrome/browser/views/toolbar_view.h +++ b/chrome/browser/views/toolbar_view.h @@ -88,7 +88,7 @@ class ToolbarView : public AccessibleToolbarView, views::MenuButton* page_menu() const { return page_menu_; } views::MenuButton* app_menu() const { return app_menu_; } bool collapsed() const { return collapsed_; } - void set_collapsed(bool val) { collapsed_ = val; } + void SetCollapsed(bool val); // Overridden from views::FocusChangeListener: virtual void FocusWillChange(views::View* focused_before, diff --git a/chrome/test/test_location_bar.h b/chrome/test/test_location_bar.h index ba9bce4..6face25 100644 --- a/chrome/test/test_location_bar.h +++ b/chrome/test/test_location_bar.h @@ -49,6 +49,8 @@ class TestLocationBar : public LocationBar { virtual AutocompleteEditView* location_entry() { return NULL; } + virtual void PushForceHidden() {} + virtual void PopForceHidden() {} virtual LocationBarTesting* GetLocationBarForTesting() { return NULL; } |