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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 // reduce the chance of future regressions. | 761 // reduce the chance of future regressions. |
762 bool is_prerendering = | 762 bool is_prerendering = |
763 prerender::PrerenderHelper::IsPrerendering(render_frame); | 763 prerender::PrerenderHelper::IsPrerendering(render_frame); |
764 | 764 |
765 bool power_saver_setting_on = | 765 bool power_saver_setting_on = |
766 status == | 766 status == |
767 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 767 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
768 PowerSaverInfo power_saver_info = | 768 PowerSaverInfo power_saver_info = |
769 PowerSaverInfo::Get(render_frame, power_saver_setting_on, params, | 769 PowerSaverInfo::Get(render_frame, power_saver_setting_on, params, |
770 info, frame->document().url()); | 770 info, frame->document().url()); |
| 771 // Prevent small plugins from loading by using a placeholder until |
| 772 // we can determine the unobscured size of the object. |
| 773 bool blocked_for_tinyness = |
| 774 ChromePluginPlaceholder::IsSmallContentFilterEnabled() && |
| 775 power_saver_info.power_saver_enabled; |
| 776 |
771 if (power_saver_info.blocked_for_background_tab || is_prerendering || | 777 if (power_saver_info.blocked_for_background_tab || is_prerendering || |
772 !power_saver_info.poster_attribute.empty()) { | 778 !power_saver_info.poster_attribute.empty() || |
| 779 blocked_for_tinyness) { |
773 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( | 780 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( |
774 render_frame, frame, params, info, identifier, group_name, | 781 render_frame, frame, params, info, identifier, group_name, |
775 power_saver_info.poster_attribute.empty() | 782 power_saver_info.poster_attribute.empty() |
776 ? IDR_BLOCKED_PLUGIN_HTML | 783 ? IDR_BLOCKED_PLUGIN_HTML |
777 : IDR_PLUGIN_POSTER_HTML, | 784 : IDR_PLUGIN_POSTER_HTML, |
778 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 785 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
779 power_saver_info); | 786 power_saver_info); |
780 placeholder->set_blocked_for_prerendering(is_prerendering); | 787 placeholder->set_blocked_for_prerendering(is_prerendering); |
| 788 placeholder->set_blocked_for_tinyness(blocked_for_tinyness); |
781 placeholder->AllowLoading(); | 789 placeholder->AllowLoading(); |
782 break; | 790 break; |
783 } | 791 } |
784 | 792 |
785 std::unique_ptr<content::PluginInstanceThrottler> throttler; | 793 std::unique_ptr<content::PluginInstanceThrottler> throttler; |
786 | |
787 // Small content filter requires routing through a placeholder. | |
788 if (ChromePluginPlaceholder::IsSmallContentFilterEnabled() && | |
789 power_saver_info.power_saver_enabled) { | |
790 // The feature only applies to flash plugins. | |
791 if (power_saver_info.is_eligible) { | |
792 placeholder = ChromePluginPlaceholder::CreateDelayedPlugin( | |
793 render_frame, frame, params, info, identifier, group_name, | |
794 power_saver_info); | |
795 break; | |
796 } | |
797 } | |
798 | |
799 if (power_saver_info.power_saver_enabled) { | 794 if (power_saver_info.power_saver_enabled) { |
800 throttler = PluginInstanceThrottler::Create(); | 795 throttler = PluginInstanceThrottler::Create(); |
801 // PluginPreroller manages its own lifetime. | 796 // PluginPreroller manages its own lifetime. |
802 new PluginPreroller( | 797 new PluginPreroller( |
803 render_frame, frame, params, info, identifier, group_name, | 798 render_frame, frame, params, info, identifier, group_name, |
804 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 799 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
805 throttler.get()); | 800 throttler.get()); |
806 } | 801 } |
807 | 802 |
808 return render_frame->CreatePlugin(frame, info, params, | 803 return render_frame->CreatePlugin(frame, info, params, |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 // chrome.system.network.getNetworkInterfaces provides the same | 1378 // chrome.system.network.getNetworkInterfaces provides the same |
1384 // information. Also, the enforcement of sending and binding UDP is already done | 1379 // information. Also, the enforcement of sending and binding UDP is already done |
1385 // by chrome extension permission model. | 1380 // by chrome extension permission model. |
1386 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { | 1381 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { |
1387 #if defined(ENABLE_EXTENSIONS) | 1382 #if defined(ENABLE_EXTENSIONS) |
1388 return !IsStandaloneExtensionProcess(); | 1383 return !IsStandaloneExtensionProcess(); |
1389 #else | 1384 #else |
1390 return true; | 1385 return true; |
1391 #endif | 1386 #endif |
1392 } | 1387 } |
OLD | NEW |