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