diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 22:35:13 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 22:35:13 +0000 |
commit | 208d3b7d52b46f9a641d432433dc59894878880d (patch) | |
tree | db72721b64e095787c06631ba468f71b158e1649 /chrome/default_plugin | |
parent | 32d2669f5b705998451d1106f6072aaf7b38d30e (diff) | |
download | chromium_src-208d3b7d52b46f9a641d432433dc59894878880d.zip chromium_src-208d3b7d52b46f9a641d432433dc59894878880d.tar.gz chromium_src-208d3b7d52b46f9a641d432433dc59894878880d.tar.bz2 |
Moved the following IPC messages used by the chrome NPAPI plugin installer out of content
into Chrome.
1. PluginProcessHostMsg_GetPluginFinderUrl
2. PluginProcessHostMsg_MissingPluginStatus
3. PluginProcessHostMsg_DownloadUrl
These messages are prefixed with Chrome. Removed the InstallMissingPlugin and OnInstallMissingPlugin
handlers from the NPAPI plugin sources and from our webkit plugin implementation. The plugin infobar
no longer sends over an IPC message to initiate installation of the third party plugin. It sends over
a windows message which is handled in the plugin installer for Windows. This functionality is not
implemented for the mac and linux as before.
To display the plugin installation infobar the PluginProcessHostMsg_MissingPluginStatus message
sent by the plugin needs the routing id and the renderer process id. This information is now
passed along with the plugin instantiation parameters in NPP_New. These parameters are only read
by the default plugin.
This is a continuation of the fixes to ensure that IPC's don't span across content and chrome.
BUG=87335
Review URL: http://codereview.chromium.org/7812020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/default_plugin')
-rw-r--r-- | chrome/default_plugin/default_plugin.gyp | 2 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_gtk.cc | 20 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_gtk.h | 5 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_mac.h | 5 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_mac.mm | 16 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_win.cc | 57 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_win.h | 18 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_installer_base.cc | 34 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_installer_base.h | 33 |
9 files changed, 152 insertions, 38 deletions
diff --git a/chrome/default_plugin/default_plugin.gyp b/chrome/default_plugin/default_plugin.gyp index 8ced102..1b89034 100644 --- a/chrome/default_plugin/default_plugin.gyp +++ b/chrome/default_plugin/default_plugin.gyp @@ -32,6 +32,8 @@ 'plugin_impl_mac.mm', 'plugin_impl_win.cc', 'plugin_impl_win.h', + 'plugin_installer_base.cc', + 'plugin_installer_base.h', 'plugin_main.cc', 'plugin_main.h', ], diff --git a/chrome/default_plugin/plugin_impl_gtk.cc b/chrome/default_plugin/plugin_impl_gtk.cc index bca4b37..378e80d 100644 --- a/chrome/default_plugin/plugin_impl_gtk.cc +++ b/chrome/default_plugin/plugin_impl_gtk.cc @@ -4,12 +4,16 @@ #include "chrome/default_plugin/plugin_impl_gtk.h" -#include <gdk/gdkx.h> +#include <X11/Xdefs.h> +#include <gtk/gtk.h> #include "base/file_util.h" #include "base/path_service.h" #include "base/string_util.h" +#include "chrome/common/chrome_plugin_messages.h" #include "chrome/default_plugin/plugin_main.h" +#include "content/common/child_thread.h" +#include "content/common/content_constants.h" #include "googleurl/src/gurl.h" #include "grit/webkit_strings.h" #include "unicode/locid.h" @@ -45,7 +49,8 @@ bool PluginInstallerImpl::Initialize(void* module_handle, NPP instance, instance_ = instance; mime_type_ = mime_type; - return true; + return PluginInstallerBase::Initialize(module_handle, instance, mime_type, + argc, argn, argv); } bool PluginInstallerImpl::NPP_SetWindow(NPWindow* window_info) { @@ -133,9 +138,10 @@ void PluginInstallerImpl::ShowInstallDialog() { } void PluginInstallerImpl::NotifyPluginStatus(int status) { - default_plugin::g_browser->getvalue( - instance_, - static_cast<NPNVariable>( - webkit::npapi::default_plugin::kMissingPluginStatusStart + status), - NULL); + ChildThread::current()->Send( + new ChromePluginProcessHostMsg_MissingPluginStatus( + status, + renderer_process_id(), + render_view_id(), + 0)); } diff --git a/chrome/default_plugin/plugin_impl_gtk.h b/chrome/default_plugin/plugin_impl_gtk.h index 995b708..33ac44a 100644 --- a/chrome/default_plugin/plugin_impl_gtk.h +++ b/chrome/default_plugin/plugin_impl_gtk.h @@ -10,6 +10,7 @@ #include <gtk/gtk.h> +#include "chrome/default_plugin/plugin_installer_base.h" #include "third_party/npapi/bindings/npapi.h" #include "ui/gfx/native_widget_types.h" @@ -33,7 +34,7 @@ class PluginDatabaseHandler; // Provides the plugin installation functionality. This class is // instantiated with the information like the mime type of the // target plugin, the display mode, etc. -class PluginInstallerImpl { +class PluginInstallerImpl : public PluginInstallerBase { public: // mode is the plugin instantiation mode, i.e. whether it is a full // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) @@ -127,7 +128,7 @@ class PluginInstallerImpl { // Describes why the notification was sent. void URLNotify(const char* url, NPReason reason); - // Used by the renderer to indicate plugin install through the infobar. + // Used by the renderer to pass events (for e.g. input events) to the plugin. int16 NPP_HandleEvent(void* event); const std::string& mime_type() const { return mime_type_; } diff --git a/chrome/default_plugin/plugin_impl_mac.h b/chrome/default_plugin/plugin_impl_mac.h index fdd6fda..ebd9127 100644 --- a/chrome/default_plugin/plugin_impl_mac.h +++ b/chrome/default_plugin/plugin_impl_mac.h @@ -8,6 +8,7 @@ #include <string> +#include "chrome/default_plugin/plugin_installer_base.h" #include "third_party/npapi/bindings/npapi.h" #include "ui/gfx/native_widget_types.h" @@ -39,7 +40,7 @@ class PluginDatabaseHandler; // Provides the plugin installation functionality. This class is // instantiated with the information like the mime type of the // target plugin, the display mode, etc. -class PluginInstallerImpl { +class PluginInstallerImpl : public PluginInstallerBase { public: // mode is the plugin instantiation mode, i.e. whether it is a full // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) @@ -133,7 +134,7 @@ class PluginInstallerImpl { // Describes why the notification was sent. void URLNotify(const char* url, NPReason reason); - // Used by the renderer to indicate plugin install through the infobar. + // Used by the renderer to pass events (for e.g. input events) to the plugin. int16 NPP_HandleEvent(void* event); const std::string& mime_type() const { return mime_type_; } diff --git a/chrome/default_plugin/plugin_impl_mac.mm b/chrome/default_plugin/plugin_impl_mac.mm index b6deb28..927c32f 100644 --- a/chrome/default_plugin/plugin_impl_mac.mm +++ b/chrome/default_plugin/plugin_impl_mac.mm @@ -9,7 +9,9 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/string_util.h" +#include "chrome/common/chrome_plugin_messages.h" #include "chrome/default_plugin/plugin_main.h" +#include "content/common/child_thread.h" #include "googleurl/src/gurl.h" #include "grit/default_plugin_resources.h" #include "grit/webkit_strings.h" @@ -55,7 +57,8 @@ bool PluginInstallerImpl::Initialize(void* module_handle, NPP instance, ResourceBundle& rb = ResourceBundle::GetSharedInstance(); image_ = rb.GetNativeImageNamed(IDR_PLUGIN_ICON); - return true; + return PluginInstallerBase::Initialize(module_handle, instance, mime_type, + argc, argn, argv); } bool PluginInstallerImpl::NPP_SetWindow(NPWindow* window_info) { @@ -192,9 +195,10 @@ void PluginInstallerImpl::ShowInstallDialog() { } void PluginInstallerImpl::NotifyPluginStatus(int status) { - default_plugin::g_browser->getvalue( - instance_, - static_cast<NPNVariable>( - webkit::npapi::default_plugin::kMissingPluginStatusStart + status), - NULL); + ChildThread::current()->Send( + new ChromePluginProcessHostMsg_MissingPluginStatus( + status, + renderer_process_id(), + render_view_id(), + 0)); } diff --git a/chrome/default_plugin/plugin_impl_win.cc b/chrome/default_plugin/plugin_impl_win.cc index 90c604f..94e0cae 100644 --- a/chrome/default_plugin/plugin_impl_win.cc +++ b/chrome/default_plugin/plugin_impl_win.cc @@ -10,6 +10,7 @@ #include "base/path_service.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "chrome/common/chrome_plugin_messages.h" #include "chrome/default_plugin/plugin_main.h" #include "content/common/child_thread.h" #include "content/common/plugin_messages.h" @@ -23,6 +24,9 @@ static const int TOOLTIP_MAX_WIDTH = 500; +int PluginInstallerImpl::instance_count_ = 0; +bool PluginInstallerImpl::show_install_infobar_ = true; + PluginInstallerImpl::PluginInstallerImpl(int16 mode) : instance_(NULL), mode_(mode), @@ -40,9 +44,14 @@ PluginInstallerImpl::PluginInstallerImpl(int16 mode) new PluginInstallationJobMonitorThread()), plugin_database_handler_(*this), plugin_download_url_for_display_(false) { + instance_count_++; } PluginInstallerImpl::~PluginInstallerImpl() { + instance_count_--; + if (instance_count_ == 0) + show_install_infobar_ = true; + if (!disable_plugin_finder_) installation_job_monitor_thread_->Stop(); @@ -72,7 +81,7 @@ bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance, mime_type_ = mime_type; ChildThread::current()->Send( - new PluginProcessHostMsg_GetPluginFinderUrl(&plugin_finder_url_)); + new ChromePluginProcessHostMsg_GetPluginFinderUrl(&plugin_finder_url_)); if (plugin_finder_url_.empty()) disable_plugin_finder_ = true; @@ -89,8 +98,8 @@ bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance, } else { DisplayStatus(IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_PLUGIN_FINDER_DISABLED); } - - return true; + return PluginInstallerBase::Initialize(module_handle, instance, mime_type, + argc, argn, argv); } void PluginInstallerImpl::Shutdown() { @@ -257,8 +266,6 @@ void PluginInstallerImpl::URLNotify(const char* url, NPReason reason) { if (plugin_available) { DVLOG(1) << "Plugin available for mime type " << mime_type_; DisplayAvailablePluginStatus(); - NotifyPluginStatus( - webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE); } else { DLOG(WARNING) << "No plugin available for mime type " << mime_type_; DisplayStatus(IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG); @@ -267,15 +274,6 @@ void PluginInstallerImpl::URLNotify(const char* url, NPReason reason) { } int16 PluginInstallerImpl::NPP_HandleEvent(void* event) { - NPEvent* npp_event = static_cast<NPEvent*>(event); - if (npp_event->event == - webkit::npapi::default_plugin::kInstallMissingPluginMessage) { - // We could get this message because InfoBar may not be in sync with our - // internal processing. So we need to check the status. - if (plugin_installer_state() == PluginListDownloaded) { - ShowInstallDialog(); - } - } return 0; } @@ -330,6 +328,12 @@ bool PluginInstallerImpl::NPP_SetWindow(NPWindow* window_info) { UpdateWindow(hwnd()); ShowWindow(hwnd(), SW_SHOW); + // Show the infobar only once. + if (show_install_infobar_) { + show_install_infobar_ = false; + NotifyPluginStatus( + webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE); + } return true; } @@ -342,7 +346,7 @@ void PluginInstallerImpl::DownloadPlugin() { DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); if (!plugin_download_url_for_display_) { - ChildThread::current()->Send(new PluginProcessHostMsg_DownloadUrl( + ChildThread::current()->Send(new ChromePluginProcessHostMsg_DownloadUrl( plugin_download_url_, hwnd())); } else { default_plugin::g_browser->geturl(instance(), @@ -624,6 +628,18 @@ LRESULT PluginInstallerImpl::OnCopyData(UINT message, WPARAM wparam, return 0; } +LRESULT PluginInstallerImpl::OnInstallPluginMessage(UINT message, + WPARAM wparam, + LPARAM lparam, + BOOL& handled) { + // We could get this message because InfoBar may not be in sync with our + // internal processing. So we need to check the status. + if (plugin_installer_state() == PluginListDownloaded) { + ShowInstallDialog(); + } + return 0; +} + bool PluginInstallerImpl::InitializeResources(HINSTANCE module_handle) { DCHECK(icon_ == NULL); DCHECK(regular_font_ == NULL); @@ -650,9 +666,10 @@ bool PluginInstallerImpl::InitializeResources(HINSTANCE module_handle) { } void PluginInstallerImpl::NotifyPluginStatus(int status) { - default_plugin::g_browser->getvalue( - instance_, - static_cast<NPNVariable>( - webkit::npapi::default_plugin::kMissingPluginStatusStart + status), - NULL); + ChildThread::current()->Send( + new ChromePluginProcessHostMsg_MissingPluginStatus( + status, + renderer_process_id(), + render_view_id(), + hwnd())); } diff --git a/chrome/default_plugin/plugin_impl_win.h b/chrome/default_plugin/plugin_impl_win.h index 78bcbbf..dc51d12 100644 --- a/chrome/default_plugin/plugin_impl_win.h +++ b/chrome/default_plugin/plugin_impl_win.h @@ -10,9 +10,12 @@ #include "chrome/default_plugin/install_dialog.h" #include "chrome/default_plugin/plugin_database_handler.h" +#include "chrome/default_plugin/plugin_installer_base.h" #include "chrome/default_plugin/plugin_install_job_monitor.h" +#include "chrome/default_plugin/plugin_main.h" #include "third_party/npapi/bindings/npapi.h" #include "ui/base/win/window_impl.h" +#include "webkit/plugins/npapi/default_plugin_shared.h" // Possible plugin installer states. enum PluginInstallerState { @@ -34,7 +37,8 @@ class PluginDatabaseHandler; // Provides the plugin installation functionality. This class is // instantiated with the information like the mime type of the // target plugin, the display mode, etc. -class PluginInstallerImpl : public ui::WindowImpl { +class PluginInstallerImpl : public PluginInstallerBase, + public ui::WindowImpl { public: static const int kRefreshPluginsMessage = WM_APP + 1; @@ -50,6 +54,9 @@ class PluginInstallerImpl : public ui::WindowImpl { MESSAGE_HANDLER(kRefreshPluginsMessage, OnRefreshPlugins) MESSAGE_HANDLER(WM_COPYDATA, OnCopyData) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) + MESSAGE_HANDLER( + webkit::npapi::default_plugin::kInstallMissingPluginMessage, + OnInstallPluginMessage) END_MSG_MAP() // Initializes the plugin with the instance information, mime type @@ -190,6 +197,9 @@ class PluginInstallerImpl : public ui::WindowImpl { BOOL& handled); LRESULT OnSetCursor(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); + // Handles the install plugin message coming from the plugin infobar. + LRESULT OnInstallPluginMessage(UINT message, WPARAM wparam, LPARAM lparam, + BOOL& handled); // Refreshes the loaded plugin list and reloads the current page. LRESULT OnRefreshPlugins(UINT message, WPARAM wparam, LPARAM lparam, @@ -311,6 +321,12 @@ class PluginInstallerImpl : public ui::WindowImpl { // Tooltip Window. HWND tooltip_; + // Count of plugin instances. + static int instance_count_; + + // Set to true if the plugin install infobar is to be shown. + static bool show_install_infobar_; + DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); }; diff --git a/chrome/default_plugin/plugin_installer_base.cc b/chrome/default_plugin/plugin_installer_base.cc new file mode 100644 index 0000000..e863564 --- /dev/null +++ b/chrome/default_plugin/plugin_installer_base.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/default_plugin/plugin_installer_base.h" + +#include "base/string_number_conversions.h" +#include "base/string_util.h" +#include "content/common/content_constants.h" + +PluginInstallerBase::PluginInstallerBase() + : renderer_process_id_(0), + render_view_id_(0) { +} + +PluginInstallerBase::~PluginInstallerBase() { +} + +bool PluginInstallerBase::Initialize(void* module_handle, NPP instance, + NPMIMEType mime_type, int16 argc, + char* argn[], char* argv[]) { + for (int16_t index = 0; index < argc; ++index) { + if (!base::strncasecmp(argn[index], + content::kDefaultPluginRenderProcessId, + strlen(argn[index]))) { + base::StringToInt(argv[index], &renderer_process_id_); + } else if (!base::strncasecmp(argn[index], + content::kDefaultPluginRenderViewId, + strlen(argn[index]))) { + base::StringToInt(argv[index], &render_view_id_); + } + } + return true; +} diff --git a/chrome/default_plugin/plugin_installer_base.h b/chrome/default_plugin/plugin_installer_base.h new file mode 100644 index 0000000..928ad10 --- /dev/null +++ b/chrome/default_plugin/plugin_installer_base.h @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_DEFAULT_PLUGIN_PLUGIN_INSTALLER_BASE_H_ +#define CHROME_DEFAULT_PLUGIN_PLUGIN_INSTALLER_BASE_H_ + +#include "base/basictypes.h" +#include "third_party/npapi/bindings/npapi.h" + +// Base class for the plugin installer. +class PluginInstallerBase { + public: + PluginInstallerBase(); + virtual ~PluginInstallerBase(); + + bool Initialize(void* module_handle, NPP instance, NPMIMEType mime_type, + int16 argc, char* argn[], char* argv[]); + + int renderer_process_id() const { + return renderer_process_id_; + } + + int render_view_id() const { + return render_view_id_; + } + + private: + int renderer_process_id_; + int render_view_id_; +}; + +#endif // CHROME_DEFAULT_PLUGIN_PLUGIN_INSTALLER_BASE_H_ |