| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_PLUGINS_NPAPI_GTK_PLUGIN_CONTAINER_MANAGER_H_ | |
| 6 #define WEBKIT_PLUGINS_NPAPI_GTK_PLUGIN_CONTAINER_MANAGER_H_ | |
| 7 | |
| 8 #include <gtk/gtk.h> | |
| 9 #include <map> | |
| 10 | |
| 11 #include "ui/gfx/native_widget_types.h" | |
| 12 #include "webkit/plugins/webkit_plugins_export.h" | |
| 13 | |
| 14 typedef struct _GtkWidget GtkWidget; | |
| 15 | |
| 16 namespace webkit { | |
| 17 namespace npapi { | |
| 18 | |
| 19 struct WebPluginGeometry; | |
| 20 | |
| 21 // Helper class that creates and manages plugin containers (GtkSocket). | |
| 22 class WEBKIT_PLUGINS_EXPORT GtkPluginContainerManager { | |
| 23 public: | |
| 24 GtkPluginContainerManager(); | |
| 25 ~GtkPluginContainerManager(); | |
| 26 | |
| 27 // Sets the widget that will host the plugin containers. Must be a GtkFixed. | |
| 28 void set_host_widget(GtkWidget *widget) { host_widget_ = widget; } | |
| 29 | |
| 30 // Creates a new plugin container, for a given plugin XID. | |
| 31 GtkWidget* CreatePluginContainer(gfx::PluginWindowHandle id); | |
| 32 | |
| 33 // Destroys a plugin container, given the plugin XID. | |
| 34 void DestroyPluginContainer(gfx::PluginWindowHandle id); | |
| 35 | |
| 36 // Takes an update from WebKit about a plugin's position and side and moves | |
| 37 // the plugin accordingly. | |
| 38 void MovePluginContainer(const WebPluginGeometry& move); | |
| 39 | |
| 40 private: | |
| 41 // Maps a plugin XID to the corresponding container widget. | |
| 42 GtkWidget* MapIDToWidget(gfx::PluginWindowHandle id); | |
| 43 | |
| 44 // Maps a container widget to the corresponding plugin XID. | |
| 45 gfx::PluginWindowHandle MapWidgetToID(GtkWidget* widget); | |
| 46 | |
| 47 // Callback for when the plugin container gets realized, at which point it | |
| 48 // plugs the plugin XID. | |
| 49 static void RealizeCallback(GtkWidget *widget, void *user_data); | |
| 50 | |
| 51 // Parent of the plugin containers. | |
| 52 GtkWidget* host_widget_; | |
| 53 | |
| 54 // A map that associates plugin containers to the plugin XID. | |
| 55 typedef std::map<gfx::PluginWindowHandle, GtkWidget*> PluginWindowToWidgetMap; | |
| 56 PluginWindowToWidgetMap plugin_window_to_widget_map_; | |
| 57 }; | |
| 58 | |
| 59 } // namespace npapi | |
| 60 } // namespace webkit | |
| 61 | |
| 62 #endif // WEBKIT_PLUGINS_NPAPI_GTK_PLUGIN_CONTAINER_MANAGER_H_ | |
| OLD | NEW |