summaryrefslogtreecommitdiffstats
path: root/webkit/default_plugin/install_dialog.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 00:43:21 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 00:43:21 +0000
commit92899e21866e90a17e365704ed310b5641423a1e (patch)
tree06b2b2e881933260e2993134af6b3e21ef20ea48 /webkit/default_plugin/install_dialog.cc
parent1e59d767e37888d61dbee21a3ef6d52409e21ea5 (diff)
downloadchromium_src-92899e21866e90a17e365704ed310b5641423a1e.zip
chromium_src-92899e21866e90a17e365704ed310b5641423a1e.tar.gz
chromium_src-92899e21866e90a17e365704ed310b5641423a1e.tar.bz2
Fix two issues with the plugin installer.
The first is that we weren't reloading the pages with plugins. The second is that there was a InstallerDialog instance per plugin object on the page. On a page like nytimes.com that creates and destroys a Flash object on loading, this meant that if the user clicked on the plugin/infobar inbetween, the dialog would show up and then get hidden abruptly. TEST=go to nytimes.com on a machine without Flash installed and click the infobar as soon as it shows up. BUG=20690 Review URL: http://codereview.chromium.org/179051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/default_plugin/install_dialog.cc')
-rw-r--r--webkit/default_plugin/install_dialog.cc74
1 files changed, 52 insertions, 22 deletions
diff --git a/webkit/default_plugin/install_dialog.cc b/webkit/default_plugin/install_dialog.cc
index 6b20939..38ab863 100644
--- a/webkit/default_plugin/install_dialog.cc
+++ b/webkit/default_plugin/install_dialog.cc
@@ -4,22 +4,59 @@
#include "webkit/default_plugin/install_dialog.h"
+#include "base/hash_tables.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "grit/webkit_strings.h"
#include "webkit/default_plugin/plugin_impl.h"
#include "webkit/glue/webkit_glue.h"
-bool PluginInstallDialog::Initialize(PluginInstallerImpl* plugin_impl,
- const std::wstring& plugin_name) {
- if (!plugin_impl) {
- NOTREACHED();
- return false;
+typedef base::hash_map<const std::wstring, PluginInstallDialog*> DialogMap;
+base::LazyInstance<DialogMap> s_dialogs(base::LINKER_INITIALIZED);
+
+PluginInstallDialog* PluginInstallDialog::AddInstaller(
+ PluginInstallerImpl* plugin_impl, const std::wstring& plugin_name) {
+ PluginInstallDialog* dialog;
+ if (s_dialogs.Get().count(plugin_name)) {
+ dialog = s_dialogs.Get()[plugin_name];
+ } else {
+ dialog = new PluginInstallDialog(plugin_name);
}
- plugin_impl_ = plugin_impl;
- plugin_name_ = plugin_name;
- return true;
+ dialog->installers_.push_back(plugin_impl);
+ return dialog;
+}
+
+PluginInstallDialog::PluginInstallDialog(const std::wstring& plugin_name)
+ : plugin_name_(plugin_name) {
+ s_dialogs.Get()[plugin_name] = this;
+}
+
+PluginInstallDialog::~PluginInstallDialog() {
+ s_dialogs.Get().erase(plugin_name_);
+ if (IsWindow())
+ DestroyWindow();
+}
+
+void PluginInstallDialog::RemoveInstaller(PluginInstallerImpl* installer) {
+ for (size_t i = 0; i < installers_.size(); ++i) {
+ if (installers_[i] == installer) {
+ installers_.erase(installers_.begin() + i);
+ if (installers_.empty())
+ delete this;
+ return;
+ }
+ }
+ NOTREACHED();
+}
+
+void PluginInstallDialog::ShowInstallDialog() {
+ if (IsWindow())
+ return;
+
+ Create(NULL, NULL);
+ ShowWindow(SW_SHOW);
}
HWND PluginInstallDialog::Create(HWND parent_window, LPARAM init_param) {
@@ -66,7 +103,7 @@ HWND PluginInstallDialog::Create(HWND parent_window, LPARAM init_param) {
HGLOBAL rtl_layout_dialog_template = NULL;
- if (IsRTLLayout()) {
+ if (PluginInstallerImpl::IsRTLLayout()) {
rtl_layout_dialog_template = GlobalAlloc(GPTR, dialog_template_size);
DCHECK(rtl_layout_dialog_template != NULL);
@@ -137,33 +174,26 @@ LRESULT PluginInstallDialog::OnInitDialog(UINT message, WPARAM wparam,
LRESULT PluginInstallDialog::OnGetPlugin(WORD notify_code, WORD id,
HWND wnd_ctl, BOOL &handled) {
- if (!plugin_impl_) {
- NOTREACHED();
- return 0;
- }
-
DestroyWindow();
- plugin_impl_->DownloadPlugin();
+ if (!installers_.empty())
+ installers_[0]->DownloadPlugin();
+
return 0;
}
LRESULT PluginInstallDialog::OnCancel(WORD notify_code, WORD id, HWND wnd_ctl,
BOOL &handled) {
DestroyWindow();
- plugin_impl_->DownloadCancelled();
+ if (!installers_.empty())
+ installers_[0]->DownloadCancelled();
return 0;
}
-
-bool PluginInstallDialog::IsRTLLayout() const {
- return plugin_impl_ ? plugin_impl_->IsRTLLayout() : false;
-}
-
// TODO(idana) bug# 1246452: use the library l10n_util once it is moved from
// the Chrome module into the Base module. For now, we simply copy/paste the
// same code.
void PluginInstallDialog::AdjustTextDirectionality(std::wstring* text) const {
- if (IsRTLLayout()) {
+ if (PluginInstallerImpl::IsRTLLayout()) {
// Inserting an RLE (Right-To-Left Embedding) mark as the first character.
text->insert(0, L"\x202B");