OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 5 #ifndef UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
6 #define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 6 #define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // availible and it goes very much against the grain of the code to make it so. | 24 // availible and it goes very much against the grain of the code to make it so. |
25 // Also, we worry that GTK might choose to change the underlying X window id | 25 // Also, we worry that GTK might choose to change the underlying X window id |
26 // when, say, the widget is hidden or repacked. Finally, if we used XIDs then a | 26 // when, say, the widget is hidden or repacked. Finally, if we used XIDs then a |
27 // compromised renderer could start asking questions about any X windows on the | 27 // compromised renderer could start asking questions about any X windows on the |
28 // system. | 28 // system. |
29 // | 29 // |
30 // Thus, we have this object. It produces random NativeViewIds from GtkWidget | 30 // Thus, we have this object. It produces random NativeViewIds from GtkWidget |
31 // pointers and observes the various signals from the widget for when an X | 31 // pointers and observes the various signals from the widget for when an X |
32 // window is created, destroyed etc. Thus it provides a thread safe mapping | 32 // window is created, destroyed etc. Thus it provides a thread safe mapping |
33 // from NativeViewIds to the current XID for that widget. | 33 // from NativeViewIds to the current XID for that widget. |
34 class UI_EXPORT GtkNativeViewManager { | 34 class GFX_EXPORT GtkNativeViewManager { |
35 public: | 35 public: |
36 // Returns the singleton instance. | 36 // Returns the singleton instance. |
37 static GtkNativeViewManager* GetInstance(); | 37 static GtkNativeViewManager* GetInstance(); |
38 | 38 |
39 // Must be called from the UI thread: | 39 // Must be called from the UI thread: |
40 // | 40 // |
41 // Return a NativeViewId for the given widget and attach to the various | 41 // Return a NativeViewId for the given widget and attach to the various |
42 // signals emitted by that widget. The NativeViewId is pseudo-randomly | 42 // signals emitted by that widget. The NativeViewId is pseudo-randomly |
43 // allocated so that a compromised renderer trying to guess values will fail | 43 // allocated so that a compromised renderer trying to guess values will fail |
44 // with high probability. The NativeViewId will not be reused for the | 44 // with high probability. The NativeViewId will not be reused for the |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // | 129 // |
130 // An XID will map to NULL, if there is an outstanding reference but the | 130 // An XID will map to NULL, if there is an outstanding reference but the |
131 // widget was destroyed. In this case, the destruction of the X window | 131 // widget was destroyed. In this case, the destruction of the X window |
132 // is deferred to the dropping of all references. | 132 // is deferred to the dropping of all references. |
133 std::map<XID, PermanentXIDInfo> perm_xid_to_info_; | 133 std::map<XID, PermanentXIDInfo> perm_xid_to_info_; |
134 | 134 |
135 DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager); | 135 DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager); |
136 }; | 136 }; |
137 | 137 |
138 #endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ | 138 #endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ |
OLD | NEW |