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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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
Index: chrome/browser/plugins/plugin_infobar_delegates.cc
diff --git a/chrome/browser/plugins/plugin_infobar_delegates.cc b/chrome/browser/plugins/plugin_infobar_delegates.cc
index 6530594b5241ec55bc25adab8779975837c71b8a..dc0d973f6a64c586c87ccc401ee283354b52a908 100644
--- a/chrome/browser/plugins/plugin_infobar_delegates.cc
+++ b/chrome/browser/plugins/plugin_infobar_delegates.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/user_metrics.h"
@@ -48,10 +49,9 @@ using base::UserMetricsAction;
// PluginInfoBarDelegate ------------------------------------------------------
-PluginInfoBarDelegate::PluginInfoBarDelegate(const std::string& identifier)
- : ConfirmInfoBarDelegate(),
- identifier_(identifier) {
-}
+PluginInfoBarDelegate::PluginInfoBarDelegate(content::WebContents* web_contents,
+ const std::string& identifier)
+ : ContentConfirmInfoBarDelegate(web_contents), identifier_(identifier) {}
PluginInfoBarDelegate::~PluginInfoBarDelegate() {
}
@@ -86,9 +86,9 @@ void UnauthorizedPluginInfoBarDelegate::Create(
HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier) {
- infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
- scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate(
- content_settings, name, identifier))));
+ infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<
+ ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate(
+ infobar_service->web_contents(), content_settings, name, identifier))));
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown"));
std::string utf8_name(base::UTF16ToUTF8(name));
@@ -110,13 +110,13 @@ void UnauthorizedPluginInfoBarDelegate::Create(
}
UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate(
+ content::WebContents* web_contents,
HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier)
- : PluginInfoBarDelegate(identifier),
+ : PluginInfoBarDelegate(web_contents, identifier),
content_settings_(content_settings),
- name_(name) {
-}
+ name_(name) {}
UnauthorizedPluginInfoBarDelegate::~UnauthorizedPluginInfoBarDelegate() {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed"));
@@ -176,17 +176,22 @@ void OutdatedPluginInfoBarDelegate::Create(
base::string16 name(plugin_metadata->name());
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,
+ infobar_service->web_contents(),
+ installer,
+ plugin_metadata.Pass(),
+ l10n_util::GetStringFUTF16(
+ (installer->state() == PluginInstaller::INSTALLER_STATE_IDLE)
+ ? IDS_PLUGIN_OUTDATED_PROMPT
+ : IDS_PLUGIN_DOWNLOADING,
name)))));
}
OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate(
+ content::WebContents* web_contents,
PluginInstaller* installer,
scoped_ptr<PluginMetadata> plugin_metadata,
const base::string16& message)
- : PluginInfoBarDelegate(plugin_metadata->identifier()),
+ : PluginInfoBarDelegate(web_contents, plugin_metadata->identifier()),
WeakPluginInstallerObserver(installer),
plugin_metadata_(plugin_metadata.Pass()),
message_(message) {
@@ -293,8 +298,12 @@ void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar(
// keep replacing infobar delegates infinitely).
if ((message_ == message) || !infobar()->owner())
return;
- PluginInstallerInfoBarDelegate::Replace(
- infobar(), installer(), plugin_metadata_->Clone(), false, message);
+ PluginInstallerInfoBarDelegate::Replace(web_contents(),
+ infobar(),
+ installer(),
+ plugin_metadata_->Clone(),
+ false,
+ message);
}
@@ -315,43 +324,53 @@ void PluginInstallerInfoBarDelegate::Create(
#endif
infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(new PluginInstallerInfoBarDelegate(
- installer, plugin_metadata.Pass(), callback, true,
+ infobar_service->web_contents(),
+ installer,
+ plugin_metadata.Pass(),
+ callback,
+ true,
l10n_util::GetStringFUTF16(
- (installer->state() == PluginInstaller::INSTALLER_STATE_IDLE) ?
- IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT :
- IDS_PLUGIN_DOWNLOADING,
+ (installer->state() == PluginInstaller::INSTALLER_STATE_IDLE)
+ ? IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT
+ : IDS_PLUGIN_DOWNLOADING,
name)))));
}
-
void PluginInstallerInfoBarDelegate::Replace(
+ content::WebContents* web_contents,
InfoBar* infobar,
PluginInstaller* installer,
scoped_ptr<PluginMetadata> plugin_metadata,
bool new_install,
const base::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,
+ ConfirmInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate>(new PluginInstallerInfoBarDelegate(
+ web_contents,
+ installer,
+ plugin_metadata.Pass(),
+ PluginInstallerInfoBarDelegate::InstallCallback(),
+ new_install,
+ message))),
+ InfoBarService::GetActiveEntryID(web_contents));
}
PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate(
+ content::WebContents* web_contents,
PluginInstaller* installer,
scoped_ptr<PluginMetadata> plugin_metadata,
const InstallCallback& callback,
bool new_install,
const base::string16& message)
- : ConfirmInfoBarDelegate(),
+ : ContentConfirmInfoBarDelegate(web_contents),
WeakPluginInstallerObserver(installer),
plugin_metadata_(plugin_metadata.Pass()),
callback_(callback),
new_install_(new_install),
- message_(message) {
-}
+ message_(message) {}
PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() {
}
@@ -432,7 +451,11 @@ void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar(
// keep replacing infobar delegates infinitely).
if ((message_ == message) || !infobar()->owner())
return;
- Replace(infobar(), installer(), plugin_metadata_->Clone(), new_install_,
+ Replace(web_contents(),
+ infobar(),
+ installer(),
+ plugin_metadata_->Clone(),
+ new_install_,
message);
}
@@ -447,17 +470,15 @@ void PluginMetroModeInfoBarDelegate::Create(
PluginMetroModeInfoBarDelegate::Mode mode,
const base::string16& name) {
infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
- scoped_ptr<ConfirmInfoBarDelegate>(
- new PluginMetroModeInfoBarDelegate(mode, name))));
+ scoped_ptr<ConfirmInfoBarDelegate>(new PluginMetroModeInfoBarDelegate(
+ infobar_service->web_contents(), mode, name))));
}
PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate(
+ content::WebContents* web_contents,
PluginMetroModeInfoBarDelegate::Mode mode,
const base::string16& name)
- : ConfirmInfoBarDelegate(),
- mode_(mode),
- name_(name) {
-}
+ : ContentConfirmInfoBarDelegate(web_contents), mode_(mode), name_(name) {}
PluginMetroModeInfoBarDelegate::~PluginMetroModeInfoBarDelegate() {
}

Powered by Google App Engine
This is Rietveld 408576698