diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 00:43:21 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 00:43:21 +0000 |
commit | 92899e21866e90a17e365704ed310b5641423a1e (patch) | |
tree | 06b2b2e881933260e2993134af6b3e21ef20ea48 /webkit | |
parent | 1e59d767e37888d61dbee21a3ef6d52409e21ea5 (diff) | |
download | chromium_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')
-rw-r--r-- | webkit/api/src/WebKit.cpp | 2 | ||||
-rw-r--r-- | webkit/default_plugin/install_dialog.cc | 74 | ||||
-rw-r--r-- | webkit/default_plugin/install_dialog.h | 27 | ||||
-rw-r--r-- | webkit/default_plugin/plugin_impl_win.cc | 13 | ||||
-rw-r--r-- | webkit/default_plugin/plugin_impl_win.h | 4 |
5 files changed, 77 insertions, 43 deletions
diff --git a/webkit/api/src/WebKit.cpp b/webkit/api/src/WebKit.cpp index 55b9088..8bdf2a8 100644 --- a/webkit/api/src/WebKit.cpp +++ b/webkit/api/src/WebKit.cpp @@ -137,7 +137,7 @@ void enableMediaPlayer() void resetPluginCache() { - WebCore::Page::refreshPlugins(false); + WebCore::Page::refreshPlugins(true); } void enableDatabases() 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"); diff --git a/webkit/default_plugin/install_dialog.h b/webkit/default_plugin/install_dialog.h index d755827..c07c554 100644 --- a/webkit/default_plugin/install_dialog.h +++ b/webkit/default_plugin/install_dialog.h @@ -8,6 +8,7 @@ #include <atlbase.h> #include <atlwin.h> #include <string> +#include <vector> #include "webkit/default_plugin/default_plugin_resources.h" @@ -18,11 +19,6 @@ class PluginInstallerImpl; // where it would be downloaded from, etc. class PluginInstallDialog : public CDialogImpl<PluginInstallDialog> { public: - PluginInstallDialog() - : plugin_impl_(NULL) { - } - ~PluginInstallDialog() {} - enum {IDD = IDD_DEFAULT_PLUGIN_INSTALL_DIALOG}; BEGIN_MSG_MAP(PluginInstallDialog) @@ -31,26 +27,33 @@ class PluginInstallDialog : public CDialogImpl<PluginInstallDialog> { COMMAND_ID_HANDLER(IDCANCEL, OnCancel) END_MSG_MAP() - bool Initialize(PluginInstallerImpl* plugin_impl, - const std::wstring& plugin_name); + // Creates or returns the existing object for the given plugin name. + // Call RemoveInstaller when done. + static PluginInstallDialog* AddInstaller(PluginInstallerImpl* plugin_impl, + const std::wstring& plugin_name); + + // Lets this object know that the given installer object is going away. + void RemoveInstaller(PluginInstallerImpl* installer); + + void ShowInstallDialog(); + + private: + PluginInstallDialog(const std::wstring& plugin_name); + ~PluginInstallDialog(); // Implemented to ensure that we handle RTL layouts correctly. HWND Create(HWND parent_window, LPARAM init_param); - protected: LRESULT OnInitDialog(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); LRESULT OnGetPlugin(WORD notify_code, WORD id, HWND wnd_ctl, BOOL &handled); LRESULT OnCancel(WORD notify_code, WORD id, HWND wnd_ctl, BOOL &handled); - // Determines whether the UI layout is right-to-left. - bool IsRTLLayout() const; - // Wraps the string with Unicode directionality characters in order to make // sure BiDi text is rendered correctly when the UI layout is right-to-left. void AdjustTextDirectionality(std::wstring* text) const; - PluginInstallerImpl* plugin_impl_; + std::vector<PluginInstallerImpl*> installers_; std::wstring plugin_name_; }; diff --git a/webkit/default_plugin/plugin_impl_win.cc b/webkit/default_plugin/plugin_impl_win.cc index 0bc7270..dcd1c4d 100644 --- a/webkit/default_plugin/plugin_impl_win.cc +++ b/webkit/default_plugin/plugin_impl_win.cc @@ -27,6 +27,7 @@ PluginInstallerImpl::PluginInstallerImpl(int16 mode) mode_(mode), plugin_install_stream_(NULL), plugin_installer_state_(PluginInstallerStateUndefined), + install_dialog_(PluginInstallDialog::AddInstaller(this, plugin_name_)), enable_click_(false), icon_(NULL), bold_font_(NULL), @@ -115,9 +116,11 @@ bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance, } void PluginInstallerImpl::Shutdown() { - if (install_dialog_.IsWindow()) { - install_dialog_.DestroyWindow(); + if (install_dialog_) { + install_dialog_->RemoveInstaller(this); + install_dialog_ = NULL; } + if (IsWindow(hwnd())) { DestroyWindow(hwnd()); } @@ -403,7 +406,7 @@ LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam, // currently use this code since code in WebKit should not depend on code in // Chrome. We can fix this by pulling (at least part of) the l10n_util // functionality up into the Base module. -bool PluginInstallerImpl::IsRTLLayout() const { +bool PluginInstallerImpl::IsRTLLayout() { const icu::Locale& locale = icu::Locale::getDefault(); const char* lang = locale.getLanguage(); @@ -553,9 +556,7 @@ void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc, void PluginInstallerImpl::ShowInstallDialog() { enable_click_ = false; - install_dialog_.Initialize(this, plugin_name_); - install_dialog_.Create(hwnd(), NULL); - install_dialog_.ShowWindow(SW_SHOW); + install_dialog_->ShowInstallDialog(); } LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, diff --git a/webkit/default_plugin/plugin_impl_win.h b/webkit/default_plugin/plugin_impl_win.h index a0e5596..1a1e123 100644 --- a/webkit/default_plugin/plugin_impl_win.h +++ b/webkit/default_plugin/plugin_impl_win.h @@ -187,7 +187,7 @@ class PluginInstallerImpl : public base::WindowImpl { // Returns whether or not the UI layout is right-to-left (such as Hebrew or // Arabic). - bool IsRTLLayout() const; + static bool IsRTLLayout(); // Parses the plugin instantiation arguments. This includes checking for // whether this is an activex install and reading the appropriate @@ -348,7 +348,7 @@ class PluginInstallerImpl : public base::WindowImpl { // The current state of the plugin installer. PluginInstallerState plugin_installer_state_; // Used to display the UI for plugin installation. - PluginInstallDialog install_dialog_; + PluginInstallDialog* install_dialog_; // To enable auto refresh of the plugin window once the installation // is complete, we spawn the installation process in a job, and monitor // IO completion events on the job. When the active process count of the |