Index: chrome/browser/google/google_url_tracker_map_entry.cc |
diff --git a/chrome/browser/google/google_url_tracker_map_entry.cc b/chrome/browser/google/google_url_tracker_map_entry.cc |
index e0798fd144f58c9afe72064c15bf136aa99863b2..39666ce461bb7fff6d6938e9990332b9bee21618 100644 |
--- a/chrome/browser/google/google_url_tracker_map_entry.cc |
+++ b/chrome/browser/google/google_url_tracker_map_entry.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -7,10 +7,8 @@ |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/google/google_url_tracker.h" |
#include "chrome/browser/google/google_url_tracker_infobar_delegate.h" |
+#include "chrome/browser/infobars/infobar_service.h" |
#include "components/infobars/core/infobar.h" |
-#include "content/public/browser/notification_details.h" |
-#include "content/public/browser/notification_source.h" |
- |
GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry( |
GoogleURLTracker* google_url_tracker, |
@@ -19,32 +17,22 @@ GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry( |
: google_url_tracker_(google_url_tracker), |
infobar_service_(infobar_service), |
infobar_delegate_(NULL), |
- navigation_controller_(navigation_controller) { |
+ navigation_controller_(navigation_controller), |
+ observing_(false) { |
+ DCHECK(infobar_service_); |
} |
GoogleURLTrackerMapEntry::~GoogleURLTrackerMapEntry() { |
-} |
- |
-void GoogleURLTrackerMapEntry::Observe( |
- int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
- DCHECK(infobar_delegate_); |
- DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
- DCHECK_EQ(infobar_service_, content::Source<InfoBarService>(source).ptr()); |
- if (content::Details<infobars::InfoBar::RemovedDetails>( |
- details)->first->delegate() == infobar_delegate_) { |
- google_url_tracker_->DeleteMapEntryForService(infobar_service_); |
- // WARNING: At this point |this| has been deleted! |
- } |
+ if (observing_) |
+ infobar_service_->RemoveObserver(this); |
} |
void GoogleURLTrackerMapEntry::SetInfoBarDelegate( |
GoogleURLTrackerInfoBarDelegate* infobar_delegate) { |
DCHECK(!infobar_delegate_); |
infobar_delegate_ = infobar_delegate; |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
- content::Source<InfoBarService>(infobar_service_)); |
+ infobar_service_->AddObserver(this); |
+ observing_ = true; |
} |
void GoogleURLTrackerMapEntry::Close(bool redo_search) { |
@@ -57,3 +45,22 @@ void GoogleURLTrackerMapEntry::Close(bool redo_search) { |
} |
// WARNING: At this point |this| has been deleted! |
} |
+ |
+// infobars::InfoBarManager::Observer implementation. |
+ |
+void GoogleURLTrackerMapEntry::OnInfoBarRemoved(infobars::InfoBar* infobar, |
+ bool animate) { |
+ DCHECK(infobar_delegate_); |
+ if (infobar->delegate() == infobar_delegate_) { |
+ google_url_tracker_->DeleteMapEntryForService(infobar_service_); |
+ // WARNING: At this point |this| has been deleted! |
+ } |
+} |
+ |
+void GoogleURLTrackerMapEntry::OnManagerShuttingDown( |
+ infobars::InfoBarManager* manager) { |
+ DCHECK(observing_); |
+ DCHECK_EQ(infobar_service_, manager); |
+ manager->RemoveObserver(this); |
+ observing_ = false; |
+} |