| 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 status_value = | 771 status_value = |
| 772 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; | 772 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; |
| 773 } | 773 } |
| 774 #endif | 774 #endif |
| 775 | 775 |
| 776 auto create_blocked_plugin = | 776 auto create_blocked_plugin = |
| 777 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( | 777 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( |
| 778 int template_id, const base::string16& message) { | 778 int template_id, const base::string16& message) { |
| 779 return ChromePluginPlaceholder::CreateBlockedPlugin( | 779 return ChromePluginPlaceholder::CreateBlockedPlugin( |
| 780 render_frame, frame, params, info, identifier, group_name, | 780 render_frame, frame, params, info, identifier, group_name, |
| 781 template_id, message, std::string(), GURL()); | 781 template_id, message, PlaceholderPosterInfo()); |
| 782 }; | 782 }; |
| 783 switch (status_value) { | 783 switch (status_value) { |
| 784 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { | 784 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { |
| 785 NOTREACHED(); | 785 NOTREACHED(); |
| 786 break; | 786 break; |
| 787 } | 787 } |
| 788 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: | 788 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: |
| 789 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { | 789 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { |
| 790 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 790 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
| 791 const bool is_nacl_plugin = | 791 const bool is_nacl_plugin = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 #if defined(ENABLE_PLUGINS) | 851 #if defined(ENABLE_PLUGINS) |
| 852 bool power_saver_enabled = | 852 bool power_saver_enabled = |
| 853 status_value == | 853 status_value == |
| 854 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 854 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
| 855 bool blocked_for_background_tab = | 855 bool blocked_for_background_tab = |
| 856 render_frame->IsHidden() && power_saver_enabled; | 856 render_frame->IsHidden() && power_saver_enabled; |
| 857 | 857 |
| 858 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) | 858 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) |
| 859 TrackPosterParamPresence(params, power_saver_enabled); | 859 TrackPosterParamPresence(params, power_saver_enabled); |
| 860 | 860 |
| 861 std::string poster_attribute; | 861 PlaceholderPosterInfo poster_info; |
| 862 if (power_saver_enabled) | 862 if (power_saver_enabled) { |
| 863 poster_attribute = GetPluginInstancePosterAttribute(params); | 863 poster_info.poster_attribute = |
| 864 GetPluginInstancePosterAttribute(params); |
| 865 poster_info.base_url = frame->document().url(); |
| 866 } |
| 864 | 867 |
| 865 // Delay loading plugins if prerendering. | 868 // Delay loading plugins if prerendering. |
| 866 // TODO(mmenke): In the case of prerendering, feed into | 869 // TODO(mmenke): In the case of prerendering, feed into |
| 867 // ChromeContentRendererClient::CreatePlugin instead, to | 870 // ChromeContentRendererClient::CreatePlugin instead, to |
| 868 // reduce the chance of future regressions. | 871 // reduce the chance of future regressions. |
| 869 bool is_prerendering = | 872 bool is_prerendering = |
| 870 prerender::PrerenderHelper::IsPrerendering(render_frame); | 873 prerender::PrerenderHelper::IsPrerendering(render_frame); |
| 871 if (blocked_for_background_tab || is_prerendering || | 874 if (blocked_for_background_tab || is_prerendering || |
| 872 !poster_attribute.empty()) { | 875 !poster_info.poster_attribute.empty()) { |
| 873 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( | 876 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( |
| 874 render_frame, frame, params, info, identifier, group_name, | 877 render_frame, frame, params, info, identifier, group_name, |
| 875 poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML | 878 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML |
| 876 : IDR_PLUGIN_POSTER_HTML, | 879 : IDR_PLUGIN_POSTER_HTML, |
| 877 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 880 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
| 878 poster_attribute, frame->document().url()); | 881 poster_info); |
| 879 placeholder->set_blocked_for_background_tab( | 882 placeholder->set_blocked_for_background_tab( |
| 880 blocked_for_background_tab); | 883 blocked_for_background_tab); |
| 881 placeholder->set_blocked_for_prerendering(is_prerendering); | 884 placeholder->set_blocked_for_prerendering(is_prerendering); |
| 882 placeholder->set_power_saver_enabled(power_saver_enabled); | 885 placeholder->set_power_saver_enabled(power_saver_enabled); |
| 883 placeholder->set_allow_loading(true); | 886 placeholder->set_allow_loading(true); |
| 884 break; | 887 break; |
| 885 } | 888 } |
| 886 | 889 |
| 887 scoped_ptr<content::PluginInstanceThrottler> throttler; | 890 scoped_ptr<content::PluginInstanceThrottler> throttler; |
| 888 if (power_saver_enabled) { | 891 if (power_saver_enabled) { |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 if (mime_type == content::kBrowserPluginMimeType) { | 1627 if (mime_type == content::kBrowserPluginMimeType) { |
| 1625 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1628 return new extensions::ExtensionsGuestViewContainer(render_frame); |
| 1626 } else { | 1629 } else { |
| 1627 return new extensions::MimeHandlerViewContainer( | 1630 return new extensions::MimeHandlerViewContainer( |
| 1628 render_frame, mime_type, original_url); | 1631 render_frame, mime_type, original_url); |
| 1629 } | 1632 } |
| 1630 #else | 1633 #else |
| 1631 return NULL; | 1634 return NULL; |
| 1632 #endif | 1635 #endif |
| 1633 } | 1636 } |
| OLD | NEW |