1 // Copyright (c) 2012 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/flash_drm.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/private/ppb_flash_device_id.h"
9 #include "ppapi/c/private/ppb_flash_drm.h"
10 #include "ppapi/cpp/module_impl.h"
16 template <> const char* interface_name
<PPB_Flash_DRM_1_0
>() {
17 return PPB_FLASH_DRM_INTERFACE_1_0
;
20 template <> const char* interface_name
<PPB_Flash_DeviceID_1_0
>() {
21 return PPB_FLASH_DEVICEID_INTERFACE_1_0
;
31 DRM::DRM(const InstanceHandle
& instance
) : Resource() {
32 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
33 PassRefFromConstructor(get_interface
<PPB_Flash_DRM_1_0
>()->Create(
34 instance
.pp_instance()));
35 } else if (has_interface
<PPB_Flash_DeviceID_1_0
>()) {
36 PassRefFromConstructor(get_interface
<PPB_Flash_DeviceID_1_0
>()->Create(
37 instance
.pp_instance()));
41 int32_t DRM::GetDeviceID(const CompletionCallbackWithOutput
<Var
>& callback
) {
42 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
43 return get_interface
<PPB_Flash_DRM_1_0
>()->GetDeviceID(
46 callback
.pp_completion_callback());
48 if (has_interface
<PPB_Flash_DeviceID_1_0
>()) {
49 return get_interface
<PPB_Flash_DeviceID_1_0
>()->GetDeviceID(
52 callback
.pp_completion_callback());
54 return callback
.MayForce(PP_ERROR_NOINTERFACE
);
57 bool DRM::GetHmonitor(int64_t* hmonitor
) {
58 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
59 return PP_ToBool(get_interface
<PPB_Flash_DRM_1_0
>()->GetHmonitor(
66 int32_t DRM::GetVoucherFile(
67 const CompletionCallbackWithOutput
<FileRef
>& callback
) {
68 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
69 return get_interface
<PPB_Flash_DRM_1_0
>()->GetVoucherFile(
72 callback
.pp_completion_callback());
74 return PP_ERROR_FAILED
;