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

Unified 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: Rebased on origin/master and fixed a minor conflict Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
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 5cb484f53717ca31d0695b18b16b13e376140ad8..22fa439106304ba2bcdcebc453f10e2991f38b27 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -281,6 +281,30 @@ bool SecurityOriginForInstance(PP_Instance instance_id,
return true;
}
+// Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the
+// 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.c_str(), data.size());
xhwang 2012/06/18 20:20:41 Not a big difference here, but I feel data.data()
Tom Finegan 2012/06/18 20:36:58 Done.
+
+ return resource.Release();
+}
+
} // namespace
// static
@@ -323,6 +347,7 @@ PluginInstance::PluginInstance(
has_content_area_focus_(false),
find_identifier_(-1),
resource_creation_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ plugin_decryption_interface_(NULL),
plugin_find_interface_(NULL),
plugin_messaging_interface_(NULL),
plugin_mouse_lock_interface_(NULL),
@@ -954,6 +979,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_ =
@@ -1256,6 +1291,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())
+ return false;
+
+ PP_Resource init_resource = 0;
+ 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
+ // 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;
}
@@ -1840,6 +1967,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) {

Powered by Google App Engine
This is Rietveld 408576698