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

Side by Side Diff: content/renderer/pepper/renderer_ppapi_host_impl.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix DEPS Created 8 years, 2 months 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
OLDNEW
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 "content/renderer/pepper/renderer_ppapi_host_impl.h" 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/renderer/pepper/pepper_graphics_2d_host.h"
8 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" 9 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
9 #include "content/renderer/pepper/pepper_in_process_router.h" 10 #include "content/renderer/pepper/pepper_in_process_router.h"
10 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" 11 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
11 #include "content/renderer/render_view_impl.h" 12 #include "content/renderer/render_view_impl.h"
13 #include "ppapi/host/ppapi_host.h"
12 #include "ppapi/proxy/host_dispatcher.h" 14 #include "ppapi/proxy/host_dispatcher.h"
13 #include "webkit/plugins/ppapi/host_globals.h" 15 #include "webkit/plugins/ppapi/host_globals.h"
16 #include "webkit/plugins/ppapi/plugin_delegate.h"
14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
15 18
16 using webkit::ppapi::HostGlobals; 19 using webkit::ppapi::HostGlobals;
17 using webkit::ppapi::PluginInstance; 20 using webkit::ppapi::PluginInstance;
18 21
19 namespace content { 22 namespace content {
20 23
21 // Out-of-process constructor. 24 // Out-of-process constructor.
22 RendererPpapiHostImpl::RendererPpapiHostImpl( 25 RendererPpapiHostImpl::RendererPpapiHostImpl(
23 webkit::ppapi::PluginModule* module, 26 webkit::ppapi::PluginModule* module,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 instance->module()->GetEmbedderState()); 95 instance->module()->GetEmbedderState());
93 } 96 }
94 97
95 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> 98 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>
96 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( 99 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI(
97 webkit::ppapi::PluginInstance* instance) { 100 webkit::ppapi::PluginInstance* instance) {
98 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( 101 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>(
99 new PepperInProcessResourceCreation(this, instance)); 102 new PepperInProcessResourceCreation(this, instance));
100 } 103 }
101 104
102 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { 105 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() const {
103 return ppapi_host_.get(); 106 return ppapi_host_.get();
104 } 107 }
105 108
106 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( 109 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance(
107 PP_Instance instance) const { 110 PP_Instance instance) const {
108 PluginInstance* instance_object = GetAndValidateInstance(instance); 111 PluginInstance* instance_object = GetAndValidateInstance(instance);
109 if (!instance_object) 112 if (!instance_object)
110 return NULL; 113 return NULL;
111 114
112 // Since we're the embedder, we can make assumptions about the delegate on 115 // Since we're the embedder, we can make assumptions about the delegate on
113 // the instance and get back to our RenderView. 116 // the instance and get back to our RenderView.
114 return static_cast<PepperPluginDelegateImpl*>( 117 return static_cast<PepperPluginDelegateImpl*>(
115 instance_object->delegate())->render_view(); 118 instance_object->delegate())->render_view();
116 } 119 }
117 120
121 webkit::ppapi::PluginDelegate::PlatformGraphics2D*
122 RendererPpapiHostImpl::GetPlatformGraphics2D(
123 PP_Resource resource) const {
124 ppapi::host::ResourceHost* resource_host =
125 GetPpapiHost()->GetResourceHost(resource);
126 if (resource_host && !resource_host->IsGraphics2DHost()) {
127 LOG(ERROR) << "Resource is not Graphics2D";
128 return NULL;
129 }
130 return static_cast<PepperGraphics2DHost*>(resource_host);
131 }
132
118 bool RendererPpapiHostImpl::IsValidInstance( 133 bool RendererPpapiHostImpl::IsValidInstance(
119 PP_Instance instance) const { 134 PP_Instance instance) const {
120 return !!GetAndValidateInstance(instance); 135 return !!GetAndValidateInstance(instance);
121 } 136 }
122 137
123 bool RendererPpapiHostImpl::HasUserGesture(PP_Instance instance) const { 138 bool RendererPpapiHostImpl::HasUserGesture(PP_Instance instance) const {
124 PluginInstance* instance_object = GetAndValidateInstance(instance); 139 PluginInstance* instance_object = GetAndValidateInstance(instance);
125 if (!instance_object) 140 if (!instance_object)
126 return false; 141 return false;
127 142
128 if (instance_object->module()->permissions().HasPermission( 143 if (instance_object->module()->permissions().HasPermission(
129 ppapi::PERMISSION_BYPASS_USER_GESTURE)) 144 ppapi::PERMISSION_BYPASS_USER_GESTURE))
130 return true; 145 return true;
131 return instance_object->IsProcessingUserGesture(); 146 return instance_object->IsProcessingUserGesture();
132 } 147 }
133 148
134 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance( 149 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance(
135 PP_Instance pp_instance) const { 150 PP_Instance pp_instance) const {
136 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); 151 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
137 if (!instance) 152 if (!instance)
138 return NULL; 153 return NULL;
139 if (instance->module() != module_) 154 if (instance->module() != module_)
140 return NULL; 155 return NULL;
141 return instance; 156 return instance;
142 } 157 }
143 158
144 } // namespace content 159 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698