summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google/google_url_tracker_map_entry.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/google/google_url_tracker_map_entry.cc')
-rw-r--r--chrome/browser/google/google_url_tracker_map_entry.cc47
1 files changed, 25 insertions, 22 deletions
diff --git a/chrome/browser/google/google_url_tracker_map_entry.cc b/chrome/browser/google/google_url_tracker_map_entry.cc
index d710947..f994f29 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,8 +7,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/google/google_url_tracker.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,
@@ -17,25 +15,14 @@ GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry(
: google_url_tracker_(google_url_tracker),
infobar_manager_(infobar_manager),
infobar_delegate_(NULL),
- navigation_helper_(navigation_helper.Pass()) {
+ navigation_helper_(navigation_helper.Pass()),
+ observing_(false) {
+ DCHECK(infobar_manager_);
}
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_manager_,
- content::Source<infobars::InfoBarManager>(source).ptr());
- if (content::Details<infobars::InfoBar::RemovedDetails>(
- details)->first->delegate() == infobar_delegate_) {
- google_url_tracker_->DeleteMapEntryForManager(infobar_manager_);
- // WARNING: At this point |this| has been deleted!
- }
+ if (observing_)
+ infobar_manager_->RemoveObserver(this);
}
void GoogleURLTrackerMapEntry::SetInfoBarDelegate(
@@ -47,9 +34,8 @@ void GoogleURLTrackerMapEntry::SetInfoBarDelegate(
// the case where the user accepts the new Google URL.
infobar_delegate->set_navigation_helper(navigation_helper_.Pass());
infobar_delegate_ = infobar_delegate;
- registrar_.Add(this,
- chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
- content::Source<infobars::InfoBarManager>(infobar_manager_));
+ infobar_manager_->AddObserver(this);
+ observing_ = true;
}
void GoogleURLTrackerMapEntry::Close(bool redo_search) {
@@ -62,3 +48,20 @@ void GoogleURLTrackerMapEntry::Close(bool redo_search) {
}
// WARNING: At this point |this| has been deleted!
}
+
+void GoogleURLTrackerMapEntry::OnInfoBarRemoved(infobars::InfoBar* infobar,
+ bool animate) {
+ DCHECK(infobar_delegate_);
+ if (infobar->delegate() == infobar_delegate_) {
+ google_url_tracker_->DeleteMapEntryForManager(infobar_manager_);
+ // WARNING: At this point |this| has been deleted!
+ }
+}
+
+void GoogleURLTrackerMapEntry::OnManagerShuttingDown(
+ infobars::InfoBarManager* manager) {
+ DCHECK(observing_);
+ DCHECK_EQ(infobar_manager_, manager);
+ manager->RemoveObserver(this);
+ observing_ = false;
+}