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 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 // Updates the instance's tracking of the location of the plugin location | 114 // Updates the instance's tracking of the location of the plugin location |
115 // relative to the upper left of the screen. | 115 // relative to the upper left of the screen. |
116 void set_plugin_origin(const gfx::Point& origin) { plugin_origin_ = origin; } | 116 void set_plugin_origin(const gfx::Point& origin) { plugin_origin_ = origin; } |
117 // Updates the instance's tracking of the frame of the containing window | 117 // Updates the instance's tracking of the frame of the containing window |
118 // relative to the upper left of the screen. | 118 // relative to the upper left of the screen. |
119 void set_window_frame(const gfx::Rect& frame) { | 119 void set_window_frame(const gfx::Rect& frame) { |
120 containing_window_frame_ = frame; | 120 containing_window_frame_ = frame; |
121 } | 121 } |
122 #endif | 122 #endif |
123 | 123 |
124 // Creates a stream for sending an URL. If notify_id is non-zero, it will | 124 // Creates a stream for sending an URL. Set object_url to true if the load is |
125 // send a notification to the plugin when the stream is complete; otherwise it | 125 // for the object tag's url, or false if it's for a url that the plugin |
126 // will not. Set object_url to true if the load is for the object tag's url, | 126 // fetched through NPN_GetUrl[Notify]. |
127 // or false if it's for a url that the plugin fetched through | |
128 // NPN_GetUrl[Notify]. | |
129 PluginStreamUrl* CreateStream(unsigned long resource_id, | 127 PluginStreamUrl* CreateStream(unsigned long resource_id, |
dcheng
2015/11/18 18:38:18
Then we could probably nuke this too.
Nate Chapin
2015/11/18 23:28:50
Done.
| |
130 const GURL& url, | 128 const GURL& url, |
131 const std::string& mime_type, | 129 const std::string& mime_type); |
132 int notify_id); | |
133 | 130 |
134 // For each instance, we track all streams. When the | 131 // For each instance, we track all streams. When the |
135 // instance closes, all remaining streams are also | 132 // instance closes, all remaining streams are also |
136 // closed. All streams associated with this instance | 133 // closed. All streams associated with this instance |
137 // should call AddStream so that they can be cleaned | 134 // should call AddStream so that they can be cleaned |
138 // up when the instance shuts down. | 135 // up when the instance shuts down. |
139 void AddStream(PluginStream* stream); | 136 void AddStream(PluginStream* stream); |
140 | 137 |
141 // This is called when a stream is closed. We remove the stream from the | 138 // This is called when a stream is closed. We remove the stream from the |
142 // list, which releases the reference maintained to the stream. | 139 // list, which releases the reference maintained to the stream. |
143 void RemoveStream(PluginStream* stream); | 140 void RemoveStream(PluginStream* stream); |
144 | 141 |
145 // Closes all open streams on this instance. | 142 // Closes all open streams on this instance. |
146 void CloseStreams(); | 143 void CloseStreams(); |
147 | 144 |
148 // Returns the WebPluginResourceClient object for a stream that has become | 145 // Returns the WebPluginResourceClient object for a stream that has become |
149 // seekable. | 146 // seekable. |
150 WebPluginResourceClient* GetRangeRequest(int id); | 147 WebPluginResourceClient* GetRangeRequest(int id); |
151 | 148 |
152 // Have the plugin create its script object. | 149 // Have the plugin create its script object. |
153 NPObject* GetPluginScriptableObject(); | 150 NPObject* GetPluginScriptableObject(); |
154 | 151 |
155 // Returns the form value of this instance. | 152 // Returns the form value of this instance. |
156 bool GetFormValue(base::string16* value); | 153 bool GetFormValue(base::string16* value); |
157 | 154 |
158 // WebViewDelegate methods that we implement. This is for handling | |
159 // callbacks during getURLNotify. | |
160 void DidFinishLoadWithReason(const GURL& url, NPReason reason, int notify_id); | |
161 | |
162 // If true, send the Mozilla user agent instead of Chrome's to the plugin. | 155 // If true, send the Mozilla user agent instead of Chrome's to the plugin. |
163 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } | 156 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } |
164 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } | 157 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } |
165 | 158 |
166 // If the plugin instance is backed by a texture, return its ID in the | 159 // If the plugin instance is backed by a texture, return its ID in the |
167 // compositor's namespace. Otherwise return 0. Returns 0 by default. | 160 // compositor's namespace. Otherwise return 0. Returns 0 by default. |
168 unsigned GetBackingTextureId(); | 161 unsigned GetBackingTextureId(); |
169 | 162 |
170 // Helper that implements NPN_PluginThreadAsyncCall semantics | 163 // Helper that implements NPN_PluginThreadAsyncCall semantics |
171 void PluginThreadAsyncCall(void (*func)(void *), | 164 void PluginThreadAsyncCall(void (*func)(void *), |
(...skipping 26 matching lines...) Expand all Loading... | |
198 NPError NPP_GetValue(NPPVariable, void*); | 191 NPError NPP_GetValue(NPPVariable, void*); |
199 NPError NPP_SetValue(NPNVariable, void*); | 192 NPError NPP_SetValue(NPNVariable, void*); |
200 short NPP_HandleEvent(void*); | 193 short NPP_HandleEvent(void*); |
201 void NPP_Destroy(); | 194 void NPP_Destroy(); |
202 bool NPP_Print(NPPrint* platform_print); | 195 bool NPP_Print(NPPrint* platform_print); |
203 void NPP_URLRedirectNotify(const char* url, int32_t status, | 196 void NPP_URLRedirectNotify(const char* url, int32_t status, |
204 void* notify_data); | 197 void* notify_data); |
205 | 198 |
206 void SendJavaScriptStream(const GURL& url, | 199 void SendJavaScriptStream(const GURL& url, |
207 const std::string& result, | 200 const std::string& result, |
208 bool success, | 201 bool success); |
209 int notify_id); | |
210 | 202 |
211 void DidReceiveManualResponse(const GURL& url, | 203 void DidReceiveManualResponse(const GURL& url, |
212 const std::string& mime_type, | 204 const std::string& mime_type, |
213 const std::string& headers, | 205 const std::string& headers, |
214 uint32 expected_length, | 206 uint32 expected_length, |
215 uint32 last_modified); | 207 uint32 last_modified); |
216 void DidReceiveManualData(const char* buffer, int length); | 208 void DidReceiveManualData(const char* buffer, int length); |
217 void DidFinishManualLoading(); | 209 void DidFinishManualLoading(); |
218 void DidManualLoadFail(); | 210 void DidManualLoadFail(); |
219 | 211 |
220 void PushPopupsEnabledState(bool enabled); | 212 void PushPopupsEnabledState(bool enabled); |
221 void PopPopupsEnabledState(); | 213 void PopPopupsEnabledState(); |
222 | 214 |
223 bool popups_allowed() const { | 215 bool popups_allowed() const { |
224 return popups_enabled_stack_.empty() ? false : popups_enabled_stack_.top(); | 216 return popups_enabled_stack_.empty() ? false : popups_enabled_stack_.top(); |
225 } | 217 } |
226 | 218 |
227 // Initiates byte range reads for plugins. | 219 // Initiates byte range reads for plugins. |
228 void RequestRead(NPStream* stream, NPByteRange* range_list); | 220 void RequestRead(NPStream* stream, NPByteRange* range_list); |
229 | 221 |
230 // Handles GetURL/GetURLNotify/PostURL/PostURLNotify requests initiated | 222 // Handles GetURL/GetURLNotify/PostURL/PostURLNotify requests initiated |
231 // by plugins. | 223 // by plugins. |
232 void RequestURL(const char* url, | 224 void RequestURL(const char* url, |
233 const char* method, | 225 const char* method, |
234 const char* target, | 226 const char* target, |
235 const char* buf, | 227 const char* buf, |
236 unsigned int len, | 228 unsigned int len); |
237 bool notify, | |
238 void* notify_data); | |
239 | |
240 // Handles NPN_URLRedirectResponse calls issued by plugins in response to | |
241 // HTTP URL redirect notifications. | |
242 void URLRedirectResponse(bool allow, void* notify_data); | |
243 | |
244 bool handles_url_redirects() const { return handles_url_redirects_; } | |
245 | 229 |
246 private: | 230 private: |
247 friend class base::RefCountedThreadSafe<PluginInstance>; | 231 friend class base::RefCountedThreadSafe<PluginInstance>; |
248 | 232 |
249 #if defined(OS_MACOSX) | 233 #if defined(OS_MACOSX) |
250 friend class ScopedCurrentPluginEvent; | 234 friend class ScopedCurrentPluginEvent; |
251 // Sets the event that the plugin is currently handling. The object is not | 235 // Sets the event that the plugin is currently handling. The object is not |
252 // owned or copied, so the caller must call this again with NULL before the | 236 // owned or copied, so the caller must call this again with NULL before the |
253 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather | 237 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather |
254 // than calling this directly. | 238 // than calling this directly. |
255 void set_currently_handled_event(NPCocoaEvent* event) { | 239 void set_currently_handled_event(NPCocoaEvent* event) { |
256 currently_handled_event_ = event; | 240 currently_handled_event_ = event; |
257 } | 241 } |
258 #endif | 242 #endif |
259 | 243 |
260 ~PluginInstance(); | 244 ~PluginInstance(); |
261 void OnPluginThreadAsyncCall(void (*func)(void *), void* userData); | 245 void OnPluginThreadAsyncCall(void (*func)(void *), void* userData); |
262 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), | 246 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), |
263 NPP id, uint32 timer_id); | 247 NPP id, uint32 timer_id); |
264 bool IsValidStream(const NPStream* stream); | 248 bool IsValidStream(const NPStream* stream); |
265 void GetNotifyData(int notify_id, bool* notify, void** notify_data); | |
266 | 249 |
267 // This is a hack to get the real player plugin to work with chrome | 250 // This is a hack to get the real player plugin to work with chrome |
268 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via | 251 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via |
269 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in | 252 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in |
270 // the plugin are invoked via an interface by firefox. The plugin instance | 253 // the plugin are invoked via an interface by firefox. The plugin instance |
271 // handle which is passed to every NPAPI method is owned by the real player | 254 // handle which is passed to every NPAPI method is owned by the real player |
272 // plugin, i.e. it expects the ndata member to point to a structure which | 255 // plugin, i.e. it expects the ndata member to point to a structure which |
273 // it knows about. Eventually it dereferences this structure and compares | 256 // it knows about. Eventually it dereferences this structure and compares |
274 // a member variable at offset 0x24(Version 6.0.11.2888) /2D (Version | 257 // a member variable at offset 0x24(Version 6.0.11.2888) /2D (Version |
275 // 6.0.11.3088) with 0 and on failing this check, takes a different code | 258 // 6.0.11.3088) with 0 and on failing this check, takes a different code |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 uint32 interval; | 314 uint32 interval; |
332 bool repeat; | 315 bool repeat; |
333 }; | 316 }; |
334 typedef std::map<uint32, TimerInfo> TimerMap; | 317 typedef std::map<uint32, TimerInfo> TimerMap; |
335 TimerMap timers_; | 318 TimerMap timers_; |
336 | 319 |
337 // Tracks pending GET/POST requests so that the plugin-given data doesn't | 320 // Tracks pending GET/POST requests so that the plugin-given data doesn't |
338 // cross process boundaries to an untrusted process. | 321 // cross process boundaries to an untrusted process. |
339 typedef std::map<int, void*> PendingRequestMap; | 322 typedef std::map<int, void*> PendingRequestMap; |
340 PendingRequestMap pending_requests_; | 323 PendingRequestMap pending_requests_; |
341 int next_notify_id_; | |
342 | 324 |
343 // Used to track pending range requests so that when WebPlugin replies to us | 325 // Used to track pending range requests so that when WebPlugin replies to us |
344 // we can match the reply to the stream. | 326 // we can match the reply to the stream. |
345 typedef std::map<int, scoped_refptr<PluginStream> > PendingRangeRequestMap; | 327 typedef std::map<int, scoped_refptr<PluginStream> > PendingRangeRequestMap; |
346 PendingRangeRequestMap pending_range_requests_; | 328 PendingRangeRequestMap pending_range_requests_; |
347 int next_range_request_id_; | 329 int next_range_request_id_; |
348 // The plugin handles the NPAPI URL redirect notification API. | 330 // The plugin handles the NPAPI URL redirect notification API. |
349 // See here https://wiki.mozilla.org/NPAPI:HTTPRedirectHandling | 331 // See here https://wiki.mozilla.org/NPAPI:HTTPRedirectHandling |
350 bool handles_url_redirects_; | 332 bool handles_url_redirects_; |
351 | 333 |
(...skipping 11 matching lines...) Expand all Loading... | |
363 | 345 |
364 private: | 346 private: |
365 scoped_refptr<PluginInstance> instance_; | 347 scoped_refptr<PluginInstance> instance_; |
366 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); | 348 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); |
367 }; | 349 }; |
368 #endif | 350 #endif |
369 | 351 |
370 } // namespace content | 352 } // namespace content |
371 | 353 |
372 #endif // CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ | 354 #endif // CONTENT_CHILD_NPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |