Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_container.cc

Issue 6788014: Fix DCHECK() in infobar animation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/infobars/infobar_container.h" 5 #include "chrome/browser/ui/views/infobars/infobar_container.h"
6 6
7 #include "chrome/browser/tab_contents/infobar_delegate.h" 7 #include "chrome/browser/tab_contents/infobar_delegate.h"
8 #include "chrome/browser/ui/views/infobars/infobar.h" 8 #include "chrome/browser/ui/views/infobars/infobar.h"
9 #include "content/browser/tab_contents/tab_contents.h" 9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "content/common/notification_details.h" 10 #include "content/common/notification_details.h"
11 #include "content/common/notification_source.h" 11 #include "content/common/notification_source.h"
12 12
13 InfoBarContainer::Delegate::~Delegate() { 13 InfoBarContainer::Delegate::~Delegate() {
14 } 14 }
15 15
16 InfoBarContainer::InfoBarContainer(Delegate* delegate) 16 InfoBarContainer::InfoBarContainer(Delegate* delegate)
17 : delegate_(delegate), 17 : delegate_(delegate),
18 tab_contents_(NULL) { 18 tab_contents_(NULL) {
19 } 19 }
20 20
21 InfoBarContainer::~InfoBarContainer() { 21 InfoBarContainer::~InfoBarContainer() {
22 // Before we remove any children, we reset |delegate_|, so that no removals 22 // Before we remove any children, we reset |delegate_|, so that no removals
23 // will result in us trying to call delegate_->InfoBarContainerSizeChanged(). 23 // will result in us trying to call
24 // This is important because at this point |delegate_| may be shutting down, 24 // delegate_->InfoBarContainerHeightChanged(). This is important because at
25 // and it's at best unimportant and at worst disastrous to call that. 25 // this point |delegate_| may be shutting down, and it's at best unimportant
26 // and at worst disastrous to call that.
26 delegate_ = NULL; 27 delegate_ = NULL;
27 ChangeTabContents(NULL); 28 ChangeTabContents(NULL);
28 } 29 }
29 30
30 void InfoBarContainer::ChangeTabContents(TabContents* contents) { 31 void InfoBarContainer::ChangeTabContents(TabContents* contents) {
31 registrar_.RemoveAll(); 32 registrar_.RemoveAll();
32 33
33 while (!infobars_.empty()) { 34 while (!infobars_.empty()) {
34 InfoBar* infobar = *infobars_.begin(); 35 InfoBar* infobar = *infobars_.begin();
35 // NULL the container pointer first so that if the infobar is currently 36 // NULL the container pointer first so that if the infobar is currently
(...skipping 17 matching lines...) Expand all
53 54
54 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) { 55 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) {
55 // As when we removed the infobars above, we prevent callbacks to 56 // As when we removed the infobars above, we prevent callbacks to
56 // OnInfoBarAnimated() for each infobar. 57 // OnInfoBarAnimated() for each infobar.
57 AddInfoBar(tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(), false, 58 AddInfoBar(tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(), false,
58 NO_CALLBACK); 59 NO_CALLBACK);
59 } 60 }
60 } 61 }
61 62
62 // Now that everything is up to date, signal the delegate to re-layout. 63 // Now that everything is up to date, signal the delegate to re-layout.
63 OnInfoBarAnimated(true); 64 OnInfoBarHeightChanged(true);
64 } 65 }
65 66
66 void InfoBarContainer::OnInfoBarAnimated(bool done) { 67 void InfoBarContainer::OnInfoBarHeightChanged(bool is_animating) {
67 if (delegate_) 68 if (delegate_)
68 delegate_->InfoBarContainerSizeChanged(!done); 69 delegate_->InfoBarContainerHeightChanged(is_animating);
69 } 70 }
70 71
71 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) { 72 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
72 tab_contents_->RemoveInfoBar(delegate); 73 tab_contents_->RemoveInfoBar(delegate);
73 } 74 }
74 75
75 void InfoBarContainer::RemoveInfoBar(InfoBar* infobar) { 76 void InfoBarContainer::RemoveInfoBar(InfoBar* infobar) {
76 PlatformSpecificRemoveInfoBar(infobar); 77 PlatformSpecificRemoveInfoBar(infobar);
77 infobars_.erase(infobar); 78 infobars_.erase(infobar);
78 } 79 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool animate, 126 bool animate,
126 CallbackStatus callback_status) { 127 CallbackStatus callback_status) {
127 infobars_.insert(infobar); 128 infobars_.insert(infobar);
128 PlatformSpecificAddInfoBar(infobar); 129 PlatformSpecificAddInfoBar(infobar);
129 if (callback_status == WANT_CALLBACK) 130 if (callback_status == WANT_CALLBACK)
130 infobar->set_container(this); 131 infobar->set_container(this);
131 infobar->Show(animate); 132 infobar->Show(animate);
132 if (callback_status == NO_CALLBACK) 133 if (callback_status == NO_CALLBACK)
133 infobar->set_container(this); 134 infobar->set_container(this);
134 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_container.h ('k') | chrome/browser/ui/views/infobars/infobar_container_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698