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