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 }
21
~MockRendererPpapiHost()22 MockRendererPpapiHost::~MockRendererPpapiHost() {
23 }
24
GetPpapiHost()25 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() {
26 return &ppapi_host_;
27 }
28
IsValidInstance(PP_Instance instance) const29 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const {
30 return instance == pp_instance_;
31 }
32
GetPluginInstance(PP_Instance instance) const33 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance(
34 PP_Instance instance) const {
35 return plugin_instance_.get();
36 }
37
GetRenderFrameForInstance(PP_Instance instance) const38 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance(
39 PP_Instance instance) const {
40 return NULL;
41 }
42
GetRenderViewForInstance(PP_Instance instance) const43 RenderView* MockRendererPpapiHost::GetRenderViewForInstance(
44 PP_Instance instance) const {
45 if (instance == pp_instance_)
46 return render_view_;
47 return NULL;
48 }
49
GetContainerForInstance(PP_Instance instance) const50 blink::WebPluginContainer* MockRendererPpapiHost::GetContainerForInstance(
51 PP_Instance instance) const {
52 NOTIMPLEMENTED();
53 return NULL;
54 }
55
GetPluginPID() const56 base::ProcessId MockRendererPpapiHost::GetPluginPID() const {
57 NOTIMPLEMENTED();
58 return base::kNullProcessId;
59 }
60
HasUserGesture(PP_Instance instance) const61 bool MockRendererPpapiHost::HasUserGesture(PP_Instance instance) const {
62 return has_user_gesture_;
63 }
64
GetRoutingIDForWidget(PP_Instance instance) const65 int MockRendererPpapiHost::GetRoutingIDForWidget(PP_Instance instance) const {
66 return 0;
67 }
68
PluginPointToRenderFrame(PP_Instance instance,const gfx::Point & pt) const69 gfx::Point MockRendererPpapiHost::PluginPointToRenderFrame(
70 PP_Instance instance,
71 const gfx::Point& pt) const {
72 return gfx::Point();
73 }
74
ShareHandleWithRemote(base::PlatformFile handle,bool should_close_source)75 IPC::PlatformFileForTransit MockRendererPpapiHost::ShareHandleWithRemote(
76 base::PlatformFile handle,
77 bool should_close_source) {
78 NOTIMPLEMENTED();
79 return IPC::InvalidPlatformFileForTransit();
80 }
81
IsRunningInProcess() const82 bool MockRendererPpapiHost::IsRunningInProcess() const {
83 return false;
84 }
85
CreateBrowserResourceHosts(PP_Instance instance,const std::vector<IPC::Message> & nested_msgs,const base::Callback<void (const std::vector<int> &)> & callback) const86 void MockRendererPpapiHost::CreateBrowserResourceHosts(
87 PP_Instance instance,
88 const std::vector<IPC::Message>& nested_msgs,
89 const base::Callback<void(const std::vector<int>&)>& callback) const {
90 callback.Run(std::vector<int>(nested_msgs.size(), 0));
91 return;
92 }
93
GetDocumentURL(PP_Instance instance) const94 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const {
95 NOTIMPLEMENTED();
96 return GURL();
97 }
98
99 } // namespace content
100