From 967b2d6855f9ecc30f79657c5a1d4e61f14d13b2 Mon Sep 17 00:00:00 2001 From: "bauerb@chromium.org" Date: Mon, 23 Jan 2012 14:19:17 +0000 Subject: Use a Javascript callback to notify a missing plug-in when the placeholder has finished loading. While I'm updating the renderer resources, clean up the style sheets a bit. BUG=105627 TEST=ExtensionBrowserTest.PluginPrivate Review URL: http://codereview.chromium.org/9212004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118676 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/plugins/missing_plugin.cc | 21 +++++++++++++-------- chrome/renderer/plugins/missing_plugin.h | 4 +++- chrome/renderer/plugins/plugin_placeholder.cc | 3 --- chrome/renderer/plugins/plugin_placeholder.h | 1 - 4 files changed, 16 insertions(+), 13 deletions(-) (limited to 'chrome/renderer/plugins') diff --git a/chrome/renderer/plugins/missing_plugin.cc b/chrome/renderer/plugins/missing_plugin.cc index 9a1a4b1..a8ef543 100644 --- a/chrome/renderer/plugins/missing_plugin.cc +++ b/chrome/renderer/plugins/missing_plugin.cc @@ -73,7 +73,8 @@ MissingPlugin::MissingPlugin(RenderView* render_view, WebFrame* frame, const WebPluginParams& params, const std::string& html_data) - : PluginPlaceholder(render_view, frame, params, html_data) { + : PluginPlaceholder(render_view, frame, params, html_data), + finished_loading_(false) { RenderThread::Get()->AddObserver(this); #if defined(ENABLE_PLUGIN_INSTALLATION) placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); @@ -96,6 +97,9 @@ void MissingPlugin::BindWebFrame(WebFrame* frame) { PluginPlaceholder::BindWebFrame(frame); BindCallback("hide", base::Bind(&MissingPlugin::HideCallback, base::Unretained(this))); + BindCallback("didFinishLoading", + base::Bind(&MissingPlugin::DidFinishLoadingCallback, + base::Unretained(this))); } void MissingPlugin::HideCallback(const CppArgumentList& args, @@ -104,6 +108,13 @@ void MissingPlugin::HideCallback(const CppArgumentList& args, HidePluginInternal(); } +void MissingPlugin::DidFinishLoadingCallback(const CppArgumentList& args, + CppVariant* result) { + finished_loading_ = true; + if (message_.length() > 0) + UpdateMessage(); +} + void MissingPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { WebContextMenuData menu_data; @@ -200,12 +211,11 @@ void MissingPlugin::PluginListChanged() { void MissingPlugin::SetMessage(const string16& message) { message_ = message; - if (!plugin()->web_view()->mainFrame()->isLoading()) + if (finished_loading_) UpdateMessage(); } void MissingPlugin::UpdateMessage() { - DCHECK(!plugin()->web_view()->mainFrame()->isLoading()); std::string script = "window.setMessage(" + base::GetDoubleQuotedJson(message_) + ")"; plugin()->web_view()->mainFrame()->executeScript( @@ -222,8 +232,3 @@ void MissingPlugin::ContextMenuAction(unsigned id) { NOTREACHED(); } } - -void MissingPlugin::DidFinishLoading() { - if (message_.length() > 0) - UpdateMessage(); -} diff --git a/chrome/renderer/plugins/missing_plugin.h b/chrome/renderer/plugins/missing_plugin.h index 69936f2..117334b 100644 --- a/chrome/renderer/plugins/missing_plugin.h +++ b/chrome/renderer/plugins/missing_plugin.h @@ -27,7 +27,6 @@ class MissingPlugin : public PluginPlaceholder, // WebViewPlugin::Delegate methods: virtual void BindWebFrame(WebKit::WebFrame* frame) OVERRIDE; virtual void ShowContextMenu(const WebKit::WebMouseEvent&) OVERRIDE; - virtual void DidFinishLoading() OVERRIDE; #if defined(ENABLE_PLUGIN_INSTALLATION) // IPC::Channel::Listener methods: @@ -48,6 +47,8 @@ class MissingPlugin : public PluginPlaceholder, virtual ~MissingPlugin(); void HideCallback(const CppArgumentList& args, CppVariant* result); + void DidFinishLoadingCallback(const CppArgumentList& args, + CppVariant* result); void OnDidNotFindMissingPlugin(); #if defined(ENABLE_PLUGIN_INSTALLATION) @@ -66,6 +67,7 @@ class MissingPlugin : public PluginPlaceholder, int32 placeholder_routing_id_; #endif + bool finished_loading_; string16 message_; DISALLOW_COPY_AND_ASSIGN(MissingPlugin); diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index bb7cc03..7bceea5 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -122,6 +122,3 @@ void PluginPlaceholder::WillDestroyPlugin() { void PluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { } - -void PluginPlaceholder::DidFinishLoading() { -} diff --git a/chrome/renderer/plugins/plugin_placeholder.h b/chrome/renderer/plugins/plugin_placeholder.h index 1cf2fbe..f6c9675 100644 --- a/chrome/renderer/plugins/plugin_placeholder.h +++ b/chrome/renderer/plugins/plugin_placeholder.h @@ -45,7 +45,6 @@ class PluginPlaceholder : public content::RenderViewObserver, virtual void BindWebFrame(WebKit::WebFrame* frame) OVERRIDE; virtual void WillDestroyPlugin() OVERRIDE; virtual void ShowContextMenu(const WebKit::WebMouseEvent& event) OVERRIDE; - virtual void DidFinishLoading() OVERRIDE; private: WebKit::WebFrame* frame_; -- cgit v1.1