Index: chrome/browser/ui/hung_plugin_tab_helper.cc |
diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc |
index 4791b7f144764c1c01e0ba947fdb8cd4e885f985..374932018845c63b1e30d2a4e0e28338e40730ba 100644 |
--- a/chrome/browser/ui/hung_plugin_tab_helper.cc |
+++ b/chrome/browser/ui/hung_plugin_tab_helper.cc |
@@ -10,6 +10,7 @@ |
#include "base/process/process.h" |
#include "base/rand_util.h" |
#include "build/build_config.h" |
+#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/infobars/infobar_service.h" |
#include "chrome/common/chrome_version_info.h" |
#include "components/infobars/core/confirm_infobar_delegate.h" |
@@ -17,6 +18,8 @@ |
#include "content/public/browser/browser_child_process_host_iterator.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/child_process_data.h" |
+#include "content/public/browser/notification_details.h" |
+#include "content/public/browser/notification_service.h" |
#include "content/public/browser/plugin_service.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/common/process_type.h" |
@@ -258,15 +261,12 @@ |
DEFINE_WEB_CONTENTS_USER_DATA_KEY(HungPluginTabHelper); |
HungPluginTabHelper::HungPluginTabHelper(content::WebContents* contents) |
- : content::WebContentsObserver(contents), |
- number_of_infobars_(0) { |
+ : content::WebContentsObserver(contents) { |
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
+ content::NotificationService::AllSources()); |
} |
HungPluginTabHelper::~HungPluginTabHelper() { |
- // If we're getting shut down before the InfoBarService, we need to unregister |
- // as an observer. |
- if (number_of_infobars_ != 0) |
- InfoBarService::FromWebContents(web_contents())->RemoveObserver(this); |
} |
void HungPluginTabHelper::PluginCrashed(const base::FilePath& plugin_path, |
@@ -321,16 +321,17 @@ |
ShowBar(plugin_child_id, state.get()); |
} |
-void HungPluginTabHelper::OnInfoBarRemoved(infobars::InfoBar* infobar, |
- bool animate) { |
+void HungPluginTabHelper::Observe( |
+ int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) { |
+ DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
+ infobars::InfoBar* infobar = |
+ content::Details<infobars::InfoBar::RemovedDetails>(details)->first; |
for (PluginStateMap::iterator i = hung_plugins_.begin(); |
i != hung_plugins_.end(); ++i) { |
PluginState* state = i->second.get(); |
if (state->infobar == infobar) { |
- --number_of_infobars_; |
- if (number_of_infobars_ == 0) |
- InfoBarService::FromWebContents(web_contents())->RemoveObserver(this); |
- |
state->infobar = NULL; |
// Schedule the timer to re-show the infobar if the plugin continues to be |
@@ -411,12 +412,6 @@ |
DCHECK(!state->infobar); |
state->infobar = HungPluginInfoBarDelegate::Create(infobar_service, this, |
child_id, state->name); |
- |
- if (state->infobar) { |
- ++number_of_infobars_; |
- if (number_of_infobars_ == 1) |
- infobar_service->AddObserver(this); |
- } |
} |
void HungPluginTabHelper::CloseBar(PluginState* state) { |