summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 20:43:25 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 20:43:25 +0000
commit944acbb822c2f171526b64943c8174584494fa72 (patch)
tree3928c5f7f53ee547d99dafcadca15e552db0bc28 /chrome/browser
parent3a552d667b98a7ccc081fc53a216e0f48a6e5920 (diff)
downloadchromium_src-944acbb822c2f171526b64943c8174584494fa72.zip
chromium_src-944acbb822c2f171526b64943c8174584494fa72.tar.gz
chromium_src-944acbb822c2f171526b64943c8174584494fa72.tar.bz2
Change notification handling to prevent multiple 'Do you mean...?' infobars from
displaying in a tab. This could happen when the user types in a new query before the AlternateNavURLFetcher was able to resolve the URL. BUG=43378 TEST=Load two single word domains within quick succession in the same tab. Review URL: http://codereview.chromium.org/2747006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/alternate_nav_url_fetcher.cc47
1 files changed, 27 insertions, 20 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc
index bdca7a8..fc21226 100644
--- a/chrome/browser/alternate_nav_url_fetcher.cc
+++ b/chrome/browser/alternate_nav_url_fetcher.cc
@@ -35,26 +35,33 @@ void AlternateNavURLFetcher::Observe(NotificationType type,
const NotificationDetails& details) {
switch (type.value) {
case NotificationType::NAV_ENTRY_PENDING:
- controller_ = Source<NavigationController>(source).ptr();
- DCHECK(controller_->pending_entry());
-
- // Unregister for this notification now that we're pending, and start
- // listening for the corresponding commit. We also need to listen for the
- // tab close command since that means the load will never commit!
- registrar_.Remove(this, NotificationType::NAV_ENTRY_PENDING,
- NotificationService::AllSources());
- registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(controller_));
- registrar_.Add(this, NotificationType::TAB_CLOSED,
- Source<NavigationController>(controller_));
-
- DCHECK_EQ(NOT_STARTED, state_);
- state_ = IN_PROGRESS;
- fetcher_.reset(new URLFetcher(GURL(alternate_nav_url_), URLFetcher::HEAD,
- this));
- fetcher_->set_request_context(
- controller_->profile()->GetRequestContext());
- fetcher_->Start();
+ // If we've already received a notification for the same controller, we
+ // should delete ourselves as that indicates that the page is being
+ // re-loaded so this instance is now stale.
+ // http://crbug.com/43378
+ if (!infobar_contents_ &&
+ controller_ == Source<NavigationController>(source).ptr()) {
+ delete this;
+ } else if (!controller_) {
+ controller_ = Source<NavigationController>(source).ptr();
+ DCHECK(controller_->pending_entry());
+
+ // Start listening for the commit notification. We also need to listen
+ // for the tab close command since that means the load will never
+ // commit!
+ registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(controller_));
+ registrar_.Add(this, NotificationType::TAB_CLOSED,
+ Source<NavigationController>(controller_));
+
+ DCHECK_EQ(NOT_STARTED, state_);
+ state_ = IN_PROGRESS;
+ fetcher_.reset(new URLFetcher(GURL(alternate_nav_url_),
+ URLFetcher::HEAD, this));
+ fetcher_->set_request_context(
+ controller_->profile()->GetRequestContext());
+ fetcher_->Start();
+ }
break;
case NotificationType::NAV_ENTRY_COMMITTED: