OLD | NEW |
---|---|
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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 ContentSettingsObserver* observer = | 677 ContentSettingsObserver* observer = |
678 ContentSettingsObserver::Get(render_frame); | 678 ContentSettingsObserver::Get(render_frame); |
679 | 679 |
680 const ContentSettingsType content_type = | 680 const ContentSettingsType content_type = |
681 ShouldUseJavaScriptSettingForPlugin(plugin) ? | 681 ShouldUseJavaScriptSettingForPlugin(plugin) ? |
682 CONTENT_SETTINGS_TYPE_JAVASCRIPT : | 682 CONTENT_SETTINGS_TYPE_JAVASCRIPT : |
683 CONTENT_SETTINGS_TYPE_PLUGINS; | 683 CONTENT_SETTINGS_TYPE_PLUGINS; |
684 | 684 |
685 if ((status_value == | 685 if ((status_value == |
686 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || | 686 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || |
687 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || | |
688 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && | 687 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && |
689 observer->IsPluginTemporarilyAllowed(identifier)) { | 688 observer->IsPluginTemporarilyAllowed(identifier)) { |
690 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; | 689 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; |
691 } | 690 } |
692 | 691 |
693 // Allow full-page plug-ins for click-to-play. | |
694 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay && | |
695 !frame->parent() && | |
696 !frame->opener() && | |
697 frame->document().isPluginDocument()) { | |
698 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; | |
699 } | |
700 | |
701 #if defined(OS_WIN) | 692 #if defined(OS_WIN) |
702 // In Windows we need to check if we can load NPAPI plugins. | 693 // In Windows we need to check if we can load NPAPI plugins. |
703 // For example, if the render view is in the Ash desktop, we should not. | 694 // For example, if the render view is in the Ash desktop, we should not. |
704 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed && | 695 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed && |
705 plugin.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { | 696 plugin.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { |
706 if (observer->AreNPAPIPluginsBlocked()) | 697 if (observer->AreNPAPIPluginsBlocked()) |
707 status_value = | 698 status_value = |
708 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; | 699 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; |
709 } | 700 } |
710 #endif | 701 #endif |
711 | 702 |
712 auto create_blocked_plugin = | 703 auto create_blocked_plugin = |
713 [&render_frame, &frame, ¶ms, &plugin, &identifier, &group_name]( | 704 [&render_frame, &frame, ¶ms, &plugin, &identifier, &group_name]( |
714 int template_id, const base::string16& message, | 705 int template_id, const base::string16& message, |
715 const GURL& poster_url) { | 706 const GURL& poster_url) { |
716 return ChromePluginPlaceholder::CreateBlockedPlugin( | 707 return ChromePluginPlaceholder::CreateBlockedPlugin( |
717 render_frame, frame, params, plugin, identifier, group_name, | 708 render_frame, frame, params, plugin, identifier, group_name, |
718 template_id, message, poster_url); | 709 template_id, message, poster_url); |
719 }; | 710 }; |
720 switch (status_value) { | 711 switch (status_value) { |
721 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { | 712 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { |
722 NOTREACHED(); | 713 NOTREACHED(); |
723 break; | 714 break; |
724 } | 715 } |
725 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: { | 716 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: |
717 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { | |
726 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 718 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
727 const bool is_nacl_plugin = | 719 const bool is_nacl_plugin = |
728 plugin.name == ASCIIToUTF16(nacl::kNaClPluginName); | 720 plugin.name == ASCIIToUTF16(nacl::kNaClPluginName); |
729 const bool is_nacl_mime_type = | 721 const bool is_nacl_mime_type = |
730 actual_mime_type == nacl::kNaClPluginMimeType; | 722 actual_mime_type == nacl::kNaClPluginMimeType; |
731 const bool is_pnacl_mime_type = | 723 const bool is_pnacl_mime_type = |
732 actual_mime_type == nacl::kPnaclPluginMimeType; | 724 actual_mime_type == nacl::kPnaclPluginMimeType; |
733 if (is_nacl_plugin || is_nacl_mime_type || is_pnacl_mime_type) { | 725 if (is_nacl_plugin || is_nacl_mime_type || is_pnacl_mime_type) { |
734 bool is_nacl_unrestricted = false; | 726 bool is_nacl_unrestricted = false; |
735 if (is_nacl_mime_type) { | 727 if (is_nacl_mime_type) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 | 779 |
788 RenderFrame::PluginPowerSaverMode power_saver_mode = | 780 RenderFrame::PluginPowerSaverMode power_saver_mode = |
789 RenderFrame::POWER_SAVER_MODE_ESSENTIAL; | 781 RenderFrame::POWER_SAVER_MODE_ESSENTIAL; |
790 #if defined(ENABLE_PLUGINS) | 782 #if defined(ENABLE_PLUGINS) |
791 bool show_poster = false; | 783 bool show_poster = false; |
792 GURL poster_url; | 784 GURL poster_url; |
793 bool cross_origin_main_content = false; | 785 bool cross_origin_main_content = false; |
794 if (render_frame->ShouldThrottleContent(params, frame->document().url(), | 786 if (render_frame->ShouldThrottleContent(params, frame->document().url(), |
795 &poster_url, | 787 &poster_url, |
796 &cross_origin_main_content)) { | 788 &cross_origin_main_content)) { |
797 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 789 if (status_value == |
798 switches::kEnablePluginPowerSaver)) { | 790 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { |
799 power_saver_mode = | 791 power_saver_mode = |
800 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; | 792 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; |
801 show_poster = poster_url.is_valid(); | 793 show_poster = poster_url.is_valid(); |
802 } else { | 794 } else { |
803 power_saver_mode = | 795 power_saver_mode = |
804 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; | 796 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; |
805 } | 797 } |
806 } | 798 } |
807 | 799 |
808 // Delay loading plugins if prerendering. | 800 // Delay loading plugins if prerendering. |
809 // TODO(mmenke): In the case of prerendering, feed into | 801 // TODO(mmenke): In the case of prerendering, feed into |
810 // ChromeContentRendererClient::CreatePlugin instead, to | 802 // ChromeContentRendererClient::CreatePlugin instead, to |
811 // reduce the chance of future regressions. | 803 // reduce the chance of future regressions. |
812 bool is_prerendering = | 804 bool is_prerendering = |
813 prerender::PrerenderHelper::IsPrerendering(render_frame); | 805 prerender::PrerenderHelper::IsPrerendering(render_frame); |
814 if (is_prerendering || show_poster) { | 806 if (is_prerendering || show_poster) { |
815 placeholder = create_blocked_plugin( | 807 placeholder = create_blocked_plugin( |
816 show_poster ? IDR_PLUGIN_POSTER_HTML | 808 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML, |
817 : IDR_CLICK_TO_PLAY_PLUGIN_HTML, | |
818 l10n_util::GetStringFUTF16(IDS_PLUGIN_LOAD, group_name), | 809 l10n_util::GetStringFUTF16(IDS_PLUGIN_LOAD, group_name), |
819 poster_url); | 810 poster_url); |
820 placeholder->set_blocked_for_prerendering(is_prerendering); | 811 placeholder->set_blocked_for_prerendering(is_prerendering); |
821 placeholder->set_power_saver_mode(power_saver_mode); | 812 placeholder->set_power_saver_mode(power_saver_mode); |
822 placeholder->set_allow_loading(true); | 813 placeholder->set_allow_loading(true); |
823 break; | 814 break; |
824 } else if (cross_origin_main_content) { | 815 } else if (cross_origin_main_content) { |
825 GURL content_origin = GURL(params.url).GetOrigin(); | 816 GURL content_origin = GURL(params.url).GetOrigin(); |
826 render_frame->WhitelistContentOrigin(content_origin); | 817 render_frame->WhitelistContentOrigin(content_origin); |
827 } | 818 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( | 876 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( |
886 render_frame->GetRoutingID(), | 877 render_frame->GetRoutingID(), |
887 group_name, | 878 group_name, |
888 identifier)); | 879 identifier)); |
889 } else { | 880 } else { |
890 // Send IPC for showing blocked plugins page action. | 881 // Send IPC for showing blocked plugins page action. |
891 observer->DidBlockContentType(content_type, group_name); | 882 observer->DidBlockContentType(content_type, group_name); |
892 } | 883 } |
893 break; | 884 break; |
894 } | 885 } |
895 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { | |
896 placeholder = create_blocked_plugin( | |
897 IDR_CLICK_TO_PLAY_PLUGIN_HTML, | |
898 l10n_util::GetStringFUTF16(IDS_PLUGIN_LOAD, group_name), GURL()); | |
groby-ooo-7-16
2014/12/11 19:22:03
Do we still need IDS_PLUGIN_LOAD?
tommycli
2014/12/12 00:45:23
Done. You are correct. This is now extraneous.
| |
899 placeholder->set_allow_loading(true); | |
900 RenderThread::Get()->RecordAction( | |
901 UserMetricsAction("Plugin_ClickToPlay")); | |
902 observer->DidBlockContentType(content_type, group_name); | |
903 break; | |
904 } | |
905 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { | 886 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { |
906 placeholder = create_blocked_plugin( | 887 placeholder = create_blocked_plugin( |
907 IDR_BLOCKED_PLUGIN_HTML, | 888 IDR_BLOCKED_PLUGIN_HTML, |
908 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), GURL()); | 889 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), GURL()); |
909 placeholder->set_allow_loading(true); | 890 placeholder->set_allow_loading(true); |
910 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); | 891 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); |
911 observer->DidBlockContentType(content_type, group_name); | 892 observer->DidBlockContentType(content_type, group_name); |
912 break; | 893 break; |
913 } | 894 } |
914 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { | 895 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 if (mime_type == content::kBrowserPluginMimeType) { | 1562 if (mime_type == content::kBrowserPluginMimeType) { |
1582 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1563 return new extensions::ExtensionsGuestViewContainer(render_frame); |
1583 } else { | 1564 } else { |
1584 return new extensions::MimeHandlerViewContainer( | 1565 return new extensions::MimeHandlerViewContainer( |
1585 render_frame, mime_type, original_url); | 1566 render_frame, mime_type, original_url); |
1586 } | 1567 } |
1587 #else | 1568 #else |
1588 return NULL; | 1569 return NULL; |
1589 #endif | 1570 #endif |
1590 } | 1571 } |
OLD | NEW |