Chromium Code Reviews| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "third_party/WebKit/public/web/WebView.h" | 28 #include "third_party/WebKit/public/web/WebView.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 #include "url/origin.h" | 30 #include "url/origin.h" |
| 31 | 31 |
| 32 using base::UserMetricsAction; | 32 using base::UserMetricsAction; |
| 33 using content::PluginInstanceThrottler; | 33 using content::PluginInstanceThrottler; |
| 34 using content::RenderThread; | 34 using content::RenderThread; |
| 35 | 35 |
| 36 namespace plugins { | 36 namespace plugins { |
| 37 | 37 |
| 38 // TODO(tommycli): After a size update, re-check the size after this delay, as | |
| 39 // Blink can report incorrect sizes to plugins while the compositing state is | |
| 40 // dirty. Chosen because it seems to work. | |
| 41 const int kSizeChangeRecheckDelayMilliseconds = 100; | |
|
chrishtr
2016/03/04 05:22:09
Strictly speaking, the change to this file has to
| |
| 42 | |
| 43 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { | 38 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { |
| 44 DCHECK(!is_blocked_for_power_saver_poster_); | 39 DCHECK(!is_blocked_for_power_saver_poster_); |
| 45 is_blocked_for_power_saver_poster_ = true; | 40 is_blocked_for_power_saver_poster_ = true; |
| 46 | 41 |
| 47 render_frame()->RegisterPeripheralPlugin( | 42 render_frame()->RegisterPeripheralPlugin( |
| 48 url::Origin(GURL(GetPluginParams().url)), | 43 url::Origin(GURL(GetPluginParams().url)), |
| 49 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, | 44 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, |
| 50 weak_factory_.GetWeakPtr(), | 45 weak_factory_.GetWeakPtr(), |
| 51 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); | 46 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); |
| 52 } | 47 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 if (!power_saver_enabled_ || !finished_loading_) | 188 if (!power_saver_enabled_ || !finished_loading_) |
| 194 return; | 189 return; |
| 195 | 190 |
| 196 // Only update the unobscured rect during the recheck phase. Also early exit | 191 // Only update the unobscured rect during the recheck phase. Also early exit |
| 197 // to prevent reentrancy issues. | 192 // to prevent reentrancy issues. |
| 198 if (in_size_recheck_) { | 193 if (in_size_recheck_) { |
| 199 unobscured_rect_ = unobscured_rect; | 194 unobscured_rect_ = unobscured_rect; |
| 200 return; | 195 return; |
| 201 } | 196 } |
| 202 | 197 |
| 203 if (!size_update_timer_.IsRunning()) { | 198 RecheckSizeAndMaybeUnthrottle(); |
| 204 // TODO(tommycli): We have to post a delayed task to recheck the size, as | |
| 205 // Blink can report wrong sizes for partially obscured plugins while the | |
| 206 // compositing state is dirty. https://crbug.com/343769 | |
| 207 size_update_timer_.Start( | |
| 208 FROM_HERE, | |
| 209 base::TimeDelta::FromMilliseconds(kSizeChangeRecheckDelayMilliseconds), | |
| 210 base::Bind(&LoadablePluginPlaceholder::RecheckSizeAndMaybeUnthrottle, | |
| 211 weak_factory_.GetWeakPtr())); | |
| 212 } | |
| 213 } | 199 } |
| 214 | 200 |
| 215 void LoadablePluginPlaceholder::WasShown() { | 201 void LoadablePluginPlaceholder::WasShown() { |
| 216 if (is_blocked_for_background_tab_) { | 202 if (is_blocked_for_background_tab_) { |
| 217 is_blocked_for_background_tab_ = false; | 203 is_blocked_for_background_tab_ = false; |
| 218 if (!LoadingBlocked()) | 204 if (!LoadingBlocked()) |
| 219 LoadPlugin(); | 205 LoadPlugin(); |
| 220 } | 206 } |
| 221 } | 207 } |
| 222 | 208 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG) { | 362 content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG) { |
| 377 render_frame()->WhitelistContentOrigin(content_origin); | 363 render_frame()->WhitelistContentOrigin(content_origin); |
| 378 } | 364 } |
| 379 } | 365 } |
| 380 | 366 |
| 381 heuristic_run_before_ = true; | 367 heuristic_run_before_ = true; |
| 382 } | 368 } |
| 383 } | 369 } |
| 384 | 370 |
| 385 } // namespace plugins | 371 } // namespace plugins |
| OLD | NEW |