Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: chrome/browser/ui/hung_plugin_tab_helper.cc

Issue 338353003: Revert of Change HungPluginTabHelper to listen for infobar changes through Observer style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/hung_plugin_tab_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/ui/hung_plugin_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698