OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/google/google_url_tracker_map_entry.h" |
| 6 |
| 7 #include "chrome/browser/google/google_url_tracker.h" |
| 8 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" |
| 9 #include "chrome/browser/infobars/infobar.h" |
| 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/public/browser/notification_details.h" |
| 12 |
| 13 |
| 14 GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry( |
| 15 GoogleURLTracker* google_url_tracker, |
| 16 InfoBarTabHelper* infobar_helper, |
| 17 const content::NotificationSource& navigation_controller_source, |
| 18 const content::NotificationSource& web_contents_source) |
| 19 : google_url_tracker_(google_url_tracker), |
| 20 infobar_helper_(infobar_helper), |
| 21 infobar_(NULL), |
| 22 navigation_controller_source_(navigation_controller_source), |
| 23 web_contents_source_(web_contents_source) { |
| 24 } |
| 25 |
| 26 GoogleURLTrackerMapEntry::~GoogleURLTrackerMapEntry() { |
| 27 } |
| 28 |
| 29 void GoogleURLTrackerMapEntry::Observe( |
| 30 int type, |
| 31 const content::NotificationSource& source, |
| 32 const content::NotificationDetails& details) { |
| 33 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
| 34 DCHECK_EQ(infobar_helper_, content::Source<InfoBarTabHelper>(source).ptr()); |
| 35 if (content::Details<InfoBarRemovedDetails>(details)->first == infobar_) { |
| 36 google_url_tracker_->DeleteMapEntryForHelper(infobar_helper_); |
| 37 // WARNING: At this point |this| has been deleted! |
| 38 } |
| 39 } |
| 40 |
| 41 void GoogleURLTrackerMapEntry::SetInfoBar( |
| 42 GoogleURLTrackerInfoBarDelegate* infobar) { |
| 43 DCHECK(!infobar_); |
| 44 infobar_ = infobar; |
| 45 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
| 46 content::Source<InfoBarTabHelper>(infobar_helper_)); |
| 47 } |
| 48 |
| 49 void GoogleURLTrackerMapEntry::Close(bool redo_search) { |
| 50 if (infobar_) |
| 51 infobar_->Close(redo_search); |
| 52 else |
| 53 google_url_tracker_->DeleteMapEntryForHelper(infobar_helper_); |
| 54 // WARNING: At this point |this| has been deleted! |
| 55 } |
OLD | NEW |