| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_widget.h" | 5 #include "webkit/glue/plugins/pepper_widget.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/ppapi/c/dev/ppb_widget_dev.h" |
| 9 #include "third_party/ppapi/c/dev/ppp_widget_dev.h" |
| 8 #include "third_party/ppapi/c/pp_completion_callback.h" | 10 #include "third_party/ppapi/c/pp_completion_callback.h" |
| 9 #include "third_party/ppapi/c/pp_errors.h" | 11 #include "third_party/ppapi/c/pp_errors.h" |
| 10 #include "third_party/ppapi/c/ppb_widget.h" | |
| 11 #include "third_party/ppapi/c/ppp_widget.h" | |
| 12 #include "webkit/glue/plugins/pepper_image_data.h" | 12 #include "webkit/glue/plugins/pepper_image_data.h" |
| 13 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 13 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 14 #include "webkit/glue/plugins/pepper_plugin_module.h" | 14 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 15 | 15 |
| 16 namespace pepper { | 16 namespace pepper { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 bool IsWidget(PP_Resource resource) { | 20 bool IsWidget(PP_Resource resource) { |
| 21 return !!Resource::GetAs<Widget>(resource); | 21 return !!Resource::GetAs<Widget>(resource); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); | 42 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); |
| 43 return widget && widget->GetLocation(location); | 43 return widget && widget->GetLocation(location); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void SetLocation(PP_Resource resource, const PP_Rect* location) { | 46 void SetLocation(PP_Resource resource, const PP_Rect* location) { |
| 47 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); | 47 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); |
| 48 if (widget) | 48 if (widget) |
| 49 widget->SetLocation(location); | 49 widget->SetLocation(location); |
| 50 } | 50 } |
| 51 | 51 |
| 52 const PPB_Widget ppb_widget = { | 52 const PPB_Widget_Dev ppb_widget = { |
| 53 &IsWidget, | 53 &IsWidget, |
| 54 &Paint, | 54 &Paint, |
| 55 &HandleEvent, | 55 &HandleEvent, |
| 56 &GetLocation, | 56 &GetLocation, |
| 57 &SetLocation, | 57 &SetLocation, |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 Widget::Widget(PluginInstance* instance) | 62 Widget::Widget(PluginInstance* instance) |
| 63 : Resource(instance->module()), | 63 : Resource(instance->module()), |
| 64 instance_(instance) { | 64 instance_(instance) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 Widget::~Widget() { | 67 Widget::~Widget() { |
| 68 } | 68 } |
| 69 | 69 |
| 70 // static | 70 // static |
| 71 const PPB_Widget* Widget::GetInterface() { | 71 const PPB_Widget_Dev* Widget::GetInterface() { |
| 72 return &ppb_widget; | 72 return &ppb_widget; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool Widget::GetLocation(PP_Rect* location) { | 75 bool Widget::GetLocation(PP_Rect* location) { |
| 76 *location = location_; | 76 *location = location_; |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void Widget::SetLocation(const PP_Rect* location) { | 80 void Widget::SetLocation(const PP_Rect* location) { |
| 81 location_ = *location; | 81 location_ = *location; |
| 82 SetLocationInternal(location); | 82 SetLocationInternal(location); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void Widget::Invalidate(const PP_Rect* dirty) { | 85 void Widget::Invalidate(const PP_Rect* dirty) { |
| 86 const PPP_Widget* widget = static_cast<const PPP_Widget*>( | 86 const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>( |
| 87 module()->GetPluginInterface(PPP_WIDGET_INTERFACE)); | 87 module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE)); |
| 88 if (!widget) | 88 if (!widget) |
| 89 return; | 89 return; |
| 90 ScopedResourceId resource(this); | 90 ScopedResourceId resource(this); |
| 91 widget->Invalidate(instance_->GetPPInstance(), resource.id, dirty); | 91 widget->Invalidate(instance_->GetPPInstance(), resource.id, dirty); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace pepper | 94 } // namespace pepper |
| OLD | NEW |