Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (!allow_loading_) { 271 if (!allow_loading_) {
272 NOTREACHED(); 272 NOTREACHED();
273 return; 273 return;
274 } 274 }
275 275
276 if (premade_throttler_) { 276 if (premade_throttler_) {
277 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */); 277 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */);
278 ReplacePlugin(premade_throttler_->GetWebPlugin()); 278 ReplacePlugin(premade_throttler_->GetWebPlugin());
279 premade_throttler_ = nullptr; 279 premade_throttler_ = nullptr;
280 } else { 280 } else {
281 // TODO(mmenke): In the case of prerendering, feed into 281 ReplacePlugin(CreatePlugin());
282 // ChromeContentRendererClient::CreatePlugin instead, to
283 // reduce the chance of future regressions.
284 scoped_ptr<PluginInstanceThrottler> throttler;
285 #if defined(ENABLE_PLUGINS)
286 // If the plugin has already been marked essential in its placeholder form,
287 // we shouldn't create a new throttler and start the process all over again.
288 if (power_saver_enabled_)
289 throttler = PluginInstanceThrottler::Create();
290 #endif
291 WebPlugin* plugin = render_frame()->CreatePlugin(
292 GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass());
293
294 ReplacePlugin(plugin);
295 } 282 }
296 } 283 }
297 284
298 void LoadablePluginPlaceholder::LoadCallback() { 285 void LoadablePluginPlaceholder::LoadCallback() {
299 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); 286 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click"));
300 #if defined(ENABLE_PLUGINS) 287 #if defined(ENABLE_PLUGINS)
301 // If the user specifically clicks on the plugin content's placeholder, 288 // If the user specifically clicks on the plugin content's placeholder,
302 // disable power saver throttling for this instance. 289 // disable power saver throttling for this instance.
303 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); 290 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK);
304 #endif 291 #endif
(...skipping 22 matching lines...) Expand all
327 } 314 }
328 315
329 const content::WebPluginInfo& LoadablePluginPlaceholder::GetPluginInfo() const { 316 const content::WebPluginInfo& LoadablePluginPlaceholder::GetPluginInfo() const {
330 return plugin_info_; 317 return plugin_info_;
331 } 318 }
332 319
333 void LoadablePluginPlaceholder::SetIdentifier(const std::string& identifier) { 320 void LoadablePluginPlaceholder::SetIdentifier(const std::string& identifier) {
334 identifier_ = identifier; 321 identifier_ = identifier;
335 } 322 }
336 323
324 const std::string& LoadablePluginPlaceholder::GetIdentifier() const {
325 return identifier_;
326 }
327
337 bool LoadablePluginPlaceholder::LoadingBlocked() const { 328 bool LoadablePluginPlaceholder::LoadingBlocked() const {
338 DCHECK(allow_loading_); 329 DCHECK(allow_loading_);
339 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ || 330 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ ||
340 is_blocked_for_prerendering_; 331 is_blocked_for_prerendering_;
341 } 332 }
342 333
343 } // namespace plugins 334 } // namespace plugins
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698