1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
6
#include "oxide_pepper_flash_renderer_host.h"
8
#include "ppapi/host/dispatch_host_message.h"
9
#include "ppapi/host/host_message_context.h"
10
#include "ppapi/proxy/host_dispatcher.h"
11
#include "ppapi/proxy/ppapi_messages.h"
12
#include "ppapi/proxy/resource_message_params.h"
13
#include "ppapi/proxy/serialized_structs.h"
14
#include "ppapi/thunk/enter.h"
15
#include "ppapi/thunk/ppb_image_data_api.h"
16
#include "content/public/renderer/renderer_ppapi_host.h"
17
#include "content/public/renderer/render_thread.h"
18
#include "content/public/renderer/pepper_plugin_instance.h"
19
#include "ui/gfx/geometry/rect.h"
24
PepperFlashRendererHost::PepperFlashRendererHost(
25
content::RendererPpapiHost* host,
28
: ResourceHost(host->GetPpapiHost(), instance, resource),
30
weak_factory_(this) {}
32
PepperFlashRendererHost::~PepperFlashRendererHost() {
35
int32_t PepperFlashRendererHost::OnResourceMessageReceived(
36
const IPC::Message& msg,
37
ppapi::host::HostMessageContext* context) {
38
PPAPI_BEGIN_MESSAGE_MAP(PepperFlashRendererHost, msg)
39
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetProxyForURL,
41
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
42
OnSetInstanceAlwaysOnTop)
43
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
45
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
46
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
48
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_InvokePrinting,
50
PPAPI_END_MESSAGE_MAP()
51
return PP_ERROR_FAILED;
54
int32_t PepperFlashRendererHost::OnGetProxyForURL(
55
ppapi::host::HostMessageContext* host_context,
56
const std::string& url) {
59
return PP_ERROR_FAILED;
61
bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
63
return PP_ERROR_FAILED;
64
host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
68
int32_t PepperFlashRendererHost::OnSetInstanceAlwaysOnTop(
69
ppapi::host::HostMessageContext* host_context,
71
content::PepperPluginInstance* plugin_instance =
72
host_->GetPluginInstance(pp_instance());
74
plugin_instance->SetAlwaysOnTop(on_top);
75
// Since no reply is sent for this message, it doesn't make sense to return an
80
int32_t PepperFlashRendererHost::OnDrawGlyphs(
81
ppapi::host::HostMessageContext* host_context,
82
ppapi::proxy::PPBFlash_DrawGlyphs_Params params) {
83
if (params.glyph_indices.size() != params.glyph_advances.size() ||
84
params.glyph_indices.empty())
85
return PP_ERROR_FAILED;
90
int32_t PepperFlashRendererHost::OnNavigate(
91
ppapi::host::HostMessageContext* host_context,
92
const ppapi::URLRequestInfoData& data,
93
const std::string& target,
94
bool from_user_action) {
95
return PP_OK_COMPLETIONPENDING;
98
int32_t PepperFlashRendererHost::OnIsRectTopmost(
99
ppapi::host::HostMessageContext* host_context,
100
const PP_Rect& rect) {
102
content::PepperPluginInstance* plugin_instance =
103
host_->GetPluginInstance(pp_instance());
105
if (plugin_instance &&
106
plugin_instance->IsRectTopmost(gfx::Rect(
107
rect.point.x, rect.point.y, rect.size.width, rect.size.height)))
110
return PP_ERROR_FAILED;
113
int32_t PepperFlashRendererHost::OnInvokePrinting(
114
ppapi::host::HostMessageContext* host_context) {