Chromium Code Reviews| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 GetPluginInstancePoster(const blink::WebPluginParams& params) { |
|
Tom Sepez
2015/03/05 20:28:42
nit: maybe GetPluginInstancePosterAttribute(), sin
tommycli
2015/03/06 00:17:31
Done.
| |
| 318 const GURL& page_base_url) { | |
| 319 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); | 318 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
| 320 | 319 |
| 321 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 320 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
| 322 if (params.attributeNames[i].utf8() == "poster" && | 321 if (params.attributeNames[i].utf8() == "poster" && |
| 323 !params.attributeValues[i].isEmpty()) { | 322 !params.attributeValues[i].isEmpty()) { |
| 324 return page_base_url.Resolve(params.attributeValues[i].utf8()); | 323 return params.attributeValues[i].utf8(); |
| 325 } | 324 } |
| 326 } | 325 } |
| 327 return GURL(); | 326 return std::string(); |
| 328 } | 327 } |
| 329 #endif | 328 #endif |
| 330 | 329 |
| 331 #if defined(ENABLE_EXTENSIONS) | 330 #if defined(ENABLE_EXTENSIONS) |
| 332 bool IsStandaloneExtensionProcess() { | 331 bool IsStandaloneExtensionProcess() { |
| 333 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 332 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 334 extensions::switches::kExtensionProcess); | 333 extensions::switches::kExtensionProcess); |
| 335 } | 334 } |
| 336 #endif | 335 #endif |
| 337 } // namespace | 336 } // namespace |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { | 774 info.type == content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { |
| 776 if (observer->AreNPAPIPluginsBlocked()) | 775 if (observer->AreNPAPIPluginsBlocked()) |
| 777 status_value = | 776 status_value = |
| 778 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; | 777 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; |
| 779 } | 778 } |
| 780 #endif | 779 #endif |
| 781 | 780 |
| 782 auto create_blocked_plugin = | 781 auto create_blocked_plugin = |
| 783 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( | 782 [&render_frame, &frame, ¶ms, &info, &identifier, &group_name]( |
| 784 int template_id, const base::string16& message) { | 783 int template_id, const base::string16& message) { |
| 785 return ChromePluginPlaceholder::CreateBlockedPlugin( | 784 return ChromePluginPlaceholder::CreateBlockedPlugin( |
| 786 render_frame, frame, params, info, identifier, group_name, | 785 render_frame, frame, params, info, identifier, group_name, |
| 787 template_id, message, GURL()); | 786 template_id, message, std::string(), GURL()); |
| 788 }; | 787 }; |
| 789 switch (status_value) { | 788 switch (status_value) { |
| 790 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { | 789 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { |
| 791 NOTREACHED(); | 790 NOTREACHED(); |
| 792 break; | 791 break; |
| 793 } | 792 } |
| 794 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: | 793 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: |
| 795 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { | 794 case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: { |
| 796 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 795 #if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
| 797 const bool is_nacl_plugin = | 796 const bool is_nacl_plugin = |
| 798 info.name == ASCIIToUTF16(nacl::kNaClPluginName); | 797 info.name == ASCIIToUTF16(nacl::kNaClPluginName); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 #if defined(ENABLE_PLUGINS) | 856 #if defined(ENABLE_PLUGINS) |
| 858 bool power_saver_enabled = | 857 bool power_saver_enabled = |
| 859 status_value == | 858 status_value == |
| 860 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 859 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
| 861 bool blocked_for_background_tab = | 860 bool blocked_for_background_tab = |
| 862 render_frame->IsHidden() && power_saver_enabled; | 861 render_frame->IsHidden() && power_saver_enabled; |
| 863 | 862 |
| 864 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) | 863 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) |
| 865 TrackPosterParamPresence(params, power_saver_enabled); | 864 TrackPosterParamPresence(params, power_saver_enabled); |
| 866 | 865 |
| 867 GURL poster_url; | 866 std::string poster_attribute; |
| 868 if (power_saver_enabled) { | 867 if (power_saver_enabled) |
| 869 poster_url = | 868 poster_attribute = GetPluginInstancePoster(params); |
| 870 GetPluginInstancePosterImage(params, frame->document().url()); | |
| 871 } | |
| 872 | 869 |
| 873 // Delay loading plugins if prerendering. | 870 // Delay loading plugins if prerendering. |
| 874 // TODO(mmenke): In the case of prerendering, feed into | 871 // TODO(mmenke): In the case of prerendering, feed into |
| 875 // ChromeContentRendererClient::CreatePlugin instead, to | 872 // ChromeContentRendererClient::CreatePlugin instead, to |
| 876 // reduce the chance of future regressions. | 873 // reduce the chance of future regressions. |
| 877 bool is_prerendering = | 874 bool is_prerendering = |
| 878 prerender::PrerenderHelper::IsPrerendering(render_frame); | 875 prerender::PrerenderHelper::IsPrerendering(render_frame); |
| 879 if (blocked_for_background_tab || is_prerendering || | 876 if (blocked_for_background_tab || is_prerendering || |
| 880 poster_url.is_valid()) { | 877 !poster_attribute.empty()) { |
| 881 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( | 878 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( |
| 882 render_frame, frame, params, info, identifier, group_name, | 879 render_frame, frame, params, info, identifier, group_name, |
| 883 poster_url.is_valid() ? IDR_PLUGIN_POSTER_HTML | 880 poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML |
| 884 : IDR_BLOCKED_PLUGIN_HTML, | 881 : IDR_PLUGIN_POSTER_HTML, |
| 885 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 882 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
| 886 poster_url); | 883 poster_attribute, frame->document().url()); |
| 887 placeholder->set_blocked_for_background_tab( | 884 placeholder->set_blocked_for_background_tab( |
| 888 blocked_for_background_tab); | 885 blocked_for_background_tab); |
| 889 placeholder->set_blocked_for_prerendering(is_prerendering); | 886 placeholder->set_blocked_for_prerendering(is_prerendering); |
| 890 placeholder->set_power_saver_enabled(power_saver_enabled); | 887 placeholder->set_power_saver_enabled(power_saver_enabled); |
| 891 placeholder->set_allow_loading(true); | 888 placeholder->set_allow_loading(true); |
| 892 break; | 889 break; |
| 893 } | 890 } |
| 894 | 891 |
| 895 scoped_ptr<content::PluginInstanceThrottler> throttler = | 892 scoped_ptr<content::PluginInstanceThrottler> throttler = |
| 896 PluginInstanceThrottler::Create(power_saver_enabled); | 893 PluginInstanceThrottler::Create(power_saver_enabled); |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 if (mime_type == content::kBrowserPluginMimeType) { | 1643 if (mime_type == content::kBrowserPluginMimeType) { |
| 1647 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1644 return new extensions::ExtensionsGuestViewContainer(render_frame); |
| 1648 } else { | 1645 } else { |
| 1649 return new extensions::MimeHandlerViewContainer( | 1646 return new extensions::MimeHandlerViewContainer( |
| 1650 render_frame, mime_type, original_url); | 1647 render_frame, mime_type, original_url); |
| 1651 } | 1648 } |
| 1652 #else | 1649 #else |
| 1653 return NULL; | 1650 return NULL; |
| 1654 #endif | 1651 #endif |
| 1655 } | 1652 } |
| OLD | NEW |