OLD | NEW |
(Empty) | |
| 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 #ifndef CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 11 #include "ppapi/host/ppapi_host.h" |
| 12 #include "ppapi/proxy/resource_message_test_sink.h" |
| 13 |
| 14 namespace webkit { |
| 15 namespace ppapi { |
| 16 class PluginInstance; |
| 17 class PluginModule; |
| 18 } |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 |
| 23 // A mock RendererPpapiHost for testing resource hosts. Messages sent by |
| 24 // resources through this will get added to the test sink. |
| 25 class MockRendererPpapiHost : public RendererPpapiHost { |
| 26 public: |
| 27 // This function takes the RenderView and instance that the mock resource |
| 28 // host will be associated with. |
| 29 MockRendererPpapiHost(RenderView* render_view, |
| 30 PP_Instance instance); |
| 31 virtual ~MockRendererPpapiHost(); |
| 32 |
| 33 ppapi::proxy::ResourceMessageTestSink& sink() { return sink_; } |
| 34 PP_Instance pp_instance() const { return pp_instance_; } |
| 35 |
| 36 void set_has_user_gesture(bool gesture) { has_user_gesture_ = gesture; } |
| 37 |
| 38 // RendererPpapiHost. |
| 39 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; |
| 40 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; |
| 41 virtual RenderView* GetRenderViewForInstance( |
| 42 PP_Instance instance) const OVERRIDE; |
| 43 virtual bool HasUserGesture(PP_Instance instance) const OVERRIDE; |
| 44 |
| 45 private: |
| 46 ppapi::proxy::ResourceMessageTestSink sink_; |
| 47 ppapi::host::PpapiHost ppapi_host_; |
| 48 |
| 49 RenderView* render_view_; |
| 50 PP_Instance pp_instance_; |
| 51 |
| 52 bool has_user_gesture_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(MockRendererPpapiHost); |
| 55 }; |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_ |
| 60 |
OLD | NEW |