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

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

Issue 866173002: Plugin Power Saver: Add UI Overlay to throttled plugin using placeholder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « chrome/chrome_renderer.gypi ('k') | chrome/renderer/plugins/chrome_plugin_placeholder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 #include "chrome/renderer/content_settings_observer.h" 33 #include "chrome/renderer/content_settings_observer.h"
34 #include "chrome/renderer/external_extension.h" 34 #include "chrome/renderer/external_extension.h"
35 #include "chrome/renderer/loadtimes_extension_bindings.h" 35 #include "chrome/renderer/loadtimes_extension_bindings.h"
36 #include "chrome/renderer/media/chrome_key_systems.h" 36 #include "chrome/renderer/media/chrome_key_systems.h"
37 #include "chrome/renderer/net/net_error_helper.h" 37 #include "chrome/renderer/net/net_error_helper.h"
38 #include "chrome/renderer/net_benchmarking_extension.h" 38 #include "chrome/renderer/net_benchmarking_extension.h"
39 #include "chrome/renderer/page_load_histograms.h" 39 #include "chrome/renderer/page_load_histograms.h"
40 #include "chrome/renderer/pepper/pepper_helper.h" 40 #include "chrome/renderer/pepper/pepper_helper.h"
41 #include "chrome/renderer/playback_extension.h" 41 #include "chrome/renderer/playback_extension.h"
42 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" 42 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
43 #include "chrome/renderer/plugins/plugin_preroller.h"
43 #include "chrome/renderer/plugins/plugin_uma.h" 44 #include "chrome/renderer/plugins/plugin_uma.h"
44 #include "chrome/renderer/plugins/shadow_dom_plugin_placeholder.h" 45 #include "chrome/renderer/plugins/shadow_dom_plugin_placeholder.h"
45 #include "chrome/renderer/prefetch_helper.h" 46 #include "chrome/renderer/prefetch_helper.h"
46 #include "chrome/renderer/prerender/prerender_dispatcher.h" 47 #include "chrome/renderer/prerender/prerender_dispatcher.h"
47 #include "chrome/renderer/prerender/prerender_helper.h" 48 #include "chrome/renderer/prerender/prerender_helper.h"
48 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" 49 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h"
49 #include "chrome/renderer/prerender/prerenderer_client.h" 50 #include "chrome/renderer/prerender/prerenderer_client.h"
50 #include "chrome/renderer/principals_extension_bindings.h" 51 #include "chrome/renderer/principals_extension_bindings.h"
51 #include "chrome/renderer/safe_browsing/malware_dom_details.h" 52 #include "chrome/renderer/safe_browsing/malware_dom_details.h"
52 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 53 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); 621 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure);
621 #endif 622 #endif
622 } 623 }
623 624
624 WebPlugin* ChromeContentRendererClient::CreatePlugin( 625 WebPlugin* ChromeContentRendererClient::CreatePlugin(
625 content::RenderFrame* render_frame, 626 content::RenderFrame* render_frame,
626 WebLocalFrame* frame, 627 WebLocalFrame* frame,
627 const WebPluginParams& original_params, 628 const WebPluginParams& original_params,
628 const ChromeViewHostMsg_GetPluginInfo_Output& output) { 629 const ChromeViewHostMsg_GetPluginInfo_Output& output) {
629 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; 630 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status;
630 const WebPluginInfo& plugin = output.plugin; 631 const WebPluginInfo& info = output.plugin;
631 const std::string& actual_mime_type = output.actual_mime_type; 632 const std::string& actual_mime_type = output.actual_mime_type;
632 const base::string16& group_name = output.group_name; 633 const base::string16& group_name = output.group_name;
633 const std::string& identifier = output.group_identifier; 634 const std::string& identifier = output.group_identifier;
634 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; 635 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value;
635 GURL url(original_params.url); 636 GURL url(original_params.url);
636 std::string orig_mime_type = original_params.mimeType.utf8(); 637 std::string orig_mime_type = original_params.mimeType.utf8();
637 ChromePluginPlaceholder* placeholder = NULL; 638 ChromePluginPlaceholder* placeholder = NULL;
638 639
639 // If the browser plugin is to be enabled, this should be handled by the 640 // If the browser plugin is to be enabled, this should be handled by the
640 // renderer, so the code won't reach here due to the early exit in 641 // renderer, so the code won't reach here due to the early exit in
(...skipping 13 matching lines...) Expand all
654 GURL(ChromePluginPlaceholder::kPluginPlaceholderDataURL))) 655 GURL(ChromePluginPlaceholder::kPluginPlaceholderDataURL)))
655 ->plugin(); 656 ->plugin();
656 } 657 }
657 #endif 658 #endif
658 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url); 659 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url);
659 placeholder = ChromePluginPlaceholder::CreateMissingPlugin( 660 placeholder = ChromePluginPlaceholder::CreateMissingPlugin(
660 render_frame, frame, original_params); 661 render_frame, frame, original_params);
661 } else { 662 } else {
662 // TODO(bauerb): This should be in content/. 663 // TODO(bauerb): This should be in content/.
663 WebPluginParams params(original_params); 664 WebPluginParams params(original_params);
664 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { 665 for (size_t i = 0; i < info.mime_types.size(); ++i) {
665 if (plugin.mime_types[i].mime_type == actual_mime_type) { 666 if (info.mime_types[i].mime_type == actual_mime_type) {
666 AppendParams(plugin.mime_types[i].additional_param_names, 667 AppendParams(info.mime_types[i].additional_param_names,
667 plugin.mime_types[i].additional_param_values, 668 info.mime_types[i].additional_param_values,
668 &params.attributeNames, 669 &params.attributeNames, &params.attributeValues);
669 &params.attributeValues);
670 break; 670 break;
671 } 671 }
672 } 672 }
673 if (params.mimeType.isNull() && (actual_mime_type.size() > 0)) { 673 if (params.mimeType.isNull() && (actual_mime_type.size() > 0)) {
674 // Webkit might say that mime type is null while we already know the 674 // Webkit might say that mime type is null while we already know the
675 // actual mime type via ChromeViewHostMsg_GetPluginInfo. In that case 675 // actual mime type via ChromeViewHostMsg_GetPluginInfo. In that case
676 // we should use what we know since WebpluginDelegateProxy does some 676 // we should use what we know since WebpluginDelegateProxy does some
677 // specific initializations based on this information. 677 // specific initializations based on this information.
678 params.mimeType = WebString::fromUTF8(actual_mime_type.c_str()); 678 params.mimeType = WebString::fromUTF8(actual_mime_type.c_str());
679 } 679 }
680 680
681 ContentSettingsObserver* observer = 681 ContentSettingsObserver* observer =
682 ContentSettingsObserver::Get(render_frame); 682 ContentSettingsObserver::Get(render_frame);
683 683
684 const ContentSettingsType content_type = 684 const ContentSettingsType content_type =
685 ShouldUseJavaScriptSettingForPlugin(plugin) ? 685 ShouldUseJavaScriptSettingForPlugin(info)
686 CONTENT_SETTINGS_TYPE_JAVASCRIPT : 686 ? CONTENT_SETTINGS_TYPE_JAVASCRIPT
687 CONTENT_SETTINGS_TYPE_PLUGINS; 687 : CONTENT_SETTINGS_TYPE_PLUGINS;
688 688
689 if ((status_value == 689 if ((status_value ==
690 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || 690 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized ||
691 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || 691 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay ||
692 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && 692 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) &&
693 observer->IsPluginTemporarilyAllowed(identifier)) { 693 observer->IsPluginTemporarilyAllowed(identifier)) {
694 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 694 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
695 } 695 }
696 696
697 // Allow full-screen plug-ins for left-click-to-play. 697 // Allow full-screen plug-ins for left-click-to-play.
698 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay && 698 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay &&
699 !frame->parent() && !frame->opener() && 699 !frame->parent() && !frame->opener() &&
700 frame->document().isPluginDocument()) { 700 frame->document().isPluginDocument()) {
701 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 701 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
702 } 702 }
703 703
704 #if defined(ENABLE_PLUGINS) 704 #if defined(ENABLE_PLUGINS)
705 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed && 705 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed &&
706 base::CommandLine::ForCurrentProcess()->HasSwitch( 706 base::CommandLine::ForCurrentProcess()->HasSwitch(
707 switches::kEnablePluginPowerSaver)) { 707 switches::kEnablePluginPowerSaver)) {
708 status_value = 708 status_value =
709 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 709 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
710 } 710 }
711 #endif 711 #endif
712 712
713 #if defined(OS_WIN) 713 #if defined(OS_WIN)
714 // In Windows we need to check if we can load NPAPI plugins. 714 // In Windows we need to check if we can load NPAPI plugins.
715 // For example, if the render view is in the Ash desktop, we should not. 715 // For example, if the render view is in the Ash desktop, we should not.
716 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed && 716 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed &&
717 plugin.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { 717 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
718 if (observer->AreNPAPIPluginsBlocked()) 718 if (observer->AreNPAPIPluginsBlocked())
719 status_value = 719 status_value =
720 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; 720 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
721 } 721 }
722 #endif 722 #endif
723 723
724 auto create_blocked_plugin = 724 auto create_blocked_plugin =
725 [&render_frame, &frame, &params, &plugin, &identifier, &group_name]( 725 [&render_frame, &frame, &params, &info, &identifier, &group_name](
726 int template_id, const base::string16& message, 726 int template_id, const base::string16& message) {
727 const GURL& poster_url) {
728 return ChromePluginPlaceholder::CreateBlockedPlugin( 727 return ChromePluginPlaceholder::CreateBlockedPlugin(
729 render_frame, frame, params, plugin, identifier, group_name, 728 render_frame, frame, params, info, identifier, group_name,
730 template_id, message, poster_url); 729 template_id, message, GURL());
731 }; 730 };
732 switch (status_value) { 731 switch (status_value) {
733 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { 732 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: {
734 NOTREACHED(); 733 NOTREACHED();
735 break; 734 break;
736 } 735 }
737 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: 736 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed:
738 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { 737 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: {
739 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 738 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
740 const bool is_nacl_plugin = 739 const bool is_nacl_plugin =
741 plugin.name == ASCIIToUTF16(nacl::kNaClPluginName); 740 info.name == ASCIIToUTF16(nacl::kNaClPluginName);
742 const bool is_nacl_mime_type = 741 const bool is_nacl_mime_type =
743 actual_mime_type == nacl::kNaClPluginMimeType; 742 actual_mime_type == nacl::kNaClPluginMimeType;
744 const bool is_pnacl_mime_type = 743 const bool is_pnacl_mime_type =
745 actual_mime_type == nacl::kPnaclPluginMimeType; 744 actual_mime_type == nacl::kPnaclPluginMimeType;
746 if (is_nacl_plugin || is_nacl_mime_type || is_pnacl_mime_type) { 745 if (is_nacl_plugin || is_nacl_mime_type || is_pnacl_mime_type) {
747 bool is_nacl_unrestricted = false; 746 bool is_nacl_unrestricted = false;
748 if (is_nacl_mime_type) { 747 if (is_nacl_mime_type) {
749 is_nacl_unrestricted = 748 is_nacl_unrestricted =
750 base::CommandLine::ForCurrentProcess()->HasSwitch( 749 base::CommandLine::ForCurrentProcess()->HasSwitch(
751 switches::kEnableNaCl); 750 switches::kEnableNaCl);
752 } else if (is_pnacl_mime_type) { 751 } else if (is_pnacl_mime_type) {
753 is_nacl_unrestricted = true; 752 is_nacl_unrestricted = true;
754 } 753 }
755 GURL manifest_url; 754 GURL manifest_url;
756 GURL app_url; 755 GURL app_url;
757 if (is_nacl_mime_type || is_pnacl_mime_type) { 756 if (is_nacl_mime_type || is_pnacl_mime_type) {
758 // Normal NaCl/PNaCl embed. The app URL is the page URL. 757 // Normal NaCl/PNaCl embed. The app URL is the page URL.
759 manifest_url = url; 758 manifest_url = url;
760 app_url = frame->top()->document().url(); 759 app_url = frame->top()->document().url();
761 } else { 760 } else {
762 // NaCl is being invoked as a content handler. Look up the NaCl 761 // NaCl is being invoked as a content handler. Look up the NaCl
763 // module using the MIME type. The app URL is the manifest URL. 762 // module using the MIME type. The app URL is the manifest URL.
764 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); 763 manifest_url = GetNaClContentHandlerURL(actual_mime_type, info);
765 app_url = manifest_url; 764 app_url = manifest_url;
766 } 765 }
767 const Extension* extension = 766 const Extension* extension =
768 g_current_client->extension_dispatcher_->extensions()-> 767 g_current_client->extension_dispatcher_->extensions()->
769 GetExtensionOrAppByURL(manifest_url); 768 GetExtensionOrAppByURL(manifest_url);
770 if (!IsNaClAllowed(manifest_url, 769 if (!IsNaClAllowed(manifest_url,
771 app_url, 770 app_url,
772 is_nacl_unrestricted, 771 is_nacl_unrestricted,
773 extension, 772 extension,
774 &params)) { 773 &params)) {
775 WebString error_message; 774 WebString error_message;
776 if (is_nacl_mime_type) { 775 if (is_nacl_mime_type) {
777 error_message = 776 error_message =
778 "Only unpacked extensions and apps installed from the Chrome " 777 "Only unpacked extensions and apps installed from the Chrome "
779 "Web Store can load NaCl modules without enabling Native " 778 "Web Store can load NaCl modules without enabling Native "
780 "Client in about:flags."; 779 "Client in about:flags.";
781 } else if (is_pnacl_mime_type) { 780 } else if (is_pnacl_mime_type) {
782 error_message = 781 error_message =
783 "Portable Native Client must not be disabled in about:flags."; 782 "Portable Native Client must not be disabled in about:flags.";
784 } 783 }
785 frame->addMessageToConsole( 784 frame->addMessageToConsole(
786 WebConsoleMessage(WebConsoleMessage::LevelError, 785 WebConsoleMessage(WebConsoleMessage::LevelError,
787 error_message)); 786 error_message));
788 placeholder = create_blocked_plugin( 787 placeholder = create_blocked_plugin(
789 IDR_BLOCKED_PLUGIN_HTML, 788 IDR_BLOCKED_PLUGIN_HTML,
790 #if defined(OS_CHROMEOS) 789 #if defined(OS_CHROMEOS)
791 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED), 790 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
792 #else 791 #else
793 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 792 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
794 #endif 793 #endif
795 GURL());
796 break; 794 break;
797 } 795 }
798 } 796 }
799 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 797 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
800 798
801 scoped_ptr<content::PluginInstanceThrottler> throttler; 799 scoped_ptr<content::PluginInstanceThrottler> throttler;
802 #if defined(ENABLE_PLUGINS) 800 #if defined(ENABLE_PLUGINS)
803 PluginPowerSaverMode power_saver_mode = 801 PluginPowerSaverMode power_saver_mode =
804 PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL; 802 PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL;
805 bool show_poster = false; 803 bool show_poster = false;
806 GURL poster_url; 804 GURL poster_url;
807 bool cross_origin_main_content = false; 805 bool cross_origin_main_content = false;
808 bool blocked_for_background_tab = 806 bool blocked_for_background_tab =
809 render_frame->IsHidden() && 807 render_frame->IsHidden() &&
810 status_value == 808 status_value ==
811 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 809 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
812 if (render_frame->ShouldThrottleContent(params, frame->document().url(), 810 if (render_frame->ShouldThrottleContent(params, frame->document().url(),
813 &poster_url, 811 &poster_url,
814 &cross_origin_main_content)) { 812 &cross_origin_main_content)) {
815 // TODO(tommycli): Apply throttler behavior to all plugins. 813 // TODO(tommycli): Apply throttler behavior to all plugins.
816 if (plugin.name == base::ASCIIToUTF16(content::kFlashPluginName) && 814 if (info.name == base::ASCIIToUTF16(content::kFlashPluginName) &&
817 status_value == ChromeViewHostMsg_GetPluginInfo_Status:: 815 status_value == ChromeViewHostMsg_GetPluginInfo_Status::
818 kPlayImportantContent) { 816 kPlayImportantContent) {
819 power_saver_mode = 817 power_saver_mode =
820 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; 818 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_THROTTLED;
821 show_poster = poster_url.is_valid(); 819 show_poster = poster_url.is_valid();
822 } else { 820 } else {
823 power_saver_mode = 821 power_saver_mode =
824 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; 822 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED;
825 } 823 }
826 824
827 throttler = content::PluginInstanceThrottler::Get(render_frame, url, 825 throttler = content::PluginInstanceThrottler::Get(render_frame, url,
828 power_saver_mode); 826 power_saver_mode);
829 } 827 }
830 828
831 // Delay loading plugins if prerendering. 829 // Delay loading plugins if prerendering.
832 // TODO(mmenke): In the case of prerendering, feed into 830 // TODO(mmenke): In the case of prerendering, feed into
833 // ChromeContentRendererClient::CreatePlugin instead, to 831 // ChromeContentRendererClient::CreatePlugin instead, to
834 // reduce the chance of future regressions. 832 // reduce the chance of future regressions.
835 bool is_prerendering = 833 bool is_prerendering =
836 prerender::PrerenderHelper::IsPrerendering(render_frame); 834 prerender::PrerenderHelper::IsPrerendering(render_frame);
837 if (blocked_for_background_tab || is_prerendering || show_poster) { 835 if (blocked_for_background_tab || is_prerendering || show_poster) {
838 placeholder = create_blocked_plugin( 836 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin(
837 render_frame, frame, params, info, identifier, group_name,
839 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML, 838 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML,
840 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 839 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
841 poster_url); 840 poster_url);
842 placeholder->set_blocked_for_background_tab( 841 placeholder->set_blocked_for_background_tab(
843 blocked_for_background_tab); 842 blocked_for_background_tab);
844 placeholder->set_blocked_for_prerendering(is_prerendering); 843 placeholder->set_blocked_for_prerendering(is_prerendering);
845 placeholder->set_power_saver_mode(power_saver_mode); 844 placeholder->set_power_saver_mode(power_saver_mode);
846 placeholder->set_allow_loading(true); 845 placeholder->set_allow_loading(true);
847 break; 846 break;
848 } else if (cross_origin_main_content) { 847 } else if (cross_origin_main_content) {
849 GURL content_origin = GURL(params.url).GetOrigin(); 848 GURL content_origin = GURL(params.url).GetOrigin();
850 render_frame->WhitelistContentOrigin(content_origin); 849 render_frame->WhitelistContentOrigin(content_origin);
851 } 850 }
851
852 if (power_saver_mode ==
853 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_THROTTLED) {
854 content::PluginInstanceThrottler* throttler_raw = throttler.get();
855 blink::WebPlugin* plugin =
856 render_frame->CreatePlugin(frame, info, params, throttler.Pass());
857
858 // PluginPreroller manages its own lifetime.
859 new PluginPreroller(
860 render_frame, frame, params, info, identifier, group_name,
861 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
862 plugin, throttler_raw);
863
864 return plugin;
865 }
866
852 #endif // defined(ENABLE_PLUGINS) 867 #endif // defined(ENABLE_PLUGINS)
853 return render_frame->CreatePlugin(frame, plugin, params, 868 return render_frame->CreatePlugin(frame, info, params,
854 throttler.Pass()); 869 throttler.Pass());
855 } 870 }
856 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { 871 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: {
857 RenderThread::Get()->RecordAction( 872 RenderThread::Get()->RecordAction(
858 UserMetricsAction("Plugin_NPAPINotSupported")); 873 UserMetricsAction("Plugin_NPAPINotSupported"));
859 placeholder = create_blocked_plugin( 874 placeholder = create_blocked_plugin(
860 IDR_BLOCKED_PLUGIN_HTML, 875 IDR_BLOCKED_PLUGIN_HTML,
861 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO), GURL()); 876 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO));
862 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( 877 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported(
863 render_frame->GetRoutingID(), identifier)); 878 render_frame->GetRoutingID(), identifier));
864 break; 879 break;
865 } 880 }
866 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { 881 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: {
867 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, 882 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type,
868 url); 883 url);
869 placeholder = create_blocked_plugin( 884 placeholder = create_blocked_plugin(
870 IDR_DISABLED_PLUGIN_HTML, 885 IDR_DISABLED_PLUGIN_HTML,
871 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name), 886 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name));
872 GURL());
873 break; 887 break;
874 } 888 }
875 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { 889 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
876 #if defined(ENABLE_PLUGIN_INSTALLATION) 890 #if defined(ENABLE_PLUGIN_INSTALLATION)
877 placeholder = create_blocked_plugin( 891 placeholder = create_blocked_plugin(
878 IDR_BLOCKED_PLUGIN_HTML, 892 IDR_BLOCKED_PLUGIN_HTML,
879 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name), 893 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
880 GURL());
881 placeholder->set_allow_loading(true); 894 placeholder->set_allow_loading(true);
882 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( 895 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
883 render_frame->GetRoutingID(), placeholder->CreateRoutingId(), 896 render_frame->GetRoutingID(), placeholder->CreateRoutingId(),
884 identifier)); 897 identifier));
885 #else 898 #else
886 NOTREACHED(); 899 NOTREACHED();
887 #endif 900 #endif
888 break; 901 break;
889 } 902 }
890 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { 903 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
891 placeholder = create_blocked_plugin( 904 placeholder = create_blocked_plugin(
892 IDR_BLOCKED_PLUGIN_HTML, 905 IDR_BLOCKED_PLUGIN_HTML,
893 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name), 906 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
894 GURL());
895 break; 907 break;
896 } 908 }
897 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { 909 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
898 placeholder = create_blocked_plugin( 910 placeholder = create_blocked_plugin(
899 IDR_BLOCKED_PLUGIN_HTML, 911 IDR_BLOCKED_PLUGIN_HTML,
900 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name), 912 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name));
901 GURL());
902 placeholder->set_allow_loading(true); 913 placeholder->set_allow_loading(true);
903 if (plugin.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { 914 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
904 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( 915 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
905 render_frame->GetRoutingID(), 916 render_frame->GetRoutingID(),
906 group_name, 917 group_name,
907 identifier)); 918 identifier));
908 } 919 }
909 observer->DidBlockContentType(content_type, group_name); 920 observer->DidBlockContentType(content_type, group_name);
910 break; 921 break;
911 } 922 }
912 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { 923 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: {
913 placeholder = create_blocked_plugin( 924 placeholder = create_blocked_plugin(
914 IDR_CLICK_TO_PLAY_PLUGIN_HTML, 925 IDR_CLICK_TO_PLAY_PLUGIN_HTML,
915 l10n_util::GetStringFUTF16(IDS_PLUGIN_LOAD, group_name), GURL()); 926 l10n_util::GetStringFUTF16(IDS_PLUGIN_LOAD, group_name));
916 placeholder->set_allow_loading(true); 927 placeholder->set_allow_loading(true);
917 RenderThread::Get()->RecordAction( 928 RenderThread::Get()->RecordAction(
918 UserMetricsAction("Plugin_ClickToPlay")); 929 UserMetricsAction("Plugin_ClickToPlay"));
919 observer->DidBlockContentType(content_type, group_name); 930 observer->DidBlockContentType(content_type, group_name);
920 break; 931 break;
921 } 932 }
922 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { 933 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: {
923 placeholder = create_blocked_plugin( 934 placeholder = create_blocked_plugin(
924 IDR_BLOCKED_PLUGIN_HTML, 935 IDR_BLOCKED_PLUGIN_HTML,
925 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), GURL()); 936 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
926 placeholder->set_allow_loading(true); 937 placeholder->set_allow_loading(true);
927 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); 938 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked"));
928 observer->DidBlockContentType(content_type, group_name); 939 observer->DidBlockContentType(content_type, group_name);
929 break; 940 break;
930 } 941 }
931 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { 942 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: {
932 placeholder = create_blocked_plugin( 943 placeholder = create_blocked_plugin(
933 IDR_BLOCKED_PLUGIN_HTML, 944 IDR_BLOCKED_PLUGIN_HTML,
934 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), GURL()); 945 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
935 placeholder->set_allow_loading(false); 946 placeholder->set_allow_loading(false);
936 RenderThread::Get()->RecordAction( 947 RenderThread::Get()->RecordAction(
937 UserMetricsAction("Plugin_BlockedByPolicy")); 948 UserMetricsAction("Plugin_BlockedByPolicy"));
938 observer->DidBlockContentType(content_type, group_name); 949 observer->DidBlockContentType(content_type, group_name);
939 break; 950 break;
940 } 951 }
941 } 952 }
942 } 953 }
943 placeholder->SetStatus(status); 954 placeholder->SetStatus(status);
944 return placeholder->plugin(); 955 return placeholder->plugin();
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 if (mime_type == content::kBrowserPluginMimeType) { 1602 if (mime_type == content::kBrowserPluginMimeType) {
1592 return new extensions::ExtensionsGuestViewContainer(render_frame); 1603 return new extensions::ExtensionsGuestViewContainer(render_frame);
1593 } else { 1604 } else {
1594 return new extensions::MimeHandlerViewContainer( 1605 return new extensions::MimeHandlerViewContainer(
1595 render_frame, mime_type, original_url); 1606 render_frame, mime_type, original_url);
1596 } 1607 }
1597 #else 1608 #else
1598 return NULL; 1609 return NULL;
1599 #endif 1610 #endif
1600 } 1611 }
OLDNEW
« no previous file with comments | « chrome/chrome_renderer.gypi ('k') | chrome/renderer/plugins/chrome_plugin_placeholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698