flash_drm_resource.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/proxy/flash_drm_resource.h" 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/bind.h" 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/c/pp_errors.h" 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/proxy/dispatch_reply_message.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/proxy/ppapi_messages.h" 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/shared_impl/var.h" 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace ppapi { 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace proxy { 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)FlashDRMResource::FlashDRMResource(Connection connection, 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PP_Instance instance) 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : PluginResource(connection, instance) { 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SendCreate(BROWSER, PpapiHostMsg_FlashDRM_Create()); 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)FlashDRMResource::~FlashDRMResource() { 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)thunk::PPB_Flash_DRM_API* FlashDRMResource::AsPPB_Flash_DRM_API() { 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return this; 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int32_t FlashDRMResource::GetDeviceID(PP_Var* id, 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) scoped_refptr<TrackedCallback> callback) { 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (!id) 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return PP_ERROR_BADARGUMENT; 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) *id = PP_MakeUndefined(); 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Call<PpapiPluginMsg_FlashDRM_GetDeviceIDReply>( 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BROWSER, 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PpapiHostMsg_FlashDRM_GetDeviceID(), 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::Bind(&FlashDRMResource::OnPluginMsgGetDeviceIDReply, this, 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) id, callback)); 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return PP_OK_COMPLETIONPENDING; 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void FlashDRMResource::OnPluginMsgGetDeviceIDReply( 4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PP_Var* dest, 4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) scoped_refptr<TrackedCallback> callback, 4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const ResourceMessageReplyParams& params, 4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string& id) { 4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (TrackedCallback::IsPending(callback)) { 5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (params.result() == PP_OK) 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) *dest = StringVar::StringToPPVar(id); 5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) callback->Run(params.result()); 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace proxy 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace ppapi 58