Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / pepper / mock_renderer_ppapi_host.cc
blob1ff1ec5898e8106e10630408e703fff899680aba
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.
5 #include "content/renderer/pepper/mock_renderer_ppapi_host.h"
7 #include "content/renderer/pepper/fake_pepper_plugin_instance.h"
8 #include "ui/gfx/geometry/point.h"
10 namespace content {
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) {}
21 MockRendererPpapiHost::~MockRendererPpapiHost() {}
23 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() {
24 return &ppapi_host_;
27 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const {
28 return instance == pp_instance_;
31 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance(
32 PP_Instance instance) const {
33 return plugin_instance_.get();
36 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance(
37 PP_Instance instance) const {
38 return NULL;
41 RenderView* MockRendererPpapiHost::GetRenderViewForInstance(
42 PP_Instance instance) const {
43 if (instance == pp_instance_)
44 return render_view_;
45 return NULL;
48 blink::WebPluginContainer* MockRendererPpapiHost::GetContainerForInstance(
49 PP_Instance instance) const {
50 NOTIMPLEMENTED();
51 return NULL;
54 base::ProcessId MockRendererPpapiHost::GetPluginPID() const {
55 NOTIMPLEMENTED();
56 return base::kNullProcessId;
59 bool MockRendererPpapiHost::HasUserGesture(PP_Instance instance) const {
60 return has_user_gesture_;
63 int MockRendererPpapiHost::GetRoutingIDForWidget(PP_Instance instance) const {
64 return 0;
67 gfx::Point MockRendererPpapiHost::PluginPointToRenderFrame(
68 PP_Instance instance,
69 const gfx::Point& pt) const {
70 return gfx::Point();
73 IPC::PlatformFileForTransit MockRendererPpapiHost::ShareHandleWithRemote(
74 base::PlatformFile handle,
75 bool should_close_source) {
76 NOTIMPLEMENTED();
77 return IPC::InvalidPlatformFileForTransit();
80 bool MockRendererPpapiHost::IsRunningInProcess() const { return false; }
82 std::string MockRendererPpapiHost::GetPluginName() const {
83 return std::string();
86 void MockRendererPpapiHost::SetToExternalPluginHost() {
87 NOTIMPLEMENTED();
90 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;
98 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const {
99 NOTIMPLEMENTED();
100 return GURL();
103 } // namespace content