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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 #include "components/dns_prefetch/renderer/prescient_networking_dispatcher.h" | 63 #include "components/dns_prefetch/renderer/prescient_networking_dispatcher.h" |
| 64 #include "components/dom_distiller/core/url_constants.h" | 64 #include "components/dom_distiller/core/url_constants.h" |
| 65 #include "components/nacl/renderer/ppb_nacl_private_impl.h" | 65 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
| 66 #include "components/password_manager/content/renderer/credential_manager_client .h" | 66 #include "components/password_manager/content/renderer/credential_manager_client .h" |
| 67 #include "components/pdf/renderer/ppb_pdf_impl.h" | 67 #include "components/pdf/renderer/ppb_pdf_impl.h" |
| 68 #include "components/plugins/renderer/mobile_youtube_plugin.h" | 68 #include "components/plugins/renderer/mobile_youtube_plugin.h" |
| 69 #include "components/signin/core/common/profile_management_switches.h" | 69 #include "components/signin/core/common/profile_management_switches.h" |
| 70 #include "components/visitedlink/renderer/visitedlink_slave.h" | 70 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 71 #include "components/web_cache/renderer/web_cache_render_process_observer.h" | 71 #include "components/web_cache/renderer/web_cache_render_process_observer.h" |
| 72 #include "content/public/common/content_constants.h" | 72 #include "content/public/common/content_constants.h" |
| 73 #include "content/public/renderer/plugin_instance_throttler.h" | |
| 73 #include "content/public/renderer/render_frame.h" | 74 #include "content/public/renderer/render_frame.h" |
| 74 #include "content/public/renderer/render_thread.h" | 75 #include "content/public/renderer/render_thread.h" |
| 75 #include "content/public/renderer/render_view.h" | 76 #include "content/public/renderer/render_view.h" |
| 76 #include "content/public/renderer/render_view_visitor.h" | 77 #include "content/public/renderer/render_view_visitor.h" |
| 77 #include "extensions/common/constants.h" | 78 #include "extensions/common/constants.h" |
| 78 #include "ipc/ipc_sync_channel.h" | 79 #include "ipc/ipc_sync_channel.h" |
| 79 #include "net/base/net_errors.h" | 80 #include "net/base/net_errors.h" |
| 80 #include "ppapi/c/private/ppb_nacl_private.h" | 81 #include "ppapi/c/private/ppb_nacl_private.h" |
| 81 #include "ppapi/c/private/ppb_pdf.h" | 82 #include "ppapi/c/private/ppb_pdf.h" |
| 82 #include "ppapi/shared_impl/ppapi_switches.h" | 83 #include "ppapi/shared_impl/ppapi_switches.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 146 |
| 146 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
| 147 #include "chrome_elf/blacklist/blacklist.h" | 148 #include "chrome_elf/blacklist/blacklist.h" |
| 148 #endif | 149 #endif |
| 149 | 150 |
| 150 using autofill::AutofillAgent; | 151 using autofill::AutofillAgent; |
| 151 using autofill::PasswordAutofillAgent; | 152 using autofill::PasswordAutofillAgent; |
| 152 using autofill::PasswordGenerationAgent; | 153 using autofill::PasswordGenerationAgent; |
| 153 using base::ASCIIToUTF16; | 154 using base::ASCIIToUTF16; |
| 154 using base::UserMetricsAction; | 155 using base::UserMetricsAction; |
| 156 using content::PluginInstanceThrottler; | |
| 155 using content::RenderFrame; | 157 using content::RenderFrame; |
| 156 using content::RenderThread; | 158 using content::RenderThread; |
| 157 using content::WebPluginInfo; | 159 using content::WebPluginInfo; |
| 158 using extensions::Extension; | 160 using extensions::Extension; |
| 159 using blink::WebCache; | 161 using blink::WebCache; |
| 160 using blink::WebConsoleMessage; | 162 using blink::WebConsoleMessage; |
| 161 using blink::WebDataSource; | 163 using blink::WebDataSource; |
| 162 using blink::WebDocument; | 164 using blink::WebDocument; |
| 163 using blink::WebFrame; | 165 using blink::WebFrame; |
| 164 using blink::WebLocalFrame; | 166 using blink::WebLocalFrame; |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED), | 789 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED), |
| 788 #else | 790 #else |
| 789 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 791 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
| 790 #endif | 792 #endif |
| 791 GURL()); | 793 GURL()); |
| 792 break; | 794 break; |
| 793 } | 795 } |
| 794 } | 796 } |
| 795 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 797 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
| 796 | 798 |
| 797 RenderFrame::PluginPowerSaverMode power_saver_mode = | |
| 798 RenderFrame::POWER_SAVER_MODE_ESSENTIAL; | |
| 799 #if defined(ENABLE_PLUGINS) | 799 #if defined(ENABLE_PLUGINS) |
| 800 PluginInstanceThrottler::PluginPowerSaverMode power_saver_mode = | |
| 801 PluginInstanceThrottler::POWER_SAVER_MODE_ESSENTIAL; | |
| 800 bool show_poster = false; | 802 bool show_poster = false; |
| 801 GURL poster_url; | 803 GURL poster_url; |
| 802 bool cross_origin_main_content = false; | 804 bool cross_origin_main_content = false; |
| 803 bool blocked_for_background_tab = | 805 bool blocked_for_background_tab = |
| 804 render_frame->IsHidden() && | 806 render_frame->IsHidden() && |
| 805 status_value == | 807 status_value == |
| 806 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 808 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
| 807 if (render_frame->ShouldThrottleContent(params, frame->document().url(), | 809 if (render_frame->ShouldThrottleContent(params, frame->document().url(), |
| 808 &poster_url, | 810 &poster_url, |
| 809 &cross_origin_main_content)) { | 811 &cross_origin_main_content)) { |
| 810 if (status_value == | 812 // TODO(tommycli): Apply throttler behavior to all plugins. |
| 811 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { | 813 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status:: |
|
Lei Zhang
2015/01/14 23:49:33
nit: can you pick one style of line breaks and sti
tommycli
2015/01/15 00:26:05
I'm just doing 'git cl format'. Does it look bette
Lei Zhang
2015/01/15 01:18:38
No, but whatever.
tommycli
2015/01/15 23:19:32
Done.
| |
| 814 kPlayImportantContent && | |
| 815 plugin.name == base::ASCIIToUTF16(content::kFlashPluginName)) { | |
|
Lei Zhang
2015/01/14 23:49:33
Is this a behavior change that you didn't mention
tommycli
2015/01/15 00:26:05
Previous the Flash-only conditional was in the Thr
Lei Zhang
2015/01/15 01:18:38
The comment in content/public/renderer/plugin_inst
tommycli
2015/01/15 23:19:32
Done.
| |
| 812 power_saver_mode = | 816 power_saver_mode = |
| 813 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; | 817 PluginInstanceThrottler::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; |
| 814 show_poster = poster_url.is_valid(); | 818 show_poster = poster_url.is_valid(); |
| 815 } else { | 819 } else { |
| 816 power_saver_mode = | 820 power_saver_mode = PluginInstanceThrottler:: |
| 817 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; | 821 POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; |
| 818 } | 822 } |
| 819 } | 823 } |
| 820 | 824 |
| 821 // Delay loading plugins if prerendering. | 825 // Delay loading plugins if prerendering. |
| 822 // TODO(mmenke): In the case of prerendering, feed into | 826 // TODO(mmenke): In the case of prerendering, feed into |
| 823 // ChromeContentRendererClient::CreatePlugin instead, to | 827 // ChromeContentRendererClient::CreatePlugin instead, to |
| 824 // reduce the chance of future regressions. | 828 // reduce the chance of future regressions. |
| 825 bool is_prerendering = | 829 bool is_prerendering = |
| 826 prerender::PrerenderHelper::IsPrerendering(render_frame); | 830 prerender::PrerenderHelper::IsPrerendering(render_frame); |
| 827 if (blocked_for_background_tab || is_prerendering || show_poster) { | 831 if (blocked_for_background_tab || is_prerendering || show_poster) { |
| 828 placeholder = create_blocked_plugin( | 832 placeholder = create_blocked_plugin( |
| 829 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML, | 833 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML, |
| 830 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 834 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
| 831 poster_url); | 835 poster_url); |
| 832 placeholder->set_blocked_for_background_tab( | 836 placeholder->set_blocked_for_background_tab( |
| 833 blocked_for_background_tab); | 837 blocked_for_background_tab); |
| 834 placeholder->set_blocked_for_prerendering(is_prerendering); | 838 placeholder->set_blocked_for_prerendering(is_prerendering); |
| 835 placeholder->set_power_saver_mode(power_saver_mode); | 839 placeholder->set_power_saver_mode(power_saver_mode); |
| 836 placeholder->set_allow_loading(true); | 840 placeholder->set_allow_loading(true); |
| 837 break; | 841 break; |
| 838 } else if (cross_origin_main_content) { | 842 } else if (cross_origin_main_content) { |
| 839 GURL content_origin = GURL(params.url).GetOrigin(); | 843 GURL content_origin = GURL(params.url).GetOrigin(); |
| 840 render_frame->WhitelistContentOrigin(content_origin); | 844 render_frame->WhitelistContentOrigin(content_origin); |
| 841 } | 845 } |
| 842 #endif // defined(ENABLE_PLUGINS) | |
| 843 | 846 |
| 847 scoped_ptr<content::PluginInstanceThrottler> throttler; | |
| 848 if (power_saver_mode != | |
| 849 content::PluginInstanceThrottler::POWER_SAVER_MODE_ESSENTIAL) { | |
| 850 throttler = content::PluginInstanceThrottler::Create( | |
|
Lei Zhang
2015/01/14 23:49:33
You are never creating a throttler for POWER_SAVER
tommycli
2015/01/15 00:26:05
Nice catch! You are right. That was an oversight a
Lei Zhang
2015/01/15 01:18:38
It's still a bit unintuitive. We have:
ESSENTIAL:
tommycli
2015/01/15 23:19:32
Done.
Okay this comment helped clarify my thinkin
| |
| 851 render_frame, url, power_saver_mode); | |
| 852 } | |
| 844 return render_frame->CreatePlugin(frame, plugin, params, | 853 return render_frame->CreatePlugin(frame, plugin, params, |
| 845 power_saver_mode); | 854 throttler.Pass()); |
| 855 #else // !defined(ENABLE_PLUGINS) | |
| 856 return render_frame->CreatePlugin(frame, plugin, params, nullptr); | |
| 857 #endif | |
| 846 } | 858 } |
| 847 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { | 859 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { |
| 848 RenderThread::Get()->RecordAction( | 860 RenderThread::Get()->RecordAction( |
| 849 UserMetricsAction("Plugin_NPAPINotSupported")); | 861 UserMetricsAction("Plugin_NPAPINotSupported")); |
| 850 placeholder = create_blocked_plugin( | 862 placeholder = create_blocked_plugin( |
| 851 IDR_BLOCKED_PLUGIN_HTML, | 863 IDR_BLOCKED_PLUGIN_HTML, |
| 852 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO), GURL()); | 864 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO), GURL()); |
| 853 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( | 865 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( |
| 854 render_frame->GetRoutingID(), identifier)); | 866 render_frame->GetRoutingID(), identifier)); |
| 855 break; | 867 break; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 if (mime_type == content::kBrowserPluginMimeType) { | 1593 if (mime_type == content::kBrowserPluginMimeType) { |
| 1582 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1594 return new extensions::ExtensionsGuestViewContainer(render_frame); |
| 1583 } else { | 1595 } else { |
| 1584 return new extensions::MimeHandlerViewContainer( | 1596 return new extensions::MimeHandlerViewContainer( |
| 1585 render_frame, mime_type, original_url); | 1597 render_frame, mime_type, original_url); |
| 1586 } | 1598 } |
| 1587 #else | 1599 #else |
| 1588 return NULL; | 1600 return NULL; |
| 1589 #endif | 1601 #endif |
| 1590 } | 1602 } |
| OLD | NEW |