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