This source file includes following definitions.
- selected_id_dest_
- Initialize
- AsPPB_Flash_Menu_API
- Show
- OnReplyReceived
- OnShowReply
#include "ppapi/proxy/flash_menu_resource.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_flash_menu.h"
namespace ppapi {
namespace proxy {
FlashMenuResource::FlashMenuResource(Connection connection,
PP_Instance instance)
: PluginResource(connection, instance),
selected_id_dest_(NULL) {
}
FlashMenuResource::~FlashMenuResource() {
}
bool FlashMenuResource::Initialize(const PP_Flash_Menu* menu_data) {
SerializedFlashMenu serialized_menu;
if (!menu_data || !serialized_menu.SetPPMenu(menu_data))
return false;
SendCreate(RENDERER, PpapiHostMsg_FlashMenu_Create(serialized_menu));
return true;
}
thunk::PPB_Flash_Menu_API* FlashMenuResource::AsPPB_Flash_Menu_API() {
return this;
}
int32_t FlashMenuResource::Show(
const PP_Point* location,
int32_t* selected_id,
scoped_refptr<TrackedCallback> callback) {
if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
selected_id_dest_ = selected_id;
callback_ = callback;
SyncCall<IPC::Message>(RENDERER, PpapiHostMsg_FlashMenu_Show(*location));
return PP_OK_COMPLETIONPENDING;
}
void FlashMenuResource::OnReplyReceived(
const proxy::ResourceMessageReplyParams& params,
const IPC::Message& msg) {
switch (msg.type()) {
case PpapiPluginMsg_FlashMenu_ShowReply::ID: {
int32_t selected_id;
if (ppapi::UnpackMessage<PpapiPluginMsg_FlashMenu_ShowReply>(
msg, &selected_id))
OnShowReply(params, selected_id);
break;
}
}
}
void FlashMenuResource::OnShowReply(
const proxy::ResourceMessageReplyParams& params,
int32_t selected_id) {
if (!TrackedCallback::IsPending(callback_))
return;
*selected_id_dest_ = selected_id;
selected_id_dest_ = NULL;
callback_->Run(params.result());
}
}
}