• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "content/renderer/pepper/mock_renderer_ppapi_host.h"
6 
7 #include "content/renderer/pepper/fake_pepper_plugin_instance.h"
8 #include "ui/gfx/point.h"
9 
10 namespace content {
11 
MockRendererPpapiHost(RenderView * render_view,PP_Instance instance)12 MockRendererPpapiHost::MockRendererPpapiHost(RenderView* render_view,
13                                              PP_Instance instance)
14     : sink_(),
15       ppapi_host_(&sink_, ppapi::PpapiPermissions()),
16       render_view_(render_view),
17       pp_instance_(instance),
18       has_user_gesture_(false),
19       plugin_instance_(new FakePepperPluginInstance) {}
20 
~MockRendererPpapiHost()21 MockRendererPpapiHost::~MockRendererPpapiHost() {}
22 
GetPpapiHost()23 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() {
24   return &ppapi_host_;
25 }
26 
IsValidInstance(PP_Instance instance) const27 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const {
28   return instance == pp_instance_;
29 }
30 
GetPluginInstance(PP_Instance instance) const31 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance(
32     PP_Instance instance) const {
33   return plugin_instance_.get();
34 }
35 
GetRenderFrameForInstance(PP_Instance instance) const36 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance(
37     PP_Instance instance) const {
38   return NULL;
39 }
40 
GetRenderViewForInstance(PP_Instance instance) const41 RenderView* MockRendererPpapiHost::GetRenderViewForInstance(
42     PP_Instance instance) const {
43   if (instance == pp_instance_)
44     return render_view_;
45   return NULL;
46 }
47 
GetContainerForInstance(PP_Instance instance) const48 blink::WebPluginContainer* MockRendererPpapiHost::GetContainerForInstance(
49     PP_Instance instance) const {
50   NOTIMPLEMENTED();
51   return NULL;
52 }
53 
GetPluginPID() const54 base::ProcessId MockRendererPpapiHost::GetPluginPID() const {
55   NOTIMPLEMENTED();
56   return base::kNullProcessId;
57 }
58 
HasUserGesture(PP_Instance instance) const59 bool MockRendererPpapiHost::HasUserGesture(PP_Instance instance) const {
60   return has_user_gesture_;
61 }
62 
GetRoutingIDForWidget(PP_Instance instance) const63 int MockRendererPpapiHost::GetRoutingIDForWidget(PP_Instance instance) const {
64   return 0;
65 }
66 
PluginPointToRenderFrame(PP_Instance instance,const gfx::Point & pt) const67 gfx::Point MockRendererPpapiHost::PluginPointToRenderFrame(
68     PP_Instance instance,
69     const gfx::Point& pt) const {
70   return gfx::Point();
71 }
72 
ShareHandleWithRemote(base::PlatformFile handle,bool should_close_source)73 IPC::PlatformFileForTransit MockRendererPpapiHost::ShareHandleWithRemote(
74     base::PlatformFile handle,
75     bool should_close_source) {
76   NOTIMPLEMENTED();
77   return IPC::InvalidPlatformFileForTransit();
78 }
79 
IsRunningInProcess() const80 bool MockRendererPpapiHost::IsRunningInProcess() const { return false; }
81 
GetPluginName() const82 std::string MockRendererPpapiHost::GetPluginName() const {
83   return std::string();
84 }
85 
SetToExternalPluginHost()86 void MockRendererPpapiHost::SetToExternalPluginHost() {
87   NOTIMPLEMENTED();
88 }
89 
CreateBrowserResourceHosts(PP_Instance instance,const std::vector<IPC::Message> & nested_msgs,const base::Callback<void (const std::vector<int> &)> & callback) const90 void MockRendererPpapiHost::CreateBrowserResourceHosts(
91     PP_Instance instance,
92     const std::vector<IPC::Message>& nested_msgs,
93     const base::Callback<void(const std::vector<int>&)>& callback) const {
94   callback.Run(std::vector<int>(nested_msgs.size(), 0));
95   return;
96 }
97 
GetDocumentURL(PP_Instance instance) const98 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const {
99   NOTIMPLEMENTED();
100   return GURL();
101 }
102 
103 }  // namespace content
104