~rpadovani/oxide/type-info

« back to all changes in this revision

Viewing changes to shared/renderer/pepper/oxide_pepper_flash_renderer_host.cc

  • Committer: Riccardo Padovani
  • Date: 2015-10-19 07:56:29 UTC
  • mfrom: (1088.1.131 oxide)
  • Revision ID: riccardo@rpadovani.com-20151019075629-z0mlhwlb9xflkovw
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
6
#include "oxide_pepper_flash_renderer_host.h"
 
7
 
 
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"
 
20
 
 
21
 
 
22
namespace oxide {
 
23
 
 
24
PepperFlashRendererHost::PepperFlashRendererHost(
 
25
    content::RendererPpapiHost* host,
 
26
    PP_Instance instance,
 
27
    PP_Resource resource)
 
28
    : ResourceHost(host->GetPpapiHost(), instance, resource),
 
29
      host_(host),
 
30
      weak_factory_(this) {}
 
31
 
 
32
PepperFlashRendererHost::~PepperFlashRendererHost() {
 
33
}
 
34
 
 
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,
 
40
                                      OnGetProxyForURL)
 
41
    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
 
42
                                      OnSetInstanceAlwaysOnTop)
 
43
    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
 
44
                                      OnDrawGlyphs)
 
45
    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
 
46
    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
 
47
                                      OnIsRectTopmost)
 
48
    PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_InvokePrinting,
 
49
                                        OnInvokePrinting)
 
50
  PPAPI_END_MESSAGE_MAP()
 
51
  return PP_ERROR_FAILED;
 
52
}
 
53
 
 
54
int32_t PepperFlashRendererHost::OnGetProxyForURL(
 
55
    ppapi::host::HostMessageContext* host_context,
 
56
    const std::string& url) {
 
57
  GURL gurl(url);
 
58
  if (!gurl.is_valid())
 
59
    return PP_ERROR_FAILED;
 
60
  std::string proxy;
 
61
  bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
 
62
  if (!result)
 
63
    return PP_ERROR_FAILED;
 
64
  host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
 
65
  return PP_OK;
 
66
}
 
67
 
 
68
int32_t PepperFlashRendererHost::OnSetInstanceAlwaysOnTop(
 
69
    ppapi::host::HostMessageContext* host_context,
 
70
    bool on_top) {
 
71
  content::PepperPluginInstance* plugin_instance =
 
72
      host_->GetPluginInstance(pp_instance());
 
73
  if (plugin_instance)
 
74
    plugin_instance->SetAlwaysOnTop(on_top);
 
75
  // Since no reply is sent for this message, it doesn't make sense to return an
 
76
  // error.
 
77
  return PP_OK;
 
78
}
 
79
 
 
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;
 
86
 
 
87
  return PP_OK;
 
88
}
 
89
 
 
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;
 
96
}
 
97
 
 
98
int32_t PepperFlashRendererHost::OnIsRectTopmost(
 
99
    ppapi::host::HostMessageContext* host_context,
 
100
    const PP_Rect& rect) {
 
101
 
 
102
  content::PepperPluginInstance* plugin_instance =
 
103
      host_->GetPluginInstance(pp_instance());
 
104
 
 
105
  if (plugin_instance &&
 
106
      plugin_instance->IsRectTopmost(gfx::Rect(
 
107
          rect.point.x, rect.point.y, rect.size.width, rect.size.height)))
 
108
    return PP_OK;
 
109
 
 
110
  return PP_ERROR_FAILED;
 
111
}
 
112
 
 
113
int32_t PepperFlashRendererHost::OnInvokePrinting(
 
114
    ppapi::host::HostMessageContext* host_context) {
 
115
 
 
116
  return PP_OK;
 
117
}
 
118
 
 
119
} // oxide