diff options
author | amineer@chromium.org <amineer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 15:28:40 +0000 |
---|---|---|
committer | amineer@chromium.org <amineer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 15:28:40 +0000 |
commit | ff988725bccda617454de9761378ca82ceaddbe0 (patch) | |
tree | 838d751ccbcd8cb063f609c364cc5c7d0f155d7d | |
parent | 252b521e113e15a24c52aa9b62ded937222e1aed (diff) | |
download | chromium_src-ff988725bccda617454de9761378ca82ceaddbe0.zip chromium_src-ff988725bccda617454de9761378ca82ceaddbe0.tar.gz chromium_src-ff988725bccda617454de9761378ca82ceaddbe0.tar.bz2 |
Revert 277292 "Change HungPluginTabHelper to listen for infobar ..."
Reverting on branch to determine if suspect CL is root cause for new crasher.
BUG=385068
> Change HungPluginTabHelper to listen for infobar changes through Observer style.
>
> Test plan:
>
> 1) out/Debug/chrome --no-sandbox --ppapi-flash-path=/opt/google/chrome/PepperFlash/libpepflashplayer.so --ppapi-flash-version=`grep -i version /opt/google/chrome/PepperFlash/manifest.json | awk '{print $2}' | awk -F"\"" '{print $2}'`
> 2) Go to a site that has flash, e.g., http://www.flash-game.net/
> 3) Open Task Manager, Shift+Esc
> 4) Search for "Plug-in: Shockwave Flash" in the list.
> 5) Select it and click on "End process" button.
> 6) Go to the website and observe the infobar.
>
> Another way to test it is:
>
> 1) Add an infinite loop into ppapi/examples/scripting/post_message.cc
> 2) Build ppapi_example_post_message
> 3) out/Debug/chrome --no-sandbox --register-pepper-plugins="/home/tfarina/chromium/src/out/Debug/lib/libppapi_example_post_message.so;application/x-ppapi-post-message-example" ppapi/examples/scripting/post_message.html
>
> BUG=354380
> TEST=see above
> R=pkasting@chromium.org
>
> Review URL: https://codereview.chromium.org/297293002
TBR=tfarina@chromium.org
Review URL: https://codereview.chromium.org/336173003
git-svn-id: svn://svn.chromium.org/chrome/branches/2053/src@277446 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/hung_plugin_tab_helper.cc | 31 | ||||
-rw-r--r-- | chrome/browser/ui/hung_plugin_tab_helper.h | 20 |
2 files changed, 23 insertions, 28 deletions
diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc index 4791b7f..3749320 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 @@ HungPluginTabHelper::PluginState::~PluginState() { 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 @@ void HungPluginTabHelper::PluginHungStatusChanged( 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 @@ void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { 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) { diff --git a/chrome/browser/ui/hung_plugin_tab_helper.h b/chrome/browser/ui/hung_plugin_tab_helper.h index b71eeb7..6cf1a39 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.h +++ b/chrome/browser/ui/hung_plugin_tab_helper.h @@ -11,7 +11,8 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "components/infobars/core/infobar_manager.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" @@ -36,8 +37,8 @@ class InfoBarDelegate; // - Hide the infobar if the plugin starts responding again. // - Keep track of all of this for any number of plugins. class HungPluginTabHelper - : public infobars::InfoBarManager::Observer, - public content::WebContentsObserver, + : public content::WebContentsObserver, + public content::NotificationObserver, public content::WebContentsUserData<HungPluginTabHelper> { public: virtual ~HungPluginTabHelper(); @@ -49,6 +50,11 @@ class HungPluginTabHelper const base::FilePath& plugin_path, bool is_hung) OVERRIDE; + // content::NotificationObserver: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + // Called by an infobar when the user selects to kill the plugin. void KillPlugin(int child_id); @@ -71,17 +77,11 @@ class HungPluginTabHelper // be called even if the bar is not opened, in which case it will do nothing. void CloseBar(PluginState* state); - // infobars::InfoBarManager::Observer: - virtual void OnInfoBarRemoved(infobars::InfoBar* infobar, - bool animate) OVERRIDE; + content::NotificationRegistrar registrar_; // All currently hung plugins. PluginStateMap hung_plugins_; - // The number of hung plugin infobars open. We use this to determine when we - // should remove ourself as an observer of InfoBarManager notifications. - int number_of_infobars_; - DISALLOW_COPY_AND_ASSIGN(HungPluginTabHelper); }; |