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

Unified Diff: chrome/browser/google/google_url_tracker.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 | « no previous file | chrome/browser/infobars/infobar_tab_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google/google_url_tracker.cc
===================================================================
--- chrome/browser/google/google_url_tracker.cc (revision 134398)
+++ chrome/browser/google/google_url_tracker.cc (working copy)
@@ -86,11 +86,24 @@
}
void GoogleURLTrackerInfoBarDelegate::Show() {
- owner()->AddInfoBar(this);
showing_ = true;
+ owner()->AddInfoBar(this); // May delete |this| on failure!
}
void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) {
+ if (redo_search) {
+ // Re-do the user's search on the new domain.
+ url_canon::Replacements<char> replacements;
+ const std::string& host(new_google_url_.host());
+ replacements.SetHost(host.data(), url_parse::Component(0, host.length()));
+ GURL new_search_url(search_url_.ReplaceComponents(replacements));
+ if (new_search_url.is_valid()) {
+ content::OpenURLParams params(new_search_url, content::Referrer(),
+ CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false);
+ owner()->web_contents()->OpenURL(params);
+ }
+ }
+
if (!showing_) {
// We haven't been added to a tab, so just delete ourselves.
delete this;
@@ -104,29 +117,15 @@
google_url_tracker_->InfoBarClosed(map_key_);
google_url_tracker_ = NULL;
- // If we were showing in a background tab that was then closed, we could have
- // been leaked, and subsequently reached here due to
- // GoogleURLTracker::CloseAllInfoBars(). In this case our owner is now NULL
- // so we should just do nothing.
- // TODO(pkasting): This can go away once the InfoBar ownership model is fixed
- // so that infobars in background tabs don't leak on tab closure.
- if (!owner())
- return;
-
- if (redo_search) {
- // Re-do the user's search on the new domain.
- url_canon::Replacements<char> replacements;
- const std::string& host(new_google_url_.host());
- replacements.SetHost(host.data(), url_parse::Component(0, host.length()));
- GURL new_search_url(search_url_.ReplaceComponents(replacements));
- if (new_search_url.is_valid()) {
- content::OpenURLParams params(new_search_url, content::Referrer(),
- CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false);
- owner()->web_contents()->OpenURL(params);
- }
- }
-
- owner()->RemoveInfoBar(this);
+ // If we're already animating closed, we won't have an owner. Do nothing in
+ // this case.
+ // TODO(pkasting): For now, this can also happen if we were showing in a
+ // background tab that was then closed, in which case we'll have leaked and
+ // subsequently reached here due to GoogleURLTracker::CloseAllInfoBars().
+ // This case will no longer happen once infobars are refactored to own their
+ // delegates.
+ if (owner())
+ owner()->RemoveInfoBar(this);
}
GoogleURLTrackerInfoBarDelegate::~GoogleURLTrackerInfoBarDelegate() {
« no previous file with comments | « no previous file | chrome/browser/infobars/infobar_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698