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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 981623003: Plugin Power Saver: Implement srcset syntax for posters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return; 307 return;
308 } 308 }
309 } 309 }
310 310
311 if (power_saver_enabled) 311 if (power_saver_enabled)
312 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_ENABLED); 312 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_ENABLED);
313 else 313 else
314 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_DISABLED); 314 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_DISABLED);
315 } 315 }
316 316
317 GURL GetPluginInstancePosterImage(const blink::WebPluginParams& params, 317 std::string GetPluginInstancePosterAttribute(
318 const GURL& page_base_url) { 318 const blink::WebPluginParams& params) {
319 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); 319 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
320 320
321 for (size_t i = 0; i < params.attributeNames.size(); ++i) { 321 for (size_t i = 0; i < params.attributeNames.size(); ++i) {
322 if (params.attributeNames[i].utf8() == "poster" && 322 if (params.attributeNames[i].utf8() == "poster" &&
323 !params.attributeValues[i].isEmpty()) { 323 !params.attributeValues[i].isEmpty()) {
324 return page_base_url.Resolve(params.attributeValues[i].utf8()); 324 return params.attributeValues[i].utf8();
325 } 325 }
326 } 326 }
327 return GURL(); 327 return std::string();
328 } 328 }
329 #endif 329 #endif
330 330
331 #if defined(ENABLE_EXTENSIONS) 331 #if defined(ENABLE_EXTENSIONS)
332 bool IsStandaloneExtensionProcess() { 332 bool IsStandaloneExtensionProcess() {
333 return base::CommandLine::ForCurrentProcess()->HasSwitch( 333 return base::CommandLine::ForCurrentProcess()->HasSwitch(
334 extensions::switches::kExtensionProcess); 334 extensions::switches::kExtensionProcess);
335 } 335 }
336 #endif 336 #endif
337 } // namespace 337 } // namespace
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { 775 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
776 if (observer->AreNPAPIPluginsBlocked()) 776 if (observer->AreNPAPIPluginsBlocked())
777 status_value = 777 status_value =
778 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; 778 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
779 } 779 }
780 #endif 780 #endif
781 781
782 auto create_blocked_plugin = 782 auto create_blocked_plugin =
783 [&render_frame, &frame, &params, &info, &identifier, &group_name]( 783 [&render_frame, &frame, &params, &info, &identifier, &group_name](
784 int template_id, const base::string16& message) { 784 int template_id, const base::string16& message) {
785 return ChromePluginPlaceholder::CreateBlockedPlugin( 785 return ChromePluginPlaceholder::CreateBlockedPlugin(
786 render_frame, frame, params, info, identifier, group_name, 786 render_frame, frame, params, info, identifier, group_name,
787 template_id, message, GURL()); 787 template_id, message, std::string(), GURL());
788 }; 788 };
789 switch (status_value) { 789 switch (status_value) {
790 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { 790 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: {
791 NOTREACHED(); 791 NOTREACHED();
792 break; 792 break;
793 } 793 }
794 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: 794 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed:
795 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { 795 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: {
796 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 796 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
797 const bool is_nacl_plugin = 797 const bool is_nacl_plugin =
798 info.name == ASCIIToUTF16(nacl::kNaClPluginName); 798 info.name == ASCIIToUTF16(nacl::kNaClPluginName);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 #if defined(ENABLE_PLUGINS) 857 #if defined(ENABLE_PLUGINS)
858 bool power_saver_enabled = 858 bool power_saver_enabled =
859 status_value == 859 status_value ==
860 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 860 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
861 bool blocked_for_background_tab = 861 bool blocked_for_background_tab =
862 render_frame->IsHidden() && power_saver_enabled; 862 render_frame->IsHidden() && power_saver_enabled;
863 863
864 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) 864 if (info.name == ASCIIToUTF16(content::kFlashPluginName))
865 TrackPosterParamPresence(params, power_saver_enabled); 865 TrackPosterParamPresence(params, power_saver_enabled);
866 866
867 GURL poster_url; 867 std::string poster_attribute;
868 if (power_saver_enabled) { 868 if (power_saver_enabled)
869 poster_url = 869 poster_attribute = GetPluginInstancePosterAttribute(params);
870 GetPluginInstancePosterImage(params, frame->document().url());
871 }
872 870
873 // Delay loading plugins if prerendering. 871 // Delay loading plugins if prerendering.
874 // TODO(mmenke): In the case of prerendering, feed into 872 // TODO(mmenke): In the case of prerendering, feed into
875 // ChromeContentRendererClient::CreatePlugin instead, to 873 // ChromeContentRendererClient::CreatePlugin instead, to
876 // reduce the chance of future regressions. 874 // reduce the chance of future regressions.
877 bool is_prerendering = 875 bool is_prerendering =
878 prerender::PrerenderHelper::IsPrerendering(render_frame); 876 prerender::PrerenderHelper::IsPrerendering(render_frame);
879 if (blocked_for_background_tab || is_prerendering || 877 if (blocked_for_background_tab || is_prerendering ||
880 poster_url.is_valid()) { 878 !poster_attribute.empty()) {
881 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( 879 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin(
882 render_frame, frame, params, info, identifier, group_name, 880 render_frame, frame, params, info, identifier, group_name,
883 poster_url.is_valid() ? IDR_PLUGIN_POSTER_HTML 881 poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML
884 : IDR_BLOCKED_PLUGIN_HTML, 882 : IDR_PLUGIN_POSTER_HTML,
885 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 883 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
886 poster_url); 884 poster_attribute, frame->document().url());
887 placeholder->set_blocked_for_background_tab( 885 placeholder->set_blocked_for_background_tab(
888 blocked_for_background_tab); 886 blocked_for_background_tab);
889 placeholder->set_blocked_for_prerendering(is_prerendering); 887 placeholder->set_blocked_for_prerendering(is_prerendering);
890 placeholder->set_power_saver_enabled(power_saver_enabled); 888 placeholder->set_power_saver_enabled(power_saver_enabled);
891 placeholder->set_allow_loading(true); 889 placeholder->set_allow_loading(true);
892 break; 890 break;
893 } 891 }
894 892
895 scoped_ptr<content::PluginInstanceThrottler> throttler = 893 scoped_ptr<content::PluginInstanceThrottler> throttler =
896 PluginInstanceThrottler::Create(power_saver_enabled); 894 PluginInstanceThrottler::Create(power_saver_enabled);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 if (mime_type == content::kBrowserPluginMimeType) { 1644 if (mime_type == content::kBrowserPluginMimeType) {
1647 return new extensions::ExtensionsGuestViewContainer(render_frame); 1645 return new extensions::ExtensionsGuestViewContainer(render_frame);
1648 } else { 1646 } else {
1649 return new extensions::MimeHandlerViewContainer( 1647 return new extensions::MimeHandlerViewContainer(
1650 render_frame, mime_type, original_url); 1648 render_frame, mime_type, original_url);
1651 } 1649 }
1652 #else 1650 #else
1653 return NULL; 1651 return NULL;
1654 #endif 1652 #endif
1655 } 1653 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/plugins/chrome_plugin_placeholder.h » ('j') | components/plugins/renderer/webview_plugin.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698