| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/public/renderer/renderer_ppapi_host.h" | 10 #include "content/public/renderer/renderer_ppapi_host.h" |
| 11 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" | 11 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 12 #include "ppapi/host/ppapi_host.h" | 12 #include "ppapi/host/ppapi_host.h" |
| 13 #include "ppapi/proxy/resource_message_test_sink.h" | 13 #include "ppapi/proxy/resource_message_test_sink.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class FakePepperPluginInstance; | 16 class FakePepperPluginInstance; |
| 17 class PluginModule; | 17 class PluginModule; |
| 18 | 18 |
| 19 // A mock RendererPpapiHost for testing resource hosts. Messages sent by | 19 // A mock RendererPpapiHost for testing resource hosts. Messages sent by |
| 20 // resources through this will get added to the test sink. | 20 // resources through this will get added to the test sink. |
| 21 class MockRendererPpapiHost : public RendererPpapiHost { | 21 class MockRendererPpapiHost : public RendererPpapiHost { |
| 22 public: | 22 public: |
| 23 // This function takes the RenderView and instance that the mock resource | 23 // This function takes the RenderView and instance that the mock resource |
| 24 // host will be associated with. | 24 // host will be associated with. |
| 25 MockRendererPpapiHost(RenderView* render_view, | 25 MockRendererPpapiHost(RenderView* render_view, PP_Instance instance); |
| 26 PP_Instance instance); | |
| 27 virtual ~MockRendererPpapiHost(); | 26 virtual ~MockRendererPpapiHost(); |
| 28 | 27 |
| 29 ppapi::proxy::ResourceMessageTestSink& sink() { return sink_; } | 28 ppapi::proxy::ResourceMessageTestSink& sink() { return sink_; } |
| 30 PP_Instance pp_instance() const { return pp_instance_; } | 29 PP_Instance pp_instance() const { return pp_instance_; } |
| 31 | 30 |
| 32 // Sets whether there is currently a user gesture. Defaults to false. | 31 // Sets whether there is currently a user gesture. Defaults to false. |
| 33 void set_has_user_gesture(bool gesture) { has_user_gesture_ = gesture; } | 32 void set_has_user_gesture(bool gesture) { has_user_gesture_ = gesture; } |
| 34 | 33 |
| 35 // RendererPpapiHost. | 34 // RendererPpapiHost. |
| 36 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; | 35 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; |
| 37 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; | 36 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; |
| 38 virtual PepperPluginInstance* GetPluginInstance( | 37 virtual PepperPluginInstance* GetPluginInstance(PP_Instance instance) const |
| 39 PP_Instance instance) const OVERRIDE; | 38 OVERRIDE; |
| 40 virtual RenderFrame* GetRenderFrameForInstance( | 39 virtual RenderFrame* GetRenderFrameForInstance(PP_Instance instance) const |
| 41 PP_Instance instance) const OVERRIDE; | 40 OVERRIDE; |
| 42 virtual RenderView* GetRenderViewForInstance( | 41 virtual RenderView* GetRenderViewForInstance(PP_Instance instance) const |
| 43 PP_Instance instance) const OVERRIDE; | 42 OVERRIDE; |
| 44 virtual blink::WebPluginContainer* GetContainerForInstance( | 43 virtual blink::WebPluginContainer* GetContainerForInstance( |
| 45 PP_Instance instance) const OVERRIDE; | 44 PP_Instance instance) const OVERRIDE; |
| 46 virtual base::ProcessId GetPluginPID() const OVERRIDE; | 45 virtual base::ProcessId GetPluginPID() const OVERRIDE; |
| 47 virtual bool HasUserGesture(PP_Instance instance) const OVERRIDE; | 46 virtual bool HasUserGesture(PP_Instance instance) const OVERRIDE; |
| 48 virtual int GetRoutingIDForWidget(PP_Instance instance) const OVERRIDE; | 47 virtual int GetRoutingIDForWidget(PP_Instance instance) const OVERRIDE; |
| 49 virtual gfx::Point PluginPointToRenderFrame( | 48 virtual gfx::Point PluginPointToRenderFrame(PP_Instance instance, |
| 50 PP_Instance instance, | 49 const gfx::Point& pt) const |
| 51 const gfx::Point& pt) const OVERRIDE; | 50 OVERRIDE; |
| 52 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | 51 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( |
| 53 base::PlatformFile handle, | 52 base::PlatformFile handle, |
| 54 bool should_close_source) OVERRIDE; | 53 bool should_close_source) OVERRIDE; |
| 55 virtual bool IsRunningInProcess() const OVERRIDE; | 54 virtual bool IsRunningInProcess() const OVERRIDE; |
| 56 virtual void CreateBrowserResourceHosts( | 55 virtual void CreateBrowserResourceHosts( |
| 57 PP_Instance instance, | 56 PP_Instance instance, |
| 58 const std::vector<IPC::Message>& nested_msgs, | 57 const std::vector<IPC::Message>& nested_msgs, |
| 59 const base::Callback<void( | 58 const base::Callback<void(const std::vector<int>&)>& callback) const |
| 60 const std::vector<int>&)>& callback) const OVERRIDE; | 59 OVERRIDE; |
| 61 virtual GURL GetDocumentURL(PP_Instance instance) const OVERRIDE; | 60 virtual GURL GetDocumentURL(PP_Instance instance) const OVERRIDE; |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 ppapi::proxy::ResourceMessageTestSink sink_; | 63 ppapi::proxy::ResourceMessageTestSink sink_; |
| 65 ppapi::host::PpapiHost ppapi_host_; | 64 ppapi::host::PpapiHost ppapi_host_; |
| 66 | 65 |
| 67 RenderView* render_view_; | 66 RenderView* render_view_; |
| 68 PP_Instance pp_instance_; | 67 PP_Instance pp_instance_; |
| 69 | 68 |
| 70 bool has_user_gesture_; | 69 bool has_user_gesture_; |
| 71 | 70 |
| 72 scoped_ptr<FakePepperPluginInstance> plugin_instance_; | 71 scoped_ptr<FakePepperPluginInstance> plugin_instance_; |
| 73 | 72 |
| 74 DISALLOW_COPY_AND_ASSIGN(MockRendererPpapiHost); | 73 DISALLOW_COPY_AND_ASSIGN(MockRendererPpapiHost); |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 } // namespace content | 76 } // namespace content |
| 78 | 77 |
| 79 #endif // CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ | 78 #endif // CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| OLD | NEW |