Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / pepper / pepper_camera_device_host.h
blob3a13cac5704af1679817c255ae29f6dd9be59ca3
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "content/renderer/pepper/ppb_buffer_impl.h"
11 #include "ppapi/c/pp_size.h"
12 #include "ppapi/c/private/pp_video_capture_format.h"
13 #include "ppapi/host/host_message_context.h"
14 #include "ppapi/host/resource_host.h"
16 namespace content {
17 class PepperPlatformCameraDevice;
18 class RendererPpapiHostImpl;
20 class PepperCameraDeviceHost : public ppapi::host::ResourceHost {
21 public:
22 PepperCameraDeviceHost(RendererPpapiHostImpl* host,
23 PP_Instance instance,
24 PP_Resource resource);
26 ~PepperCameraDeviceHost() override;
28 bool Init();
30 int32_t OnResourceMessageReceived(
31 const IPC::Message& msg,
32 ppapi::host::HostMessageContext* context) override;
34 // These methods are called by PepperPlatformCameraDevice only.
36 // Called when camera device is initialized.
37 void OnInitialized(bool succeeded);
39 // Called when the video capture formats are enumerated.
40 void OnVideoCaptureFormatsEnumerated(
41 const std::vector<PP_VideoCaptureFormat>& formats);
43 private:
44 // Plugin -> host message handlers.
45 int32_t OnOpen(ppapi::host::HostMessageContext* context,
46 const std::string& device_id);
47 int32_t OnClose(ppapi::host::HostMessageContext* context);
48 int32_t OnGetSupportedVideoCaptureFormats(
49 ppapi::host::HostMessageContext* context);
51 // Utility methods.
52 void DetachPlatformCameraDevice();
54 scoped_ptr<PepperPlatformCameraDevice> platform_camera_device_;
56 RendererPpapiHostImpl* renderer_ppapi_host_;
58 ppapi::host::ReplyMessageContext open_reply_context_;
60 ppapi::host::ReplyMessageContext video_capture_formats_reply_context_;
62 DISALLOW_COPY_AND_ASSIGN(PepperCameraDeviceHost);
65 } // namespace content
67 #endif // CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_