| Index: chrome/browser/plugins/plugin_infobar_delegates.cc
|
| ===================================================================
|
| --- chrome/browser/plugins/plugin_infobar_delegates.cc (revision 238220)
|
| +++ chrome/browser/plugins/plugin_infobar_delegates.cc (working copy)
|
| @@ -8,6 +8,7 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map.h"
|
| #include "chrome/browser/google/google_util.h"
|
| +#include "chrome/browser/infobars/infobar.h"
|
| #include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/lifetime/application_lifetime.h"
|
| #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
|
| @@ -48,9 +49,8 @@
|
|
|
| // PluginInfoBarDelegate ------------------------------------------------------
|
|
|
| -PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarService* infobar_service,
|
| - const std::string& identifier)
|
| - : ConfirmInfoBarDelegate(infobar_service),
|
| +PluginInfoBarDelegate::PluginInfoBarDelegate(const std::string& identifier)
|
| + : ConfirmInfoBarDelegate(),
|
| identifier_(identifier) {
|
| }
|
|
|
| @@ -90,9 +90,9 @@
|
| HostContentSettingsMap* content_settings,
|
| const string16& name,
|
| const std::string& identifier) {
|
| - infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
|
| - new UnauthorizedPluginInfoBarDelegate(infobar_service, content_settings,
|
| - name, identifier)));
|
| + infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
|
| + scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate(
|
| + content_settings, name, identifier))));
|
|
|
| content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown"));
|
| std::string utf8_name(UTF16ToUTF8(name));
|
| @@ -114,11 +114,10 @@
|
| }
|
|
|
| UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate(
|
| - InfoBarService* infobar_service,
|
| HostContentSettingsMap* content_settings,
|
| const string16& name,
|
| const std::string& identifier)
|
| - : PluginInfoBarDelegate(infobar_service, identifier),
|
| + : PluginInfoBarDelegate(identifier),
|
| content_settings_(content_settings),
|
| name_(name) {
|
| }
|
| @@ -179,21 +178,19 @@
|
| // Copy the name out of |plugin_metadata| now, since the Pass() call below
|
| // will make it impossible to get at.
|
| string16 name(plugin_metadata->name());
|
| - infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
|
| - new OutdatedPluginInfoBarDelegate(
|
| - infobar_service, installer, plugin_metadata.Pass(),
|
| - l10n_util::GetStringFUTF16(
|
| + infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
|
| + scoped_ptr<ConfirmInfoBarDelegate>(new OutdatedPluginInfoBarDelegate(
|
| + installer, plugin_metadata.Pass(), l10n_util::GetStringFUTF16(
|
| (installer->state() == PluginInstaller::INSTALLER_STATE_IDLE) ?
|
| IDS_PLUGIN_OUTDATED_PROMPT : IDS_PLUGIN_DOWNLOADING,
|
| - name))));
|
| + name)))));
|
| }
|
|
|
| OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate(
|
| - InfoBarService* infobar_service,
|
| PluginInstaller* installer,
|
| scoped_ptr<PluginMetadata> plugin_metadata,
|
| const string16& message)
|
| - : PluginInfoBarDelegate(infobar_service, plugin_metadata->identifier()),
|
| + : PluginInfoBarDelegate(plugin_metadata->identifier()),
|
| WeakPluginInstallerObserver(installer),
|
| plugin_metadata_(plugin_metadata.Pass()),
|
| message_(message) {
|
| @@ -290,8 +287,7 @@
|
| }
|
|
|
| void OutdatedPluginInfoBarDelegate::OnlyWeakObserversLeft() {
|
| - if (owner())
|
| - owner()->RemoveInfoBar(this);
|
| + infobar()->RemoveSelf();
|
| }
|
|
|
| void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar(
|
| @@ -299,10 +295,10 @@
|
| // Return early if the message doesn't change. This is important in case the
|
| // PluginInstaller is still iterating over its observers (otherwise we would
|
| // keep replacing infobar delegates infinitely).
|
| - if ((message_ == message) || !owner())
|
| + if ((message_ == message) || !infobar()->owner())
|
| return;
|
| PluginInstallerInfoBarDelegate::Replace(
|
| - this, installer(), plugin_metadata_->Clone(), false, message);
|
| + infobar(), installer(), plugin_metadata_->Clone(), false, message);
|
| }
|
|
|
|
|
| @@ -321,39 +317,39 @@
|
| return;
|
| }
|
| #endif
|
| - infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
|
| - new PluginInstallerInfoBarDelegate(
|
| - infobar_service, installer, plugin_metadata.Pass(), callback, true,
|
| + infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
|
| + scoped_ptr<ConfirmInfoBarDelegate>(new PluginInstallerInfoBarDelegate(
|
| + installer, plugin_metadata.Pass(), callback, true,
|
| l10n_util::GetStringFUTF16(
|
| (installer->state() == PluginInstaller::INSTALLER_STATE_IDLE) ?
|
| IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT :
|
| IDS_PLUGIN_DOWNLOADING,
|
| - name))));
|
| -
|
| + name)))));
|
| }
|
|
|
| +
|
| void PluginInstallerInfoBarDelegate::Replace(
|
| - InfoBarDelegate* infobar,
|
| + InfoBar* infobar,
|
| PluginInstaller* installer,
|
| scoped_ptr<PluginMetadata> plugin_metadata,
|
| bool new_install,
|
| const string16& message) {
|
| DCHECK(infobar->owner());
|
| - infobar->owner()->ReplaceInfoBar(infobar, scoped_ptr<InfoBarDelegate>(
|
| - new PluginInstallerInfoBarDelegate(
|
| - infobar->owner(), installer, plugin_metadata.Pass(),
|
| - PluginInstallerInfoBarDelegate::InstallCallback(), new_install,
|
| - message)));
|
| + infobar->owner()->ReplaceInfoBar(infobar,
|
| + ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
|
| + new PluginInstallerInfoBarDelegate(
|
| + installer, plugin_metadata.Pass(),
|
| + PluginInstallerInfoBarDelegate::InstallCallback(), new_install,
|
| + message))));
|
| }
|
|
|
| PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate(
|
| - InfoBarService* infobar_service,
|
| PluginInstaller* installer,
|
| scoped_ptr<PluginMetadata> plugin_metadata,
|
| const InstallCallback& callback,
|
| bool new_install,
|
| const string16& message)
|
| - : ConfirmInfoBarDelegate(infobar_service),
|
| + : ConfirmInfoBarDelegate(),
|
| WeakPluginInstallerObserver(installer),
|
| plugin_metadata_(plugin_metadata.Pass()),
|
| callback_(callback),
|
| @@ -430,8 +426,7 @@
|
| }
|
|
|
| void PluginInstallerInfoBarDelegate::OnlyWeakObserversLeft() {
|
| - if (owner())
|
| - owner()->RemoveInfoBar(this);
|
| + infobar()->RemoveSelf();
|
| }
|
|
|
| void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar(
|
| @@ -439,9 +434,10 @@
|
| // Return early if the message doesn't change. This is important in case the
|
| // PluginInstaller is still iterating over its observers (otherwise we would
|
| // keep replacing infobar delegates infinitely).
|
| - if ((message_ == message) || !owner())
|
| + if ((message_ == message) || !infobar()->owner())
|
| return;
|
| - Replace(this, installer(), plugin_metadata_->Clone(), new_install_, message);
|
| + Replace(infobar(), installer(), plugin_metadata_->Clone(), new_install_,
|
| + message);
|
| }
|
|
|
|
|
| @@ -454,15 +450,15 @@
|
| InfoBarService* infobar_service,
|
| PluginMetroModeInfoBarDelegate::Mode mode,
|
| const string16& name) {
|
| - infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
|
| - new PluginMetroModeInfoBarDelegate(infobar_service, mode, name)));
|
| + infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
|
| + scoped_ptr<ConfirmInfoBarDelegate>(
|
| + new PluginMetroModeInfoBarDelegate(mode, name))));
|
| }
|
|
|
| PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate(
|
| - InfoBarService* infobar_service,
|
| PluginMetroModeInfoBarDelegate::Mode mode,
|
| const string16& name)
|
| - : ConfirmInfoBarDelegate(infobar_service),
|
| + : ConfirmInfoBarDelegate(),
|
| mode_(mode),
|
| name_(name) {
|
| }
|
|
|