| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 std::string data_url_header = "data:image/png;base64,"; | 51 std::string data_url_header = "data:image/png;base64,"; |
| 52 std::string data_url_body; | 52 std::string data_url_body; |
| 53 base::Base64Encode(png_as_string, &data_url_body); | 53 base::Base64Encode(png_as_string, &data_url_body); |
| 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 PlaceholderPosterInfo poster_info; |
| 62 poster_info.poster_attribute = keyframe_data_url_.spec(); |
| 63 poster_info.custom_poster_size = throttler_->GetSize(); |
| 64 |
| 61 ChromePluginPlaceholder* placeholder = | 65 ChromePluginPlaceholder* placeholder = |
| 62 ChromePluginPlaceholder::CreateBlockedPlugin( | 66 ChromePluginPlaceholder::CreateBlockedPlugin( |
| 63 render_frame(), frame_, params_, info_, identifier_, name_, | 67 render_frame(), frame_, params_, info_, identifier_, name_, |
| 64 IDR_PLUGIN_POSTER_HTML, message_, keyframe_data_url_.spec(), GURL()); | 68 IDR_PLUGIN_POSTER_HTML, message_, poster_info); |
| 65 placeholder->SetPremadePlugin(throttler_); | 69 placeholder->SetPremadePlugin(throttler_); |
| 66 placeholder->set_power_saver_enabled(true); | 70 placeholder->set_power_saver_enabled(true); |
| 67 placeholder->set_allow_loading(true); | 71 placeholder->set_allow_loading(true); |
| 68 | 72 |
| 69 blink::WebPluginContainer* container = | 73 blink::WebPluginContainer* container = |
| 70 throttler_->GetWebPlugin()->container(); | 74 throttler_->GetWebPlugin()->container(); |
| 71 container->setPlugin(placeholder->plugin()); | 75 container->setPlugin(placeholder->plugin()); |
| 72 | 76 |
| 73 bool success = placeholder->plugin()->initialize(container); | 77 bool success = placeholder->plugin()->initialize(container); |
| 74 DCHECK(success); | 78 DCHECK(success); |
| 75 | 79 |
| 76 container->invalidate(); | 80 container->invalidate(); |
| 77 container->reportGeometry(); | 81 container->reportGeometry(); |
| 78 | 82 |
| 79 delete this; | 83 delete this; |
| 80 } | 84 } |
| 81 | 85 |
| 82 void PluginPreroller::OnThrottlerDestroyed() { | 86 void PluginPreroller::OnThrottlerDestroyed() { |
| 83 throttler_ = nullptr; | 87 throttler_ = nullptr; |
| 84 delete this; | 88 delete this; |
| 85 } | 89 } |
| OLD | NEW |