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

Side by Side Diff: mojo/examples/pepper_container_app/plugin_instance.cc

Issue 178953003: Mojo container example for hosting Pepper plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/examples/pepper_container_app/plugin_instance.h"
6
7 #include "base/logging.h"
8 #include "mojo/examples/pepper_container_app/graphics_3d_resource.h"
9 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/c/ppp_graphics_3d.h"
13 #include "ppapi/c/ppp_instance.h"
14 #include "ppapi/shared_impl/ppb_view_shared.h"
15 #include "ppapi/shared_impl/proxy_lock.h"
16 #include "ppapi/shared_impl/tracked_callback.h"
17 #include "ppapi/thunk/enter.h"
18 #include "ppapi/thunk/ppb_graphics_3d_api.h"
19
20 namespace mojo {
21 namespace examples {
22
23 PluginInstance::PluginInstance(scoped_refptr<PluginModule> plugin_module)
24 : pp_instance_(0),
25 plugin_module_(plugin_module) {
26 pp_instance_ = MojoPpapiGlobals::Get()->AddInstance(this);
27 }
28
29 PluginInstance::~PluginInstance() {
30 MojoPpapiGlobals::Get()->InstanceDeleted(pp_instance_);
31 }
32
33 bool PluginInstance::DidCreate() {
34 ppapi::ProxyAutoUnlock unlock;
35 const PPP_Instance_1_1* instance_interface =
36 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
37 PPP_INSTANCE_INTERFACE_1_1));
38 return !!instance_interface->DidCreate(pp_instance(), 0, NULL, NULL);
39 }
40
41 void PluginInstance::DidDestroy() {
42 ppapi::ProxyAutoUnlock unlock;
43 const PPP_Instance_1_1* instance_interface =
44 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
45 PPP_INSTANCE_INTERFACE_1_1));
46 instance_interface->DidDestroy(pp_instance());
47 }
48
49 void PluginInstance::DidChangeView(const PP_Rect& bounds) {
50 ppapi::ViewData view_data;
51 view_data.rect = bounds;
52 view_data.is_fullscreen = false;
53 view_data.is_page_visible = true;
54 view_data.clip_rect = bounds;
55 view_data.device_scale = 1.0f;
56 view_data.css_scale = 1.0f;
57
58 ppapi::ScopedPPResource resource(ppapi::ScopedPPResource::PassRef(),
59 (new ppapi::PPB_View_Shared(
60 ppapi::OBJECT_IS_IMPL, pp_instance(), view_data))->GetReference());
61 {
62 ppapi::ProxyAutoUnlock unlock;
63 const PPP_Instance_1_1* instance_interface =
64 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface(
65 PPP_INSTANCE_INTERFACE_1_1));
66 instance_interface->DidChangeView(pp_instance(), resource);
67 }
68 }
69
70 void PluginInstance::Graphics3DContextLost() {
71 ppapi::ProxyAutoUnlock unlock;
72 const PPP_Graphics3D_1_0* graphic_3d_interface =
73 static_cast<const PPP_Graphics3D_1_0*>(plugin_module_->GetPluginInterface(
74 PPP_GRAPHICS_3D_INTERFACE_1_0));
75 // TODO(yzshen): Maybe we only need to notify for the bound graphics context?
76 graphic_3d_interface->Graphics3DContextLost(pp_instance());
77 }
78
79 bool PluginInstance::IsBoundGraphics(PP_Resource device) const {
80 return device != 0 && device == bound_graphics_.get();
81 }
82
83 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, PP_Resource device) {
84 if (bound_graphics_.get() == device)
85 return PP_TRUE;
86
87 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_Graphics3D_API>
88 enter(device, false);
89 if (enter.failed())
90 return PP_FALSE;
91
92 bound_graphics_ = device;
93 static_cast<Graphics3DResource*>(enter.object())->BindGraphics();
94
95 return PP_TRUE;
96 }
97
98 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) {
99 NOTIMPLEMENTED();
100 return PP_FALSE;
101 }
102
103 const ppapi::ViewData* PluginInstance::GetViewData(PP_Instance instance) {
104 NOTIMPLEMENTED();
105 return NULL;
106 }
107
108 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
109 NOTIMPLEMENTED();
110 return PP_FALSE;
111 }
112
113 PP_Var PluginInstance::GetWindowObject(PP_Instance instance) {
114 NOTIMPLEMENTED();
115 return PP_MakeUndefined();
116 }
117
118 PP_Var PluginInstance::GetOwnerElementObject(PP_Instance instance) {
119 NOTIMPLEMENTED();
120 return PP_MakeUndefined();
121 }
122
123 PP_Var PluginInstance::ExecuteScript(PP_Instance instance,
124 PP_Var script,
125 PP_Var* exception) {
126 NOTIMPLEMENTED();
127 return PP_MakeUndefined();
128 }
129
130 uint32_t PluginInstance::GetAudioHardwareOutputSampleRate(
131 PP_Instance instance) {
132 NOTIMPLEMENTED();
133 return 0;
134 }
135
136 uint32_t PluginInstance::GetAudioHardwareOutputBufferSize(
137 PP_Instance instance) {
138 NOTIMPLEMENTED();
139 return 0;
140 }
141
142 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) {
143 NOTIMPLEMENTED();
144 return PP_MakeUndefined();
145 }
146
147 void PluginInstance::Log(PP_Instance instance,
148 PP_LogLevel log_level,
149 PP_Var value) {
150 NOTIMPLEMENTED();
151 }
152
153 void PluginInstance::LogWithSource(PP_Instance instance,
154 PP_LogLevel log_level,
155 PP_Var source,
156 PP_Var value) {
157 NOTIMPLEMENTED();
158 }
159
160 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance,
161 int32_t total,
162 PP_Bool final_result) {
163 NOTIMPLEMENTED();
164 }
165
166 void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
167 int32_t index) {
168 NOTIMPLEMENTED();
169 }
170
171 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
172 NOTIMPLEMENTED();
173 return PP_FALSE;
174 }
175
176 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
177 PP_Bool fullscreen) {
178 NOTIMPLEMENTED();
179 return PP_FALSE;
180 }
181
182 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
183 NOTIMPLEMENTED();
184 return PP_FALSE;
185 }
186
187 ppapi::Resource* PluginInstance::GetSingletonResource(
188 PP_Instance instance,
189 ppapi::SingletonResourceID id) {
190 NOTIMPLEMENTED();
191 return NULL;
192 }
193
194 int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
195 uint32_t event_classes) {
196 NOTIMPLEMENTED();
197 return PP_ERROR_FAILED;
198 }
199
200 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
201 uint32_t event_classes) {
202 NOTIMPLEMENTED();
203 return PP_ERROR_FAILED;
204 }
205
206 void PluginInstance::ClearInputEventRequest(PP_Instance instance,
207 uint32_t event_classes) {
208 NOTIMPLEMENTED();
209 }
210
211 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
212 NOTIMPLEMENTED();
213 }
214
215 PP_Bool PluginInstance::SetCursor(PP_Instance instance,
216 PP_MouseCursor_Type type,
217 PP_Resource image,
218 const PP_Point* hot_spot) {
219 NOTIMPLEMENTED();
220 return PP_FALSE;
221 }
222
223 int32_t PluginInstance::LockMouse(
224 PP_Instance instance,
225 scoped_refptr<ppapi::TrackedCallback> callback) {
226 NOTIMPLEMENTED();
227 return PP_ERROR_FAILED;
228 }
229
230 void PluginInstance::UnlockMouse(PP_Instance instance) {
231 NOTIMPLEMENTED();
232 }
233
234 void PluginInstance::SetTextInputType(PP_Instance instance,
235 PP_TextInput_Type type) {
236 NOTIMPLEMENTED();
237 }
238
239 void PluginInstance::UpdateCaretPosition(PP_Instance instance,
240 const PP_Rect& caret,
241 const PP_Rect& bounding_box) {
242 NOTIMPLEMENTED();
243 }
244
245 void PluginInstance::CancelCompositionText(PP_Instance instance) {
246 NOTIMPLEMENTED();
247 }
248
249 void PluginInstance::SelectionChanged(PP_Instance instance) {
250 NOTIMPLEMENTED();
251 }
252
253 void PluginInstance::UpdateSurroundingText(PP_Instance instance,
254 const char* text,
255 uint32_t caret,
256 uint32_t anchor) {
257 NOTIMPLEMENTED();
258 }
259
260 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) {
261 NOTIMPLEMENTED();
262 }
263
264 void PluginInstance::ZoomLimitsChanged(PP_Instance instance,
265 double minimum_factor,
266 double maximum_factor) {
267 NOTIMPLEMENTED();
268 }
269
270 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance,
271 PP_URLComponents_Dev* components) {
272 NOTIMPLEMENTED();
273 return PP_MakeUndefined();
274 }
275
276 void PluginInstance::SessionCreated(PP_Instance instance,
277 uint32 session_id,
278 PP_Var web_session_id) {
279 NOTIMPLEMENTED();
280 }
281
282 void PluginInstance::SessionMessage(PP_Instance instance,
283 uint32 session_id,
284 PP_Var message,
285 PP_Var destination_url) {
286 NOTIMPLEMENTED();
287 }
288
289 void PluginInstance::SessionReady(PP_Instance instance, uint32 session_id) {
290 NOTIMPLEMENTED();
291 }
292
293 void PluginInstance::SessionClosed(PP_Instance instance, uint32 session_id) {
294 NOTIMPLEMENTED();
295 }
296
297 void PluginInstance::SessionError(PP_Instance instance,
298 uint32 session_id,
299 int32_t media_error,
300 int32_t system_error) {
301 NOTIMPLEMENTED();
302 }
303
304 void PluginInstance::DeliverBlock(PP_Instance instance,
305 PP_Resource decrypted_block,
306 const PP_DecryptedBlockInfo* block_info) {
307 NOTIMPLEMENTED();
308 }
309
310 void PluginInstance::DecoderInitializeDone(PP_Instance instance,
311 PP_DecryptorStreamType decoder_type,
312 uint32_t request_id,
313 PP_Bool success) {
314 NOTIMPLEMENTED();
315 }
316
317 void PluginInstance::DecoderDeinitializeDone(
318 PP_Instance instance,
319 PP_DecryptorStreamType decoder_type,
320 uint32_t request_id) {
321 NOTIMPLEMENTED();
322 }
323
324 void PluginInstance::DecoderResetDone(PP_Instance instance,
325 PP_DecryptorStreamType decoder_type,
326 uint32_t request_id) {
327 NOTIMPLEMENTED();
328 }
329
330 void PluginInstance::DeliverFrame(PP_Instance instance,
331 PP_Resource decrypted_frame,
332 const PP_DecryptedFrameInfo* frame_info) {
333 NOTIMPLEMENTED();
334 }
335
336 void PluginInstance::DeliverSamples(PP_Instance instance,
337 PP_Resource audio_frames,
338 const PP_DecryptedSampleInfo* sample_info) {
339 NOTIMPLEMENTED();
340 }
341
342 PP_Var PluginInstance::ResolveRelativeToDocument(
343 PP_Instance instance,
344 PP_Var relative,
345 PP_URLComponents_Dev* components) {
346 NOTIMPLEMENTED();
347 return PP_MakeUndefined();
348 }
349
350 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) {
351 NOTIMPLEMENTED();
352 return PP_FALSE;
353 }
354
355 PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance,
356 PP_Instance target) {
357 NOTIMPLEMENTED();
358 return PP_FALSE;
359 }
360
361 PP_Var PluginInstance::GetPluginInstanceURL(PP_Instance instance,
362 PP_URLComponents_Dev* components) {
363 NOTIMPLEMENTED();
364 return PP_MakeUndefined();
365 }
366
367 PP_Var PluginInstance::GetPluginReferrerURL(PP_Instance instance,
368 PP_URLComponents_Dev* components) {
369 NOTIMPLEMENTED();
370 return PP_MakeUndefined();
371 }
372
373 } // namespace examples
374 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698