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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 18 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
19 #include "ppapi/c/dev/ppp_printing_dev.h" | 19 #include "ppapi/c/dev/ppp_printing_dev.h" |
20 #include "ppapi/c/pp_completion_callback.h" | 20 #include "ppapi/c/pp_completion_callback.h" |
21 #include "ppapi/c/pp_instance.h" | 21 #include "ppapi/c/pp_instance.h" |
22 #include "ppapi/c/pp_resource.h" | 22 #include "ppapi/c/pp_resource.h" |
23 #include "ppapi/c/pp_var.h" | 23 #include "ppapi/c/pp_var.h" |
24 #include "ppapi/c/ppb_input_event.h" | 24 #include "ppapi/c/ppb_input_event.h" |
25 #include "ppapi/shared_impl/function_group_base.h" | 25 #include "ppapi/shared_impl/function_group_base.h" |
26 #include "ppapi/shared_impl/ppb_instance_shared.h" | 26 #include "ppapi/shared_impl/ppb_instance_shared.h" |
| 27 #include "ppapi/shared_impl/ppb_view_shared.h" |
27 #include "ppapi/thunk/ppb_instance_api.h" | 28 #include "ppapi/thunk/ppb_instance_api.h" |
28 #include "third_party/skia/include/core/SkRefCnt.h" | 29 #include "third_party/skia/include/core/SkRefCnt.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
31 #include "ui/base/ime/text_input_type.h" | 32 #include "ui/base/ime/text_input_type.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 #include "webkit/plugins/webkit_plugins_export.h" | 35 #include "webkit/plugins/webkit_plugins_export.h" |
35 | 36 |
36 struct PP_Point; | 37 struct PP_Point; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // | 79 // |
79 // Note: to get from a PP_Instance to a PluginInstance*, use the | 80 // Note: to get from a PP_Instance to a PluginInstance*, use the |
80 // ResourceTracker. | 81 // ResourceTracker. |
81 class WEBKIT_PLUGINS_EXPORT PluginInstance : | 82 class WEBKIT_PLUGINS_EXPORT PluginInstance : |
82 public base::RefCounted<PluginInstance>, | 83 public base::RefCounted<PluginInstance>, |
83 public ::ppapi::FunctionGroupBase, | 84 public ::ppapi::FunctionGroupBase, |
84 NON_EXPORTED_BASE(public ::ppapi::thunk::PPB_Instance_FunctionAPI), | 85 NON_EXPORTED_BASE(public ::ppapi::thunk::PPB_Instance_FunctionAPI), |
85 public ::ppapi::PPB_Instance_Shared { | 86 public ::ppapi::PPB_Instance_Shared { |
86 public: | 87 public: |
87 // Create and return a PluginInstance object which supports the | 88 // Create and return a PluginInstance object which supports the |
88 // PPP_Instance_1_0 interface. | 89 // given version. |
89 static PluginInstance* Create1_0(PluginDelegate* delegate, | 90 static PluginInstance* Create1_0(PluginDelegate* delegate, |
90 PluginModule* module, | 91 PluginModule* module, |
91 const void* ppp_instance_if_1_0); | 92 const void* ppp_instance_if_1_0); |
| 93 static PluginInstance* Create1_1(PluginDelegate* delegate, |
| 94 PluginModule* module, |
| 95 const void* ppp_instance_if_1_1); |
92 | 96 |
93 // Delete should be called by the WebPlugin before this destructor. | 97 // Delete should be called by the WebPlugin before this destructor. |
94 virtual ~PluginInstance(); | 98 virtual ~PluginInstance(); |
95 | 99 |
96 PluginDelegate* delegate() const { return delegate_; } | 100 PluginDelegate* delegate() const { return delegate_; } |
97 PluginModule* module() const { return module_.get(); } | 101 PluginModule* module() const { return module_.get(); } |
98 MessageChannel& message_channel() { return *message_channel_; } | 102 MessageChannel& message_channel() { return *message_channel_; } |
99 | 103 |
100 WebKit::WebPluginContainer* container() const { return container_; } | 104 WebKit::WebPluginContainer* container() const { return container_; } |
101 | 105 |
102 const gfx::Rect& position() const { return position_; } | |
103 const gfx::Rect& clip() const { return clip_; } | |
104 | |
105 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } | 106 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } |
106 | 107 |
107 // Returns the PP_Instance uniquely identifying this instance. Guaranteed | 108 // Returns the PP_Instance uniquely identifying this instance. Guaranteed |
108 // nonzero. | 109 // nonzero. |
109 PP_Instance pp_instance() const { return pp_instance_; } | 110 PP_Instance pp_instance() const { return pp_instance_; } |
110 | 111 |
111 // Does some pre-destructor cleanup on the instance. This is necessary | 112 // Does some pre-destructor cleanup on the instance. This is necessary |
112 // because some cleanup depends on the plugin instance still existing (like | 113 // because some cleanup depends on the plugin instance still existing (like |
113 // calling the plugin's DidDestroy function). This function is called from | 114 // calling the plugin's DidDestroy function). This function is called from |
114 // the WebPlugin implementation when WebKit is about to remove the plugin. | 115 // the WebPlugin implementation when WebKit is about to remove the plugin. |
(...skipping 22 matching lines...) Expand all Loading... |
137 // Commit the backing texture to the screen once the side effects some | 138 // Commit the backing texture to the screen once the side effects some |
138 // rendering up to an offscreen SwapBuffers are visible. | 139 // rendering up to an offscreen SwapBuffers are visible. |
139 void CommitBackingTexture(); | 140 void CommitBackingTexture(); |
140 | 141 |
141 // Called when the out-of-process plugin implementing this instance crashed. | 142 // Called when the out-of-process plugin implementing this instance crashed. |
142 void InstanceCrashed(); | 143 void InstanceCrashed(); |
143 | 144 |
144 // PPB_Instance and PPB_Instance_Private implementation. | 145 // PPB_Instance and PPB_Instance_Private implementation. |
145 const GURL& plugin_url() const { return plugin_url_; } | 146 const GURL& plugin_url() const { return plugin_url_; } |
146 bool full_frame() const { return full_frame_; } | 147 bool full_frame() const { return full_frame_; } |
| 148 const ::ppapi::ViewData& view_data() const { return view_data_; } |
147 // If |type| is not PP_CURSORTYPE_CUSTOM, |custom_image| and |hot_spot| are | 149 // If |type| is not PP_CURSORTYPE_CUSTOM, |custom_image| and |hot_spot| are |
148 // ignored. | 150 // ignored. |
149 bool SetCursor(PP_CursorType_Dev type, | 151 bool SetCursor(PP_CursorType_Dev type, |
150 PP_Resource custom_image, | 152 PP_Resource custom_image, |
151 const PP_Point* hot_spot); | 153 const PP_Point* hot_spot); |
152 | 154 |
153 // PPP_Instance and PPP_Instance_Private pass-through. | 155 // PPP_Instance and PPP_Instance_Private pass-through. |
154 bool Initialize(WebKit::WebPluginContainer* container, | 156 bool Initialize(WebKit::WebPluginContainer* container, |
155 const std::vector<std::string>& arg_names, | 157 const std::vector<std::string>& arg_names, |
156 const std::vector<std::string>& arg_values, | 158 const std::vector<std::string>& arg_values, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 void SimulateInputEvent(const ::ppapi::InputEventData& input_event); | 301 void SimulateInputEvent(const ::ppapi::InputEventData& input_event); |
300 | 302 |
301 // FunctionGroupBase overrides. | 303 // FunctionGroupBase overrides. |
302 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* | 304 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* |
303 AsPPB_Instance_FunctionAPI() OVERRIDE; | 305 AsPPB_Instance_FunctionAPI() OVERRIDE; |
304 | 306 |
305 // PPB_Instance_FunctionAPI implementation. | 307 // PPB_Instance_FunctionAPI implementation. |
306 virtual PP_Bool BindGraphics(PP_Instance instance, | 308 virtual PP_Bool BindGraphics(PP_Instance instance, |
307 PP_Resource device) OVERRIDE; | 309 PP_Resource device) OVERRIDE; |
308 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; | 310 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
| 311 virtual PP_Resource GetView(PP_Instance instance) OVERRIDE; |
| 312 virtual const ::ppapi::ViewData* GetViewData(PP_Instance instance) OVERRIDE; |
309 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; | 313 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
310 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; | 314 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
311 virtual PP_Var ExecuteScript(PP_Instance instance, | 315 virtual PP_Var ExecuteScript(PP_Instance instance, |
312 PP_Var script, | 316 PP_Var script, |
313 PP_Var* exception) OVERRIDE; | 317 PP_Var* exception) OVERRIDE; |
314 virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; | 318 virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; |
315 virtual void Log(PP_Instance instance, | 319 virtual void Log(PP_Instance instance, |
316 int log_level, | 320 int log_level, |
317 PP_Var value) OVERRIDE; | 321 PP_Var value) OVERRIDE; |
318 virtual void LogWithSource(PP_Instance instance, | 322 virtual void LogWithSource(PP_Instance instance, |
319 int log_level, | 323 int log_level, |
320 PP_Var source, | 324 PP_Var source, |
321 PP_Var value) OVERRIDE; | 325 PP_Var value) OVERRIDE; |
322 virtual void NumberOfFindResultsChanged(PP_Instance instance, | 326 virtual void NumberOfFindResultsChanged(PP_Instance instance, |
323 int32_t total, | 327 int32_t total, |
324 PP_Bool final_result) OVERRIDE; | 328 PP_Bool final_result) OVERRIDE; |
325 virtual void SelectedFindResultChanged(PP_Instance instance, | 329 virtual void SelectedFindResultChanged(PP_Instance instance, |
326 int32_t index) OVERRIDE; | 330 int32_t index) OVERRIDE; |
327 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; | 331 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; |
328 virtual PP_Bool FlashSetFullscreen(PP_Instance instance, | 332 virtual PP_Bool FlashSetFullscreen(PP_Instance instance, |
329 PP_Bool fullscreen) OVERRIDE; | 333 PP_Bool fullscreen) OVERRIDE; |
330 virtual PP_Bool FlashGetScreenSize(PP_Instance instance, | 334 virtual PP_Bool FlashGetScreenSize(PP_Instance instance, |
331 PP_Size* size) OVERRIDE; | 335 PP_Size* size) OVERRIDE; |
332 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; | |
333 virtual PP_Bool SetFullscreen(PP_Instance instance, | 336 virtual PP_Bool SetFullscreen(PP_Instance instance, |
334 PP_Bool fullscreen) OVERRIDE; | 337 PP_Bool fullscreen) OVERRIDE; |
335 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) | 338 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) |
336 OVERRIDE; | 339 OVERRIDE; |
337 virtual int32_t RequestInputEvents(PP_Instance instance, | 340 virtual int32_t RequestInputEvents(PP_Instance instance, |
338 uint32_t event_classes) OVERRIDE; | 341 uint32_t event_classes) OVERRIDE; |
339 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, | 342 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, |
340 uint32_t event_classes) OVERRIDE; | 343 uint32_t event_classes) OVERRIDE; |
341 virtual void ClearInputEventRequest(PP_Instance instance, | 344 virtual void ClearInputEventRequest(PP_Instance instance, |
342 uint32_t event_classes) OVERRIDE; | 345 uint32_t event_classes) OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 bool LoadPdfInterface(); | 380 bool LoadPdfInterface(); |
378 bool LoadPrintInterface(); | 381 bool LoadPrintInterface(); |
379 bool LoadPrivateInterface(); | 382 bool LoadPrivateInterface(); |
380 bool LoadSelectionInterface(); | 383 bool LoadSelectionInterface(); |
381 bool LoadZoomInterface(); | 384 bool LoadZoomInterface(); |
382 | 385 |
383 // Determines if we think the plugin has focus, both content area and webkit | 386 // Determines if we think the plugin has focus, both content area and webkit |
384 // (see has_webkit_focus_ below). | 387 // (see has_webkit_focus_ below). |
385 bool PluginHasFocus() const; | 388 bool PluginHasFocus() const; |
386 | 389 |
| 390 void ScheduleAsyncDidChangeView(const ::ppapi::ViewData& previous_view); |
| 391 void SendAsyncDidChangeView(const ::ppapi::ViewData& previous_view); |
| 392 void SendDidChangeView(const ::ppapi::ViewData& previous_view); |
| 393 |
387 // Reports the current plugin geometry to the plugin by calling | 394 // Reports the current plugin geometry to the plugin by calling |
388 // DidChangeView. | 395 // DidChangeView. |
389 void ReportGeometry(); | 396 void ReportGeometry(); |
390 | 397 |
391 // Queries the plugin for supported print formats and sets |format| to the | 398 // Queries the plugin for supported print formats and sets |format| to the |
392 // best format to use. Returns false if the plugin does not support any | 399 // best format to use. Returns false if the plugin does not support any |
393 // print format that we can handle (we can handle raster and PDF). | 400 // print format that we can handle (we can handle raster and PDF). |
394 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); | 401 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); |
395 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 402 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
396 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 403 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 int selection_end); | 444 int selection_end); |
438 | 445 |
439 // Checks if the security origin of the document containing this instance can | 446 // Checks if the security origin of the document containing this instance can |
440 // assess the security origin of the main frame document. | 447 // assess the security origin of the main frame document. |
441 bool CanAccessMainFrame() const; | 448 bool CanAccessMainFrame() const; |
442 | 449 |
443 // Returns true if the WebView the plugin is in renders via the accelerated | 450 // Returns true if the WebView the plugin is in renders via the accelerated |
444 // compositing path. | 451 // compositing path. |
445 bool IsViewAccelerated(); | 452 bool IsViewAccelerated(); |
446 | 453 |
447 // Remember view parameters that were sent to the plugin. | |
448 void SetSentDidChangeView(const gfx::Rect& position, const gfx::Rect& clip); | |
449 | |
450 // Track, set and reset size attributes to control the size of the plugin | 454 // Track, set and reset size attributes to control the size of the plugin |
451 // in and out of fullscreen mode. | 455 // in and out of fullscreen mode. |
452 void KeepSizeAttributesBeforeFullscreen(); | 456 void KeepSizeAttributesBeforeFullscreen(); |
453 void SetSizeAttributesForFullscreen(); | 457 void SetSizeAttributesForFullscreen(); |
454 void ResetSizeAttributesAfterFullscreen(); | 458 void ResetSizeAttributesAfterFullscreen(); |
455 | 459 |
456 PluginDelegate* delegate_; | 460 PluginDelegate* delegate_; |
457 scoped_refptr<PluginModule> module_; | 461 scoped_refptr<PluginModule> module_; |
458 scoped_ptr< ::ppapi::PPP_Instance_Combined> instance_interface_; | 462 scoped_ptr< ::ppapi::PPP_Instance_Combined> instance_interface_; |
459 | 463 |
460 PP_Instance pp_instance_; | 464 PP_Instance pp_instance_; |
461 | 465 |
462 // NULL until we have been initialized. | 466 // NULL until we have been initialized. |
463 WebKit::WebPluginContainer* container_; | 467 WebKit::WebPluginContainer* container_; |
464 | 468 |
465 // Plugin URL. | 469 // Plugin URL. |
466 GURL plugin_url_; | 470 GURL plugin_url_; |
467 | 471 |
468 // Indicates whether this is a full frame instance, which means it represents | 472 // Indicates whether this is a full frame instance, which means it represents |
469 // an entire document rather than an embed tag. | 473 // an entire document rather than an embed tag. |
470 bool full_frame_; | 474 bool full_frame_; |
471 | 475 |
| 476 // Stores the current state of the plugin view. |
| 477 ::ppapi::ViewData view_data_; |
| 478 |
472 // Indicates if we've ever sent a didChangeView to the plugin. This ensure we | 479 // Indicates if we've ever sent a didChangeView to the plugin. This ensure we |
473 // always send an initial notification, even if the position and clip are the | 480 // always send an initial notification, even if the position and clip are the |
474 // same as the default values. | 481 // same as the default values. |
475 bool sent_did_change_view_; | 482 bool sent_did_change_view_; |
476 | 483 |
477 // Position in the viewport (which moves as the page is scrolled) of this | 484 // Set to true when we've scheduled an asynchronous DidChangeView update for |
478 // plugin. This will be a 0-sized rectangle if the plugin has not yet been | 485 // the purposes of consolidating updates. When this is set, code should |
479 // laid out. | 486 // update the view_data_ but not send updates. It will be cleared once the |
480 gfx::Rect position_; | 487 // asynchronous update has been sent out. |
481 | 488 bool suppress_did_change_view_; |
482 // Current clip rect. This will be empty if the plugin is not currently | |
483 // visible. This is in the plugin's coordinate system, so fully visible will | |
484 // be (0, 0, w, h) regardless of scroll position. | |
485 gfx::Rect clip_; | |
486 | 489 |
487 // The current device context for painting in 2D or 3D. | 490 // The current device context for painting in 2D or 3D. |
488 scoped_refptr< ::ppapi::Resource> bound_graphics_; | 491 scoped_refptr< ::ppapi::Resource> bound_graphics_; |
489 | 492 |
490 // We track two types of focus, one from WebKit, which is the focus among | 493 // We track two types of focus, one from WebKit, which is the focus among |
491 // all elements of the page, one one from the browser, which is whether the | 494 // all elements of the page, one one from the browser, which is whether the |
492 // tab/window has focus. We tell the plugin it has focus only when both of | 495 // tab/window has focus. We tell the plugin it has focus only when both of |
493 // these values are set to true. | 496 // these values are set to true. |
494 bool has_webkit_focus_; | 497 bool has_webkit_focus_; |
495 bool has_content_area_focus_; | 498 bool has_content_area_focus_; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 607 |
605 PP_CompletionCallback lock_mouse_callback_; | 608 PP_CompletionCallback lock_mouse_callback_; |
606 | 609 |
607 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 610 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
608 }; | 611 }; |
609 | 612 |
610 } // namespace ppapi | 613 } // namespace ppapi |
611 } // namespace webkit | 614 } // namespace webkit |
612 | 615 |
613 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 616 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |