Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: webkit/plugins/ppapi/ppb_widget_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/plugins/ppapi/ppb_widget_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/c/dev/ppb_widget_dev.h" 8 #include "ppapi/c/dev/ppb_widget_dev.h"
9 #include "ppapi/c/dev/ppp_widget_dev.h" 9 #include "ppapi/c/dev/ppp_widget_dev.h"
10 #include "ppapi/c/pp_completion_callback.h" 10 #include "ppapi/c/pp_completion_callback.h"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "webkit/glue/plugins/pepper_common.h" 12 #include "webkit/plugins/ppapi/common.h"
13 #include "webkit/glue/plugins/pepper_image_data.h" 13 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
14 #include "webkit/glue/plugins/pepper_plugin_instance.h" 14 #include "webkit/plugins/ppapi/plugin_instance.h"
15 #include "webkit/glue/plugins/pepper_plugin_module.h" 15 #include "webkit/plugins/ppapi/plugin_module.h"
16 16
17 namespace pepper { 17 namespace webkit {
18 namespace plugins {
19 namespace ppapi {
18 20
19 namespace { 21 namespace {
20 22
21 PP_Bool IsWidget(PP_Resource resource) { 23 PP_Bool IsWidget(PP_Resource resource) {
22 return BoolToPPBool(!!Resource::GetAs<Widget>(resource)); 24 return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource));
23 } 25 }
24 26
25 PP_Bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) { 27 PP_Bool Paint(PP_Resource resource,
26 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); 28 const PP_Rect* rect,
29 PP_Resource image_id) {
30 scoped_refptr<PPB_Widget_Impl> widget(
31 Resource::GetAs<PPB_Widget_Impl>(resource));
27 if (!widget) 32 if (!widget)
28 return PP_FALSE; 33 return PP_FALSE;
29 34
30 scoped_refptr<ImageData> image(Resource::GetAs<ImageData>(image_id)); 35 scoped_refptr<PPB_ImageData_Impl> image(
36 Resource::GetAs<PPB_ImageData_Impl>(image_id));
31 if (!image) 37 if (!image)
32 return PP_FALSE; 38 return PP_FALSE;
33 39
34 return BoolToPPBool(widget->Paint(rect, image)); 40 return BoolToPPBool(widget->Paint(rect, image));
35 } 41 }
36 42
37 PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { 43 PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) {
38 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); 44 scoped_refptr<PPB_Widget_Impl> widget(
45 Resource::GetAs<PPB_Widget_Impl>(resource));
39 return BoolToPPBool(widget && widget->HandleEvent(event)); 46 return BoolToPPBool(widget && widget->HandleEvent(event));
40 } 47 }
41 48
42 PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) { 49 PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) {
43 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); 50 scoped_refptr<PPB_Widget_Impl> widget(
51 Resource::GetAs<PPB_Widget_Impl>(resource));
44 return BoolToPPBool(widget && widget->GetLocation(location)); 52 return BoolToPPBool(widget && widget->GetLocation(location));
45 } 53 }
46 54
47 void SetLocation(PP_Resource resource, const PP_Rect* location) { 55 void SetLocation(PP_Resource resource, const PP_Rect* location) {
48 scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); 56 scoped_refptr<PPB_Widget_Impl> widget(
57 Resource::GetAs<PPB_Widget_Impl>(resource));
49 if (widget) 58 if (widget)
50 widget->SetLocation(location); 59 widget->SetLocation(location);
51 } 60 }
52 61
53 const PPB_Widget_Dev ppb_widget = { 62 const PPB_Widget_Dev ppb_widget = {
54 &IsWidget, 63 &IsWidget,
55 &Paint, 64 &Paint,
56 &HandleEvent, 65 &HandleEvent,
57 &GetLocation, 66 &GetLocation,
58 &SetLocation, 67 &SetLocation,
59 }; 68 };
60 69
61 } // namespace 70 } // namespace
62 71
63 Widget::Widget(PluginInstance* instance) 72 PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
64 : Resource(instance->module()), 73 : Resource(instance->module()),
65 instance_(instance) { 74 instance_(instance) {
66 } 75 }
67 76
68 Widget::~Widget() { 77 PPB_Widget_Impl::~PPB_Widget_Impl() {
69 } 78 }
70 79
71 // static 80 // static
72 const PPB_Widget_Dev* Widget::GetInterface() { 81 const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() {
73 return &ppb_widget; 82 return &ppb_widget;
74 } 83 }
75 84
76 Widget* Widget::AsWidget() { 85 PPB_Widget_Impl* PPB_Widget_Impl::AsWidget() {
77 return this; 86 return this;
78 } 87 }
79 88
80 bool Widget::GetLocation(PP_Rect* location) { 89 bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
81 *location = location_; 90 *location = location_;
82 return true; 91 return true;
83 } 92 }
84 93
85 void Widget::SetLocation(const PP_Rect* location) { 94 void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
86 location_ = *location; 95 location_ = *location;
87 SetLocationInternal(location); 96 SetLocationInternal(location);
88 } 97 }
89 98
90 void Widget::Invalidate(const PP_Rect* dirty) { 99 void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) {
91 const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>( 100 const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>(
92 module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE)); 101 module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE));
93 if (!widget) 102 if (!widget)
94 return; 103 return;
95 ScopedResourceId resource(this); 104 ScopedResourceId resource(this);
96 widget->Invalidate(instance_->pp_instance(), resource.id, dirty); 105 widget->Invalidate(instance_->pp_instance(), resource.id, dirty);
97 } 106 }
98 107
99 } // namespace pepper 108 } // namespace ppapi
109 } // namespace plugins
110 } // namespace webkit
111
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698