| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/pepper_webplugin_impl.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
| 9 #include "content/public/common/content_constants.h" | 12 #include "content/public/common/content_constants.h" |
| 10 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 11 #include "content/public/common/pepper_plugin_info.h" | 14 #include "content/public/common/pepper_plugin_info.h" |
| 12 #include "content/public/renderer/content_renderer_client.h" | 15 #include "content/public/renderer/content_renderer_client.h" |
| 13 #include "content/public/test/render_view_test.h" | 16 #include "content/public/test/render_view_test.h" |
| 14 #include "content/renderer/pepper/pepper_webplugin_impl.h" | |
| 15 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 17 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| 16 #include "content/renderer/pepper/plugin_module.h" | 18 #include "content/renderer/pepper/plugin_module.h" |
| 17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 19 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 18 #include "content/renderer/render_frame_impl.h" | 20 #include "content/renderer/render_frame_impl.h" |
| 19 #include "content/test/test_content_client.h" | 21 #include "content/test/test_content_client.h" |
| 20 #include "ppapi/c/pp_errors.h" | 22 #include "ppapi/c/pp_errors.h" |
| 21 #include "ppapi/c/ppb_core.h" | 23 #include "ppapi/c/ppb_core.h" |
| 22 #include "ppapi/c/ppb_graphics_2d.h" | 24 #include "ppapi/c/ppb_graphics_2d.h" |
| 23 #include "ppapi/c/ppb_image_data.h" | 25 #include "ppapi/c/ppb_image_data.h" |
| 24 #include "ppapi/c/ppb_instance.h" | 26 #include "ppapi/c/ppb_instance.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 164 } |
| 163 }; | 165 }; |
| 164 class MockContentRendererClient : public ContentRendererClient { | 166 class MockContentRendererClient : public ContentRendererClient { |
| 165 public: | 167 public: |
| 166 bool OverrideCreatePlugin(RenderFrame* render_frame, | 168 bool OverrideCreatePlugin(RenderFrame* render_frame, |
| 167 blink::WebLocalFrame* frame, | 169 blink::WebLocalFrame* frame, |
| 168 const blink::WebPluginParams& params, | 170 const blink::WebPluginParams& params, |
| 169 blink::WebPlugin** plugin) override { | 171 blink::WebPlugin** plugin) override { |
| 170 current_test_->throttler_ = new PluginInstanceThrottlerImpl; | 172 current_test_->throttler_ = new PluginInstanceThrottlerImpl; |
| 171 current_test_->throttler_->AddObserver(current_test_); | 173 current_test_->throttler_->AddObserver(current_test_); |
| 172 *plugin = render_frame->CreatePlugin(frame, | 174 *plugin = render_frame->CreatePlugin( |
| 173 GetPluginInfo().ToWebPluginInfo(), params, | 175 frame, GetPluginInfo().ToWebPluginInfo(), params, |
| 174 make_scoped_ptr(current_test_->throttler_)); | 176 base::WrapUnique(current_test_->throttler_)); |
| 175 return *plugin; | 177 return *plugin; |
| 176 } | 178 } |
| 177 }; | 179 }; |
| 178 | 180 |
| 179 PluginInstanceThrottlerImpl* throttler_; | 181 PluginInstanceThrottlerImpl* throttler_; |
| 180 bool throttle_engaged_; | 182 bool throttle_engaged_; |
| 181 PP_Module pp_module_; | 183 PP_Module pp_module_; |
| 182 PP_Instance pp_instance_; | 184 PP_Instance pp_instance_; |
| 183 PP_Resource graphics2d_; | 185 PP_Resource graphics2d_; |
| 184 static PepperWebPluginImplBrowserTest* current_test_; | 186 static PepperWebPluginImplBrowserTest* current_test_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 200 LoadHTML("<!DOCTYPE html><object type='test/always-throttle'></object>"); | 202 LoadHTML("<!DOCTYPE html><object type='test/always-throttle'></object>"); |
| 201 EXPECT_NE(0, pp_instance_); | 203 EXPECT_NE(0, pp_instance_); |
| 202 LoadHTML(""); | 204 LoadHTML(""); |
| 203 EXPECT_EQ(0, pp_instance_); | 205 EXPECT_EQ(0, pp_instance_); |
| 204 EXPECT_FALSE(throttle_engaged_); | 206 EXPECT_FALSE(throttle_engaged_); |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // unnamed namespace | 209 } // unnamed namespace |
| 208 | 210 |
| 209 } // namespace content | 211 } // namespace content |
| OLD | NEW |