OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ | 8 #ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
9 #define WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ | 9 #define WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
10 | 10 |
| 11 #include <map> |
| 12 #include <set> |
| 13 #include <stack> |
11 #include <string> | 14 #include <string> |
12 #include <vector> | 15 #include <vector> |
13 #include <stack> | |
14 | 16 |
15 #include "app/gfx/native_widget_types.h" | 17 #include "app/gfx/native_widget_types.h" |
16 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
17 #include "base/file_path.h" | 19 #include "base/file_path.h" |
18 #include "base/ref_counted.h" | 20 #include "base/ref_counted.h" |
19 #include "base/scoped_ptr.h" | 21 #include "base/scoped_ptr.h" |
20 #include "webkit/glue/plugins/nphostapi.h" | 22 #include "webkit/glue/plugins/nphostapi.h" |
21 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
22 #include "third_party/npapi/bindings/npapi.h" | 24 #include "third_party/npapi/bindings/npapi.h" |
23 | 25 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void* notify_data); | 145 void* notify_data); |
144 | 146 |
145 // If true, send the Mozilla user agent instead of Chrome's to the plugin. | 147 // If true, send the Mozilla user agent instead of Chrome's to the plugin. |
146 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } | 148 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } |
147 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } | 149 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } |
148 | 150 |
149 // Helper that implements NPN_PluginThreadAsyncCall semantics | 151 // Helper that implements NPN_PluginThreadAsyncCall semantics |
150 void PluginThreadAsyncCall(void (*func)(void *), | 152 void PluginThreadAsyncCall(void (*func)(void *), |
151 void *userData); | 153 void *userData); |
152 | 154 |
| 155 uint32 ScheduleTimer(uint32 interval, |
| 156 NPBool repeat, |
| 157 void (*func)(NPP id, uint32 timer_id)); |
| 158 |
| 159 void UnscheduleTimer(uint32 timer_id); |
| 160 |
153 // | 161 // |
154 // NPAPI methods for calling the Plugin Instance | 162 // NPAPI methods for calling the Plugin Instance |
155 // | 163 // |
156 NPError NPP_New(unsigned short, short, char *[], char *[]); | 164 NPError NPP_New(unsigned short, short, char *[], char *[]); |
157 NPError NPP_SetWindow(NPWindow *); | 165 NPError NPP_SetWindow(NPWindow *); |
158 NPError NPP_NewStream(NPMIMEType, NPStream *, NPBool, unsigned short *); | 166 NPError NPP_NewStream(NPMIMEType, NPStream *, NPBool, unsigned short *); |
159 NPError NPP_DestroyStream(NPStream *, NPReason); | 167 NPError NPP_DestroyStream(NPStream *, NPReason); |
160 int NPP_WriteReady(NPStream *); | 168 int NPP_WriteReady(NPStream *); |
161 int NPP_Write(NPStream *, int, int, void *); | 169 int NPP_Write(NPStream *, int, int, void *); |
162 void NPP_StreamAsFile(NPStream *, const char *); | 170 void NPP_StreamAsFile(NPStream *, const char *); |
(...skipping 23 matching lines...) Expand all Loading... |
186 bool popups_allowed() const { | 194 bool popups_allowed() const { |
187 return popups_enabled_stack_.empty() ? false : popups_enabled_stack_.top(); | 195 return popups_enabled_stack_.empty() ? false : popups_enabled_stack_.top(); |
188 } | 196 } |
189 | 197 |
190 // Initiates byte range reads for plugins. | 198 // Initiates byte range reads for plugins. |
191 void RequestRead(NPStream* stream, NPByteRange* range_list); | 199 void RequestRead(NPStream* stream, NPByteRange* range_list); |
192 | 200 |
193 private: | 201 private: |
194 void OnPluginThreadAsyncCall(void (*func)(void *), | 202 void OnPluginThreadAsyncCall(void (*func)(void *), |
195 void *userData); | 203 void *userData); |
| 204 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), |
| 205 NPP id, |
| 206 uint32 timer_id); |
| 207 |
196 bool IsValidStream(const NPStream* stream); | 208 bool IsValidStream(const NPStream* stream); |
197 | 209 |
198 // 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 |
199 // 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 |
200 // 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 |
201 // 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 |
202 // 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 |
203 // 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 |
204 // it knows about. Eventually it dereferences this structure and compares | 216 // it knows about. Eventually it dereferences this structure and compares |
205 // 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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // NPN_GetURL/NPN_GetURLNotify calls. | 256 // NPN_GetURL/NPN_GetURLNotify calls. |
245 std::stack<bool> popups_enabled_stack_; | 257 std::stack<bool> popups_enabled_stack_; |
246 | 258 |
247 // True if in CloseStreams(). | 259 // True if in CloseStreams(). |
248 bool in_close_streams_; | 260 bool in_close_streams_; |
249 | 261 |
250 // List of files created for the current plugin instance. File names are | 262 // List of files created for the current plugin instance. File names are |
251 // added to the list every time the NPP_StreamAsFile function is called. | 263 // added to the list every time the NPP_StreamAsFile function is called. |
252 std::vector<FilePath> files_created_; | 264 std::vector<FilePath> files_created_; |
253 | 265 |
| 266 // Next unusued timer id. |
| 267 uint32 next_timer_id_; |
| 268 |
| 269 // Map of timer id to settings for timer. |
| 270 struct TimerInfo { |
| 271 uint32 interval; |
| 272 bool repeat; |
| 273 }; |
| 274 typedef std::map<uint32, TimerInfo> TimerMap; |
| 275 TimerMap timers_; |
| 276 |
254 DISALLOW_EVIL_CONSTRUCTORS(PluginInstance); | 277 DISALLOW_EVIL_CONSTRUCTORS(PluginInstance); |
255 }; | 278 }; |
256 | 279 |
257 } // namespace NPAPI | 280 } // namespace NPAPI |
258 | 281 |
259 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ | 282 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
OLD | NEW |