summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-17 17:37:25 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-17 17:37:25 +0000
commit8a4896cebe780a8ad0eb2d122fe645108d4dbcc1 (patch)
treec2df8cff53e4a4f9e6c201ae9d08470f356521a0 /chrome/browser/views
parent52d69b88461a61effe21c4b62411ccd84285e3a0 (diff)
downloadchromium_src-8a4896cebe780a8ad0eb2d122fe645108d4dbcc1.zip
chromium_src-8a4896cebe780a8ad0eb2d122fe645108d4dbcc1.tar.gz
chromium_src-8a4896cebe780a8ad0eb2d122fe645108d4dbcc1.tar.bz2
Fix for a DCHECK in the infobubble.
The InfoBubble has been changed on Windows so it is parented to its border window. That caused a change in activation changes when losing focus. This resulted in Close() been called more than once, trigerring a DCHECK. This CL ensures multiple invocation of Close don't break. BUG=46749 TEST=Bookmark a page. Click outside the bubble. Click the Edit button. Review URL: http://codereview.chromium.org/2850011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/info_bubble.cc23
-rw-r--r--chrome/browser/views/info_bubble.h12
2 files changed, 22 insertions, 13 deletions
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 274c477..5827521 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -249,19 +249,24 @@ InfoBubble* InfoBubble::Show(views::Widget* parent,
}
void InfoBubble::Close() {
+ if (show_status_ != kOpen)
+ return;
+
+ show_status_ = kClosing;
+
GetFocusManager()->UnregisterAccelerator(
views::Accelerator(base::VKEY_ESCAPE, false, false, false), this);
if (fade_away_on_close_)
FadeOut();
else
- Close(false);
+ DoClose(false);
}
void InfoBubble::AnimationEnded(const Animation* animation) {
if (static_cast<int>(animation_->GetCurrentValue()) == 0) {
// When fading out we just need to close the bubble at the end
- Close(false);
+ DoClose(false);
} else {
#if defined(OS_WIN)
// When fading in we need to remove the layered window style flag, since
@@ -297,7 +302,7 @@ InfoBubble::InfoBubble()
border_(NULL),
#endif
delegate_(NULL),
- closed_(false),
+ show_status_(kOpen),
fade_away_on_close_(false) {
}
@@ -306,7 +311,7 @@ InfoBubble::InfoBubble(views::WidgetGtk::Type type)
: WidgetGtk(type),
border_contents_(NULL),
delegate_(NULL),
- closed_(false),
+ show_status_(kOpen),
fade_away_on_close_(false) {
}
#endif
@@ -456,8 +461,6 @@ void InfoBubble::SizeToContents() {
void InfoBubble::OnActivate(UINT action, BOOL minimized, HWND window) {
// The popup should close when it is deactivated.
if (action == WA_INACTIVE) {
- if (closed_ || (animation_.get() && animation_->IsClosing()))
- return;
Close();
} else if (action == WA_ACTIVE) {
DCHECK(GetRootView()->GetChildViewCount() > 0);
@@ -471,13 +474,13 @@ void InfoBubble::IsActiveChanged() {
}
#endif
-void InfoBubble::Close(bool closed_by_escape) {
- if (closed_)
+void InfoBubble::DoClose(bool closed_by_escape) {
+ if (show_status_ == kClosed)
return;
if (delegate_)
delegate_->InfoBubbleClosing(this, closed_by_escape);
- closed_ = true;
+ show_status_ = kClosed;
#if defined(OS_WIN)
border_->Close();
WidgetWin::Close();
@@ -518,7 +521,7 @@ void InfoBubble::Fade(bool fade_in) {
bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) {
if (!delegate_ || delegate_->CloseOnEscape()) {
- Close(true);
+ DoClose(true);
return true;
}
return false;
diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h
index 3172d09..957d80a 100644
--- a/chrome/browser/views/info_bubble.h
+++ b/chrome/browser/views/info_bubble.h
@@ -252,9 +252,15 @@ class InfoBubble
#endif
private:
+ enum ShowStatus {
+ kOpen,
+ kClosing,
+ kClosed
+ };
+
// Closes the window notifying the delegate. |closed_by_escape| is true if
// the close is the result of pressing escape.
- void Close(bool closed_by_escape);
+ void DoClose(bool closed_by_escape);
// Animates to a visible state.
void FadeIn();
@@ -273,8 +279,8 @@ class InfoBubble
// The animation used to fade the bubble out.
scoped_ptr<SlideAnimation> animation_;
- // Have we been closed?
- bool closed_;
+ // The current visibility status of the bubble.
+ ShowStatus show_status_;
// Whether to fade away when the bubble closes.
bool fade_away_on_close_;