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/proxy/flash_drm_resource.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/proxy/dispatch_reply_message.h"
10 #include "ppapi/proxy/file_ref_resource.h"
11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/shared_impl/var.h"
17 FlashDRMResource::FlashDRMResource(Connection connection
,
19 : PluginResource(connection
, instance
) {
20 SendCreate(BROWSER
, PpapiHostMsg_FlashDRM_Create());
21 SendCreate(RENDERER
, PpapiHostMsg_FlashDRM_Create());
24 FlashDRMResource::~FlashDRMResource() {
27 thunk::PPB_Flash_DRM_API
* FlashDRMResource::AsPPB_Flash_DRM_API() {
31 int32_t FlashDRMResource::GetDeviceID(PP_Var
* id
,
32 scoped_refptr
<TrackedCallback
> callback
) {
34 return PP_ERROR_BADARGUMENT
;
36 *id
= PP_MakeUndefined();
38 Call
<PpapiPluginMsg_FlashDRM_GetDeviceIDReply
>(
40 PpapiHostMsg_FlashDRM_GetDeviceID(),
41 base::Bind(&FlashDRMResource::OnPluginMsgGetDeviceIDReply
, this,
43 return PP_OK_COMPLETIONPENDING
;
46 PP_Bool
FlashDRMResource::GetHmonitor(int64_t* hmonitor
) {
48 int32_t result
= SyncCall
<PpapiPluginMsg_FlashDRM_GetHmonitorReply
>(
50 PpapiHostMsg_FlashDRM_GetHmonitor(),
54 *hmonitor
= hmonitor_out
;
58 int32_t FlashDRMResource::GetVoucherFile(
59 PP_Resource
* file_ref
,
60 scoped_refptr
<TrackedCallback
> callback
) {
62 return PP_ERROR_BADARGUMENT
;
66 Call
<PpapiPluginMsg_FlashDRM_GetVoucherFileReply
>(
68 PpapiHostMsg_FlashDRM_GetVoucherFile(),
69 base::Bind(&FlashDRMResource::OnPluginMsgGetVoucherFileReply
, this,
71 return PP_OK_COMPLETIONPENDING
;
74 int32_t FlashDRMResource::MonitorIsExternal(
76 scoped_refptr
<TrackedCallback
> callback
) {
78 return PP_ERROR_BADARGUMENT
;
80 *is_external
= PP_FALSE
;
82 Call
<PpapiPluginMsg_FlashDRM_MonitorIsExternalReply
>(
84 PpapiHostMsg_FlashDRM_MonitorIsExternal(),
85 base::Bind(&FlashDRMResource::OnPluginMsgMonitorIsExternalReply
, this,
86 is_external
, callback
));
87 return PP_OK_COMPLETIONPENDING
;
90 void FlashDRMResource::OnPluginMsgGetDeviceIDReply(
92 scoped_refptr
<TrackedCallback
> callback
,
93 const ResourceMessageReplyParams
& params
,
94 const std::string
& id
) {
95 if (TrackedCallback::IsPending(callback
)) {
96 if (params
.result() == PP_OK
)
97 *dest
= StringVar::StringToPPVar(id
);
98 callback
->Run(params
.result());
102 void FlashDRMResource::OnPluginMsgGetVoucherFileReply(
104 scoped_refptr
<TrackedCallback
> callback
,
105 const ResourceMessageReplyParams
& params
,
106 const FileRefCreateInfo
& file_info
) {
107 if (TrackedCallback::IsPending(callback
)) {
108 if (params
.result() == PP_OK
) {
109 *dest
= FileRefResource::CreateFileRef(
114 callback
->Run(params
.result());
118 void FlashDRMResource::OnPluginMsgMonitorIsExternalReply(
120 scoped_refptr
<TrackedCallback
> callback
,
121 const ResourceMessageReplyParams
& params
,
122 PP_Bool is_external
) {
123 if (TrackedCallback::IsPending(callback
)) {
124 if (params
.result() == PP_OK
)
126 callback
->Run(params
.result());