| 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 "chrome/renderer/plugins/plugin_preroller.h" | 5 #include "chrome/renderer/plugins/plugin_preroller.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "chrome/grit/renderer_resources.h" | 8 #include "chrome/grit/renderer_resources.h" |
| 9 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" | 9 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
| 10 #include "third_party/WebKit/public/platform/WebRect.h" | 10 #include "third_party/WebKit/public/platform/WebRect.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 keyframe_data_url_ = GURL(data_url_header + data_url_body); | 54 keyframe_data_url_ = GURL(data_url_header + data_url_body); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void PluginPreroller::OnThrottleStateChange() { | 57 void PluginPreroller::OnThrottleStateChange() { |
| 58 if (!throttler_->IsThrottled()) | 58 if (!throttler_->IsThrottled()) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 ChromePluginPlaceholder* placeholder = | 61 ChromePluginPlaceholder* placeholder = |
| 62 ChromePluginPlaceholder::CreateBlockedPlugin( | 62 ChromePluginPlaceholder::CreateBlockedPlugin( |
| 63 render_frame(), frame_, params_, info_, identifier_, name_, | 63 render_frame(), frame_, params_, info_, identifier_, name_, |
| 64 IDR_PLUGIN_POSTER_HTML, message_, keyframe_data_url_.spec(), GURL()); | 64 IDR_PLUGIN_POSTER_HTML, message_, keyframe_data_url_.spec(), GURL(), |
| 65 throttler_->GetSize()); |
| 65 placeholder->SetPremadePlugin(throttler_); | 66 placeholder->SetPremadePlugin(throttler_); |
| 66 placeholder->set_power_saver_enabled(true); | 67 placeholder->set_power_saver_enabled(true); |
| 67 placeholder->set_allow_loading(true); | 68 placeholder->set_allow_loading(true); |
| 68 | 69 |
| 69 blink::WebPluginContainer* container = | 70 blink::WebPluginContainer* container = |
| 70 throttler_->GetWebPlugin()->container(); | 71 throttler_->GetWebPlugin()->container(); |
| 71 container->setPlugin(placeholder->plugin()); | 72 container->setPlugin(placeholder->plugin()); |
| 72 | 73 |
| 73 bool success = placeholder->plugin()->initialize(container); | 74 bool success = placeholder->plugin()->initialize(container); |
| 74 DCHECK(success); | 75 DCHECK(success); |
| 75 | 76 |
| 76 container->invalidate(); | 77 container->invalidate(); |
| 77 container->reportGeometry(); | 78 container->reportGeometry(); |
| 78 | 79 |
| 79 delete this; | 80 delete this; |
| 80 } | 81 } |
| 81 | 82 |
| 82 void PluginPreroller::OnThrottlerDestroyed() { | 83 void PluginPreroller::OnThrottlerDestroyed() { |
| 83 throttler_ = nullptr; | 84 throttler_ = nullptr; |
| 84 delete this; | 85 delete this; |
| 85 } | 86 } |
| OLD | NEW |