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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
19 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 19 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
20 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" | 20 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" |
21 #include "ppapi/c/dev/ppp_printing_dev.h" | 21 #include "ppapi/c/dev/ppp_printing_dev.h" |
22 #include "ppapi/c/pp_instance.h" | 22 #include "ppapi/c/pp_instance.h" |
23 #include "ppapi/c/pp_resource.h" | 23 #include "ppapi/c/pp_resource.h" |
24 #include "ppapi/c/pp_var.h" | 24 #include "ppapi/c/pp_var.h" |
25 #include "ppapi/c/ppp_instance.h" | 25 #include "ppapi/c/ppp_instance.h" |
26 #include "ppapi/shared_impl/function_group_base.h" | 26 #include "ppapi/shared_impl/function_group_base.h" |
| 27 #include "ppapi/shared_impl/instance_impl.h" |
27 #include "ppapi/shared_impl/ppp_instance_combined.h" | 28 #include "ppapi/shared_impl/ppp_instance_combined.h" |
28 #include "ppapi/thunk/ppb_instance_api.h" | 29 #include "ppapi/thunk/ppb_instance_api.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
30 #include "third_party/skia/include/core/SkRefCnt.h" | 31 #include "third_party/skia/include/core/SkRefCnt.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" |
32 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
33 #include "webkit/plugins/ppapi/plugin_delegate.h" | 34 #include "webkit/plugins/ppapi/plugin_delegate.h" |
34 | 35 |
35 typedef struct NPObject NPObject; | 36 typedef struct NPObject NPObject; |
36 struct PP_Var; | 37 struct PP_Var; |
37 struct PPB_Messaging; | 38 struct PPB_Messaging; |
38 struct PPB_Zoom_Dev; | 39 struct PPB_Zoom_Dev; |
39 struct PPP_Find_Dev; | 40 struct PPP_Find_Dev; |
| 41 struct PPP_InputEvent; |
40 struct PPP_Instance_Private; | 42 struct PPP_Instance_Private; |
41 struct PPP_Messaging; | 43 struct PPP_Messaging; |
42 struct PPP_Pdf; | 44 struct PPP_Pdf; |
43 struct PPP_Selection_Dev; | 45 struct PPP_Selection_Dev; |
44 struct PPP_Zoom_Dev; | 46 struct PPP_Zoom_Dev; |
45 | 47 |
46 class SkBitmap; | 48 class SkBitmap; |
47 class TransportDIB; | 49 class TransportDIB; |
48 | 50 |
49 namespace gfx { | 51 namespace gfx { |
(...skipping 25 matching lines...) Expand all Loading... |
75 class PPB_URLLoader_Impl; | 77 class PPB_URLLoader_Impl; |
76 class PPB_URLRequestInfo_Impl; | 78 class PPB_URLRequestInfo_Impl; |
77 class Resource; | 79 class Resource; |
78 | 80 |
79 // Represents one time a plugin appears on one web page. | 81 // Represents one time a plugin appears on one web page. |
80 // | 82 // |
81 // Note: to get from a PP_Instance to a PluginInstance*, use the | 83 // Note: to get from a PP_Instance to a PluginInstance*, use the |
82 // ResourceTracker. | 84 // ResourceTracker. |
83 class PluginInstance : public base::RefCounted<PluginInstance>, | 85 class PluginInstance : public base::RefCounted<PluginInstance>, |
84 public ::ppapi::FunctionGroupBase, | 86 public ::ppapi::FunctionGroupBase, |
85 public ::ppapi::thunk::PPB_Instance_FunctionAPI { | 87 public ::ppapi::thunk::PPB_Instance_FunctionAPI, |
| 88 public ::ppapi::InstanceImpl { |
86 public: | 89 public: |
87 // Create and return a PluginInstance object which supports the | 90 // Create and return a PluginInstance object which supports the |
88 // PPP_Instance_0_5 interface. | 91 // PPP_Instance_0_5 interface. |
89 static PluginInstance* Create0_5(PluginDelegate* delegate, | 92 static PluginInstance* Create0_5(PluginDelegate* delegate, |
90 PluginModule* module, | 93 PluginModule* module, |
91 const void* ppp_instance_if_0_5); | 94 const void* ppp_instance_if_0_5); |
92 | 95 |
93 // Create and return a PluginInstance object which supports the | 96 // Create and return a PluginInstance object which supports the |
94 // PPP_Instance_0_4 interface. | 97 // PPP_Instance_0_4 interface. |
95 static PluginInstance* Create0_4(PluginDelegate* delegate, | 98 static PluginInstance* Create0_4(PluginDelegate* delegate, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; | 280 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
278 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; | 281 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
279 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; | 282 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
280 virtual PP_Var ExecuteScript(PP_Instance instance, | 283 virtual PP_Var ExecuteScript(PP_Instance instance, |
281 PP_Var script, | 284 PP_Var script, |
282 PP_Var* exception) OVERRIDE; | 285 PP_Var* exception) OVERRIDE; |
283 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; | 286 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; |
284 virtual PP_Bool SetFullscreen(PP_Instance instance, | 287 virtual PP_Bool SetFullscreen(PP_Instance instance, |
285 PP_Bool fullscreen) OVERRIDE; | 288 PP_Bool fullscreen) OVERRIDE; |
286 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; | 289 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; |
| 290 virtual int32_t RequestInputEvents(PP_Instance instance, |
| 291 uint32_t event_classes) OVERRIDE; |
| 292 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, |
| 293 uint32_t event_classes) OVERRIDE; |
| 294 virtual void ClearInputEventRequest(PP_Instance instance, |
| 295 uint32_t event_classes) OVERRIDE; |
287 | 296 |
288 private: | 297 private: |
289 // See the static Create functions above for creating PluginInstance objects. | 298 // See the static Create functions above for creating PluginInstance objects. |
290 // This constructor is private so that we can hide the PPP_Instance_Combined | 299 // This constructor is private so that we can hide the PPP_Instance_Combined |
291 // details while still having 1 constructor to maintain for member | 300 // details while still having 1 constructor to maintain for member |
292 // initialization. | 301 // initialization. |
293 PluginInstance(PluginDelegate* delegate, | 302 PluginInstance(PluginDelegate* delegate, |
294 PluginModule* module, | 303 PluginModule* module, |
295 ::ppapi::PPP_Instance_Combined* instance_interface); | 304 ::ppapi::PPP_Instance_Combined* instance_interface); |
296 | 305 |
297 bool LoadFindInterface(); | 306 bool LoadFindInterface(); |
| 307 bool LoadInputEventInterface(); |
298 bool LoadMessagingInterface(); | 308 bool LoadMessagingInterface(); |
299 bool LoadPdfInterface(); | 309 bool LoadPdfInterface(); |
300 bool LoadSelectionInterface(); | 310 bool LoadSelectionInterface(); |
301 bool LoadPrintInterface(); | 311 bool LoadPrintInterface(); |
302 bool LoadPrivateInterface(); | 312 bool LoadPrivateInterface(); |
303 bool LoadZoomInterface(); | 313 bool LoadZoomInterface(); |
304 | 314 |
305 // Determines if we think the plugin has focus, both content area and webkit | 315 // Determines if we think the plugin has focus, both content area and webkit |
306 // (see has_webkit_focus_ below). | 316 // (see has_webkit_focus_ below). |
307 bool PluginHasFocus() const; | 317 bool PluginHasFocus() const; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // these values are set to true. | 390 // these values are set to true. |
381 bool has_webkit_focus_; | 391 bool has_webkit_focus_; |
382 bool has_content_area_focus_; | 392 bool has_content_area_focus_; |
383 | 393 |
384 // The id of the current find operation, or -1 if none is in process. | 394 // The id of the current find operation, or -1 if none is in process. |
385 int find_identifier_; | 395 int find_identifier_; |
386 | 396 |
387 // The plugin-provided interfaces. | 397 // The plugin-provided interfaces. |
388 const PPP_Find_Dev* plugin_find_interface_; | 398 const PPP_Find_Dev* plugin_find_interface_; |
389 const PPP_Messaging* plugin_messaging_interface_; | 399 const PPP_Messaging* plugin_messaging_interface_; |
| 400 const PPP_InputEvent* plugin_input_event_interface_; |
| 401 const PPP_Instance_Private* plugin_private_interface_; |
390 const PPP_Pdf* plugin_pdf_interface_; | 402 const PPP_Pdf* plugin_pdf_interface_; |
391 const PPP_Instance_Private* plugin_private_interface_; | |
392 const PPP_Selection_Dev* plugin_selection_interface_; | 403 const PPP_Selection_Dev* plugin_selection_interface_; |
393 const PPP_Zoom_Dev* plugin_zoom_interface_; | 404 const PPP_Zoom_Dev* plugin_zoom_interface_; |
394 | 405 |
395 // A flag to indicate whether we have asked this plugin instance for its | 406 // Flags indicating whether we have asked this plugin instance for the |
396 // messaging interface, so that we can ask only once. | 407 // corresponding interfaces, so that we can ask only once. |
| 408 bool checked_for_plugin_input_event_interface_; |
397 bool checked_for_plugin_messaging_interface_; | 409 bool checked_for_plugin_messaging_interface_; |
398 | 410 |
399 // This is only valid between a successful PrintBegin call and a PrintEnd | 411 // This is only valid between a successful PrintBegin call and a PrintEnd |
400 // call. | 412 // call. |
401 PP_PrintSettings_Dev_0_4 current_print_settings_; | 413 PP_PrintSettings_Dev_0_4 current_print_settings_; |
402 #if defined(OS_MACOSX) | 414 #if defined(OS_MACOSX) |
403 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 415 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
404 // to keep the pixels valid until CGContextEndPage is called. We use this | 416 // to keep the pixels valid until CGContextEndPage is called. We use this |
405 // variable to hold on to the pixels. | 417 // variable to hold on to the pixels. |
406 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; | 418 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 SkBitmap* sad_plugin_; | 492 SkBitmap* sad_plugin_; |
481 | 493 |
482 typedef std::set<PluginObject*> PluginObjectSet; | 494 typedef std::set<PluginObject*> PluginObjectSet; |
483 PluginObjectSet live_plugin_objects_; | 495 PluginObjectSet live_plugin_objects_; |
484 | 496 |
485 // Tracks all live ObjectVars used by this module so we can map NPObjects to | 497 // Tracks all live ObjectVars used by this module so we can map NPObjects to |
486 // the corresponding object. These are non-owning references. | 498 // the corresponding object. These are non-owning references. |
487 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; | 499 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
488 NPObjectToObjectVarMap np_object_to_object_var_; | 500 NPObjectToObjectVarMap np_object_to_object_var_; |
489 | 501 |
| 502 // Classes of events that the plugin has registered for, both for filtering |
| 503 // and not. The bits are PP_INPUTEVENT_CLASS_*. |
| 504 uint32_t input_event_mask_; |
| 505 uint32_t filtered_input_event_mask_; |
| 506 |
490 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 507 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
491 }; | 508 }; |
492 | 509 |
493 } // namespace ppapi | 510 } // namespace ppapi |
494 } // namespace webkit | 511 } // namespace webkit |
495 | 512 |
496 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 513 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |