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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void SelectFindResult(bool forward); | 200 void SelectFindResult(bool forward); |
201 void StopFind(); | 201 void StopFind(); |
202 | 202 |
203 bool SupportsPrintInterface(); | 203 bool SupportsPrintInterface(); |
204 int PrintBegin(const gfx::Rect& printable_area, int printer_dpi); | 204 int PrintBegin(const gfx::Rect& printable_area, int printer_dpi); |
205 bool PrintPage(int page_number, WebKit::WebCanvas* canvas); | 205 bool PrintPage(int page_number, WebKit::WebCanvas* canvas); |
206 void PrintEnd(); | 206 void PrintEnd(); |
207 | 207 |
208 void Graphics3DContextLost(); | 208 void Graphics3DContextLost(); |
209 | 209 |
210 // Implementation of PPB_Fullscreen_Dev. | 210 // There are 2 implementations of the fullscreen interface |
| 211 // PPB_FlashFullscreen_Dev is used by Pepper Flash. |
| 212 // PPB_Fullscreen_Dev is intended for other applications including NaCl. |
| 213 // The two interface are mutually exclusive. |
| 214 |
| 215 // Implementation of PPB_FlashFullscreen. |
211 | 216 |
212 // Because going to fullscreen is asynchronous (but going out is not), there | 217 // Because going to fullscreen is asynchronous (but going out is not), there |
213 // are 3 states: | 218 // are 3 states: |
214 // - normal (fullscreen_container_ == NULL) | 219 // - normal : fullscreen_container_ == NULL |
215 // - fullscreen pending (fullscreen_container_ != NULL, fullscreen_ == false) | 220 // flash_fullscreen_ == false |
216 // - fullscreen (fullscreen_container_ != NULL, fullscreen_ = true) | 221 // - fullscreen pending: fullscreen_container_ != NULL |
| 222 // flash_fullscreen_ == false |
| 223 // - fullscreen : fullscreen_container_ != NULL |
| 224 // flash_fullscreen_ == true |
217 // | 225 // |
218 // In normal state, events come from webkit and painting goes back to it. | 226 // In normal state, events come from webkit and painting goes back to it. |
219 // In fullscreen state, events come from the fullscreen container, and | 227 // In fullscreen state, events come from the fullscreen container, and |
220 // painting goes back to it | 228 // painting goes back to it. |
221 // In pending state, events from webkit are ignored, and as soon as we receive | 229 // In pending state, events from webkit are ignored, and as soon as we receive |
222 // events from the fullscreen container, we go to the fullscreen state. | 230 // events from the fullscreen container, we go to the fullscreen state. |
| 231 bool FlashIsFullscreenOrPending(); |
| 232 |
| 233 // Switches between fullscreen and normal mode. If |delay_report| is set to |
| 234 // false, it may report the new state through DidChangeView immediately. If |
| 235 // true, it will delay it. When called from the plugin, delay_report should be |
| 236 // true to avoid re-entrancy. |
| 237 void FlashSetFullscreen(bool fullscreen, bool delay_report); |
| 238 |
| 239 FullscreenContainer* fullscreen_container() const { |
| 240 return fullscreen_container_; |
| 241 } |
| 242 |
| 243 // Implementation of PPB_Fullscreen_Dev. |
| 244 |
| 245 // Because going to/from fullscreen is asynchronous, there are 4 states: |
| 246 // - normal : desired_fullscreen_state_ == false |
| 247 // fullscreen_ == false |
| 248 // - fullscreen pending: desired_fullscreen_state_ == true |
| 249 // fullscreen_ == false |
| 250 // - fullscreen : desired_fullscreen_state_ == true |
| 251 // fullscreen_ == true |
| 252 // - normal pending : desired_fullscreen_state_ = false |
| 253 // fullscreen_ = true |
223 bool IsFullscreenOrPending(); | 254 bool IsFullscreenOrPending(); |
224 | 255 |
225 // Switches between fullscreen and normal mode. If |delay_report| is set to | 256 // Switches between fullscreen and normal mode. If |delay_report| is set to |
226 // false, it may report the new state through DidChangeView immediately. If | 257 // false, it may report the new state through DidChangeView immediately. If |
227 // true, it will delay it. When called from the plugin, delay_report should be | 258 // true, it will delay it. When called from the plugin, delay_report should be |
228 // true to avoid re-entrancy. | 259 // true to avoid re-entrancy. |
229 void SetFullscreen(bool fullscreen, bool delay_report); | 260 void SetFullscreen(bool fullscreen, bool delay_report); |
230 | 261 |
231 // Implementation of PPB_Flash. | 262 // Implementation of PPB_Flash. |
232 int32_t Navigate(PPB_URLRequestInfo_Impl* request, | 263 int32_t Navigate(PPB_URLRequestInfo_Impl* request, |
233 const char* target, | 264 const char* target, |
234 bool from_user_action); | 265 bool from_user_action); |
235 | 266 |
236 // Implementation of PPP_Messaging. | 267 // Implementation of PPP_Messaging. |
237 void HandleMessage(PP_Var message); | 268 void HandleMessage(PP_Var message); |
238 | 269 |
239 PluginDelegate::PlatformContext3D* CreateContext3D(); | 270 PluginDelegate::PlatformContext3D* CreateContext3D(); |
240 | 271 |
241 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or | 272 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or |
242 // embedded in a page). | 273 // embedded in a page). |
243 bool IsFullPagePlugin() const; | 274 bool IsFullPagePlugin() const; |
244 | 275 |
245 FullscreenContainer* fullscreen_container() const { | |
246 return fullscreen_container_; | |
247 } | |
248 | |
249 void OnLockMouseACK(int32_t result); | 276 void OnLockMouseACK(int32_t result); |
250 void OnMouseLockLost(); | 277 void OnMouseLockLost(); |
251 | 278 |
252 // FunctionGroupBase overrides. | 279 // FunctionGroupBase overrides. |
253 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() | 280 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() |
254 OVERRIDE; | 281 OVERRIDE; |
255 | 282 |
256 // PPB_Instance_API implementation. | 283 // PPB_Instance_FunctionAPI implementation. |
257 virtual PP_Bool BindGraphics(PP_Instance instance, | 284 virtual PP_Bool BindGraphics(PP_Instance instance, |
258 PP_Resource device) OVERRIDE; | 285 PP_Resource device) OVERRIDE; |
259 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; | 286 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
260 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; | 287 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
261 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; | 288 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
262 virtual PP_Var ExecuteScript(PP_Instance instance, | 289 virtual PP_Var ExecuteScript(PP_Instance instance, |
263 PP_Var script, | 290 PP_Var script, |
264 PP_Var* exception) OVERRIDE; | 291 PP_Var* exception) OVERRIDE; |
265 virtual void Log(PP_Instance instance, | 292 virtual void Log(PP_Instance instance, |
266 int log_level, | 293 int log_level, |
267 PP_Var value) OVERRIDE; | 294 PP_Var value) OVERRIDE; |
268 virtual void LogWithSource(PP_Instance instance, | 295 virtual void LogWithSource(PP_Instance instance, |
269 int log_level, | 296 int log_level, |
270 PP_Var source, | 297 PP_Var source, |
271 PP_Var value) OVERRIDE; | 298 PP_Var value) OVERRIDE; |
272 virtual void NumberOfFindResultsChanged(PP_Instance instance, | 299 virtual void NumberOfFindResultsChanged(PP_Instance instance, |
273 int32_t total, | 300 int32_t total, |
274 PP_Bool final_result) OVERRIDE; | 301 PP_Bool final_result) OVERRIDE; |
275 virtual void SelectedFindResultChanged(PP_Instance instance, | 302 virtual void SelectedFindResultChanged(PP_Instance instance, |
276 int32_t index) OVERRIDE; | 303 int32_t index) OVERRIDE; |
277 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; | 304 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; |
278 virtual PP_Bool FlashSetFullscreen(PP_Instance instance, | 305 virtual PP_Bool FlashSetFullscreen(PP_Instance instance, |
279 PP_Bool fullscreen) OVERRIDE; | 306 PP_Bool fullscreen) OVERRIDE; |
280 virtual PP_Bool FlashGetScreenSize(PP_Instance instance, | 307 virtual PP_Bool FlashGetScreenSize(PP_Instance instance, |
281 PP_Size* size) OVERRIDE; | 308 PP_Size* size) OVERRIDE; |
| 309 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; |
| 310 virtual PP_Bool SetFullscreen(PP_Instance instance, |
| 311 PP_Bool fullscreen) OVERRIDE; |
| 312 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) |
| 313 OVERRIDE; |
282 virtual int32_t RequestInputEvents(PP_Instance instance, | 314 virtual int32_t RequestInputEvents(PP_Instance instance, |
283 uint32_t event_classes) OVERRIDE; | 315 uint32_t event_classes) OVERRIDE; |
284 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, | 316 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, |
285 uint32_t event_classes) OVERRIDE; | 317 uint32_t event_classes) OVERRIDE; |
286 virtual void ClearInputEventRequest(PP_Instance instance, | 318 virtual void ClearInputEventRequest(PP_Instance instance, |
287 uint32_t event_classes) OVERRIDE; | 319 uint32_t event_classes) OVERRIDE; |
288 virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE; | 320 virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE; |
289 virtual void ZoomLimitsChanged(PP_Instance instance, | 321 virtual void ZoomLimitsChanged(PP_Instance instance, |
290 double minimum_factor, | 322 double minimum_factor, |
291 double maximium_factor) OVERRIDE; | 323 double maximium_factor) OVERRIDE; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // The plugin 3D interface. | 487 // The plugin 3D interface. |
456 const PPP_Graphics3D* plugin_graphics_3d_interface_; | 488 const PPP_Graphics3D* plugin_graphics_3d_interface_; |
457 | 489 |
458 // Contains the cursor if it's set by the plugin. | 490 // Contains the cursor if it's set by the plugin. |
459 scoped_ptr<WebKit::WebCursorInfo> cursor_; | 491 scoped_ptr<WebKit::WebCursorInfo> cursor_; |
460 | 492 |
461 // Set to true if this plugin thinks it will always be on top. This allows us | 493 // Set to true if this plugin thinks it will always be on top. This allows us |
462 // to use a more optimized painting path in some cases. | 494 // to use a more optimized painting path in some cases. |
463 bool always_on_top_; | 495 bool always_on_top_; |
464 | 496 |
| 497 // Implementation of PPB_FlashFullscreen. |
| 498 |
465 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: | 499 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: |
466 // there is a transition state where fullscreen_container_ is non-NULL but | 500 // there is a transition state where fullscreen_container_ is non-NULL but |
467 // fullscreen_ is false (see above). | 501 // flash_fullscreen_ is false (see above). |
468 FullscreenContainer* fullscreen_container_; | 502 FullscreenContainer* fullscreen_container_; |
469 | 503 |
470 // True if we are in fullscreen mode. Note: it is false during the transition. | 504 // True if we are in fullscreen mode. False if we are in normal mode or |
| 505 // in transition to fullscreen. |
| 506 bool flash_fullscreen_; |
| 507 |
| 508 // Implementation of PPB_Fullscreen_Dev. |
| 509 |
| 510 // Since entering fullscreen mode is an asynchronous operation, we set this |
| 511 // variable to the desired state at the time we issue the fullscreen change |
| 512 // request. The plugin will receive a DidChangeView event when it goes |
| 513 // fullscreen. |
| 514 bool desired_fullscreen_state_; |
| 515 |
| 516 // True if we are in fullscreen mode. False if we are in normal mode. |
| 517 // It reflects the previous state when in transition. |
471 bool fullscreen_; | 518 bool fullscreen_; |
472 | 519 |
473 // The MessageChannel used to implement bidirectional postMessage for the | 520 // The MessageChannel used to implement bidirectional postMessage for the |
474 // instance. | 521 // instance. |
475 scoped_ptr<MessageChannel> message_channel_; | 522 scoped_ptr<MessageChannel> message_channel_; |
476 | 523 |
477 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 524 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
478 SkBitmap* sad_plugin_; | 525 SkBitmap* sad_plugin_; |
479 | 526 |
480 typedef std::set<PluginObject*> PluginObjectSet; | 527 typedef std::set<PluginObject*> PluginObjectSet; |
481 PluginObjectSet live_plugin_objects_; | 528 PluginObjectSet live_plugin_objects_; |
482 | 529 |
483 // Classes of events that the plugin has registered for, both for filtering | 530 // Classes of events that the plugin has registered for, both for filtering |
484 // and not. The bits are PP_INPUTEVENT_CLASS_*. | 531 // and not. The bits are PP_INPUTEVENT_CLASS_*. |
485 uint32_t input_event_mask_; | 532 uint32_t input_event_mask_; |
486 uint32_t filtered_input_event_mask_; | 533 uint32_t filtered_input_event_mask_; |
487 | 534 |
488 PP_CompletionCallback lock_mouse_callback_; | 535 PP_CompletionCallback lock_mouse_callback_; |
489 | 536 |
490 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 537 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
491 }; | 538 }; |
492 | 539 |
493 } // namespace ppapi | 540 } // namespace ppapi |
494 } // namespace webkit | 541 } // namespace webkit |
495 | 542 |
496 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 543 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |