Index: trunk/src/chrome/browser/plugins/plugin_infobar_delegates.cc |
=================================================================== |
--- trunk/src/chrome/browser/plugins/plugin_infobar_delegates.cc (revision 238401) |
+++ trunk/src/chrome/browser/plugins/plugin_infobar_delegates.cc (working copy) |
@@ -8,7 +8,6 @@ |
#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" |
@@ -49,8 +48,9 @@ |
// PluginInfoBarDelegate ------------------------------------------------------ |
-PluginInfoBarDelegate::PluginInfoBarDelegate(const std::string& identifier) |
- : ConfirmInfoBarDelegate(), |
+PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarService* infobar_service, |
+ const std::string& identifier) |
+ : ConfirmInfoBarDelegate(infobar_service), |
identifier_(identifier) { |
} |
@@ -90,9 +90,9 @@ |
HostContentSettingsMap* content_settings, |
const string16& name, |
const std::string& identifier) { |
- infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
- scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate( |
- content_settings, name, identifier)))); |
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
+ new UnauthorizedPluginInfoBarDelegate(infobar_service, content_settings, |
+ name, identifier))); |
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); |
std::string utf8_name(UTF16ToUTF8(name)); |
@@ -114,10 +114,11 @@ |
} |
UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( |
+ InfoBarService* infobar_service, |
HostContentSettingsMap* content_settings, |
const string16& name, |
const std::string& identifier) |
- : PluginInfoBarDelegate(identifier), |
+ : PluginInfoBarDelegate(infobar_service, identifier), |
content_settings_(content_settings), |
name_(name) { |
} |
@@ -178,19 +179,21 @@ |
// 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(ConfirmInfoBarDelegate::CreateInfoBar( |
- scoped_ptr<ConfirmInfoBarDelegate>(new OutdatedPluginInfoBarDelegate( |
- installer, plugin_metadata.Pass(), l10n_util::GetStringFUTF16( |
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
+ new OutdatedPluginInfoBarDelegate( |
+ infobar_service, 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(plugin_metadata->identifier()), |
+ : PluginInfoBarDelegate(infobar_service, plugin_metadata->identifier()), |
WeakPluginInstallerObserver(installer), |
plugin_metadata_(plugin_metadata.Pass()), |
message_(message) { |
@@ -287,7 +290,8 @@ |
} |
void OutdatedPluginInfoBarDelegate::OnlyWeakObserversLeft() { |
- infobar()->RemoveSelf(); |
+ if (owner()) |
+ owner()->RemoveInfoBar(this); |
} |
void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar( |
@@ -295,10 +299,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) || !infobar()->owner()) |
+ if ((message_ == message) || !owner()) |
return; |
PluginInstallerInfoBarDelegate::Replace( |
- infobar(), installer(), plugin_metadata_->Clone(), false, message); |
+ this, installer(), plugin_metadata_->Clone(), false, message); |
} |
@@ -317,39 +321,39 @@ |
return; |
} |
#endif |
- infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
- scoped_ptr<ConfirmInfoBarDelegate>(new PluginInstallerInfoBarDelegate( |
- installer, plugin_metadata.Pass(), callback, true, |
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
+ new PluginInstallerInfoBarDelegate( |
+ infobar_service, 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( |
- InfoBar* infobar, |
+ InfoBarDelegate* infobar, |
PluginInstaller* installer, |
scoped_ptr<PluginMetadata> plugin_metadata, |
bool new_install, |
const string16& message) { |
DCHECK(infobar->owner()); |
- infobar->owner()->ReplaceInfoBar(infobar, |
- ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
- new PluginInstallerInfoBarDelegate( |
- installer, plugin_metadata.Pass(), |
- PluginInstallerInfoBarDelegate::InstallCallback(), new_install, |
- message)))); |
+ infobar->owner()->ReplaceInfoBar(infobar, scoped_ptr<InfoBarDelegate>( |
+ new PluginInstallerInfoBarDelegate( |
+ infobar->owner(), 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(), |
+ : ConfirmInfoBarDelegate(infobar_service), |
WeakPluginInstallerObserver(installer), |
plugin_metadata_(plugin_metadata.Pass()), |
callback_(callback), |
@@ -426,7 +430,8 @@ |
} |
void PluginInstallerInfoBarDelegate::OnlyWeakObserversLeft() { |
- infobar()->RemoveSelf(); |
+ if (owner()) |
+ owner()->RemoveInfoBar(this); |
} |
void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar( |
@@ -434,10 +439,9 @@ |
// 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) || !infobar()->owner()) |
+ if ((message_ == message) || !owner()) |
return; |
- Replace(infobar(), installer(), plugin_metadata_->Clone(), new_install_, |
- message); |
+ Replace(this, installer(), plugin_metadata_->Clone(), new_install_, message); |
} |
@@ -450,15 +454,15 @@ |
InfoBarService* infobar_service, |
PluginMetroModeInfoBarDelegate::Mode mode, |
const string16& name) { |
- infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
- scoped_ptr<ConfirmInfoBarDelegate>( |
- new PluginMetroModeInfoBarDelegate(mode, name)))); |
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
+ new PluginMetroModeInfoBarDelegate(infobar_service, mode, name))); |
} |
PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( |
+ InfoBarService* infobar_service, |
PluginMetroModeInfoBarDelegate::Mode mode, |
const string16& name) |
- : ConfirmInfoBarDelegate(), |
+ : ConfirmInfoBarDelegate(infobar_service), |
mode_(mode), |
name_(name) { |
} |