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 // TODO: Need to deal with NPAPI's NPSavedData. | 5 // TODO: Need to deal with NPAPI's NPSavedData. |
6 // I haven't seen plugins use it yet. | 6 // I haven't seen plugins use it yet. |
7 | 7 |
8 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ | 8 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ |
9 #define CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ | 9 #define CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ |
10 | 10 |
| 11 #include <stdint.h> |
| 12 |
11 #include <map> | 13 #include <map> |
12 #include <stack> | 14 #include <stack> |
13 #include <string> | 15 #include <string> |
14 #include <vector> | 16 #include <vector> |
15 | 17 |
16 #include "base/basictypes.h" | |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "build/build_config.h" |
19 #include "third_party/npapi/bindings/npapi.h" | 22 #include "third_party/npapi/bindings/npapi.h" |
20 #include "third_party/npapi/bindings/nphostapi.h" | 23 #include "third_party/npapi/bindings/nphostapi.h" |
21 #include "ui/gfx/geometry/point.h" | 24 #include "ui/gfx/geometry/point.h" |
22 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
23 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
24 #include "url/gurl.h" | 27 #include "url/gurl.h" |
25 | 28 |
26 namespace base { | 29 namespace base { |
27 class SingleThreadTaskRunner; | 30 class SingleThreadTaskRunner; |
28 } | 31 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } | 137 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } |
135 | 138 |
136 // If the plugin instance is backed by a texture, return its ID in the | 139 // If the plugin instance is backed by a texture, return its ID in the |
137 // compositor's namespace. Otherwise return 0. Returns 0 by default. | 140 // compositor's namespace. Otherwise return 0. Returns 0 by default. |
138 unsigned GetBackingTextureId(); | 141 unsigned GetBackingTextureId(); |
139 | 142 |
140 // Helper that implements NPN_PluginThreadAsyncCall semantics | 143 // Helper that implements NPN_PluginThreadAsyncCall semantics |
141 void PluginThreadAsyncCall(void (*func)(void *), | 144 void PluginThreadAsyncCall(void (*func)(void *), |
142 void* userData); | 145 void* userData); |
143 | 146 |
144 uint32 ScheduleTimer(uint32 interval, | 147 uint32_t ScheduleTimer(uint32_t interval, |
145 NPBool repeat, | 148 NPBool repeat, |
146 void (*func)(NPP id, uint32 timer_id)); | 149 void (*func)(NPP id, uint32_t timer_id)); |
147 | 150 |
148 void UnscheduleTimer(uint32 timer_id); | 151 void UnscheduleTimer(uint32_t timer_id); |
149 | 152 |
150 bool ConvertPoint(double source_x, double source_y, | 153 bool ConvertPoint(double source_x, double source_y, |
151 NPCoordinateSpace source_space, | 154 NPCoordinateSpace source_space, |
152 double* dest_x, double* dest_y, | 155 double* dest_x, double* dest_y, |
153 NPCoordinateSpace dest_space); | 156 NPCoordinateSpace dest_space); |
154 | 157 |
155 NPError PopUpContextMenu(NPMenu* menu); | 158 NPError PopUpContextMenu(NPMenu* menu); |
156 | 159 |
157 // | 160 // |
158 // NPAPI methods for calling the Plugin Instance | 161 // NPAPI methods for calling the Plugin Instance |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // owned or copied, so the caller must call this again with NULL before the | 196 // owned or copied, so the caller must call this again with NULL before the |
194 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather | 197 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather |
195 // than calling this directly. | 198 // than calling this directly. |
196 void set_currently_handled_event(NPCocoaEvent* event) { | 199 void set_currently_handled_event(NPCocoaEvent* event) { |
197 currently_handled_event_ = event; | 200 currently_handled_event_ = event; |
198 } | 201 } |
199 #endif | 202 #endif |
200 | 203 |
201 ~PluginInstance(); | 204 ~PluginInstance(); |
202 void OnPluginThreadAsyncCall(void (*func)(void *), void* userData); | 205 void OnPluginThreadAsyncCall(void (*func)(void *), void* userData); |
203 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), | 206 void OnTimerCall(void (*func)(NPP id, uint32_t timer_id), |
204 NPP id, uint32 timer_id); | 207 NPP id, |
| 208 uint32_t timer_id); |
205 | 209 |
206 // This is a hack to get the real player plugin to work with chrome | 210 // This is a hack to get the real player plugin to work with chrome |
207 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via | 211 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via |
208 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in | 212 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in |
209 // the plugin are invoked via an interface by firefox. The plugin instance | 213 // the plugin are invoked via an interface by firefox. The plugin instance |
210 // handle which is passed to every NPAPI method is owned by the real player | 214 // handle which is passed to every NPAPI method is owned by the real player |
211 // plugin, i.e. it expects the ndata member to point to a structure which | 215 // plugin, i.e. it expects the ndata member to point to a structure which |
212 // it knows about. Eventually it dereferences this structure and compares | 216 // it knows about. Eventually it dereferences this structure and compares |
213 // a member variable at offset 0x24(Version 6.0.11.2888) /2D (Version | 217 // a member variable at offset 0x24(Version 6.0.11.2888) /2D (Version |
214 // 6.0.11.3088) with 0 and on failing this check, takes a different code | 218 // 6.0.11.3088) with 0 and on failing this check, takes a different code |
215 // path which causes a crash. Safari and Opera work with version 6.0.11.2888 | 219 // path which causes a crash. Safari and Opera work with version 6.0.11.2888 |
216 // by chance as their ndata structure contains a 0 at the location which real | 220 // by chance as their ndata structure contains a 0 at the location which real |
217 // player checks:(. They crash with version 6.0.11.3088 as well. The | 221 // player checks:(. They crash with version 6.0.11.3088 as well. The |
218 // following member just adds a 96 byte padding to our PluginInstance class | 222 // following member just adds a 96 byte padding to our PluginInstance class |
219 // which is passed in the ndata member. This magic number works correctly on | 223 // which is passed in the ndata member. This magic number works correctly on |
220 // Vista with UAC on or off :(. | 224 // Vista with UAC on or off :(. |
221 // NOTE: Please dont change the ordering of the member variables | 225 // NOTE: Please dont change the ordering of the member variables |
222 // New members should be added after this padding array. | 226 // New members should be added after this padding array. |
223 // TODO(iyengar) : Disassemble the Realplayer ndata structure and look into | 227 // TODO(iyengar) : Disassemble the Realplayer ndata structure and look into |
224 // the possiblity of conforming to it (http://b/issue?id=936667). We | 228 // the possiblity of conforming to it (http://b/issue?id=936667). We |
225 // could also log a bug with Real, which would save the effort. | 229 // could also log a bug with Real, which would save the effort. |
226 uint8 zero_padding_[96]; | 230 uint8_t zero_padding_[96]; |
227 scoped_refptr<PluginLib> plugin_; | 231 scoped_refptr<PluginLib> plugin_; |
228 NPP npp_; | 232 NPP npp_; |
229 scoped_refptr<PluginHost> host_; | 233 scoped_refptr<PluginHost> host_; |
230 NPPluginFuncs* npp_functions_; | 234 NPPluginFuncs* npp_functions_; |
231 gfx::PluginWindowHandle window_handle_; | 235 gfx::PluginWindowHandle window_handle_; |
232 bool windowless_; | 236 bool windowless_; |
233 bool transparent_; | 237 bool transparent_; |
234 WebPlugin* webplugin_; | 238 WebPlugin* webplugin_; |
235 std::string mime_type_; | 239 std::string mime_type_; |
236 bool use_mozilla_user_agent_; | 240 bool use_mozilla_user_agent_; |
(...skipping 12 matching lines...) Expand all Loading... |
249 | 253 |
250 // Stack indicating if popups are to be enabled for the outgoing | 254 // Stack indicating if popups are to be enabled for the outgoing |
251 // NPN_GetURL/NPN_GetURLNotify calls. | 255 // NPN_GetURL/NPN_GetURLNotify calls. |
252 std::stack<bool> popups_enabled_stack_; | 256 std::stack<bool> popups_enabled_stack_; |
253 | 257 |
254 // List of files created for the current plugin instance. File names are | 258 // List of files created for the current plugin instance. File names are |
255 // added to the list every time the NPP_StreamAsFile function is called. | 259 // added to the list every time the NPP_StreamAsFile function is called. |
256 std::vector<base::FilePath> files_created_; | 260 std::vector<base::FilePath> files_created_; |
257 | 261 |
258 // Next unusued timer id. | 262 // Next unusued timer id. |
259 uint32 next_timer_id_; | 263 uint32_t next_timer_id_; |
260 | 264 |
261 // Map of timer id to settings for timer. | 265 // Map of timer id to settings for timer. |
262 struct TimerInfo { | 266 struct TimerInfo { |
263 uint32 interval; | 267 uint32_t interval; |
264 bool repeat; | 268 bool repeat; |
265 }; | 269 }; |
266 typedef std::map<uint32, TimerInfo> TimerMap; | 270 typedef std::map<uint32_t, TimerInfo> TimerMap; |
267 TimerMap timers_; | 271 TimerMap timers_; |
268 | 272 |
269 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 273 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
270 }; | 274 }; |
271 | 275 |
272 #if defined(OS_MACOSX) | 276 #if defined(OS_MACOSX) |
273 // Helper to simplify correct usage of set_currently_handled_event. | 277 // Helper to simplify correct usage of set_currently_handled_event. |
274 // Instantiating will set |instance|'s currently handled to |event| for the | 278 // Instantiating will set |instance|'s currently handled to |event| for the |
275 // lifetime of the object, then NULL when it goes out of scope. | 279 // lifetime of the object, then NULL when it goes out of scope. |
276 class ScopedCurrentPluginEvent { | 280 class ScopedCurrentPluginEvent { |
277 public: | 281 public: |
278 ScopedCurrentPluginEvent(PluginInstance* instance, NPCocoaEvent* event); | 282 ScopedCurrentPluginEvent(PluginInstance* instance, NPCocoaEvent* event); |
279 ~ScopedCurrentPluginEvent(); | 283 ~ScopedCurrentPluginEvent(); |
280 | 284 |
281 private: | 285 private: |
282 scoped_refptr<PluginInstance> instance_; | 286 scoped_refptr<PluginInstance> instance_; |
283 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); | 287 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); |
284 }; | 288 }; |
285 #endif | 289 #endif |
286 | 290 |
287 } // namespace content | 291 } // namespace content |
288 | 292 |
289 #endif // CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ | 293 #endif // CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |