Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: webkit/tools/test_shell/webview_host_gtk.cc

Issue 146078: linux: OOP windowed plugins (Closed)
Patch Set: new version Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webkit/tools/test_shell/webview_host.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 6
7 #include "webkit/tools/test_shell/webview_host.h" 7 #include "webkit/tools/test_shell/webview_host.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/gfx/rect.h" 10 #include "base/gfx/rect.h"
11 #include "base/gfx/size.h" 11 #include "base/gfx/size.h"
12 #include "skia/ext/platform_canvas.h" 12 #include "skia/ext/platform_canvas.h"
13 #include "webkit/glue/plugins/gtk_plugin_container.h" 13 #include "webkit/glue/plugins/gtk_plugin_container.h"
14 #include "webkit/glue/webview.h" 14 #include "webkit/glue/webview.h"
15 15
16 // static 16 // static
17 WebViewHost* WebViewHost::Create(GtkWidget* parent_view, 17 WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
18 WebViewDelegate* delegate, 18 WebViewDelegate* delegate,
19 const WebPreferences& prefs) { 19 const WebPreferences& prefs) {
20 WebViewHost* host = new WebViewHost(); 20 WebViewHost* host = new WebViewHost();
21 21
22 host->view_ = WebWidgetHost::CreateWidget(parent_view, host); 22 host->view_ = WebWidgetHost::CreateWidget(parent_view, host);
23 host->plugin_container_host_.set_host_widget(host->view_);
23 g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host); 24 g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host);
24 25
25 host->webwidget_ = WebView::Create(delegate, prefs); 26 host->webwidget_ = WebView::Create(delegate, prefs);
26 host->webwidget_->Layout(); 27 host->webwidget_->Layout();
27 28
28 return host; 29 return host;
29 } 30 }
30 31
31 WebView* WebViewHost::webview() const { 32 WebView* WebViewHost::webview() const {
32 return static_cast<WebView*>(webwidget_); 33 return static_cast<WebView*>(webwidget_);
33 } 34 }
34 35
35 GdkNativeWindow WebViewHost::CreatePluginContainer() { 36 GdkNativeWindow WebViewHost::CreatePluginContainer() {
36 GtkWidget* plugin_container = gtk_plugin_container_new(); 37 return plugin_container_host_.CreatePluginContainer();
37 g_signal_connect(G_OBJECT(plugin_container), "plug-removed",
38 G_CALLBACK(OnPlugRemovedThunk), this);
39 gtk_container_add(GTK_CONTAINER(view_handle()), plugin_container);
40 gtk_widget_show(plugin_container);
41 gtk_widget_realize(plugin_container);
42
43 GdkNativeWindow id = gtk_socket_get_id(GTK_SOCKET(plugin_container));
44
45 native_window_to_widget_map_.insert(std::make_pair(id, plugin_container));
46
47 return id;
48 }
49
50 GtkWidget* WebViewHost::MapIDToWidget(GdkNativeWindow id) {
51 NativeWindowToWidgetMap::const_iterator i =
52 native_window_to_widget_map_.find(id);
53 if (i != native_window_to_widget_map_.end())
54 return i->second;
55
56 LOG(ERROR) << "Request for widget host for unknown window id " << id;
57
58 return NULL;
59 } 38 }
60 39
61 void WebViewHost::OnPluginWindowDestroyed(GdkNativeWindow id) { 40 void WebViewHost::OnPluginWindowDestroyed(GdkNativeWindow id) {
62 GtkWidget* plugin_container = MapIDToWidget(id); 41 plugin_container_host_.DestroyPluginContainer(id);
63 if (!plugin_container)
64 return;
65
66 native_window_to_widget_map_.erase(id);
67 gtk_widget_destroy(plugin_container);
68 } 42 }
69
70 gboolean WebViewHost::OnPlugRemoved(GtkSocket* socket) {
71 return TRUE; // Don't destroy our widget; we manage it ourselves.
72 }
73
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/webview_host.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698