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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } | 649 } |
650 #endif | 650 #endif |
651 | 651 |
652 ChromeViewHostMsg_GetPluginInfo_Output output; | 652 ChromeViewHostMsg_GetPluginInfo_Output output; |
653 #if defined(ENABLE_PLUGINS) | 653 #if defined(ENABLE_PLUGINS) |
654 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( | 654 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( |
655 render_frame->GetRoutingID(), GURL(params.url), | 655 render_frame->GetRoutingID(), GURL(params.url), |
656 frame->top()->document().url(), orig_mime_type, &output)); | 656 frame->top()->document().url(), orig_mime_type, &output)); |
657 | 657 |
658 #else | 658 #else |
659 output.status.value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; | 659 output.status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; |
660 #endif | 660 #endif |
661 *plugin = CreatePlugin(render_frame, frame, params, output); | 661 *plugin = CreatePlugin(render_frame, frame, params, output); |
662 return true; | 662 return true; |
663 } | 663 } |
664 | 664 |
665 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( | 665 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( |
666 content::RenderFrame* render_frame, | 666 content::RenderFrame* render_frame, |
667 const base::FilePath& plugin_path) { | 667 const base::FilePath& plugin_path) { |
668 ChromePluginPlaceholder* placeholder = | 668 ChromePluginPlaceholder* placeholder = |
669 ChromePluginPlaceholder::CreateErrorPlugin(render_frame, plugin_path); | 669 ChromePluginPlaceholder::CreateErrorPlugin(render_frame, plugin_path); |
(...skipping 16 matching lines...) Expand all Loading... |
686 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. | 686 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. |
687 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); | 687 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); |
688 #endif | 688 #endif |
689 } | 689 } |
690 | 690 |
691 WebPlugin* ChromeContentRendererClient::CreatePlugin( | 691 WebPlugin* ChromeContentRendererClient::CreatePlugin( |
692 content::RenderFrame* render_frame, | 692 content::RenderFrame* render_frame, |
693 blink::WebLocalFrame* frame, | 693 blink::WebLocalFrame* frame, |
694 const WebPluginParams& original_params, | 694 const WebPluginParams& original_params, |
695 const ChromeViewHostMsg_GetPluginInfo_Output& output) { | 695 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
696 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; | |
697 const WebPluginInfo& info = output.plugin; | 696 const WebPluginInfo& info = output.plugin; |
698 const std::string& actual_mime_type = output.actual_mime_type; | 697 const std::string& actual_mime_type = output.actual_mime_type; |
699 const base::string16& group_name = output.group_name; | 698 const base::string16& group_name = output.group_name; |
700 const std::string& identifier = output.group_identifier; | 699 const std::string& identifier = output.group_identifier; |
701 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; | 700 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; |
702 GURL url(original_params.url); | 701 GURL url(original_params.url); |
703 std::string orig_mime_type = original_params.mimeType.utf8(); | 702 std::string orig_mime_type = original_params.mimeType.utf8(); |
704 ChromePluginPlaceholder* placeholder = NULL; | 703 ChromePluginPlaceholder* placeholder = NULL; |
705 | 704 |
706 // If the browser plugin is to be enabled, this should be handled by the | 705 // If the browser plugin is to be enabled, this should be handled by the |
707 // renderer, so the code won't reach here due to the early exit in | 706 // renderer, so the code won't reach here due to the early exit in |
708 // OverrideCreatePlugin. | 707 // OverrideCreatePlugin. |
709 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || | 708 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || |
710 orig_mime_type == content::kBrowserPluginMimeType) { | 709 orig_mime_type == content::kBrowserPluginMimeType) { |
711 #if defined(OS_ANDROID) | 710 #if defined(OS_ANDROID) |
712 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) { | 711 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) { |
713 base::StringPiece template_html( | 712 base::StringPiece template_html( |
714 ResourceBundle::GetSharedInstance().GetRawDataResource( | 713 ResourceBundle::GetSharedInstance().GetRawDataResource( |
715 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); | 714 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); |
716 return (new plugins::MobileYouTubePlugin( | 715 return (new plugins::MobileYouTubePlugin( |
717 render_frame, | 716 render_frame, |
718 frame, | 717 frame, |
719 original_params, | 718 original_params, |
(...skipping 25 matching lines...) Expand all Loading... |
745 } | 744 } |
746 | 745 |
747 ContentSettingsObserver* observer = | 746 ContentSettingsObserver* observer = |
748 ContentSettingsObserver::Get(render_frame); | 747 ContentSettingsObserver::Get(render_frame); |
749 | 748 |
750 const ContentSettingsType content_type = | 749 const ContentSettingsType content_type = |
751 ShouldUseJavaScriptSettingForPlugin(info) | 750 ShouldUseJavaScriptSettingForPlugin(info) |
752 ? CONTENT_SETTINGS_TYPE_JAVASCRIPT | 751 ? CONTENT_SETTINGS_TYPE_JAVASCRIPT |
753 : CONTENT_SETTINGS_TYPE_PLUGINS; | 752 : CONTENT_SETTINGS_TYPE_PLUGINS; |
754 | 753 |
755 if ((status_value == | 754 if ((status == ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || |
756 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || | 755 status == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && |
757 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && | |
758 observer->IsPluginTemporarilyAllowed(identifier)) { | 756 observer->IsPluginTemporarilyAllowed(identifier)) { |
759 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; | 757 status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; |
760 } | 758 } |
761 | 759 |
762 #if defined(OS_WIN) | 760 #if defined(OS_WIN) |
763 // In Windows we need to check if we can load NPAPI plugins. | 761 // In Windows we need to check if we can load NPAPI plugins. |
764 // For example, if the render view is in the Ash desktop, we should not. | 762 // For example, if the render view is in the Ash desktop, we should not. |
765 // If user is on ALLOW or DETECT setting, loading needs to be blocked here. | 763 // If user is on ALLOW or DETECT setting, loading needs to be blocked here. |
766 if ((status_value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || | 764 if ((status == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || |
767 status_value == | 765 status == |
768 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) && | 766 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) && |
769 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { | 767 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { |
770 if (observer->AreNPAPIPluginsBlocked()) | 768 if (observer->AreNPAPIPluginsBlocked()) |
771 status_value = | 769 status = ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; |
772 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; | |
773 } | 770 } |
774 #endif | 771 #endif |
775 | 772 |
776 auto create_blocked_plugin = | 773 auto create_blocked_plugin = |
777 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( | 774 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( |
778 int template_id, const base::string16& message) { | 775 int template_id, const base::string16& message) { |
779 return ChromePluginPlaceholder::CreateBlockedPlugin( | 776 return ChromePluginPlaceholder::CreateBlockedPlugin( |
780 render_frame, frame, params, info, identifier, group_name, | 777 render_frame, frame, params, info, identifier, group_name, |
781 template_id, message, PlaceholderPosterInfo()); | 778 template_id, message, PlaceholderPosterInfo()); |
782 }; | 779 }; |
783 switch (status_value) { | 780 switch (status) { |
784 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { | 781 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { |
785 NOTREACHED(); | 782 NOTREACHED(); |
786 break; | 783 break; |
787 } | 784 } |
788 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: | 785 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: |
789 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { | 786 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { |
790 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 787 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
791 const bool is_nacl_plugin = | 788 const bool is_nacl_plugin = |
792 info.name == ASCIIToUTF16(nacl::kNaClPluginName); | 789 info.name == ASCIIToUTF16(nacl::kNaClPluginName); |
793 const bool is_nacl_mime_type = | 790 const bool is_nacl_mime_type = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 "Client in about:flags."; | 828 "Client in about:flags."; |
832 } else if (is_pnacl_mime_type) { | 829 } else if (is_pnacl_mime_type) { |
833 error_message = | 830 error_message = |
834 "Portable Native Client must not be disabled in about:flags."; | 831 "Portable Native Client must not be disabled in about:flags."; |
835 } | 832 } |
836 frame->addMessageToConsole( | 833 frame->addMessageToConsole( |
837 WebConsoleMessage(WebConsoleMessage::LevelError, | 834 WebConsoleMessage(WebConsoleMessage::LevelError, |
838 error_message)); | 835 error_message)); |
839 placeholder = create_blocked_plugin( | 836 placeholder = create_blocked_plugin( |
840 IDR_BLOCKED_PLUGIN_HTML, | 837 IDR_BLOCKED_PLUGIN_HTML, |
841 #if defined(OS_CHROMEOS) | 838 #if defined(OS_CHROMEOS) |
842 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | 839 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); |
843 #else | 840 #else |
844 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 841 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
845 #endif | 842 #endif |
846 break; | 843 break; |
847 } | 844 } |
848 } | 845 } |
849 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 846 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
850 | 847 |
851 #if defined(ENABLE_PLUGINS) | 848 #if defined(ENABLE_PLUGINS) |
852 // Delay loading plugins if prerendering. | 849 // Delay loading plugins if prerendering. |
853 // TODO(mmenke): In the case of prerendering, feed into | 850 // TODO(mmenke): In the case of prerendering, feed into |
854 // ChromeContentRendererClient::CreatePlugin instead, to | 851 // ChromeContentRendererClient::CreatePlugin instead, to |
855 // reduce the chance of future regressions. | 852 // reduce the chance of future regressions. |
856 bool is_prerendering = | 853 bool is_prerendering = |
857 prerender::PrerenderHelper::IsPrerendering(render_frame); | 854 prerender::PrerenderHelper::IsPrerendering(render_frame); |
858 | 855 |
859 // TODO(tommycli): Plugin Power Saver is disabled on prerendered pages. | 856 // TODO(tommycli): Plugin Power Saver is disabled on prerendered pages. |
860 // This is because the placeholder does not feed back into | 857 // This is because the placeholder does not feed back into |
861 // ChromeContentRendererClient::CreatePlugin. Because of this, it does | 858 // ChromeContentRendererClient::CreatePlugin. Because of this, it does |
862 // not handle the preroll to UI overlay placeholder flow correctly. | 859 // not handle the preroll to UI overlay placeholder flow correctly. |
863 // | 860 // |
864 // Background tab plugin deferral is disabled for the same reason. | 861 // Background tab plugin deferral is disabled for the same reason. |
865 // | 862 // |
866 // https://crbug.com/471427 | 863 // https://crbug.com/471427 |
867 bool power_saver_enabled = | 864 bool power_saver_enabled = |
868 !is_prerendering && | 865 !is_prerendering && |
869 status_value == | 866 status == |
870 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 867 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
871 | 868 |
872 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) | 869 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) |
873 TrackPosterParamPresence(params, power_saver_enabled); | 870 TrackPosterParamPresence(params, power_saver_enabled); |
874 | 871 |
875 PlaceholderPosterInfo poster_info; | 872 PlaceholderPosterInfo poster_info; |
876 if (power_saver_enabled) { | 873 if (power_saver_enabled) { |
877 poster_info.poster_attribute = | 874 poster_info.poster_attribute = |
878 GetPluginInstancePosterAttribute(params); | 875 GetPluginInstancePosterAttribute(params); |
879 poster_info.base_url = frame->document().url(); | 876 poster_info.base_url = frame->document().url(); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 if (mime_type == content::kBrowserPluginMimeType) { | 1629 if (mime_type == content::kBrowserPluginMimeType) { |
1633 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1630 return new extensions::ExtensionsGuestViewContainer(render_frame); |
1634 } else { | 1631 } else { |
1635 return new extensions::MimeHandlerViewContainer( | 1632 return new extensions::MimeHandlerViewContainer( |
1636 render_frame, mime_type, original_url); | 1633 render_frame, mime_type, original_url); |
1637 } | 1634 } |
1638 #else | 1635 #else |
1639 return NULL; | 1636 return NULL; |
1640 #endif | 1637 #endif |
1641 } | 1638 } |
OLD | NEW |