| 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 "components/plugins/renderer/loadable_plugin_placeholder.h" | 5 #include "components/plugins/renderer/loadable_plugin_placeholder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 using content::PluginInstanceThrottler; | 34 using content::PluginInstanceThrottler; |
| 35 using content::RenderFrame; | 35 using content::RenderFrame; |
| 36 using content::RenderThread; | 36 using content::RenderThread; |
| 37 | 37 |
| 38 namespace plugins { | 38 namespace plugins { |
| 39 | 39 |
| 40 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { | 40 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { |
| 41 DCHECK(!is_blocked_for_power_saver_poster_); | 41 DCHECK(!is_blocked_for_power_saver_poster_); |
| 42 is_blocked_for_power_saver_poster_ = true; | 42 is_blocked_for_power_saver_poster_ = true; |
| 43 | 43 |
| 44 DCHECK(render_frame()); |
| 44 render_frame()->RegisterPeripheralPlugin( | 45 render_frame()->RegisterPeripheralPlugin( |
| 45 url::Origin(GURL(GetPluginParams().url)), | 46 url::Origin(GURL(GetPluginParams().url)), |
| 46 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, | 47 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, |
| 47 weak_factory_.GetWeakPtr(), | 48 weak_factory_.GetWeakPtr(), |
| 48 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); | 49 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void LoadablePluginPlaceholder::SetPremadePlugin( | 52 void LoadablePluginPlaceholder::SetPremadePlugin( |
| 52 content::PluginInstanceThrottler* throttler) { | 53 content::PluginInstanceThrottler* throttler) { |
| 53 DCHECK(throttler); | 54 DCHECK(throttler); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Pass through JavaScript access to the underlying throttled plugin. | 175 // Pass through JavaScript access to the underlying throttled plugin. |
| 175 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { | 176 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { |
| 176 return premade_throttler_->GetWebPlugin()->V8ScriptableObject(isolate); | 177 return premade_throttler_->GetWebPlugin()->V8ScriptableObject(isolate); |
| 177 } | 178 } |
| 178 return v8::Local<v8::Object>(); | 179 return v8::Local<v8::Object>(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void LoadablePluginPlaceholder::OnUnobscuredRectUpdate( | 182 void LoadablePluginPlaceholder::OnUnobscuredRectUpdate( |
| 182 const gfx::Rect& unobscured_rect) { | 183 const gfx::Rect& unobscured_rect) { |
| 183 DCHECK(content::RenderThread::Get()); | 184 DCHECK(content::RenderThread::Get()); |
| 185 if (!render_frame()) |
| 186 return; |
| 184 | 187 |
| 185 if (!plugin() || !finished_loading_) | 188 if (!plugin() || !finished_loading_) |
| 186 return; | 189 return; |
| 187 | 190 |
| 188 if (!is_blocked_for_tinyness_ && !is_blocked_for_power_saver_poster_) | 191 if (!is_blocked_for_tinyness_ && !is_blocked_for_power_saver_poster_) |
| 189 return; | 192 return; |
| 190 | 193 |
| 191 if (unobscured_rect_ == unobscured_rect) | 194 if (unobscured_rect_ == unobscured_rect) |
| 192 return; | 195 return; |
| 193 | 196 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 return identifier_; | 371 return identifier_; |
| 369 } | 372 } |
| 370 | 373 |
| 371 bool LoadablePluginPlaceholder::LoadingBlocked() const { | 374 bool LoadablePluginPlaceholder::LoadingBlocked() const { |
| 372 DCHECK(allow_loading_); | 375 DCHECK(allow_loading_); |
| 373 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || | 376 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || |
| 374 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; | 377 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; |
| 375 } | 378 } |
| 376 | 379 |
| 377 } // namespace plugins | 380 } // namespace plugins |
| OLD | NEW |