diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 18:41:32 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 18:41:32 +0000 |
commit | 5be94dffc6b19e0ed8397879ad60fe06e498cb3a (patch) | |
tree | 0deaf3ff22bb9d56cab3fcaf8e0a51dea050bd3d /chrome/browser/modal_html_dialog_delegate.cc | |
parent | 0b5f1163a0060e848d90684a2b1c2c8269df292b (diff) | |
download | chromium_src-5be94dffc6b19e0ed8397879ad60fe06e498cb3a.zip chromium_src-5be94dffc6b19e0ed8397879ad60fe06e498cb3a.tar.gz chromium_src-5be94dffc6b19e0ed8397879ad60fe06e498cb3a.tar.bz2 |
Use a NotificationRegistrar to listen for notifications.BUG=2381
Review URL: http://codereview.chromium.org/113743
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/modal_html_dialog_delegate.cc')
-rw-r--r-- | chrome/browser/modal_html_dialog_delegate.cc | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/chrome/browser/modal_html_dialog_delegate.cc b/chrome/browser/modal_html_dialog_delegate.cc index 12cc713..d566b86 100644 --- a/chrome/browser/modal_html_dialog_delegate.cc +++ b/chrome/browser/modal_html_dialog_delegate.cc @@ -15,9 +15,8 @@ ModalHtmlDialogDelegate::ModalHtmlDialogDelegate( : contents_(contents), sync_response_(sync_result) { // Listen for when the TabContents or its renderer dies. - NotificationService::current()-> - AddObserver(this, NotificationType::TAB_CONTENTS_DISCONNECTED, - Source<TabContents>(contents_)); + registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED, + Source<TabContents>(contents_)); // This information is needed to show the dialog HTML content. params_.url = url; @@ -27,7 +26,6 @@ ModalHtmlDialogDelegate::ModalHtmlDialogDelegate( } ModalHtmlDialogDelegate::~ModalHtmlDialogDelegate() { - RemoveObserver(); } void ModalHtmlDialogDelegate::Observe(NotificationType type, @@ -35,7 +33,8 @@ void ModalHtmlDialogDelegate::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(type == NotificationType::TAB_CONTENTS_DISCONNECTED); DCHECK(Source<TabContents>(source).ptr() == contents_); - RemoveObserver(); + registrar_.RemoveAll(); + contents_ = NULL; } bool ModalHtmlDialogDelegate::IsDialogModal() const { @@ -65,14 +64,3 @@ void ModalHtmlDialogDelegate::OnDialogClosed(const std::string& json_retval) { // We are done with this request, so delete us. delete this; } - -void ModalHtmlDialogDelegate::RemoveObserver() { - if (!contents_) - return; - - NotificationService::current()->RemoveObserver( - this, - NotificationType::TAB_CONTENTS_DISCONNECTED, - Source<TabContents>(contents_)); - contents_ = NULL; // No longer safe to access. -} |