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.
4
5 #include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
6
7 #include "content/public/renderer/pepper_plugin_instance.h"
8 #include "content/public/renderer/renderer_ppapi_host.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/host/dispatch_host_message.h"
11 #include "ppapi/host/host_message_context.h"
12 #include "ppapi/host/ppapi_host.h"
13 #include "ppapi/proxy/ppapi_messages.h"
14
PepperFlashFullscreenHost(content::RendererPpapiHost * host,PP_Instance instance,PP_Resource resource)15 PepperFlashFullscreenHost::PepperFlashFullscreenHost(
16 content::RendererPpapiHost* host,
17 PP_Instance instance,
18 PP_Resource resource)
19 : ResourceHost(host->GetPpapiHost(), instance, resource),
20 renderer_ppapi_host_(host) {
21 }
22
~PepperFlashFullscreenHost()23 PepperFlashFullscreenHost::~PepperFlashFullscreenHost() {
24 }
25
OnResourceMessageReceived(const IPC::Message & msg,ppapi::host::HostMessageContext * context)26 int32_t PepperFlashFullscreenHost::OnResourceMessageReceived(
27 const IPC::Message& msg,
28 ppapi::host::HostMessageContext* context) {
29 IPC_BEGIN_MESSAGE_MAP(PepperFlashFullscreenHost, msg)
30 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
31 PpapiHostMsg_FlashFullscreen_SetFullscreen,
32 OnSetFullscreen)
33 IPC_END_MESSAGE_MAP()
34 return PP_ERROR_FAILED;
35 }
36
OnSetFullscreen(ppapi::host::HostMessageContext * context,bool fullscreen)37 int32_t PepperFlashFullscreenHost::OnSetFullscreen(
38 ppapi::host::HostMessageContext* context,
39 bool fullscreen) {
40 content::PepperPluginInstance* plugin_instance =
41 renderer_ppapi_host_->GetPluginInstance(pp_instance());
42 if (plugin_instance && plugin_instance->FlashSetFullscreen(fullscreen, true))
43 return PP_OK;
44 return PP_ERROR_FAILED;
45 }
46