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

Unified Diff: chrome/browser/plugins/plugin_observer.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/plugins/plugin_infobar_delegates.cc ('k') | chrome/browser/ssl/ssl_tab_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/plugins/plugin_observer.cc
===================================================================
--- chrome/browser/plugins/plugin_observer.cc (revision 175396)
+++ chrome/browser/plugins/plugin_observer.cc (working copy)
@@ -32,15 +32,14 @@
#include "webkit/plugins/webplugininfo.h"
#if defined(ENABLE_PLUGIN_INSTALLATION)
+#if defined(OS_WIN)
+#include "base/win/metro.h"
+#endif
#include "chrome/browser/plugins/plugin_installer.h"
#include "chrome/browser/plugins/plugin_installer_observer.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
-#if defined(OS_WIN)
-#include "base/win/metro.h"
-#endif
-
using content::OpenURLParams;
using content::PluginService;
using content::Referrer;
@@ -189,14 +188,9 @@
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_PLUGIN_CRASHED);
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->AddInfoBar(
- new SimpleAlertInfoBarDelegate(
- infobar_service,
- icon,
- l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name),
- true));
+ SimpleAlertInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()), icon,
+ l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), true);
}
bool PluginObserver::OnMessageReceived(const IPC::Message& message) {
@@ -227,14 +221,11 @@
void PluginObserver::OnBlockedUnauthorizedPlugin(
const string16& name,
const std::string& identifier) {
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->AddInfoBar(
- new UnauthorizedPluginInfoBarDelegate(
- infobar_service,
- Profile::FromBrowserContext(web_contents()->GetBrowserContext())->
- GetHostContentSettingsMap(),
- name, identifier));
+ UnauthorizedPluginInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()),
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext())->
+ GetHostContentSettingsMap(),
+ name, identifier);
}
void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id,
@@ -252,11 +243,9 @@
plugin_placeholders_[placeholder_id] =
new PluginPlaceholderHost(this, placeholder_id,
plugin->name(), installer);
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->AddInfoBar(
- OutdatedPluginInfoBarDelegate::Create(web_contents(),
- installer, plugin.Pass()));
+ OutdatedPluginInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()), installer,
+ plugin.Pass());
#else
// If we don't support third-party plug-in installation, we shouldn't have
// outdated plug-ins.
@@ -283,25 +272,11 @@
new PluginPlaceholderHost(this, placeholder_id,
plugin_metadata->name(),
installer);
- PluginInstallerInfoBarDelegate::InstallCallback callback =
+ PluginInstallerInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()), installer,
+ plugin_metadata.Pass(),
base::Bind(&PluginObserver::InstallMissingPlugin,
- weak_ptr_factory_.GetWeakPtr(), installer);
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- InfoBarDelegate* delegate;
-#if !defined(OS_WIN)
- delegate = PluginInstallerInfoBarDelegate::Create(
- infobar_service, installer, plugin_metadata.Pass(), callback);
-#else
- delegate = base::win::IsMetroProcess() ?
- new PluginMetroModeInfoBarDelegate(
- infobar_service,
- PluginMetroModeInfoBarDelegate::MISSING_PLUGIN,
- plugin_metadata->name()) :
- PluginInstallerInfoBarDelegate::Create(
- infobar_service, installer, plugin_metadata.Pass(), callback);
-#endif
- infobar_service->AddInfoBar(delegate);
+ weak_ptr_factory_.GetWeakPtr(), installer));
}
void PluginObserver::InstallMissingPlugin(
@@ -341,15 +316,13 @@
g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path);
string16 plugin_name =
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->AddInfoBar(new SimpleAlertInfoBarDelegate(
- infobar_service,
+ SimpleAlertInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()),
&ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_PLUGIN_CRASHED),
l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT,
plugin_name),
- true /* auto_expire */));
+ true /* auto_expire */);
}
void PluginObserver::OnNPAPINotSupported(const std::string& identifier) {
@@ -375,13 +348,9 @@
return;
}
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->AddInfoBar(
- new PluginMetroModeInfoBarDelegate(
- infobar_service,
- PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED,
- plugin->name()));
+ PluginMetroModeInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(web_contents()),
+ PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name());
#else
NOTREACHED();
#endif
« no previous file with comments | « chrome/browser/plugins/plugin_infobar_delegates.cc ('k') | chrome/browser/ssl/ssl_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698