diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:52:31 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:52:31 +0000 |
commit | c83c9e683a9376cea1ef675bfe92f7dbb98d45f5 (patch) | |
tree | f50ff4edc61b1baa1dd10c8716af53fbeb7ce65e /chrome/browser/chromeos/compact_location_bar_host.h | |
parent | ea99c3abb5ad6121d94a4c4cf1ca683d4f0ebd90 (diff) | |
download | chromium_src-c83c9e683a9376cea1ef675bfe92f7dbb98d45f5.zip chromium_src-c83c9e683a9376cea1ef675bfe92f7dbb98d45f5.tar.gz chromium_src-c83c9e683a9376cea1ef675bfe92f7dbb98d45f5.tar.bz2 |
Use dropdown bar for compact location bar.
* Refactored CompactLocationBar to Host/View to use DropdownBarHost/View.
* Changed the logic to show/hide. Per cole's request, losing focus now hides the location bar.
Following features are not implemented yet.
* Window cripping while animating.
* Adjust location when toolbar is shown (it's always under tab)
* clipping autocomplete dropdown.
Timer code is no longer used right now, but is left intentionally as we may put it back.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/525018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35674 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/compact_location_bar_host.h')
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_host.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/compact_location_bar_host.h b/chrome/browser/chromeos/compact_location_bar_host.h new file mode 100644 index 0000000..1d7b683 --- /dev/null +++ b/chrome/browser/chromeos/compact_location_bar_host.h @@ -0,0 +1,105 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_ +#define CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_ + +#include "app/animation.h" +#include "app/gfx/native_widget_types.h" +#include "base/gfx/rect.h" +#include "base/timer.h" +#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/views/dropdown_bar_host.h" +#include "views/controls/textfield/textfield.h" + +class BrowserView; +class TabContents; +class Tab; + +namespace chromeos { + +class CompactLocationBarView; + +//////////////////////////////////////////////////////////////////////////////// +// +// The CompactLocationBarHost implements the container window for the +// floating location bar. It uses the appropriate implementation from +// compact_location_bar_host_gtk.cc to draw its content and is +// responsible for showing, hiding, closing, and moving the window. +// +// There is one CompactLocationBarHost per BrowserView, and its state +// is updated whenever the selected Tab is changed. The +// CompactLocationBarHost is created when the BrowserView is attached +// to the frame's Widget for the first time, and enabled/disabled +// when the compact navigation bar is toggled. +// +//////////////////////////////////////////////////////////////////////////////// +class CompactLocationBarHost : public DropdownBarHost, + public TabStripModelObserver { + public: + explicit CompactLocationBarHost(BrowserView* browser_view); + virtual ~CompactLocationBarHost(); + + // Returns the bounds to locale the compact location bar under the tab. + gfx::Rect GetBoundsUnderTab(int tab_index) const; + + // Updates the content and the position of the compact location bar. + // |index| is the index of the tab the compact location bar + // will be attached to and |animate| specifies if the location bar + // should animate when shown. + void Update(int index, bool animate); + + // (Re)Starts the popup timer that hides the popup after X seconds. + void StartAutoHideTimer(); + + // Cancels the popup timer. + void CancelAutoHideTimer(); + + // Enable/disable the compact location bar. + void SetEnabled(bool enabled); + + // Overridden from views::AcceleratorTarget in DropdownBarHost class. + virtual bool AcceleratorPressed(const views::Accelerator& accelerator); + + // Overridden from DropdownBarHost class. + virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect); + virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw); + + // Overriden from TabStripModelObserver class. + virtual void TabInsertedAt(TabContents* contents, + int index, + bool foreground); + virtual void TabClosingAt(TabContents* contents, int index); + virtual void TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture); + virtual void TabMoved(TabContents* contents, + int from_index, + int to_index, + bool pinned_state_changed); + virtual void TabChangedAt(TabContents* contents, int index, + TabChangeType change_type); + + private: + void HideCallback() { + Hide(true); + } + + // Returns CompactLocationBarView. + CompactLocationBarView* GetClbView(); + + bool IsCurrentTabIndex(int index); + + // The index of the tab that the compact location bar is attached to. + int current_tab_index_; + + scoped_ptr<base::OneShotTimer<CompactLocationBarHost> > auto_hide_timer_; + + DISALLOW_COPY_AND_ASSIGN(CompactLocationBarHost); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_ |