Don't announce clipboard events if the event target is not visible and focused.
[chromium-blink-merge.git] / ppapi / cpp / private / camera_device_private.cc
blob1ca39f7dc63a673e761c19c373a8a9688979e090
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 #include "ppapi/cpp/private/camera_device_private.h"
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module_impl.h"
12 #include "ppapi/cpp/private/camera_capabilities_private.h"
14 namespace pp {
16 namespace {
18 template <>
19 const char* interface_name<PPB_CameraDevice_Private_0_1>() {
20 return PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1;
23 } // namespace
25 CameraDevice_Private::CameraDevice_Private() {
28 CameraDevice_Private::CameraDevice_Private(const CameraDevice_Private& other)
29 : Resource(other) {
32 CameraDevice_Private::CameraDevice_Private(const Resource& resource)
33 : Resource(resource) {
34 PP_DCHECK(IsCameraDevice(resource));
37 CameraDevice_Private::CameraDevice_Private(const InstanceHandle& instance) {
38 if (has_interface<PPB_CameraDevice_Private_0_1>()) {
39 PassRefFromConstructor(
40 get_interface<PPB_CameraDevice_Private_0_1>()->Create(
41 instance.pp_instance()));
42 return;
44 PP_DCHECK(false);
47 CameraDevice_Private::CameraDevice_Private(PassRef, PP_Resource resource)
48 : Resource(PASS_REF, resource) {
51 CameraDevice_Private::~CameraDevice_Private() {
54 int32_t CameraDevice_Private::Open(const Var& device_id,
55 const CompletionCallback& callback) {
56 if (!has_interface<PPB_CameraDevice_Private_0_1>())
57 return callback.MayForce(PP_ERROR_NOINTERFACE);
59 return get_interface<PPB_CameraDevice_Private_0_1>()->Open(
60 pp_resource(), device_id.pp_var(), callback.pp_completion_callback());
63 void CameraDevice_Private::Close() {
64 if (has_interface<PPB_CameraDevice_Private_0_1>())
65 get_interface<PPB_CameraDevice_Private_0_1>()->Close(pp_resource());
68 int32_t CameraDevice_Private::GetCameraCapabilities(
69 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) {
70 if (!has_interface<PPB_CameraDevice_Private_0_1>())
71 return callback.MayForce(PP_ERROR_NOINTERFACE);
73 return get_interface<PPB_CameraDevice_Private_0_1>()->GetCameraCapabilities(
74 pp_resource(), callback.output(), callback.pp_completion_callback());
77 // static
78 bool CameraDevice_Private::IsCameraDevice(const Resource& resource) {
79 if (!has_interface<PPB_CameraDevice_Private_0_1>())
80 return false;
82 return PP_ToBool(
83 get_interface<PPB_CameraDevice_Private_0_1>()->IsCameraDevice(
84 resource.pp_resource()));
87 } // namespace pp