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 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 22 MockRendererPpapiHost::~MockRendererPpapiHost() { 23 } 24 25 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() { 26 return &ppapi_host_; 27 } 28 29 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const { 30 return instance == pp_instance_; 31 } 32 33 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance( 34 PP_Instance instance) const { 35 return plugin_instance_.get(); 36 } 37 38 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance( 39 PP_Instance instance) const { 40 return NULL; 41 } 42 43 RenderView* MockRendererPpapiHost::GetRenderViewForInstance( 44 PP_Instance instance) const { 45 if (instance == pp_instance_) 46 return render_view_; 47 return NULL; 48 } 49 50 blink::WebPluginContainer* MockRendererPpapiHost::GetContainerForInstance( 51 PP_Instance instance) const { 52 NOTIMPLEMENTED(); 53 return NULL; 54 } 55 56 base::ProcessId MockRendererPpapiHost::GetPluginPID() const { 57 NOTIMPLEMENTED(); 58 return base::kNullProcessId; 59 } 60 61 bool MockRendererPpapiHost::HasUserGesture(PP_Instance instance) const { 62 return has_user_gesture_; 63 } 64 65 int MockRendererPpapiHost::GetRoutingIDForWidget(PP_Instance instance) const { 66 return 0; 67 } 68 69 gfx::Point MockRendererPpapiHost::PluginPointToRenderFrame( 70 PP_Instance instance, 71 const gfx::Point& pt) const { 72 return gfx::Point(); 73 } 74 75 IPC::PlatformFileForTransit MockRendererPpapiHost::ShareHandleWithRemote( 76 base::PlatformFile handle, 77 bool should_close_source) { 78 NOTIMPLEMENTED(); 79 return IPC::InvalidPlatformFileForTransit(); 80 } 81 82 bool MockRendererPpapiHost::IsRunningInProcess() const { 83 return false; 84 } 85 86 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 94 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const { 95 NOTIMPLEMENTED(); 96 return GURL(); 97 } 98 99 } // namespace content 100