| 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 #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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ppapi/c/pp_resource.h" | 27 #include "ppapi/c/pp_resource.h" |
| 28 #include "ppapi/c/pp_var.h" | 28 #include "ppapi/c/pp_var.h" |
| 29 #include "ppapi/c/ppb_core.h" | 29 #include "ppapi/c/ppb_core.h" |
| 30 #include "ppapi/c/ppb_instance.h" | 30 #include "ppapi/c/ppb_instance.h" |
| 31 #include "ppapi/c/ppp_input_event.h" | 31 #include "ppapi/c/ppp_input_event.h" |
| 32 #include "ppapi/c/ppp_instance.h" | 32 #include "ppapi/c/ppp_instance.h" |
| 33 #include "ppapi/c/ppp_messaging.h" | 33 #include "ppapi/c/ppp_messaging.h" |
| 34 #include "ppapi/c/ppp_mouse_lock.h" | 34 #include "ppapi/c/ppp_mouse_lock.h" |
| 35 #include "ppapi/c/private/ppb_instance_private.h" | 35 #include "ppapi/c/private/ppb_instance_private.h" |
| 36 #include "ppapi/c/private/ppp_instance_private.h" | 36 #include "ppapi/c/private/ppp_instance_private.h" |
| 37 #include "ppapi/shared_impl/input_event_impl.h" | 37 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| 38 #include "ppapi/shared_impl/ppb_url_util_shared.h" |
| 38 #include "ppapi/shared_impl/resource.h" | 39 #include "ppapi/shared_impl/resource.h" |
| 39 #include "ppapi/shared_impl/time_conversion.h" | 40 #include "ppapi/shared_impl/time_conversion.h" |
| 40 #include "ppapi/shared_impl/url_util_impl.h" | |
| 41 #include "ppapi/shared_impl/var.h" | 41 #include "ppapi/shared_impl/var.h" |
| 42 #include "ppapi/thunk/enter.h" | 42 #include "ppapi/thunk/enter.h" |
| 43 #include "ppapi/thunk/ppb_buffer_api.h" | 43 #include "ppapi/thunk/ppb_buffer_api.h" |
| 44 #include "printing/units.h" | 44 #include "printing/units.h" |
| 45 #include "skia/ext/platform_canvas.h" | 45 #include "skia/ext/platform_canvas.h" |
| 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
| 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 #include "ui/gfx/codec/jpeg_codec.h" | 94 #include "ui/gfx/codec/jpeg_codec.h" |
| 95 #include "ui/gfx/gdi_util.h" | 95 #include "ui/gfx/gdi_util.h" |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 #if defined(OS_MACOSX) && defined(USE_SKIA) | 98 #if defined(OS_MACOSX) && defined(USE_SKIA) |
| 99 #include "skia/ext/skia_utils_mac.h" | 99 #include "skia/ext/skia_utils_mac.h" |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 using base::StringPrintf; | 102 using base::StringPrintf; |
| 103 using ppapi::InputEventData; | 103 using ppapi::InputEventData; |
| 104 using ppapi::InputEventImpl; | 104 using ppapi::PPB_InputEvent_Shared; |
| 105 using ppapi::PpapiGlobals; | 105 using ppapi::PpapiGlobals; |
| 106 using ppapi::StringVar; | 106 using ppapi::StringVar; |
| 107 using ppapi::thunk::EnterResourceNoLock; | 107 using ppapi::thunk::EnterResourceNoLock; |
| 108 using ppapi::thunk::PPB_Buffer_API; | 108 using ppapi::thunk::PPB_Buffer_API; |
| 109 using ppapi::thunk::PPB_Graphics2D_API; | 109 using ppapi::thunk::PPB_Graphics2D_API; |
| 110 using ppapi::thunk::PPB_Graphics3D_API; | 110 using ppapi::thunk::PPB_Graphics3D_API; |
| 111 using ppapi::thunk::PPB_ImageData_API; | 111 using ppapi::thunk::PPB_ImageData_API; |
| 112 using ppapi::thunk::PPB_Instance_FunctionAPI; | 112 using ppapi::thunk::PPB_Instance_FunctionAPI; |
| 113 using ppapi::Var; | 113 using ppapi::Var; |
| 114 using WebKit::WebBindings; | 114 using WebKit::WebBindings; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 // Send the event. | 585 // Send the event. |
| 586 bool handled = false; | 586 bool handled = false; |
| 587 if (filtered_input_event_mask_ & event_class) | 587 if (filtered_input_event_mask_ & event_class) |
| 588 event.is_filtered = true; | 588 event.is_filtered = true; |
| 589 else | 589 else |
| 590 handled = true; // Unfiltered events are assumed to be handled. | 590 handled = true; // Unfiltered events are assumed to be handled. |
| 591 scoped_refptr<InputEventImpl> event_resource( | 591 scoped_refptr<PPB_InputEvent_Shared> event_resource( |
| 592 new InputEventImpl(InputEventImpl::InitAsImpl(), | 592 new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), |
| 593 pp_instance(), event)); | 593 pp_instance(), event)); |
| 594 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 594 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
| 595 pp_instance(), event_resource->pp_resource())); | 595 pp_instance(), event_resource->pp_resource())); |
| 596 return handled; | 596 return handled; |
| 597 } | 597 } |
| 598 | 598 |
| 599 bool PluginInstance::HandleCompositionStart(const string16& text) { | 599 bool PluginInstance::HandleCompositionStart(const string16& text) { |
| 600 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, | 600 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, |
| 601 text); | 601 text); |
| 602 } | 602 } |
| 603 | 603 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 // Actually send the event. | 680 // Actually send the event. |
| 681 std::vector< ::ppapi::InputEventData > events; | 681 std::vector< ::ppapi::InputEventData > events; |
| 682 CreateInputEventData(event, &events); | 682 CreateInputEventData(event, &events); |
| 683 | 683 |
| 684 // Each input event may generate more than one PP_InputEvent. | 684 // Each input event may generate more than one PP_InputEvent. |
| 685 for (size_t i = 0; i < events.size(); i++) { | 685 for (size_t i = 0; i < events.size(); i++) { |
| 686 if (filtered_input_event_mask_ & event_class) | 686 if (filtered_input_event_mask_ & event_class) |
| 687 events[i].is_filtered = true; | 687 events[i].is_filtered = true; |
| 688 else | 688 else |
| 689 rv = true; // Unfiltered events are assumed to be handled. | 689 rv = true; // Unfiltered events are assumed to be handled. |
| 690 scoped_refptr<InputEventImpl> event_resource( | 690 scoped_refptr<PPB_InputEvent_Shared> event_resource( |
| 691 new InputEventImpl(InputEventImpl::InitAsImpl(), | 691 new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), |
| 692 pp_instance(), events[i])); | 692 pp_instance(), events[i])); |
| 693 | 693 |
| 694 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 694 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
| 695 pp_instance(), event_resource->pp_resource())); | 695 pp_instance(), event_resource->pp_resource())); |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 } | 698 } |
| 699 | 699 |
| 700 if (cursor_.get()) | 700 if (cursor_.get()) |
| 701 *cursor_info = *cursor_; | 701 *cursor_info = *cursor_; |
| 702 return rv; | 702 return rv; |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 PP_Var PluginInstance::ResolveRelativeToDocument( | 1899 PP_Var PluginInstance::ResolveRelativeToDocument( |
| 1900 PP_Instance instance, | 1900 PP_Instance instance, |
| 1901 PP_Var relative, | 1901 PP_Var relative, |
| 1902 PP_URLComponents_Dev* components) { | 1902 PP_URLComponents_Dev* components) { |
| 1903 StringVar* relative_string = StringVar::FromPPVar(relative); | 1903 StringVar* relative_string = StringVar::FromPPVar(relative); |
| 1904 if (!relative_string) | 1904 if (!relative_string) |
| 1905 return PP_MakeNull(); | 1905 return PP_MakeNull(); |
| 1906 | 1906 |
| 1907 WebElement plugin_element = container()->element(); | 1907 WebElement plugin_element = container()->element(); |
| 1908 GURL document_url = plugin_element.document().baseURL(); | 1908 GURL document_url = plugin_element.document().baseURL(); |
| 1909 return ::ppapi::URLUtilImpl::GenerateURLReturn( | 1909 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( |
| 1910 module()->pp_module(), | 1910 module()->pp_module(), |
| 1911 document_url.Resolve(relative_string->value()), | 1911 document_url.Resolve(relative_string->value()), |
| 1912 components); | 1912 components); |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { | 1915 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { |
| 1916 StringVar* url_string = StringVar::FromPPVar(url); | 1916 StringVar* url_string = StringVar::FromPPVar(url); |
| 1917 if (!url_string) | 1917 if (!url_string) |
| 1918 return PP_FALSE; | 1918 return PP_FALSE; |
| 1919 | 1919 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1937 WebKit::WebSecurityOrigin target_origin; | 1937 WebKit::WebSecurityOrigin target_origin; |
| 1938 if (!SecurityOriginForInstance(instance, &target_origin)) | 1938 if (!SecurityOriginForInstance(instance, &target_origin)) |
| 1939 return PP_FALSE; | 1939 return PP_FALSE; |
| 1940 | 1940 |
| 1941 return BoolToPPBool(our_origin.canAccess(target_origin)); | 1941 return BoolToPPBool(our_origin.canAccess(target_origin)); |
| 1942 } | 1942 } |
| 1943 | 1943 |
| 1944 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, | 1944 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, |
| 1945 PP_URLComponents_Dev* components) { | 1945 PP_URLComponents_Dev* components) { |
| 1946 WebKit::WebDocument document = container()->element().document(); | 1946 WebKit::WebDocument document = container()->element().document(); |
| 1947 return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), | 1947 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( |
| 1948 document.url(), components); | 1948 module()->pp_module(), document.url(), components); |
| 1949 } | 1949 } |
| 1950 | 1950 |
| 1951 PP_Var PluginInstance::GetPluginInstanceURL( | 1951 PP_Var PluginInstance::GetPluginInstanceURL( |
| 1952 PP_Instance instance, | 1952 PP_Instance instance, |
| 1953 PP_URLComponents_Dev* components) { | 1953 PP_URLComponents_Dev* components) { |
| 1954 return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), | 1954 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(module()->pp_module(), |
| 1955 plugin_url_, components); | 1955 plugin_url_, |
| 1956 components); |
| 1956 } | 1957 } |
| 1957 | 1958 |
| 1958 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1959 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
| 1959 cursor_.reset(cursor); | 1960 cursor_.reset(cursor); |
| 1960 if (fullscreen_container_) { | 1961 if (fullscreen_container_) { |
| 1961 fullscreen_container_->DidChangeCursor(*cursor); | 1962 fullscreen_container_->DidChangeCursor(*cursor); |
| 1962 } else { | 1963 } else { |
| 1963 delegate()->DidChangeCursor(this, *cursor); | 1964 delegate()->DidChangeCursor(this, *cursor); |
| 1964 } | 1965 } |
| 1965 } | 1966 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 screen_size_for_fullscreen_ = gfx::Size(); | 2026 screen_size_for_fullscreen_ = gfx::Size(); |
| 2026 WebElement element = container_->element(); | 2027 WebElement element = container_->element(); |
| 2027 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2028 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2028 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2029 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2029 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2030 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2030 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2031 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2031 } | 2032 } |
| 2032 | 2033 |
| 2033 } // namespace ppapi | 2034 } // namespace ppapi |
| 2034 } // namespace webkit | 2035 } // namespace webkit |
| OLD | NEW |