summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-07 00:52:31 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-07 00:52:31 +0000
commitc83c9e683a9376cea1ef675bfe92f7dbb98d45f5 (patch)
treef50ff4edc61b1baa1dd10c8716af53fbeb7ce65e /chrome/browser/views
parentea99c3abb5ad6121d94a4c4cf1ca683d4f0ebd90 (diff)
downloadchromium_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/views')
-rw-r--r--chrome/browser/views/dropdown_bar_host.cc24
-rw-r--r--chrome/browser/views/dropdown_bar_host.h17
-rw-r--r--chrome/browser/views/find_bar_host.cc2
-rw-r--r--chrome/browser/views/frame/browser_view.cc3
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc4
5 files changed, 38 insertions, 12 deletions
diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc
index ee647d25..aa66672 100644
--- a/chrome/browser/views/dropdown_bar_host.cc
+++ b/chrome/browser/views/dropdown_bar_host.cc
@@ -26,7 +26,8 @@ bool DropdownBarHost::disable_animations_during_testing_ = false;
DropdownBarHost::DropdownBarHost(BrowserView* browser_view)
: browser_view_(browser_view),
animation_offset_(0),
- esc_accel_target_registered_(false) {
+ esc_accel_target_registered_(false),
+ is_visible_(false) {
}
void DropdownBarHost::Init(DropdownBarView* view) {
@@ -58,15 +59,20 @@ DropdownBarHost::~DropdownBarHost() {
focus_tracker_.reset(NULL);
}
-void DropdownBarHost::Show() {
+void DropdownBarHost::Show(bool animate) {
// Stores the currently focused view, and tracks focus changes so that we can
// restore focus when the dropdown widget is closed.
focus_tracker_.reset(new views::ExternalFocusTracker(view_, focus_manager_));
- if (disable_animations_during_testing_) {
- animation_->Reset(1);
- AnimationProgressed(animation_.get());
+ if (!animate || disable_animations_during_testing_) {
+ if (!is_visible_) {
+ // Don't re-start the animation.
+ is_visible_ = true;
+ animation_->Reset(1);
+ AnimationProgressed(animation_.get());
+ }
} else {
+ is_visible_ = true;
animation_->Reset();
animation_->Show();
}
@@ -81,10 +87,15 @@ bool DropdownBarHost::IsAnimating() const {
}
void DropdownBarHost::Hide(bool animate) {
+ if (!IsVisible()) {
+ return;
+ }
if (animate && !disable_animations_during_testing_) {
animation_->Reset(1.0);
animation_->Hide();
} else {
+ StopAnimation();
+ is_visible_ = false;
host_->Hide();
}
}
@@ -94,7 +105,7 @@ void DropdownBarHost::StopAnimation() {
}
bool DropdownBarHost::IsVisible() const {
- return host_->IsVisible();
+ return is_visible_;
}
////////////////////////////////////////////////////////////////////////////////
@@ -149,6 +160,7 @@ void DropdownBarHost::AnimationEnded(const Animation* animation) {
if (!animation_->IsShowing()) {
// Animation has finished closing.
host_->Hide();
+ is_visible_ = false;
} else {
// Animation has finished opening.
}
diff --git a/chrome/browser/views/dropdown_bar_host.h b/chrome/browser/views/dropdown_bar_host.h
index 635ee18..58dcc17 100644
--- a/chrome/browser/views/dropdown_bar_host.h
+++ b/chrome/browser/views/dropdown_bar_host.h
@@ -49,7 +49,7 @@ class DropdownBarHost : public views::AcceleratorTarget,
// Returns true if the dropdown bar view is visible, or false otherwise.
bool IsVisible() const;
// Shows the dropdown bar.
- void Show();
+ void Show(bool animate);
// Hides the dropdown bar.
void Hide(bool animate);
// Selects text in the entry field and set focus.
@@ -84,13 +84,13 @@ class DropdownBarHost : public views::AcceleratorTarget,
// having to poll it while it animates to open/closed status.
static bool disable_animations_during_testing_;
+ // Returns the browser view that the dropdown belongs to.
+ BrowserView* browser_view() const { return browser_view_; }
+
protected:
// Returns the dropdown bar view.
DropdownBarView* view() const { return view_; }
- // Returns the browser view that the dropdown belongs to.
- BrowserView* browser_view() const { return browser_view_; }
-
// Returns the focus tracker.
views::ExternalFocusTracker* focus_tracker() const {
return focus_tracker_.get();
@@ -143,6 +143,11 @@ class DropdownBarHost : public views::AcceleratorTarget,
const TabContents* contents,
const views::Textfield::Keystroke& key_stroke);
+ // Returns the animation for the dropdown.
+ SlideAnimation* animation() {
+ return animation_.get();
+ }
+
private:
// The BrowserView that created us.
BrowserView* browser_view_;
@@ -172,6 +177,10 @@ class DropdownBarHost : public views::AcceleratorTarget,
// dropdown bar. It contains the DropdownBarView.
scoped_ptr<views::Widget> host_;
+ // A flag to manually manage visibility. GTK/X11 is asynchrnous and
+ // the state of the widget can be out of sync.
+ bool is_visible_;
+
DISALLOW_COPY_AND_ASSIGN(DropdownBarHost);
};
diff --git a/chrome/browser/views/find_bar_host.cc b/chrome/browser/views/find_bar_host.cc
index 1e7cca7..212baf7 100644
--- a/chrome/browser/views/find_bar_host.cc
+++ b/chrome/browser/views/find_bar_host.cc
@@ -51,7 +51,7 @@ FindBarHost::~FindBarHost() {
}
void FindBarHost::Show() {
- DropdownBarHost::Show();
+ DropdownBarHost::Show(true);
}
void FindBarHost::SetFocusAndSelection() {
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index f708963..5a230f3 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -445,6 +445,9 @@ BrowserView::~BrowserView() {
// notifications will call back into deleted objects).
download_shelf_.reset();
+ // Destory extender before destroying browser.
+ browser_extender_.reset();
+
// Explicitly set browser_ to NULL.
browser_.reset();
}
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 9c36b43..9a419db 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -782,7 +782,8 @@ void TabStrip::DestroyDraggedSourceTab(Tab* tab) {
}
gfx::Rect TabStrip::GetIdealBounds(int index) {
- DCHECK(index >= 0 && index < GetTabCount());
+ DCHECK_GE(index, 0);
+ DCHECK_LT(index, GetTabCount());
return tab_data_.at(index).ideal_bounds;
}
@@ -1953,6 +1954,7 @@ void TabStrip::RemoveTabAt(int index) {
removed->GetParent()->RemoveChildView(removed);
delete removed;
}
+ GenerateIdealBounds();
}
void TabStrip::HandleGlobalMouseMoveEvent() {