OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" |
24 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
25 #include "webkit/plugins/ppapi/plugin_delegate.h" | 25 #include "webkit/plugins/ppapi/plugin_delegate.h" |
26 | 26 |
27 typedef struct NPObject NPObject; | 27 typedef struct NPObject NPObject; |
28 struct PP_Var; | 28 struct PP_Var; |
29 struct PPB_Instance; | 29 struct PPB_Instance; |
30 struct PPB_Find_Dev; | 30 struct PPB_Find_Dev; |
31 struct PPB_Fullscreen_Dev; | 31 struct PPB_Fullscreen_Dev; |
| 32 struct PPB_Messaging_Dev; |
32 struct PPB_Zoom_Dev; | 33 struct PPB_Zoom_Dev; |
33 struct PPP_Find_Dev; | 34 struct PPP_Find_Dev; |
34 struct PPP_Instance; | 35 struct PPP_Instance; |
| 36 struct PPP_Messaging_Dev; |
35 struct PPP_Pdf; | 37 struct PPP_Pdf; |
36 struct PPP_Selection_Dev; | 38 struct PPP_Selection_Dev; |
37 struct PPP_Zoom_Dev; | 39 struct PPP_Zoom_Dev; |
38 | 40 |
39 class SkBitmap; | 41 class SkBitmap; |
40 class TransportDIB; | 42 class TransportDIB; |
41 | 43 |
42 namespace gfx { | 44 namespace gfx { |
43 class Rect; | 45 class Rect; |
44 } | 46 } |
45 | 47 |
46 namespace WebKit { | 48 namespace WebKit { |
47 struct WebCursorInfo; | 49 struct WebCursorInfo; |
48 class WebInputEvent; | 50 class WebInputEvent; |
49 class WebPluginContainer; | 51 class WebPluginContainer; |
50 } | 52 } |
51 | 53 |
52 namespace webkit { | 54 namespace webkit { |
53 namespace ppapi { | 55 namespace ppapi { |
54 | 56 |
55 class FullscreenContainer; | 57 class FullscreenContainer; |
| 58 class MessageChannel; |
56 class ObjectVar; | 59 class ObjectVar; |
57 class PluginDelegate; | 60 class PluginDelegate; |
58 class PluginModule; | 61 class PluginModule; |
59 class PluginObject; | 62 class PluginObject; |
60 class PPB_Graphics2D_Impl; | 63 class PPB_Graphics2D_Impl; |
61 class PPB_ImageData_Impl; | 64 class PPB_ImageData_Impl; |
62 class PPB_Surface3D_Impl; | 65 class PPB_Surface3D_Impl; |
63 class PPB_URLLoader_Impl; | 66 class PPB_URLLoader_Impl; |
64 class Resource; | 67 class Resource; |
65 | 68 |
66 // Represents one time a plugin appears on one web page. | 69 // Represents one time a plugin appears on one web page. |
67 // | 70 // |
68 // Note: to get from a PP_Instance to a PluginInstance*, use the | 71 // Note: to get from a PP_Instance to a PluginInstance*, use the |
69 // ResourceTracker. | 72 // ResourceTracker. |
70 class PluginInstance : public base::RefCounted<PluginInstance> { | 73 class PluginInstance : public base::RefCounted<PluginInstance> { |
71 public: | 74 public: |
72 PluginInstance(PluginDelegate* delegate, | 75 PluginInstance(PluginDelegate* delegate, |
73 PluginModule* module, | 76 PluginModule* module, |
74 const PPP_Instance* instance_interface); | 77 const PPP_Instance* instance_interface); |
75 ~PluginInstance(); | 78 ~PluginInstance(); |
76 | 79 |
77 static const PPB_Instance* GetInterface(); | 80 static const PPB_Instance* GetInterface(); |
78 | 81 |
79 // Returns a pointer to the interface implementing PPB_Find that is | 82 // Returns a pointer to the interface implementing PPB_Find that is |
80 // exposed to the plugin. | 83 // exposed to the plugin. |
81 static const PPB_Find_Dev* GetFindInterface(); | 84 static const PPB_Find_Dev* GetFindInterface(); |
82 static const PPB_Fullscreen_Dev* GetFullscreenInterface(); | 85 static const PPB_Fullscreen_Dev* GetFullscreenInterface(); |
| 86 static const PPB_Messaging_Dev* GetMessagingInterface(); |
83 static const PPB_Zoom_Dev* GetZoomInterface(); | 87 static const PPB_Zoom_Dev* GetZoomInterface(); |
84 | 88 |
85 PluginDelegate* delegate() const { return delegate_; } | 89 PluginDelegate* delegate() const { return delegate_; } |
86 PluginModule* module() const { return module_.get(); } | 90 PluginModule* module() const { return module_.get(); } |
| 91 MessageChannel& message_channel() { return *message_channel_; } |
87 | 92 |
88 WebKit::WebPluginContainer* container() const { return container_; } | 93 WebKit::WebPluginContainer* container() const { return container_; } |
89 | 94 |
90 const gfx::Rect& position() const { return position_; } | 95 const gfx::Rect& position() const { return position_; } |
91 const gfx::Rect& clip() const { return clip_; } | 96 const gfx::Rect& clip() const { return clip_; } |
92 | 97 |
93 int find_identifier() const { return find_identifier_; } | 98 int find_identifier() const { return find_identifier_; } |
94 | 99 |
95 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } | 100 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } |
96 | 101 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 208 |
204 // Switches between fullscreen and normal mode. If |delay_report| is set to | 209 // Switches between fullscreen and normal mode. If |delay_report| is set to |
205 // false, it may report the new state through DidChangeView immediately. If | 210 // false, it may report the new state through DidChangeView immediately. If |
206 // true, it will delay it. When called from the plugin, delay_report should be | 211 // true, it will delay it. When called from the plugin, delay_report should be |
207 // true to avoid re-entrancy. | 212 // true to avoid re-entrancy. |
208 void SetFullscreen(bool fullscreen, bool delay_report); | 213 void SetFullscreen(bool fullscreen, bool delay_report); |
209 | 214 |
210 // Implementation of PPB_Flash. | 215 // Implementation of PPB_Flash. |
211 bool NavigateToURL(const char* url, const char* target); | 216 bool NavigateToURL(const char* url, const char* target); |
212 | 217 |
| 218 // Implementation of PPB_Messaging and PPP_Messaging. |
| 219 void PostMessage(PP_Var message); |
| 220 void HandleMessage(PP_Var message); |
| 221 |
213 PluginDelegate::PlatformContext3D* CreateContext3D(); | 222 PluginDelegate::PlatformContext3D* CreateContext3D(); |
214 | 223 |
215 // Tracks all live ObjectVar. This is so we can map between PluginModule + | 224 // Tracks all live ObjectVar. This is so we can map between PluginModule + |
216 // NPObject and get the ObjectVar corresponding to it. This Add/Remove | 225 // NPObject and get the ObjectVar corresponding to it. This Add/Remove |
217 // function should be called by the ObjectVar when it is created and | 226 // function should be called by the ObjectVar when it is created and |
218 // destroyed. | 227 // destroyed. |
219 void AddNPObjectVar(ObjectVar* object_var); | 228 void AddNPObjectVar(ObjectVar* object_var); |
220 void RemoveNPObjectVar(ObjectVar* object_var); | 229 void RemoveNPObjectVar(ObjectVar* object_var); |
221 | 230 |
222 // Looks up a previously registered ObjectVar for the given NPObject and | 231 // Looks up a previously registered ObjectVar for the given NPObject and |
223 // module. Returns NULL if there is no ObjectVar corresponding to the given | 232 // module. Returns NULL if there is no ObjectVar corresponding to the given |
224 // NPObject for the given module. See AddNPObjectVar above. | 233 // NPObject for the given module. See AddNPObjectVar above. |
225 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; | 234 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; |
226 | 235 |
227 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or | 236 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or |
228 // embedded in a page). | 237 // embedded in a page). |
229 bool IsFullPagePlugin() const; | 238 bool IsFullPagePlugin() const; |
230 | 239 |
231 private: | 240 private: |
232 bool LoadFindInterface(); | 241 bool LoadFindInterface(); |
| 242 bool LoadMessagingInterface(); |
233 bool LoadPdfInterface(); | 243 bool LoadPdfInterface(); |
234 bool LoadSelectionInterface(); | 244 bool LoadSelectionInterface(); |
235 bool LoadZoomInterface(); | 245 bool LoadZoomInterface(); |
236 | 246 |
237 // Determines if we think the plugin has focus, both content area and webkit | 247 // Determines if we think the plugin has focus, both content area and webkit |
238 // (see has_webkit_focus_ below). | 248 // (see has_webkit_focus_ below). |
239 bool PluginHasFocus() const; | 249 bool PluginHasFocus() const; |
240 | 250 |
241 // Reports the current plugin geometry to the plugin by calling | 251 // Reports the current plugin geometry to the plugin by calling |
242 // DidChangeView. | 252 // DidChangeView. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // tab/window has focus. We tell the plugin it has focus only when both of | 318 // tab/window has focus. We tell the plugin it has focus only when both of |
309 // these values are set to true. | 319 // these values are set to true. |
310 bool has_webkit_focus_; | 320 bool has_webkit_focus_; |
311 bool has_content_area_focus_; | 321 bool has_content_area_focus_; |
312 | 322 |
313 // The id of the current find operation, or -1 if none is in process. | 323 // The id of the current find operation, or -1 if none is in process. |
314 int find_identifier_; | 324 int find_identifier_; |
315 | 325 |
316 // The plugin-provided interfaces. | 326 // The plugin-provided interfaces. |
317 const PPP_Find_Dev* plugin_find_interface_; | 327 const PPP_Find_Dev* plugin_find_interface_; |
| 328 const PPP_Messaging_Dev* plugin_messaging_interface_; |
318 const PPP_Pdf* plugin_pdf_interface_; | 329 const PPP_Pdf* plugin_pdf_interface_; |
319 const PPP_Selection_Dev* plugin_selection_interface_; | 330 const PPP_Selection_Dev* plugin_selection_interface_; |
320 const PPP_Zoom_Dev* plugin_zoom_interface_; | 331 const PPP_Zoom_Dev* plugin_zoom_interface_; |
321 | 332 |
| 333 // A flag to indicate whether we have asked this plugin instance for its |
| 334 // messaging interface, so that we can ask only once. |
| 335 bool checked_for_plugin_messaging_interface_; |
| 336 |
322 // This is only valid between a successful PrintBegin call and a PrintEnd | 337 // This is only valid between a successful PrintBegin call and a PrintEnd |
323 // call. | 338 // call. |
324 PP_PrintSettings_Dev current_print_settings_; | 339 PP_PrintSettings_Dev current_print_settings_; |
325 #if defined(OS_MACOSX) | 340 #if defined(OS_MACOSX) |
326 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 341 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
327 // to keep the pixels valid until CGContextEndPage is called. We use this | 342 // to keep the pixels valid until CGContextEndPage is called. We use this |
328 // variable to hold on to the pixels. | 343 // variable to hold on to the pixels. |
329 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; | 344 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; |
330 #elif defined(OS_LINUX) | 345 #elif defined(OS_LINUX) |
331 // On Linux, all pages need to be written to a PDF file in one shot. However, | 346 // On Linux, all pages need to be written to a PDF file in one shot. However, |
(...skipping 24 matching lines...) Expand all Loading... |
356 bool always_on_top_; | 371 bool always_on_top_; |
357 | 372 |
358 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: | 373 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: |
359 // there is a transition state where fullscreen_container_ is non-NULL but | 374 // there is a transition state where fullscreen_container_ is non-NULL but |
360 // fullscreen_ is false (see above). | 375 // fullscreen_ is false (see above). |
361 FullscreenContainer* fullscreen_container_; | 376 FullscreenContainer* fullscreen_container_; |
362 | 377 |
363 // True if we are in fullscreen mode. Note: it is false during the transition. | 378 // True if we are in fullscreen mode. Note: it is false during the transition. |
364 bool fullscreen_; | 379 bool fullscreen_; |
365 | 380 |
| 381 // The MessageChannel used to implement bidirectional postMessage for the |
| 382 // instance. |
| 383 scoped_ptr<MessageChannel> message_channel_; |
| 384 |
366 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 385 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
367 SkBitmap* sad_plugin_; | 386 SkBitmap* sad_plugin_; |
368 | 387 |
369 typedef std::set<PluginObject*> PluginObjectSet; | 388 typedef std::set<PluginObject*> PluginObjectSet; |
370 PluginObjectSet live_plugin_objects_; | 389 PluginObjectSet live_plugin_objects_; |
371 | 390 |
372 // Tracks all live ObjectVars used by this module so we can map NPObjects to | 391 // Tracks all live ObjectVars used by this module so we can map NPObjects to |
373 // the corresponding object. These are non-owning references. | 392 // the corresponding object. These are non-owning references. |
374 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; | 393 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
375 NPObjectToObjectVarMap np_object_to_object_var_; | 394 NPObjectToObjectVarMap np_object_to_object_var_; |
376 | 395 |
377 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 396 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
378 }; | 397 }; |
379 | 398 |
380 } // namespace ppapi | 399 } // namespace ppapi |
381 } // namespace webkit | 400 } // namespace webkit |
382 | 401 |
383 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 402 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |