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

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 3186022: Merging r56866 to M6 branch:... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/tab_contents.cc
===================================================================
--- chrome/browser/tab_contents/tab_contents.cc (revision 56923)
+++ chrome/browser/tab_contents/tab_contents.cc (working copy)
@@ -1040,12 +1040,20 @@
NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
Source<TabContents>(this),
Details<InfoBarDelegate>(delegate));
- infobar_delegates_.erase(it);
- // Remove ourselves as an observer if we are tracking no more InfoBars.
- if (infobar_delegates_.empty()) {
- registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&controller_));
+ // Just to be safe, make sure the delegate was not removed by an observer.
+ it = find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
+ if (it != infobar_delegates_.end()) {
+ infobar_delegates_.erase(it);
+ // Remove ourselves as an observer if we are tracking no more InfoBars.
+ if (infobar_delegates_.empty()) {
+ registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(&controller_));
+ }
+ } else {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
}
}
}
@@ -1070,10 +1078,21 @@
Source<TabContents>(this),
Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get()));
- // Remove the old one.
- infobar_delegates_.erase(it);
+ // Just to be safe, make sure the delegate was not removed by an observer.
+ it = find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
+ if (it != infobar_delegates_.end()) {
+ // Remove the old one.
+ infobar_delegates_.erase(it);
+ } else {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
+ }
// Add the new one.
+ DCHECK(find(infobar_delegates_.begin(),
+ infobar_delegates_.end(), new_delegate) ==
+ infobar_delegates_.end());
infobar_delegates_.push_back(new_delegate);
}
@@ -1461,6 +1480,13 @@
for (int i = infobar_delegate_count() - 1; i >= 0; --i) {
InfoBarDelegate* delegate = GetInfoBarDelegateAt(i);
+ if (!delegate) {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
+ continue;
+ }
+
if (delegate->ShouldExpire(details))
RemoveInfoBar(delegate);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698