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

Unified Diff: webkit/default_plugin/install_dialog.cc

Issue 179051: Fix two issues with the plugin installer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « webkit/default_plugin/install_dialog.h ('k') | webkit/default_plugin/plugin_impl_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/default_plugin/install_dialog.cc
===================================================================
--- webkit/default_plugin/install_dialog.cc (revision 24950)
+++ webkit/default_plugin/install_dialog.cc (working copy)
@@ -4,24 +4,61 @@
#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) {
// Most of the code here is based on CDialogImpl<T>::Create.
DCHECK(m_hWnd == NULL);
@@ -66,7 +103,7 @@
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::OnGetPlugin(WORD notify_code, WORD id,
HWND wnd_ctl, BOOL &handled) {
- if (!plugin_impl_) {
- NOTREACHED();
- return 0;
- }
+ DestroyWindow();
+ if (!installers_.empty())
+ installers_[0]->DownloadPlugin();
- DestroyWindow();
- plugin_impl_->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");
« no previous file with comments | « webkit/default_plugin/install_dialog.h ('k') | webkit/default_plugin/plugin_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698