diff options
Diffstat (limited to 'chrome/browser/plugin_installer.cc')
-rw-r--r-- | chrome/browser/plugin_installer.cc | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc index 1d42d80..afd0314 100644 --- a/chrome/browser/plugin_installer.cc +++ b/chrome/browser/plugin_installer.cc @@ -4,9 +4,9 @@ #include "chrome/browser/plugin_installer.h" -#include "chrome/app/theme/theme_resources.h" -#include "chrome/browser/web_contents_view.h" #include "base/string_util.h" +#include "chrome/app/theme/theme_resources.h" +#include "chrome/browser/web_contents.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "webkit/default_plugin/default_plugin_shared.h" @@ -15,33 +15,24 @@ PluginInstaller::PluginInstaller(WebContents* web_contents) : web_contents_(web_contents), - current_bar_(NULL) { + ConfirmInfoBarDelegate(web_contents) { } PluginInstaller::~PluginInstaller() { - if (current_bar_) - current_bar_->Close(); + // Remove any InfoBars we may be showing. + web_contents_->RemoveInfoBar(this); } void PluginInstaller::OnMissingPluginStatus(int status) { switch(status) { case default_plugin::MISSING_PLUGIN_AVAILABLE: { - // Display missing plugin InfoBar if a missing plugin is available. - if (current_bar_) - return; - - // TODO(brettw) have a more general way to add to the info bar rather - // than mucking with it directly. - InfoBarView* view = web_contents_->view()->GetInfoBarView(); - current_bar_ = new PluginInstallerBar(this); - view->AddChildView(current_bar_); + web_contents_->AddInfoBar(this); break; } case default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { // Hide the InfoBar if user already started download/install of the // missing plugin. - if (current_bar_) - current_bar_->Close(); + web_contents_->RemoveInfoBar(this); break; } default: { @@ -51,38 +42,25 @@ void PluginInstaller::OnMissingPluginStatus(int status) { } } -void PluginInstaller::OnStartLoading() { - if (current_bar_) - current_bar_->BeginClose(); -} - -void PluginInstaller::OnBarDestroy(InfoBarConfirmView* bar) { - if (current_bar_ == bar) - current_bar_ = NULL; +std::wstring PluginInstaller::GetMessageText() const { + return l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT); } -void PluginInstaller::OnOKButtonPressed() { - current_bar_->BeginClose(); - web_contents_->render_view_host()->InstallMissingPlugin(); +SkBitmap* PluginInstaller::GetIcon() const { + return ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_INFOBAR_PLUGIN_INSTALL); } -PluginInstaller::PluginInstallerBar - ::PluginInstallerBar(PluginInstaller* plugin_installer) - : plugin_installer_(plugin_installer), - InfoBarConfirmView( - l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT)) { - SetOKButtonLabel( - l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON)); - RemoveCancelButton(); - ResourceBundle &rb = ResourceBundle::GetSharedInstance(); - SetIcon(*rb.GetBitmapNamed(IDR_INFOBAR_PLUGIN_INSTALL)); +int PluginInstaller::GetButtons() const { + return BUTTON_OK; } -PluginInstaller::PluginInstallerBar::~PluginInstallerBar() { - plugin_installer_->OnBarDestroy(this); +std::wstring PluginInstaller::GetButtonLabel(InfoBarButton button) const { + if (button == BUTTON_OK) + return l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); + return ConfirmInfoBarDelegate::GetButtonLabel(button); } -void PluginInstaller::PluginInstallerBar::OKButtonPressed() { - plugin_installer_->OnOKButtonPressed(); +void PluginInstaller::Accept() { + web_contents_->render_view_host()->InstallMissingPlugin(); } - |