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 374932018845c63b1e30d2a4e0e28338e40730ba..91dc2570ce6d21b7d40c8556a5303310a79c40ce 100644 |
--- a/chrome/browser/ui/hung_plugin_tab_helper.cc |
+++ b/chrome/browser/ui/hung_plugin_tab_helper.cc |
@@ -10,7 +10,6 @@ |
#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" |
@@ -18,8 +17,6 @@ |
#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" |
@@ -262,8 +259,6 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(HungPluginTabHelper); |
HungPluginTabHelper::HungPluginTabHelper(content::WebContents* contents) |
: content::WebContentsObserver(contents) { |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
- content::NotificationService::AllSources()); |
} |
HungPluginTabHelper::~HungPluginTabHelper() { |
@@ -321,33 +316,6 @@ void HungPluginTabHelper::PluginHungStatusChanged( |
ShowBar(plugin_child_id, state.get()); |
} |
-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) { |
- state->infobar = NULL; |
- |
- // Schedule the timer to re-show the infobar if the plugin continues to be |
- // hung. |
- state->timer.Start(FROM_HERE, state->next_reshow_delay, |
- base::Bind(&HungPluginTabHelper::OnReshowTimer, |
- base::Unretained(this), |
- i->first)); |
- |
- // Next time we do this, delay it twice as long to avoid being annoying. |
- state->next_reshow_delay *= 2; |
- return; |
- } |
- } |
-} |
- |
void HungPluginTabHelper::KillPlugin(int child_id) { |
#if defined(OS_WIN) |
// Dump renderers that are sending or receiving pepper messages, in order to |
@@ -409,6 +377,8 @@ void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { |
if (!infobar_service) |
return; |
+ infobar_service->AddObserver(this); |
tfarina
2014/05/25 21:53:30
I can't put this in the ctor, because otherwise, w
Peter Kasting
2014/05/26 21:16:12
You should only be doing this if we're not already
|
+ |
DCHECK(!state->infobar); |
state->infobar = HungPluginInfoBarDelegate::Create(infobar_service, this, |
child_id, state->name); |
@@ -422,3 +392,34 @@ void HungPluginTabHelper::CloseBar(PluginState* state) { |
state->infobar = NULL; |
} |
} |
+ |
+void HungPluginTabHelper::OnInfoBarRemoved(infobars::InfoBar* infobar, |
+ bool animate) { |
+ for (PluginStateMap::iterator i = hung_plugins_.begin(); |
+ i != hung_plugins_.end(); ++i) { |
+ PluginState* state = i->second.get(); |
+ if (state->infobar == infobar) { |
+ state->infobar = NULL; |
+ |
+ // Schedule the timer to re-show the infobar if the plugin continues to be |
+ // hung. |
+ state->timer.Start(FROM_HERE, |
+ state->next_reshow_delay, |
+ base::Bind(&HungPluginTabHelper::OnReshowTimer, |
+ base::Unretained(this), |
+ i->first)); |
+ |
+ // Next time we do this, delay it twice as long to avoid being annoying. |
+ state->next_reshow_delay *= 2; |
+ return; |
+ } |
+ } |
+} |
+ |
+void HungPluginTabHelper::OnManagerShuttingDown( |
+ infobars::InfoBarManager* manager) { |
+ InfoBarService* infobar_service = |
+ InfoBarService::FromWebContents(web_contents()); |
+ if (infobar_service) |
+ infobar_service->RemoveObserver(this); |
+} |