summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 17:40:46 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 17:40:46 +0000
commit700d3d58213d15dea1beb2f7f7122e77e7ea2a47 (patch)
tree5d6a3c72fa58cccd7a7f7ddba5c77ed0edbe5135 /chrome/plugin
parentd1ae85447a12e97b0758b0d113a12e2d6c6d09b4 (diff)
downloadchromium_src-700d3d58213d15dea1beb2f7f7122e77e7ea2a47.zip
chromium_src-700d3d58213d15dea1beb2f7f7122e77e7ea2a47.tar.gz
chromium_src-700d3d58213d15dea1beb2f7f7122e77e7ea2a47.tar.bz2
linux: OOP windowed plugins
There are still a few issues, but that's a start. - only windowed plugins - we can't currently create the gtksocket in background tabs, because their gtkwidgets are not yet in the hierarchy, so they can't be realized (that's what gives the XID). - the plugin process talks to the browser process through the renderer process to create/destroy the gtksockets, because the plugin doesn't know which renderer it's talking to. We need a bit more plumbing to be able to have direct IPC. - some code is duplicated between chrome and test_shell. We should probably refactor it, but I'm not sure where the common part should live. Patch from Antoine Labour <piman@google.com>, with some touchups by me. Review URL: http://codereview.chromium.org/146078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/plugin_main.cc16
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc13
-rw-r--r--chrome/plugin/webplugin_proxy.cc25
-rw-r--r--chrome/plugin/webplugin_proxy.h4
4 files changed, 37 insertions, 21 deletions
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc
index fb8880f..a710b70 100644
--- a/chrome/plugin/plugin_main.cc
+++ b/chrome/plugin/plugin_main.cc
@@ -67,6 +67,22 @@ int PluginMain(const MainFunctionParams& parameters) {
MB_OK | MB_SETFOREGROUND);
}
#else
+#if defined(OS_LINUX)
+ {
+ // XEmbed plugins assume they are hosted in a Gtk application, so we need
+ // to initialize Gtk in the plugin process.
+ // TODO(evanm): hoist this up nearer to where we have argc/argv.
+ const std::vector<std::string>& args = parameters.command_line_.argv();
+ int argc = args.size();
+ scoped_array<const char *> argv(new const char *[argc + 1]);
+ for (int i = 0; i < argc; ++i) {
+ argv[i] = args[i].c_str();
+ }
+ argv[argc] = NULL;
+ const char **argv_pointer = argv.get();
+ gtk_init(&argc, const_cast<char***>(&argv_pointer));
+ }
+#endif
NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc.";
#endif
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index e607667..3bfd002 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -128,14 +128,15 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
FilePath path = FilePath::FromWStringHack(
command_line.GetSwitchValue(switches::kPluginPath));
+
+ gfx::PluginWindowHandle parent = NULL;
#if defined(OS_WIN)
- delegate_ = WebPluginDelegate::Create(
- path, mime_type_, gfx::NativeViewFromId(params.containing_window));
-#else
- NOTIMPLEMENTED() << " need to figure out nativeview id business";
- delegate_ = WebPluginDelegate::Create(
- path, mime_type_, NULL);
+ parent = gfx::NativeViewFromId(params.containing_window);
+#elif defined(OS_LINUX)
+ PluginThread::current()->Send(new PluginProcessHostMsg_MapNativeViewId(
+ params.containing_window, &parent));
#endif
+ delegate_ = WebPluginDelegate::Create(path, mime_type_, parent);
if (delegate_) {
webplugin_ = new WebPluginProxy(channel_, instance_id_, delegate_);
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index 57c07fc..3d6a6ac 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -56,12 +56,16 @@ bool WebPluginProxy::Send(IPC::Message* msg) {
return channel_->Send(msg);
}
-void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) {
-#if defined(OS_WIN)
- Send(new PluginHostMsg_SetWindow(route_id_, gfx::IdFromNativeView(window)));
-#else
- NOTIMPLEMENTED();
+#if defined(OS_LINUX)
+gfx::PluginWindowHandle WebPluginProxy::CreatePluginContainer() {
+ gfx::PluginWindowHandle container;
+ Send(new PluginHostMsg_CreatePluginContainer(route_id_, &container));
+ return container;
+}
#endif
+
+void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) {
+ Send(new PluginHostMsg_SetWindow(route_id_, window));
}
void WebPluginProxy::WillDestroyWindow(gfx::PluginWindowHandle window) {
@@ -69,6 +73,8 @@ void WebPluginProxy::WillDestroyWindow(gfx::PluginWindowHandle window) {
PluginThread::current()->Send(
new PluginProcessHostMsg_PluginWindowDestroyed(
window, ::GetParent(window)));
+#elif defined(OS_LINUX)
+ Send(new PluginHostMsg_DestroyPluginContainer(route_id_, window));
#else
NOTIMPLEMENTED();
#endif
@@ -275,7 +281,6 @@ void WebPluginProxy::HandleURLRequest(const char *method,
if (!target && (0 == base::strcasecmp(method, "GET"))) {
// Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082
// for more details on this.
-#if defined(OS_WIN)
if (delegate_->GetQuirks() &
WebPluginDelegate::PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS) {
GURL request_url(url);
@@ -285,10 +290,6 @@ void WebPluginProxy::HandleURLRequest(const char *method,
return;
}
}
-#else
- // TODO(port): we need a GetQuirks() on our delegate impl.
- NOTIMPLEMENTED();
-#endif
}
PluginHostMsg_URLRequest_Params params;
@@ -402,7 +403,6 @@ void WebPluginProxy::UpdateGeometry(
const gfx::Rect& clip_rect,
const TransportDIB::Id& windowless_buffer_id,
const TransportDIB::Id& background_buffer_id) {
-#if defined(OS_WIN)
// TODO(port): this isn't correct usage of a TransportDIB; for now,
// the caller temporarly just stuffs the handle into the HANDLE
// field of the TransportDIB::Id so it should behave like the older
@@ -410,8 +410,9 @@ void WebPluginProxy::UpdateGeometry(
gfx::Rect old = delegate_->GetRect();
gfx::Rect old_clip_rect = delegate_->GetClipRect();
- bool moved = old.x() != window_rect.x() || old.y() != window_rect.y();
delegate_->UpdateGeometry(window_rect, clip_rect);
+#if defined(OS_WIN)
+ bool moved = old.x() != window_rect.x() || old.y() != window_rect.y();
if (windowless_buffer_id.handle) {
// The plugin's rect changed, so now we have a new buffer to draw into.
SetWindowlessBuffer(windowless_buffer_id.handle,
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index c7bbe91..0388514 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -38,9 +38,7 @@ class WebPluginProxy : public WebPlugin {
// WebPlugin overrides
#if defined(OS_LINUX)
- gfx::PluginWindowHandle CreatePluginContainer() {
- return 0; // Temporary empty stub while we restructure test_shell.
- }
+ gfx::PluginWindowHandle CreatePluginContainer();
#endif
void SetWindow(gfx::PluginWindowHandle window);
void WillDestroyWindow(gfx::PluginWindowHandle window);