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 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" | 5 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" |
6 | 6 |
| 7 #include "content/public/renderer/render_view.h" |
7 #include "content/renderer/pepper/fake_pepper_plugin_instance.h" | 8 #include "content/renderer/pepper/fake_pepper_plugin_instance.h" |
8 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 MockRendererPpapiHost::MockRendererPpapiHost(RenderView* render_view, | 13 MockRendererPpapiHost::MockRendererPpapiHost(RenderView* render_view, |
13 PP_Instance instance) | 14 PP_Instance instance) |
14 : sink_(), | 15 : sink_(), |
15 ppapi_host_(&sink_, ppapi::PpapiPermissions()), | 16 ppapi_host_(&sink_, ppapi::PpapiPermissions()), |
16 render_view_(render_view), | 17 render_view_(render_view), |
17 pp_instance_(instance), | 18 pp_instance_(instance), |
18 has_user_gesture_(false), | 19 has_user_gesture_(false), |
19 plugin_instance_(new FakePepperPluginInstance) {} | 20 plugin_instance_(new FakePepperPluginInstance) { |
| 21 if (render_view) |
| 22 render_frame_ = render_view->GetMainRenderFrame(); |
| 23 } |
20 | 24 |
21 MockRendererPpapiHost::~MockRendererPpapiHost() {} | 25 MockRendererPpapiHost::~MockRendererPpapiHost() {} |
22 | 26 |
23 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() { | 27 ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() { |
24 return &ppapi_host_; | 28 return &ppapi_host_; |
25 } | 29 } |
26 | 30 |
27 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const { | 31 bool MockRendererPpapiHost::IsValidInstance(PP_Instance instance) const { |
28 return instance == pp_instance_; | 32 return instance == pp_instance_; |
29 } | 33 } |
30 | 34 |
31 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance( | 35 PepperPluginInstance* MockRendererPpapiHost::GetPluginInstance( |
32 PP_Instance instance) const { | 36 PP_Instance instance) const { |
33 return plugin_instance_.get(); | 37 return plugin_instance_.get(); |
34 } | 38 } |
35 | 39 |
36 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance( | 40 RenderFrame* MockRendererPpapiHost::GetRenderFrameForInstance( |
37 PP_Instance instance) const { | 41 PP_Instance instance) const { |
| 42 if (instance == pp_instance_) |
| 43 return render_frame_; |
38 return NULL; | 44 return NULL; |
39 } | 45 } |
40 | 46 |
41 RenderView* MockRendererPpapiHost::GetRenderViewForInstance( | 47 RenderView* MockRendererPpapiHost::GetRenderViewForInstance( |
42 PP_Instance instance) const { | 48 PP_Instance instance) const { |
43 if (instance == pp_instance_) | 49 if (instance == pp_instance_) |
44 return render_view_; | 50 return render_view_; |
45 return NULL; | 51 return NULL; |
46 } | 52 } |
47 | 53 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 callback.Run(std::vector<int>(nested_msgs.size(), 0)); | 107 callback.Run(std::vector<int>(nested_msgs.size(), 0)); |
102 return; | 108 return; |
103 } | 109 } |
104 | 110 |
105 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const { | 111 GURL MockRendererPpapiHost::GetDocumentURL(PP_Instance instance) const { |
106 NOTIMPLEMENTED(); | 112 NOTIMPLEMENTED(); |
107 return GURL(); | 113 return GURL(); |
108 } | 114 } |
109 | 115 |
110 } // namespace content | 116 } // namespace content |
OLD | NEW |