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

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

Issue 10545036: Add PPAPI decryptor interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement enough thunk stuff to call into PluginInstance CDM stubs Created 8 years, 5 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
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 "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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // returned vector are only guaranteed valid so long as the vector of strings 287 // returned vector are only guaranteed valid so long as the vector of strings
288 // is not modified. 288 // is not modified.
289 scoped_array<const char*> StringVectorToArgArray( 289 scoped_array<const char*> StringVectorToArgArray(
290 const std::vector<std::string>& vector) { 290 const std::vector<std::string>& vector) {
291 scoped_array<const char*> array(new const char*[vector.size()]); 291 scoped_array<const char*> array(new const char*[vector.size()]);
292 for (size_t i = 0; i < vector.size(); ++i) 292 for (size_t i = 0; i < vector.size(); ++i)
293 array[i] = vector[i].c_str(); 293 array[i] = vector[i].c_str();
294 return array.Pass(); 294 return array.Pass();
295 } 295 }
296 296
297 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the
ddorwin 2012/07/13 19:19:48 What did you base this on? It seems we should be a
Tom Finegan 2012/07/17 01:11:10 It's actually a wild guess based on a lot of time
298 // buffer resource, and returns it. Returns a PP_Resource equal to 0 on
299 // failure.
300 PP_Resource MakeBufferResource(PP_Instance instance,
301 const std::string& data) {
302 if (!data.size())
303 return 0;
304
305 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size()));
306 if (!resource.get())
307 return 0;
308
309 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true);
310 if (enter.failed())
311 return 0;
312
313 BufferAutoMapper mapper(enter.object());
314 if (!mapper.data() || mapper.size() < data.size())
315 return 0;
316 memcpy(mapper.data(), data.data(), data.size());
317
318 // Add the resource to the tracker...
319 // TODO(tomfinegan): wild guess/no idea if this is right.
320 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource.get());
321
322 return resource.Release();
323 }
324
297 } // namespace 325 } // namespace
298 326
299 // static 327 // static
300 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, 328 PluginInstance* PluginInstance::Create(PluginDelegate* delegate,
301 PluginModule* module) { 329 PluginModule* module) {
302 base::Callback<const void*(const char*)> get_plugin_interface_func = 330 base::Callback<const void*(const char*)> get_plugin_interface_func =
303 base::Bind(&PluginModule::GetPluginInterface, module); 331 base::Bind(&PluginModule::GetPluginInterface, module);
304 PPP_Instance_Combined* ppp_instance_combined = 332 PPP_Instance_Combined* ppp_instance_combined =
305 PPP_Instance_Combined::Create(get_plugin_interface_func); 333 PPP_Instance_Combined::Create(get_plugin_interface_func);
306 if (!ppp_instance_combined) 334 if (!ppp_instance_combined)
307 return NULL; 335 return NULL;
308 return new PluginInstance(delegate, module, ppp_instance_combined); 336 return new PluginInstance(delegate, module, ppp_instance_combined);
309 } 337 }
310 338
311 PluginInstance::PluginInstance( 339 PluginInstance::PluginInstance(
312 PluginDelegate* delegate, 340 PluginDelegate* delegate,
313 PluginModule* module, 341 PluginModule* module,
314 ::ppapi::PPP_Instance_Combined* instance_interface) 342 ::ppapi::PPP_Instance_Combined* instance_interface)
315 : delegate_(delegate), 343 : delegate_(delegate),
316 module_(module), 344 module_(module),
317 instance_interface_(instance_interface), 345 instance_interface_(instance_interface),
318 pp_instance_(0), 346 pp_instance_(0),
319 container_(NULL), 347 container_(NULL),
320 full_frame_(false), 348 full_frame_(false),
321 sent_initial_did_change_view_(false), 349 sent_initial_did_change_view_(false),
322 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 350 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
323 has_webkit_focus_(false), 351 has_webkit_focus_(false),
324 has_content_area_focus_(false), 352 has_content_area_focus_(false),
325 find_identifier_(-1), 353 find_identifier_(-1),
354 plugin_decryption_interface_(NULL),
326 plugin_find_interface_(NULL), 355 plugin_find_interface_(NULL),
327 plugin_input_event_interface_(NULL), 356 plugin_input_event_interface_(NULL),
328 plugin_messaging_interface_(NULL), 357 plugin_messaging_interface_(NULL),
329 plugin_mouse_lock_interface_(NULL), 358 plugin_mouse_lock_interface_(NULL),
330 plugin_pdf_interface_(NULL), 359 plugin_pdf_interface_(NULL),
331 plugin_private_interface_(NULL), 360 plugin_private_interface_(NULL),
332 plugin_selection_interface_(NULL), 361 plugin_selection_interface_(NULL),
333 plugin_textinput_interface_(NULL), 362 plugin_textinput_interface_(NULL),
334 plugin_zoom_interface_(NULL), 363 plugin_zoom_interface_(NULL),
335 checked_for_plugin_input_event_interface_(false), 364 checked_for_plugin_input_event_interface_(false),
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 981
953 void PluginInstance::StopFind() { 982 void PluginInstance::StopFind() {
954 // Keep a reference on the stack. See NOTE above. 983 // Keep a reference on the stack. See NOTE above.
955 scoped_refptr<PluginInstance> ref(this); 984 scoped_refptr<PluginInstance> ref(this);
956 if (!LoadFindInterface()) 985 if (!LoadFindInterface())
957 return; 986 return;
958 find_identifier_ = -1; 987 find_identifier_ = -1;
959 plugin_find_interface_->StopFind(pp_instance()); 988 plugin_find_interface_->StopFind(pp_instance());
960 } 989 }
961 990
991 bool PluginInstance::LoadContentDecryptionModuleInterface() {
992 if (!plugin_decryption_interface_) {
993 plugin_decryption_interface_ =
994 static_cast<const PPP_ContentDecryptionModule_Dev*>(
995 module_->GetPluginInterface(
996 PPP_CONTENTDECRYPTIONMODULE_DEV_INTERFACE));
997 }
998 return !!plugin_decryption_interface_;
999 }
1000
962 bool PluginInstance::LoadFindInterface() { 1001 bool PluginInstance::LoadFindInterface() {
963 if (!plugin_find_interface_) { 1002 if (!plugin_find_interface_) {
964 plugin_find_interface_ = 1003 plugin_find_interface_ =
965 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( 1004 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface(
966 PPP_FIND_DEV_INTERFACE)); 1005 PPP_FIND_DEV_INTERFACE));
967 } 1006 }
968 1007
969 return !!plugin_find_interface_; 1008 return !!plugin_find_interface_;
970 } 1009 }
971 1010
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 if (!LoadPdfInterface()) 1302 if (!LoadPdfInterface())
1264 return; 1303 return;
1265 PP_PrivatePageTransformType transform_type = 1304 PP_PrivatePageTransformType transform_type =
1266 type == WebPlugin::RotationType90Clockwise ? 1305 type == WebPlugin::RotationType90Clockwise ?
1267 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : 1306 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW :
1268 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; 1307 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW;
1269 plugin_pdf_interface_->Transform(pp_instance(), transform_type); 1308 plugin_pdf_interface_->Transform(pp_instance(), transform_type);
1270 // NOTE: plugin instance may have been deleted. 1309 // NOTE: plugin instance may have been deleted.
1271 } 1310 }
1272 1311
1312 bool PluginInstance::GenerateKeyRequest(const std::string& key_system,
1313 const std::string& init_data) {
1314 if (!LoadContentDecryptionModuleInterface())
1315 return false;
1316
1317 StringVar key_system_var(key_system);
1318 if (key_system_var.value().size() < key_system.size())
ddorwin 2012/07/13 19:19:48 What is the purpose of this check, and why is it "
Tom Finegan 2012/07/17 01:11:10 Above is gone now-- I wasn't using StringVar corre
1319 return false;
1320
1321 PP_Resource init_resource = 0;
ddorwin 2012/07/13 19:19:48 Would prefer this to have the full name ("init_dat
Tom Finegan 2012/07/17 01:11:10 Done.
1322 if (init_data.size()) {
1323 ScopedPPResource init_data_resource(ScopedPPResource::PassRef(),
1324 MakeBufferResource(pp_instance(),
1325 init_data));
1326
1327 if (!init_data_resource.get())
1328 return false;
1329 init_resource = init_data_resource.Release();
1330 }
1331
1332 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest(
1333 pp_instance(),
1334 key_system_var.GetPPVar(),
1335 init_resource));
1336 }
1337
1338 bool PluginInstance::AddKey(const std::string& session_id,
1339 const std::string& key) {
1340 if (!LoadContentDecryptionModuleInterface())
1341 return false;
1342
1343 StringVar session_id_var(session_id);
1344 if (session_id_var.value().size() < session_id.size())
1345 return false;
1346
1347 ScopedPPResource key_resource(ScopedPPResource::PassRef(),
1348 MakeBufferResource(pp_instance(), key));
1349 if (!key_resource.get())
1350 return false;
1351
1352 return PP_ToBool(plugin_decryption_interface_->AddKey(
1353 pp_instance(),
1354 session_id_var.GetPPVar(),
1355 key_resource));
1356 }
1357
1358 bool PluginInstance::CancelKeyRequest(const std::string& session_id) {
1359 if (!LoadContentDecryptionModuleInterface())
1360 return false;
1361 StringVar session_id_var(session_id);
1362 if (session_id_var.value().size() < session_id.size())
1363 return false;
1364 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest(
1365 pp_instance(),
1366 session_id_var.GetPPVar()));
1367 }
1368
1369 bool PluginInstance::Decrypt(const std::string& encrypted_block,
1370 const CDMStatusCB& callback) {
1371 if (!LoadContentDecryptionModuleInterface())
1372 return false;
1373 ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(),
1374 MakeBufferResource(pp_instance(),
1375 encrypted_block));
1376 if (!encrypted_resource.get())
1377 return false;
1378 // TODO(tomfinegan): wrap callback in PP_CompletionCallback and pass it to
ddorwin 2012/07/13 19:19:48 As discussed offline, we probably aren't doing thi
1379 // the plugin.
1380 PP_CompletionCallback pp_callback = {NULL, NULL, 0};
1381 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(),
1382 encrypted_resource,
1383 pp_callback));
1384 }
1385
1386 bool PluginInstance::DecryptAndDecode(const std::string& encrypted_block,
1387 const CDMStatusCB& callback) {
1388 if (!LoadContentDecryptionModuleInterface())
1389 return false;
1390 ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(),
1391 MakeBufferResource(pp_instance(),
1392 encrypted_block));
1393 if (!encrypted_resource.get())
1394 return false;
1395 // TODO(tomfinegan): wrap callback in PP_CompletionCallback and pass it to
1396 // the plugin.
1397 PP_CompletionCallback pp_callback = {NULL, NULL, 0};
1398 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode(
1399 pp_instance(),
1400 encrypted_resource,
1401 pp_callback));
1402 }
1403
1273 bool PluginInstance::FlashIsFullscreenOrPending() { 1404 bool PluginInstance::FlashIsFullscreenOrPending() {
1274 return fullscreen_container_ != NULL; 1405 return fullscreen_container_ != NULL;
1275 } 1406 }
1276 1407
1277 bool PluginInstance::IsFullscreenOrPending() { 1408 bool PluginInstance::IsFullscreenOrPending() {
1278 return desired_fullscreen_state_; 1409 return desired_fullscreen_state_;
1279 } 1410 }
1280 1411
1281 bool PluginInstance::SetFullscreen(bool fullscreen) { 1412 bool PluginInstance::SetFullscreen(bool fullscreen) {
1282 // Keep a reference on the stack. See NOTE above. 1413 // Keep a reference on the stack. See NOTE above.
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { 1978 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) {
1848 std::string encoding = delegate()->GetDefaultEncoding(); 1979 std::string encoding = delegate()->GetDefaultEncoding();
1849 return StringVar::StringToPPVar(encoding); 1980 return StringVar::StringToPPVar(encoding);
1850 } 1981 }
1851 1982
1852 PP_Var PluginInstance::GetFontFamilies(PP_Instance instance) { 1983 PP_Var PluginInstance::GetFontFamilies(PP_Instance instance) {
1853 // No in-process implementation. 1984 // No in-process implementation.
1854 return PP_MakeUndefined(); 1985 return PP_MakeUndefined();
1855 } 1986 }
1856 1987
1988 void PluginInstance::NeedKey(PP_Instance instance,
1989 PP_Var key_system,
1990 PP_Var session_id,
1991 PP_Resource init_data) {
1992 }
1993
1994 void PluginInstance::KeyAdded(PP_Instance instance,
1995 PP_Var key_system,
1996 PP_Var session_id) {
1997 }
1998
1999 void PluginInstance::KeyMessage(PP_Instance instance,
2000 PP_Var key_system,
2001 PP_Var session_id,
2002 PP_Resource message,
2003 PP_Var default_url) {
2004 }
2005
2006 void PluginInstance::KeyError(PP_Instance instance,
2007 PP_Var key_system,
2008 PP_Var session_id,
2009 uint16_t media_error,
2010 uint16_t system_error) {
2011 }
2012
2013 void PluginInstance::DeliverBlock(PP_Instance instance,
2014 PP_Resource decrypted_block,
2015 PP_CompletionCallback callback) {
2016 }
2017
2018 void PluginInstance::DeliverFrame(PP_Instance instance,
2019 PP_Resource decrypted_frame,
2020 PP_CompletionCallback callback) {
2021 }
2022
2023 void PluginInstance::DeliverSamples(PP_Instance instance,
2024 PP_Resource decrypted_samples,
2025 PP_CompletionCallback callback) {
2026 }
2027
2028
1857 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, 2029 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance,
1858 int32_t total, 2030 int32_t total,
1859 PP_Bool final_result) { 2031 PP_Bool final_result) {
1860 DCHECK_NE(find_identifier_, -1); 2032 DCHECK_NE(find_identifier_, -1);
1861 delegate_->NumberOfFindResultsChanged(find_identifier_, total, 2033 delegate_->NumberOfFindResultsChanged(find_identifier_, total,
1862 PP_ToBool(final_result)); 2034 PP_ToBool(final_result));
1863 } 2035 }
1864 2036
1865 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, 2037 void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
1866 int32_t index) { 2038 int32_t index) {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 screen_size_for_fullscreen_ = gfx::Size(); 2386 screen_size_for_fullscreen_ = gfx::Size();
2215 WebElement element = container_->element(); 2387 WebElement element = container_->element();
2216 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2388 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2217 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2389 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2218 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2390 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2219 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2391 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2220 } 2392 }
2221 2393
2222 } // namespace ppapi 2394 } // namespace ppapi
2223 } // namespace webkit 2395 } // namespace webkit
OLDNEW
« webkit/plugins/ppapi/ppapi_plugin_instance.h ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698