summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 02:14:11 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 02:14:11 +0000
commitd29171a549b5c20980b9930c07e34da97bcbd13c (patch)
tree0acbe45178f5313cdd704652fc6f866c4255833b /content/renderer
parentc0131a39a53f46594e6af35127f8c1b4e3bebd28 (diff)
downloadchromium_src-d29171a549b5c20980b9930c07e34da97bcbd13c.zip
chromium_src-d29171a549b5c20980b9930c07e34da97bcbd13c.tar.gz
chromium_src-d29171a549b5c20980b9930c07e34da97bcbd13c.tar.bz2
Implement host side of sync EnumerateVideoCaptureDevices
This implements the host side of the sync ppapi function EnumerateVideoCaptureDevices. BUG=none TEST=Wrote a sample that runs the sync and non-sync versions. Ran it and compared the outputs. Review URL: https://chromiumcodereview.appspot.com/11016007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/pepper/content_renderer_pepper_host_factory.cc11
-rw-r--r--content/renderer/pepper/pepper_flash_host.cc82
-rw-r--r--content/renderer/pepper/pepper_flash_host.h47
3 files changed, 140 insertions, 0 deletions
diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
index 6d77832..732db9f 100644
--- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc
+++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "content/renderer/pepper/pepper_file_chooser_host.h"
+#include "content/renderer/pepper/pepper_flash_host.h"
#include "content/renderer/pepper/pepper_websocket_host.h"
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
#include "ppapi/host/resource_host.h"
@@ -55,6 +56,16 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
host_, instance, params.pp_resource()));
}
}
+
+ // Resources for Flash interfaces.
+ if (GetPermissions().HasPermission(ppapi::PERMISSION_FLASH)) {
+ switch (message.type()) {
+ case PpapiHostMsg_Flash_Create::ID:
+ return scoped_ptr<ResourceHost>(new PepperFlashHost(
+ host_, instance, params.pp_resource()));
+ }
+ }
+
return scoped_ptr<ResourceHost>();
}
diff --git a/content/renderer/pepper/pepper_flash_host.cc b/content/renderer/pepper/pepper_flash_host.cc
new file mode 100644
index 0000000..d2e9f6f
--- /dev/null
+++ b/content/renderer/pepper/pepper_flash_host.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/pepper/pepper_flash_host.h"
+
+#include <vector>
+
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/enter_proxy.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/thunk/ppb_video_capture_api.h"
+
+using ppapi::proxy::EnterHostFromHostResource;
+using ppapi::proxy::EnterHostFromHostResourceForceCallback;
+using ppapi::thunk::PPB_VideoCapture_API;
+
+namespace content {
+
+PepperFlashHost::PepperFlashHost(
+ RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
+
+PepperFlashHost::~PepperFlashHost() {
+}
+
+int32_t PepperFlashHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperFlashHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+ PpapiHostMsg_Flash_EnumerateVideoCaptureDevices,
+ OnMsgEnumerateVideoCaptureDevices)
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashHost::OnMsgEnumerateVideoCaptureDevices(
+ ppapi::host::HostMessageContext* host_context,
+ const ppapi::HostResource& host_resource) {
+ EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter(
+ host_resource, callback_factory_,
+ &PepperFlashHost::OnEnumerateVideoCaptureDevicesComplete,
+ host_context->MakeReplyMessageContext(),
+ host_resource);
+ if (enter.succeeded()) {
+ // We don't want the output to go into a PP_ResourceArray (which is
+ // deprecated), so just pass in NULL. We'll grab the DeviceRefData vector
+ // in the callback and convert it to a PP_ArrayOutput in the plugin.
+ enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback()));
+ }
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperFlashHost::OnEnumerateVideoCaptureDevicesComplete(
+ int32_t result,
+ ppapi::host::ReplyMessageContext reply_message_context,
+ const ppapi::HostResource& host_resource) {
+ std::vector<ppapi::DeviceRefData> devices;
+ if (result == PP_OK) {
+ EnterHostFromHostResource<PPB_VideoCapture_API> enter(host_resource);
+ if (enter.succeeded())
+ devices = enter.object()->GetDeviceRefData();
+ else
+ result = PP_ERROR_FAILED;
+ }
+ reply_message_context.params.set_result(result);
+ host()->SendReply(reply_message_context,
+ PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply(devices));
+}
+
+} // namespace content
+
diff --git a/content/renderer/pepper/pepper_flash_host.h b/content/renderer/pepper/pepper_flash_host.h
new file mode 100644
index 0000000..5073bc8
--- /dev/null
+++ b/content/renderer/pepper/pepper_flash_host.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_PEPPER_PEPPER_FLASH_HOST_H_
+#define CONTENT_RENDERER_PEPPER_PEPPER_FLASH_HOST_H_
+
+#include "base/basictypes.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/proxy_completion_callback_factory.h"
+
+namespace content {
+
+class RendererPpapiHost;
+
+class PepperFlashHost
+ : public ppapi::host::ResourceHost {
+ public:
+ PepperFlashHost(RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+ virtual ~PepperFlashHost();
+
+ virtual int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) OVERRIDE;
+
+ int32_t OnMsgEnumerateVideoCaptureDevices(
+ ppapi::host::HostMessageContext* host_context,
+ const ppapi::HostResource& host_resource);
+ private:
+ void OnEnumerateVideoCaptureDevicesComplete(
+ int32_t result,
+ ppapi::host::ReplyMessageContext reply_message_context,
+ const ppapi::HostResource& host_resource);
+
+ ppapi::proxy::ProxyCompletionCallbackFactory<PepperFlashHost>
+ callback_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashHost);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_FLASH_HOST_H_