summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-03 19:07:30 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-03 19:07:30 +0000
commit4923229ec942699c100556ead557576a816a285c (patch)
tree438c07b04fbc19affdc194e8d88f580039774c09
parent9715b85f74e95db5345fd33ef43ff48eb0ce983f (diff)
downloadchromium_src-4923229ec942699c100556ead557576a816a285c.zip
chromium_src-4923229ec942699c100556ead557576a816a285c.tar.gz
chromium_src-4923229ec942699c100556ead557576a816a285c.tar.bz2
Fix initial plugin Mac plugin focus and visibily
Also simplifies the way initial window state is set, by sending the same message that's used for later changes just after initialization instead of adding parameters to the init message. While this means we send one more async message if the plugin's renderer is visible, we remove an unnecessary synchronous call to the browser procces for plugins in background tabs, and we defer that synchronous call until after plugin initialization has started in the visible case. BUG=51391 TEST=Plugins loaded in a foreground page should react to keystrokes without having to switch tabs. Mouseovers should continue to work as before. Review URL: http://codereview.chromium.org/3356006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58521 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/plugin_messages.h27
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc5
-rw-r--r--chrome/renderer/render_view.cc8
-rw-r--r--chrome/renderer/render_widget.h2
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc12
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm6
6 files changed, 11 insertions, 49 deletions
diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h
index 190fdba..56eaf50 100644
--- a/chrome/common/plugin_messages.h
+++ b/chrome/common/plugin_messages.h
@@ -42,11 +42,6 @@ struct PluginMsg_Init_Params {
std::vector<std::string> arg_values;
bool load_manually;
int host_render_view_routing_id;
-#if defined(OS_MACOSX)
- gfx::Rect containing_window_frame;
- gfx::Rect containing_content_frame;
- bool containing_window_has_focus;
-#endif
};
struct PluginHostMsg_URLRequest_Params {
@@ -128,11 +123,6 @@ struct ParamTraits<PluginMsg_Init_Params> {
WriteParam(m, p.arg_values);
WriteParam(m, p.load_manually);
WriteParam(m, p.host_render_view_routing_id);
-#if defined(OS_MACOSX)
- WriteParam(m, p.containing_window_frame);
- WriteParam(m, p.containing_content_frame);
- WriteParam(m, p.containing_window_has_focus);
-#endif
}
static bool Read(const Message* m, void** iter, param_type* p) {
return ReadParam(m, iter, &p->containing_window) &&
@@ -141,14 +131,7 @@ struct ParamTraits<PluginMsg_Init_Params> {
ReadParam(m, iter, &p->arg_names) &&
ReadParam(m, iter, &p->arg_values) &&
ReadParam(m, iter, &p->load_manually) &&
- ReadParam(m, iter, &p->host_render_view_routing_id)
-#if defined(OS_MACOSX)
- &&
- ReadParam(m, iter, &p->containing_window_frame) &&
- ReadParam(m, iter, &p->containing_content_frame) &&
- ReadParam(m, iter, &p->containing_window_has_focus)
-#endif
- ;
+ ReadParam(m, iter, &p->host_render_view_routing_id);
}
static void Log(const param_type& p, std::string* l) {
l->append("(");
@@ -165,14 +148,6 @@ struct ParamTraits<PluginMsg_Init_Params> {
LogParam(p.load_manually, l);
l->append(", ");
LogParam(p.host_render_view_routing_id, l);
-#if defined(OS_MACOSX)
- l->append(", ");
- LogParam(p.containing_window_frame, l);
- l->append(", ");
- LogParam(p.containing_content_frame, l);
- l->append(", ");
- LogParam(p.containing_window_has_focus, l);
-#endif
l->append(")");
}
};
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index acf83b1..0802d31 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -191,11 +191,6 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
params.arg_values,
webplugin_,
params.load_manually);
-#if defined(OS_MACOSX)
- delegate_->WindowFrameChanged(params.containing_window_frame,
- params.containing_content_frame);
- delegate_->SetWindowHasFocus(params.containing_window_has_focus);
-#endif
}
}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 7fa91bc..803abae 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -585,6 +585,14 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
#if defined(OS_MACOSX)
void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) {
plugin_delegates_.insert(delegate);
+ // If the renderer is visible, set initial visibility and focus state.
+ if (!is_hidden()) {
+ delegate->SetContainerVisibility(true);
+ if (webview() && webview()->isActive())
+ delegate->SetWindowFocus(true);
+ if (has_focus())
+ delegate->SetContentAreaFocus(true);
+ }
}
void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) {
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index a6de929..2d8ea717 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -224,6 +224,8 @@ class RenderWidget : public IPC::Channel::Listener,
// the focus on our own when the browser did not focus us.
void ClearFocus();
+ bool has_focus() const { return has_focus_; }
+
// Set the pending window rect.
// Because the real render_widget is hosted in another process, there is
// a time period where we may have set a new window rect which has not yet
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index f1019cb..a5490af 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -375,18 +375,6 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url,
params.arg_values.push_back("opaque");
}
}
-
- params.containing_window_frame = render_view_->rootWindowRect();
- // If the renderer isn't currently visible, don't bother asking for anything
- // else; the plugin will get real data when its renderer becomes visible.
- if (params.containing_window_frame.IsEmpty()) {
- params.containing_content_frame = gfx::Rect();
- params.containing_window_has_focus = false;
- } else {
- params.containing_content_frame = render_view_->windowRect();
- WebKit::WebView* webview = render_view_->webview();
- params.containing_window_has_focus = webview && webview->isActive();
- }
#endif
params.load_manually = load_manually;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 73d8f3c..dd3a83b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -385,12 +385,6 @@ bool WebPluginDelegateImpl::PlatformInitialize() {
break;
}
- // TODO(stuartmorgan): We need real plugin container visibility information
- // when the plugin is initialized; for now, assume it's visible.
- // None of the calls SetContainerVisibility would make are useful at this
- // point, so we just set the initial state directly.
- container_is_visible_ = true;
-
// Let the WebPlugin know that we are windowless (unless this is a
// Core Animation plugin, in which case BindFakePluginWindowHandle will take
// care of setting up the appropriate window handle).