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

Unified Diff: content/renderer/pepper/content_renderer_pepper_host_factory.cc

Issue 16335018: Add NaCl proxies for Pepper Video Source and Destination resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux (create SIMPLE image data). Created 7 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: content/renderer/pepper/content_renderer_pepper_host_factory.cc
diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
index 21ba784df5172a59945f28d07de36d27b82b61d4..d7872c9cad2e5a5335ad92f7f79ccc2045b4926d 100644
--- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc
+++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
@@ -6,6 +6,8 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
+#include "content/public/common/content_client.h"
+#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/pepper/pepper_audio_input_host.h"
#include "content/renderer/pepper/pepper_file_chooser_host.h"
#include "content/renderer/pepper/pepper_file_io_host.h"
@@ -22,11 +24,32 @@
#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_structs.h"
+#include "third_party/WebKit/public/platform/WebURL.h"
+#include "third_party/WebKit/public/web/WebDocument.h"
+#include "third_party/WebKit/public/web/WebElement.h"
+#include "third_party/WebKit/public/web/WebPluginContainer.h"
using ppapi::host::ResourceHost;
using ppapi::proxy::SerializedTrueTypeFontDesc;
using ppapi::UnpackMessage;
+namespace {
+
+bool CanUseMediaStreamAPI(const content::RendererPpapiHost* host,
+ PP_Instance instance) {
+ WebKit::WebPluginContainer* container =
+ host->GetContainerForInstance(instance);
+ if (!container)
+ return false;
+
+ GURL document_url = container->element().document().url();
+ content::ContentRendererClient* content_renderer_client =
+ content::GetContentClient()->renderer();
+ return content_renderer_client->AllowPepperMediaStreamAPI(document_url);
+}
+
+}
+
namespace content {
ContentRendererPepperHostFactory::ContentRendererPepperHostFactory(
@@ -81,6 +104,19 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
case PpapiHostMsg_WebSocket_Create::ID:
return scoped_ptr<ResourceHost>(new PepperWebSocketHost(
host_, instance, params.pp_resource()));
+#if defined(ENABLE_WEBRTC)
+ // These private MediaStream interfaces are exposed as if they were public
+ // so they can be used by NaCl plugins. However, they are available only
+ // for whitelisted apps.
+ case PpapiHostMsg_VideoDestination_Create::ID:
+ if (CanUseMediaStreamAPI(host_, instance))
+ return scoped_ptr<ResourceHost>(new PepperVideoDestinationHost(
+ host_, instance, params.pp_resource()));
+ case PpapiHostMsg_VideoSource_Create::ID:
+ if (CanUseMediaStreamAPI(host_, instance))
+ return scoped_ptr<ResourceHost>(new PepperVideoSourceHost(
+ host_, instance, params.pp_resource()));
+#endif // defined(ENABLE_WEBRTC)
}
// Dev interfaces.
@@ -119,20 +155,6 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
}
}
-#if defined(ENABLE_WEBRTC)
- // Private interfaces.
- if (GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE)) {
- switch (message.type()) {
- case PpapiHostMsg_VideoDestination_Create::ID:
- return scoped_ptr<ResourceHost>(new PepperVideoDestinationHost(
- host_, instance, params.pp_resource()));
- case PpapiHostMsg_VideoSource_Create::ID:
- return scoped_ptr<ResourceHost>(new PepperVideoSourceHost(
- host_, instance, params.pp_resource()));
- }
- }
-#endif
-
return scoped_ptr<ResourceHost>();
}

Powered by Google App Engine
This is Rietveld 408576698