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

Unified Diff: chrome/browser/infobars/infobar_tab_helper.cc

Issue 10262026: A few small tweaks based on further analysis of GoogleURLTracker: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/infobars/infobar_tab_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/infobars/infobar_tab_helper.cc
===================================================================
--- chrome/browser/infobars/infobar_tab_helper.cc (revision 134398)
+++ chrome/browser/infobars/infobar_tab_helper.cc (working copy)
@@ -38,8 +38,10 @@
return;
}
- for (size_t i = 0; i < infobars_.size(); ++i) {
- if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) {
+ for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end();
+ ++i) {
+ if ((*i)->EqualsDelegate(delegate)) {
+ DCHECK_NE(*i, delegate);
delegate->InfoBarClosed();
return;
}
@@ -75,17 +77,14 @@
return;
}
- size_t i;
- for (i = 0; i < infobars_.size(); ++i) {
- if (GetInfoBarDelegateAt(i) == old_delegate)
- break;
- }
- DCHECK_LT(i, infobars_.size());
+ InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(),
+ old_delegate));
+ DCHECK(i != infobars_.end());
- infobars_.insert(infobars_.begin() + i, new_delegate);
+ i = infobars_.insert(i, new_delegate) + 1;
// Remove the old delegate before notifying, so that if any observers call
// back to AddInfoBar() or similar, we don't dupe-check against this delegate.
- infobars_.erase(infobars_.begin() + i + 1);
+ infobars_.erase(i);
old_delegate->clear_owner();
InfoBarReplacedDetails replaced_details(old_delegate, new_delegate);
@@ -106,18 +105,13 @@
return;
}
- size_t i;
- for (i = 0; i < infobars_.size(); ++i) {
- if (GetInfoBarDelegateAt(i) == delegate)
- break;
- }
- DCHECK_LT(i, infobars_.size());
- InfoBarDelegate* infobar = infobars_[i];
+ InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), delegate));
+ DCHECK(i != infobars_.end());
- infobar->clear_owner();
+ delegate->clear_owner();
// Remove the delegate before notifying, so that if any observers call back to
// AddInfoBar() or similar, we don't dupe-check against this delegate.
- infobars_.erase(infobars_.begin() + i);
+ infobars_.erase(i);
// Remove ourselves as an observer if we are tracking no more InfoBars.
if (infobars_.empty()) {
registrar_.Remove(
@@ -126,7 +120,7 @@
&web_contents()->GetController()));
}
- InfoBarRemovedDetails removed_details(infobar, animate);
+ InfoBarRemovedDetails removed_details(delegate, animate);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
content::Source<InfoBarTabHelper>(this),
« no previous file with comments | « chrome/browser/infobars/infobar_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698