Chromium Code Reviews| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| index 215fa73b795ee0ca6120b6f2f0143e7ce610113b..0eb48a15e5e391efd44c11ff3b2466e2ceb95265 100644 |
| --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| @@ -294,6 +294,34 @@ scoped_array<const char*> StringVectorToArgArray( |
| return array.Pass(); |
| } |
| +// 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
|
| +// buffer resource, and returns it. Returns a PP_Resource equal to 0 on |
| +// failure. |
| +PP_Resource MakeBufferResource(PP_Instance instance, |
| + const std::string& data) { |
| + if (!data.size()) |
| + return 0; |
| + |
| + ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size())); |
| + if (!resource.get()) |
| + return 0; |
| + |
| + EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
| + if (enter.failed()) |
| + return 0; |
| + |
| + BufferAutoMapper mapper(enter.object()); |
| + if (!mapper.data() || mapper.size() < data.size()) |
| + return 0; |
| + memcpy(mapper.data(), data.data(), data.size()); |
| + |
| + // Add the resource to the tracker... |
| + // TODO(tomfinegan): wild guess/no idea if this is right. |
| + PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource.get()); |
| + |
| + return resource.Release(); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -323,6 +351,7 @@ PluginInstance::PluginInstance( |
| has_webkit_focus_(false), |
| has_content_area_focus_(false), |
| find_identifier_(-1), |
| + plugin_decryption_interface_(NULL), |
| plugin_find_interface_(NULL), |
| plugin_input_event_interface_(NULL), |
| plugin_messaging_interface_(NULL), |
| @@ -959,6 +988,16 @@ void PluginInstance::StopFind() { |
| plugin_find_interface_->StopFind(pp_instance()); |
| } |
| +bool PluginInstance::LoadContentDecryptionModuleInterface() { |
| + if (!plugin_decryption_interface_) { |
| + plugin_decryption_interface_ = |
| + static_cast<const PPP_ContentDecryptionModule_Dev*>( |
| + module_->GetPluginInterface( |
| + PPP_CONTENTDECRYPTIONMODULE_DEV_INTERFACE)); |
| + } |
| + return !!plugin_decryption_interface_; |
| +} |
| + |
| bool PluginInstance::LoadFindInterface() { |
| if (!plugin_find_interface_) { |
| plugin_find_interface_ = |
| @@ -1270,6 +1309,98 @@ void PluginInstance::RotateView(WebPlugin::RotationType type) { |
| // NOTE: plugin instance may have been deleted. |
| } |
| +bool PluginInstance::GenerateKeyRequest(const std::string& key_system, |
| + const std::string& init_data) { |
| + if (!LoadContentDecryptionModuleInterface()) |
| + return false; |
| + |
| + StringVar key_system_var(key_system); |
| + 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
|
| + return false; |
| + |
| + 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.
|
| + if (init_data.size()) { |
| + ScopedPPResource init_data_resource(ScopedPPResource::PassRef(), |
| + MakeBufferResource(pp_instance(), |
| + init_data)); |
| + |
| + if (!init_data_resource.get()) |
| + return false; |
| + init_resource = init_data_resource.Release(); |
| + } |
| + |
| + return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( |
| + pp_instance(), |
| + key_system_var.GetPPVar(), |
| + init_resource)); |
| +} |
| + |
| +bool PluginInstance::AddKey(const std::string& session_id, |
| + const std::string& key) { |
| + if (!LoadContentDecryptionModuleInterface()) |
| + return false; |
| + |
| + StringVar session_id_var(session_id); |
| + if (session_id_var.value().size() < session_id.size()) |
| + return false; |
| + |
| + ScopedPPResource key_resource(ScopedPPResource::PassRef(), |
| + MakeBufferResource(pp_instance(), key)); |
| + if (!key_resource.get()) |
| + return false; |
| + |
| + return PP_ToBool(plugin_decryption_interface_->AddKey( |
| + pp_instance(), |
| + session_id_var.GetPPVar(), |
| + key_resource)); |
| +} |
| + |
| +bool PluginInstance::CancelKeyRequest(const std::string& session_id) { |
| + if (!LoadContentDecryptionModuleInterface()) |
| + return false; |
| + StringVar session_id_var(session_id); |
| + if (session_id_var.value().size() < session_id.size()) |
| + return false; |
| + return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( |
| + pp_instance(), |
| + session_id_var.GetPPVar())); |
| +} |
| + |
| +bool PluginInstance::Decrypt(const std::string& encrypted_block, |
| + const CDMStatusCB& callback) { |
| + if (!LoadContentDecryptionModuleInterface()) |
| + return false; |
| + ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(), |
| + MakeBufferResource(pp_instance(), |
| + encrypted_block)); |
| + if (!encrypted_resource.get()) |
| + return false; |
| + // 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
|
| + // the plugin. |
| + PP_CompletionCallback pp_callback = {NULL, NULL, 0}; |
| + return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), |
| + encrypted_resource, |
| + pp_callback)); |
| +} |
| + |
| +bool PluginInstance::DecryptAndDecode(const std::string& encrypted_block, |
| + const CDMStatusCB& callback) { |
| + if (!LoadContentDecryptionModuleInterface()) |
| + return false; |
| + ScopedPPResource encrypted_resource(ScopedPPResource::PassRef(), |
| + MakeBufferResource(pp_instance(), |
| + encrypted_block)); |
| + if (!encrypted_resource.get()) |
| + return false; |
| + // TODO(tomfinegan): wrap callback in PP_CompletionCallback and pass it to |
| + // the plugin. |
| + PP_CompletionCallback pp_callback = {NULL, NULL, 0}; |
| + return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( |
| + pp_instance(), |
| + encrypted_resource, |
| + pp_callback)); |
| +} |
| + |
| bool PluginInstance::FlashIsFullscreenOrPending() { |
| return fullscreen_container_ != NULL; |
| } |
| @@ -1854,6 +1985,47 @@ PP_Var PluginInstance::GetFontFamilies(PP_Instance instance) { |
| return PP_MakeUndefined(); |
| } |
| +void PluginInstance::NeedKey(PP_Instance instance, |
| + PP_Var key_system, |
| + PP_Var session_id, |
| + PP_Resource init_data) { |
| +} |
| + |
| +void PluginInstance::KeyAdded(PP_Instance instance, |
| + PP_Var key_system, |
| + PP_Var session_id) { |
| +} |
| + |
| +void PluginInstance::KeyMessage(PP_Instance instance, |
| + PP_Var key_system, |
| + PP_Var session_id, |
| + PP_Resource message, |
| + PP_Var default_url) { |
| +} |
| + |
| +void PluginInstance::KeyError(PP_Instance instance, |
| + PP_Var key_system, |
| + PP_Var session_id, |
| + uint16_t media_error, |
| + uint16_t system_error) { |
| +} |
| + |
| +void PluginInstance::DeliverBlock(PP_Instance instance, |
| + PP_Resource decrypted_block, |
| + PP_CompletionCallback callback) { |
| +} |
| + |
| +void PluginInstance::DeliverFrame(PP_Instance instance, |
| + PP_Resource decrypted_frame, |
| + PP_CompletionCallback callback) { |
| +} |
| + |
| +void PluginInstance::DeliverSamples(PP_Instance instance, |
| + PP_Resource decrypted_samples, |
| + PP_CompletionCallback callback) { |
| +} |
| + |
| + |
| void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
| int32_t total, |
| PP_Bool final_result) { |