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. | |
brettw
2011/03/22 05:59:11
I'd just use one comment for both of these functio
| |
219 void PostMessage(PP_Var message); | |
220 // Passthrough for PPP_Messaging. | |
221 void HandleMessage(PP_Var message); | |
222 | |
213 PluginDelegate::PlatformContext3D* CreateContext3D(); | 223 PluginDelegate::PlatformContext3D* CreateContext3D(); |
214 | 224 |
215 // Tracks all live ObjectVar. This is so we can map between PluginModule + | 225 // Tracks all live ObjectVar. This is so we can map between PluginModule + |
216 // NPObject and get the ObjectVar corresponding to it. This Add/Remove | 226 // NPObject and get the ObjectVar corresponding to it. This Add/Remove |
217 // function should be called by the ObjectVar when it is created and | 227 // function should be called by the ObjectVar when it is created and |
218 // destroyed. | 228 // destroyed. |
219 void AddNPObjectVar(ObjectVar* object_var); | 229 void AddNPObjectVar(ObjectVar* object_var); |
220 void RemoveNPObjectVar(ObjectVar* object_var); | 230 void RemoveNPObjectVar(ObjectVar* object_var); |
221 | 231 |
222 // Looks up a previously registered ObjectVar for the given NPObject and | 232 // Looks up a previously registered ObjectVar for the given NPObject and |
223 // module. Returns NULL if there is no ObjectVar corresponding to the given | 233 // module. Returns NULL if there is no ObjectVar corresponding to the given |
224 // NPObject for the given module. See AddNPObjectVar above. | 234 // NPObject for the given module. See AddNPObjectVar above. |
225 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; | 235 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; |
226 | 236 |
227 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or | 237 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or |
228 // embedded in a page). | 238 // embedded in a page). |
229 bool IsFullPagePlugin() const; | 239 bool IsFullPagePlugin() const; |
230 | 240 |
231 private: | 241 private: |
232 bool LoadFindInterface(); | 242 bool LoadFindInterface(); |
243 bool LoadMessagingInterface(); | |
233 bool LoadPdfInterface(); | 244 bool LoadPdfInterface(); |
234 bool LoadSelectionInterface(); | 245 bool LoadSelectionInterface(); |
235 bool LoadZoomInterface(); | 246 bool LoadZoomInterface(); |
236 | 247 |
237 // Determines if we think the plugin has focus, both content area and webkit | 248 // Determines if we think the plugin has focus, both content area and webkit |
238 // (see has_webkit_focus_ below). | 249 // (see has_webkit_focus_ below). |
239 bool PluginHasFocus() const; | 250 bool PluginHasFocus() const; |
240 | 251 |
241 // Reports the current plugin geometry to the plugin by calling | 252 // Reports the current plugin geometry to the plugin by calling |
242 // DidChangeView. | 253 // 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 | 319 // tab/window has focus. We tell the plugin it has focus only when both of |
309 // these values are set to true. | 320 // these values are set to true. |
310 bool has_webkit_focus_; | 321 bool has_webkit_focus_; |
311 bool has_content_area_focus_; | 322 bool has_content_area_focus_; |
312 | 323 |
313 // The id of the current find operation, or -1 if none is in process. | 324 // The id of the current find operation, or -1 if none is in process. |
314 int find_identifier_; | 325 int find_identifier_; |
315 | 326 |
316 // The plugin-provided interfaces. | 327 // The plugin-provided interfaces. |
317 const PPP_Find_Dev* plugin_find_interface_; | 328 const PPP_Find_Dev* plugin_find_interface_; |
329 const PPP_Messaging_Dev* plugin_messaging_interface_; | |
318 const PPP_Pdf* plugin_pdf_interface_; | 330 const PPP_Pdf* plugin_pdf_interface_; |
319 const PPP_Selection_Dev* plugin_selection_interface_; | 331 const PPP_Selection_Dev* plugin_selection_interface_; |
320 const PPP_Zoom_Dev* plugin_zoom_interface_; | 332 const PPP_Zoom_Dev* plugin_zoom_interface_; |
321 | 333 |
322 // This is only valid between a successful PrintBegin call and a PrintEnd | 334 // This is only valid between a successful PrintBegin call and a PrintEnd |
323 // call. | 335 // call. |
324 PP_PrintSettings_Dev current_print_settings_; | 336 PP_PrintSettings_Dev current_print_settings_; |
325 #if defined(OS_MACOSX) | 337 #if defined(OS_MACOSX) |
326 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 338 // 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 | 339 // to keep the pixels valid until CGContextEndPage is called. We use this |
(...skipping 28 matching lines...) Expand all Loading... | |
356 bool always_on_top_; | 368 bool always_on_top_; |
357 | 369 |
358 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: | 370 // 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 | 371 // there is a transition state where fullscreen_container_ is non-NULL but |
360 // fullscreen_ is false (see above). | 372 // fullscreen_ is false (see above). |
361 FullscreenContainer* fullscreen_container_; | 373 FullscreenContainer* fullscreen_container_; |
362 | 374 |
363 // True if we are in fullscreen mode. Note: it is false during the transition. | 375 // True if we are in fullscreen mode. Note: it is false during the transition. |
364 bool fullscreen_; | 376 bool fullscreen_; |
365 | 377 |
378 // The MessageChannel used to implement bidirectional postMessage for the | |
379 // instance. | |
380 scoped_ptr<MessageChannel> message_channel_; | |
381 | |
366 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 382 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
367 SkBitmap* sad_plugin_; | 383 SkBitmap* sad_plugin_; |
368 | 384 |
369 typedef std::set<PluginObject*> PluginObjectSet; | 385 typedef std::set<PluginObject*> PluginObjectSet; |
370 PluginObjectSet live_plugin_objects_; | 386 PluginObjectSet live_plugin_objects_; |
371 | 387 |
372 // Tracks all live ObjectVars used by this module so we can map NPObjects to | 388 // Tracks all live ObjectVars used by this module so we can map NPObjects to |
373 // the corresponding object. These are non-owning references. | 389 // the corresponding object. These are non-owning references. |
374 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; | 390 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
375 NPObjectToObjectVarMap np_object_to_object_var_; | 391 NPObjectToObjectVarMap np_object_to_object_var_; |
376 | 392 |
377 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 393 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
378 }; | 394 }; |
379 | 395 |
380 } // namespace ppapi | 396 } // namespace ppapi |
381 } // namespace webkit | 397 } // namespace webkit |
382 | 398 |
383 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 399 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |