| Index: chrome/default_plugin/plugin_impl_win.cc
|
| diff --git a/chrome/default_plugin/plugin_impl_win.cc b/chrome/default_plugin/plugin_impl_win.cc
|
| index 0b7043af6db334fb6d39e84af57267a185ccd2a9..7a1913bedd1803a3084f856d54a6f70b14ba829b 100644
|
| --- a/chrome/default_plugin/plugin_impl_win.cc
|
| +++ b/chrome/default_plugin/plugin_impl_win.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <shellapi.h>
|
|
|
| +#include "base/bind.h"
|
| #include "base/file_util.h"
|
| #include "base/path_service.h"
|
| #include "base/string_util.h"
|
| @@ -41,8 +42,8 @@ PluginInstallerImpl::PluginInstallerImpl(int16 mode)
|
| underline_font_(NULL),
|
| tooltip_(NULL),
|
| installation_job_monitor_thread_(
|
| - new PluginInstallationJobMonitorThread()),
|
| - plugin_database_handler_(*this),
|
| + new base::win::ProcessMonitor()),
|
| + plugin_database_handler_(),
|
| plugin_download_url_for_display_(false) {
|
| instance_count_++;
|
| }
|
| @@ -65,6 +66,29 @@ PluginInstallerImpl::~PluginInstallerImpl() {
|
| DestroyWindow(tooltip_);
|
| }
|
|
|
| +void PluginInstallerImpl::DownloadPluginList(
|
| + const std::string& plugin_finder_url) {
|
| + DCHECK(default_plugin::g_browser->geturlnotify);
|
| + default_plugin::g_browser->geturlnotify(
|
| + instance(), plugin_finder_url.c_str(), NULL, NULL);
|
| +}
|
| +
|
| +void PluginInstallerImpl::OnPluginListDownloaded() {
|
| + DVLOG(1) << "Received Done notification for plugin list download";
|
| + plugin_database_handler_.ParsePluginList();
|
| + if (plugin_database_handler_.GetPluginDetailsForMimeType(
|
| + mime_type_.c_str(), desired_language_.c_str(),
|
| + &plugin_download_url_, &plugin_name_,
|
| + &plugin_download_url_for_display_)) {
|
| + install_dialog_ = PluginInstallDialog::AddInstaller(this, plugin_name_);
|
| + set_plugin_installer_state(PluginListDownloaded);
|
| + } else {
|
| + set_plugin_installer_state(PluginListDownloadedPluginNotFound);
|
| + }
|
| +
|
| + plugin_database_handler_.Close(false);
|
| +}
|
| +
|
| bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance,
|
| NPMIMEType mime_type, int16 argc,
|
| char* argn[], char* argv[]) {
|
| @@ -91,13 +115,9 @@ bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance,
|
| // immediately notify the browser if a plug-in is available.
|
| PluginInstallerBase::SetRoutingIds(argc, argn, argv);
|
| if (!disable_plugin_finder_) {
|
| - if (!installation_job_monitor_thread_->Initialize()) {
|
| - NOTREACHED() << "Failed to initialize plugin install job";
|
| - return false;
|
| - }
|
| -
|
| DisplayStatus(IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_NO_PLUGIN_NAME);
|
| - plugin_database_handler_.DownloadPluginsFileIfNeeded(plugin_finder_url_);
|
| + plugin_database_handler_.DownloadPluginsFileIfNeeded(plugin_finder_url_,
|
| + this);
|
| } else {
|
| DisplayStatus(IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_PLUGIN_FINDER_DISABLED);
|
| }
|
| @@ -244,20 +264,7 @@ void PluginInstallerImpl::URLNotify(const char* url, NPReason reason) {
|
| if (plugin_installer_state_ == PluginListDownloadInitiated) {
|
| bool plugin_available = false;
|
| if (reason == NPRES_DONE) {
|
| - DVLOG(1) << "Received Done notification for plugin list download";
|
| - plugin_database_handler_.ParsePluginList();
|
| - if (plugin_database_handler_.GetPluginDetailsForMimeType(
|
| - mime_type_.c_str(), desired_language_.c_str(),
|
| - &plugin_download_url_, &plugin_name_,
|
| - &plugin_download_url_for_display_)) {
|
| - plugin_available = true;
|
| - install_dialog_ = PluginInstallDialog::AddInstaller(this, plugin_name_);
|
| - set_plugin_installer_state(PluginListDownloaded);
|
| - } else {
|
| - set_plugin_installer_state(PluginListDownloadedPluginNotFound);
|
| - }
|
| -
|
| - plugin_database_handler_.Close(false);
|
| + OnPluginListDownloaded();
|
| } else {
|
| DLOG(WARNING) << "Failed to download plugin list";
|
| set_plugin_installer_state(PluginListDownloadFailed);
|
| @@ -265,7 +272,7 @@ void PluginInstallerImpl::URLNotify(const char* url, NPReason reason) {
|
| plugin_database_handler_.Close(true);
|
| }
|
|
|
| - if (plugin_available) {
|
| + if (plugin_installer_state() == PluginListDownloaded) {
|
| DVLOG(1) << "Plugin available for mime type " << mime_type_;
|
| NotifyPluginStatus(
|
| webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE);
|
| @@ -324,7 +331,6 @@ bool PluginInstallerImpl::NPP_SetWindow(NPWindow* window_info) {
|
| set_window_style(WS_CHILD | WS_BORDER);
|
| Init(parent_window, gfx::Rect(parent_rect));
|
| DCHECK(IsWindow(hwnd()));
|
| - installation_job_monitor_thread_->set_plugin_window(hwnd());
|
|
|
| CreateToolTip();
|
| UpdateToolTip();
|
| @@ -548,16 +554,7 @@ LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam,
|
| NotifyPluginStatus(
|
| webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD);
|
| } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) {
|
| - DCHECK(default_plugin::g_browser);
|
| - DCHECK(default_plugin::g_browser->geturl);
|
| - default_plugin::g_browser->geturl(
|
| - instance_,
|
| - "javascript:navigator.plugins.refresh(true)",
|
| - "_self");
|
| - default_plugin::g_browser->geturl(
|
| - instance_,
|
| - "javascript:window.location.reload(true)",
|
| - "_self");
|
| + RefreshPlugins();
|
| }
|
|
|
| return 0;
|
| @@ -573,8 +570,7 @@ LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam,
|
| return 0;
|
| }
|
|
|
| -LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam,
|
| - LPARAM lparam, BOOL& handled) {
|
| +void PluginInstallerImpl::RefreshPlugins() {
|
| DCHECK(default_plugin::g_browser);
|
| DCHECK(default_plugin::g_browser->geturl);
|
| default_plugin::g_browser->geturl(
|
| @@ -585,7 +581,6 @@ LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam,
|
| instance_,
|
| "javascript:window.location.reload(true)",
|
| "_self");
|
| - return 0;
|
| }
|
|
|
| LRESULT PluginInstallerImpl::OnCopyData(UINT message, WPARAM wparam,
|
| @@ -622,8 +617,10 @@ LRESULT PluginInstallerImpl::OnCopyData(UINT message, WPARAM wparam,
|
| } else {
|
| DVLOG(1) << "Successfully launched plugin installer";
|
| set_plugin_installer_state(PluginInstallerLaunchSuccess);
|
| - installation_job_monitor_thread_->AssignProcessToJob(
|
| - shell_execute_info.hProcess);
|
| + installation_job_monitor_thread_->Initialize(
|
| + shell_execute_info.hProcess,
|
| + base::Bind(&PluginInstallerImpl::RefreshPlugins,
|
| + base::Unretained(this)));
|
| DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG);
|
| enable_click_ = true;
|
| RefreshDisplay();
|
|
|