| 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" | 5 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 class MockContentClient : public TestContentClient { | 160 class MockContentClient : public TestContentClient { |
| 161 public: | 161 public: |
| 162 void AddPepperPlugins(std::vector<PepperPluginInfo>* plugins) override { | 162 void AddPepperPlugins(std::vector<PepperPluginInfo>* plugins) override { |
| 163 plugins->push_back(GetPluginInfo()); | 163 plugins->push_back(GetPluginInfo()); |
| 164 } | 164 } |
| 165 }; | 165 }; |
| 166 class MockContentRendererClient : public ContentRendererClient { | 166 class MockContentRendererClient : public ContentRendererClient { |
| 167 public: | 167 public: |
| 168 bool OverrideCreatePlugin(RenderFrame* render_frame, | 168 bool OverrideCreatePlugin(RenderFrame* render_frame, |
| 169 blink::WebLocalFrame* frame, | |
| 170 const blink::WebPluginParams& params, | 169 const blink::WebPluginParams& params, |
| 171 blink::WebPlugin** plugin) override { | 170 blink::WebPlugin** plugin) override { |
| 172 current_test_->throttler_ = | 171 current_test_->throttler_ = |
| 173 new PluginInstanceThrottlerImpl(RenderFrame::DONT_RECORD_DECISION); | 172 new PluginInstanceThrottlerImpl(RenderFrame::DONT_RECORD_DECISION); |
| 174 current_test_->throttler_->AddObserver(current_test_); | 173 current_test_->throttler_->AddObserver(current_test_); |
| 175 *plugin = render_frame->CreatePlugin( | 174 *plugin = render_frame->CreatePlugin( |
| 176 frame, GetPluginInfo().ToWebPluginInfo(), params, | 175 GetPluginInfo().ToWebPluginInfo(), params, |
| 177 base::WrapUnique(current_test_->throttler_)); | 176 base::WrapUnique(current_test_->throttler_)); |
| 178 return *plugin; | 177 return *plugin; |
| 179 } | 178 } |
| 180 }; | 179 }; |
| 181 | 180 |
| 182 PluginInstanceThrottlerImpl* throttler_; | 181 PluginInstanceThrottlerImpl* throttler_; |
| 183 bool throttle_engaged_; | 182 bool throttle_engaged_; |
| 184 PP_Module pp_module_; | 183 PP_Module pp_module_; |
| 185 PP_Instance pp_instance_; | 184 PP_Instance pp_instance_; |
| 186 PP_Resource graphics2d_; | 185 PP_Resource graphics2d_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 203 LoadHTML("<!DOCTYPE html><object type='test/always-throttle'></object>"); | 202 LoadHTML("<!DOCTYPE html><object type='test/always-throttle'></object>"); |
| 204 EXPECT_NE(0, pp_instance_); | 203 EXPECT_NE(0, pp_instance_); |
| 205 LoadHTML(""); | 204 LoadHTML(""); |
| 206 EXPECT_EQ(0, pp_instance_); | 205 EXPECT_EQ(0, pp_instance_); |
| 207 EXPECT_FALSE(throttle_engaged_); | 206 EXPECT_FALSE(throttle_engaged_); |
| 208 } | 207 } |
| 209 | 208 |
| 210 } // unnamed namespace | 209 } // unnamed namespace |
| 211 | 210 |
| 212 } // namespace content | 211 } // namespace content |
| OLD | NEW |