OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ppapi/c/private/ppp_instance_private.h" | 32 #include "ppapi/c/private/ppp_instance_private.h" |
33 #include "ppapi/shared_impl/ppapi_preferences.h" | 33 #include "ppapi/shared_impl/ppapi_preferences.h" |
34 #include "ppapi/shared_impl/ppb_gamepad_shared.h" | 34 #include "ppapi/shared_impl/ppb_gamepad_shared.h" |
35 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 35 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
36 #include "ppapi/shared_impl/ppb_url_util_shared.h" | 36 #include "ppapi/shared_impl/ppb_url_util_shared.h" |
37 #include "ppapi/shared_impl/ppb_view_shared.h" | 37 #include "ppapi/shared_impl/ppb_view_shared.h" |
38 #include "ppapi/shared_impl/ppp_instance_combined.h" | 38 #include "ppapi/shared_impl/ppp_instance_combined.h" |
39 #include "ppapi/shared_impl/resource.h" | 39 #include "ppapi/shared_impl/resource.h" |
40 #include "ppapi/shared_impl/scoped_pp_resource.h" | 40 #include "ppapi/shared_impl/scoped_pp_resource.h" |
41 #include "ppapi/shared_impl/time_conversion.h" | 41 #include "ppapi/shared_impl/time_conversion.h" |
| 42 #include "ppapi/shared_impl/url_request_info_data.h" |
42 #include "ppapi/shared_impl/var.h" | 43 #include "ppapi/shared_impl/var.h" |
43 #include "ppapi/thunk/enter.h" | 44 #include "ppapi/thunk/enter.h" |
44 #include "ppapi/thunk/ppb_buffer_api.h" | 45 #include "ppapi/thunk/ppb_buffer_api.h" |
45 #include "printing/units.h" | 46 #include "printing/units.h" |
46 #include "third_party/skia/include/core/SkCanvas.h" | 47 #include "third_party/skia/include/core/SkCanvas.h" |
47 #include "third_party/skia/include/core/SkRect.h" | 48 #include "third_party/skia/include/core/SkRect.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
(...skipping 20 matching lines...) Expand all Loading... |
72 #include "webkit/plugins/ppapi/fullscreen_container.h" | 73 #include "webkit/plugins/ppapi/fullscreen_container.h" |
73 #include "webkit/plugins/ppapi/gfx_conversion.h" | 74 #include "webkit/plugins/ppapi/gfx_conversion.h" |
74 #include "webkit/plugins/ppapi/host_globals.h" | 75 #include "webkit/plugins/ppapi/host_globals.h" |
75 #include "webkit/plugins/ppapi/message_channel.h" | 76 #include "webkit/plugins/ppapi/message_channel.h" |
76 #include "webkit/plugins/ppapi/npapi_glue.h" | 77 #include "webkit/plugins/ppapi/npapi_glue.h" |
77 #include "webkit/plugins/ppapi/plugin_module.h" | 78 #include "webkit/plugins/ppapi/plugin_module.h" |
78 #include "webkit/plugins/ppapi/plugin_object.h" | 79 #include "webkit/plugins/ppapi/plugin_object.h" |
79 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 80 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
80 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 81 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
81 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 82 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
82 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" | |
83 #include "webkit/plugins/ppapi/ppp_pdf.h" | 83 #include "webkit/plugins/ppapi/ppp_pdf.h" |
84 #include "webkit/plugins/ppapi/url_request_info_util.h" | 84 #include "webkit/plugins/ppapi/url_request_info_util.h" |
85 #include "webkit/plugins/sad_plugin.h" | 85 #include "webkit/plugins/sad_plugin.h" |
86 | 86 |
87 #if defined(OS_MACOSX) | 87 #if defined(OS_MACOSX) |
88 #include "printing/metafile_impl.h" | 88 #include "printing/metafile_impl.h" |
89 #if !defined(USE_SKIA) | 89 #if !defined(USE_SKIA) |
90 #include "base/mac/mac_util.h" | 90 #include "base/mac/mac_util.h" |
91 #include "base/mac/scoped_cftyperef.h" | 91 #include "base/mac/scoped_cftyperef.h" |
92 #endif // !defined(USE_SKIA) | 92 #endif // !defined(USE_SKIA) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 sad_plugin_(NULL), | 373 sad_plugin_(NULL), |
374 input_event_mask_(0), | 374 input_event_mask_(0), |
375 filtered_input_event_mask_(0), | 375 filtered_input_event_mask_(0), |
376 text_input_type_(kPluginDefaultTextInputType), | 376 text_input_type_(kPluginDefaultTextInputType), |
377 text_input_caret_(0, 0, 0, 0), | 377 text_input_caret_(0, 0, 0, 0), |
378 text_input_caret_bounds_(0, 0, 0, 0), | 378 text_input_caret_bounds_(0, 0, 0, 0), |
379 text_input_caret_set_(false), | 379 text_input_caret_set_(false), |
380 selection_caret_(0), | 380 selection_caret_(0), |
381 selection_anchor_(0), | 381 selection_anchor_(0), |
382 pending_user_gesture_(0.0), | 382 pending_user_gesture_(0.0), |
383 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 383 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 384 document_loader_(NULL) { |
384 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 385 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
385 | 386 |
386 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 387 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
387 DCHECK(delegate); | 388 DCHECK(delegate); |
388 module_->InstanceCreated(this); | 389 module_->InstanceCreated(this); |
389 delegate_->InstanceCreated(this); | 390 delegate_->InstanceCreated(this); |
390 message_channel_.reset(new MessageChannel(this)); | 391 message_channel_.reset(new MessageChannel(this)); |
391 | 392 |
392 view_data_.is_page_visible = delegate->IsPageVisible(); | 393 view_data_.is_page_visible = delegate->IsPageVisible(); |
393 | 394 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 argn_ = arg_names; | 578 argn_ = arg_names; |
578 argv_ = arg_values; | 579 argv_ = arg_values; |
579 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); | 580 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); |
580 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_)); | 581 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_)); |
581 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), | 582 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), |
582 argn_.size(), | 583 argn_.size(), |
583 argn_array.get(), | 584 argn_array.get(), |
584 argv_array.get())); | 585 argv_array.get())); |
585 } | 586 } |
586 | 587 |
587 bool PluginInstance::HandleDocumentLoad(PPB_URLLoader_Impl* loader) { | 588 bool PluginInstance::HandleDocumentLoad( |
588 if (!document_loader_) | 589 const WebKit::WebURLResponse& response) { |
589 document_loader_ = loader; | 590 DCHECK(!document_loader_); |
590 DCHECK(loader == document_loader_.get()); | 591 if (module()->is_crashed()) { |
591 | 592 // Don't create a resource for a crashed plugin. |
592 return PP_ToBool(instance_interface_->HandleDocumentLoad( | 593 container()->element().document().frame()->stopLoading(); |
593 pp_instance(), loader->pp_resource())); | 594 return false; |
| 595 } |
| 596 delegate()->HandleDocumentLoad(this, response); |
| 597 // If the load was not abandoned, document_loader_ will now be set. It's |
| 598 // possible that the load was canceled by now and document_loader_ was |
| 599 // already nulled out. |
| 600 return true; |
594 } | 601 } |
595 | 602 |
596 bool PluginInstance::SendCompositionEventToPlugin(PP_InputEvent_Type type, | 603 bool PluginInstance::SendCompositionEventToPlugin(PP_InputEvent_Type type, |
597 const string16& text) { | 604 const string16& text) { |
598 std::vector<WebKit::WebCompositionUnderline> empty; | 605 std::vector<WebKit::WebCompositionUnderline> empty; |
599 return SendCompositionEventWithUnderlineInformationToPlugin( | 606 return SendCompositionEventWithUnderlineInformationToPlugin( |
600 type, text, empty, static_cast<int>(text.size()), | 607 type, text, empty, static_cast<int>(text.size()), |
601 static_cast<int>(text.size())); | 608 static_cast<int>(text.size())); |
602 } | 609 } |
603 | 610 |
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 argn_array.get(), argv_array.get())) | 2410 argn_array.get(), argv_array.get())) |
2404 return false; | 2411 return false; |
2405 | 2412 |
2406 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView | 2413 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView |
2407 // event. This way, SendDidChangeView will send the "current" view | 2414 // event. This way, SendDidChangeView will send the "current" view |
2408 // immediately (before other events like HandleDocumentLoad). | 2415 // immediately (before other events like HandleDocumentLoad). |
2409 sent_initial_did_change_view_ = false; | 2416 sent_initial_did_change_view_ = false; |
2410 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); | 2417 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); |
2411 SendDidChangeView(); | 2418 SendDidChangeView(); |
2412 | 2419 |
2413 // If we received HandleDocumentLoad, re-send it now via the proxy. | 2420 // TODO(brettw) handle re-sending HandleDocumentLoad to the proxied plugin. |
2414 if (document_loader_) | |
2415 HandleDocumentLoad(document_loader_.get()); | |
2416 return true; | 2421 return true; |
2417 } | 2422 } |
2418 | 2423 |
2419 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 2424 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
2420 cursor_.reset(cursor); | 2425 cursor_.reset(cursor); |
2421 if (fullscreen_container_) { | 2426 if (fullscreen_container_) { |
2422 fullscreen_container_->DidChangeCursor(*cursor); | 2427 fullscreen_container_->DidChangeCursor(*cursor); |
2423 } else { | 2428 } else { |
2424 delegate()->DidChangeCursor(this, *cursor); | 2429 delegate()->DidChangeCursor(this, *cursor); |
2425 } | 2430 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 screen_size_for_fullscreen_ = gfx::Size(); | 2484 screen_size_for_fullscreen_ = gfx::Size(); |
2480 WebElement element = container_->element(); | 2485 WebElement element = container_->element(); |
2481 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2486 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2482 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2487 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2483 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2488 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2484 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2489 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2485 } | 2490 } |
2486 | 2491 |
2487 } // namespace ppapi | 2492 } // namespace ppapi |
2488 } // namespace webkit | 2493 } // namespace webkit |
OLD | NEW |