Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 849723002: Plugin Power Saver: Make PepperPluginInstanceThrottler interface public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/plugins/renderer/plugin_placeholder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
157 using content::PluginPowerSaverMode;
155 using content::RenderFrame; 158 using content::RenderFrame;
156 using content::RenderThread; 159 using content::RenderThread;
157 using content::WebPluginInfo; 160 using content::WebPluginInfo;
158 using extensions::Extension; 161 using extensions::Extension;
159 using blink::WebCache; 162 using blink::WebCache;
160 using blink::WebConsoleMessage; 163 using blink::WebConsoleMessage;
161 using blink::WebDataSource; 164 using blink::WebDataSource;
162 using blink::WebDocument; 165 using blink::WebDocument;
163 using blink::WebFrame; 166 using blink::WebFrame;
164 using blink::WebLocalFrame; 167 using blink::WebLocalFrame;
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED), 790 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED),
788 #else 791 #else
789 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 792 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
790 #endif 793 #endif
791 GURL()); 794 GURL());
792 break; 795 break;
793 } 796 }
794 } 797 }
795 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 798 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
796 799
797 RenderFrame::PluginPowerSaverMode power_saver_mode = 800 scoped_ptr<content::PluginInstanceThrottler> throttler;
798 RenderFrame::POWER_SAVER_MODE_ESSENTIAL;
799 #if defined(ENABLE_PLUGINS) 801 #if defined(ENABLE_PLUGINS)
802 PluginPowerSaverMode power_saver_mode =
803 PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL;
800 bool show_poster = false; 804 bool show_poster = false;
801 GURL poster_url; 805 GURL poster_url;
802 bool cross_origin_main_content = false; 806 bool cross_origin_main_content = false;
803 bool blocked_for_background_tab = 807 bool blocked_for_background_tab =
804 render_frame->IsHidden() && 808 render_frame->IsHidden() &&
805 status_value == 809 status_value ==
806 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 810 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
807 if (render_frame->ShouldThrottleContent(params, frame->document().url(), 811 if (render_frame->ShouldThrottleContent(params, frame->document().url(),
808 &poster_url, 812 &poster_url,
809 &cross_origin_main_content)) { 813 &cross_origin_main_content)) {
810 if (status_value == 814 // TODO(tommycli): Apply throttler behavior to all plugins.
811 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { 815 if (plugin.name == base::ASCIIToUTF16(content::kFlashPluginName) &&
816 status_value == ChromeViewHostMsg_GetPluginInfo_Status::
817 kPlayImportantContent) {
812 power_saver_mode = 818 power_saver_mode =
813 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; 819 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_THROTTLED;
814 show_poster = poster_url.is_valid(); 820 show_poster = poster_url.is_valid();
815 } else { 821 } else {
816 power_saver_mode = 822 power_saver_mode =
817 RenderFrame::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; 823 PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED;
818 } 824 }
825
826 throttler = content::PluginInstanceThrottler::Get(render_frame, url,
827 power_saver_mode);
819 } 828 }
820 829
821 // Delay loading plugins if prerendering. 830 // Delay loading plugins if prerendering.
822 // TODO(mmenke): In the case of prerendering, feed into 831 // TODO(mmenke): In the case of prerendering, feed into
823 // ChromeContentRendererClient::CreatePlugin instead, to 832 // ChromeContentRendererClient::CreatePlugin instead, to
824 // reduce the chance of future regressions. 833 // reduce the chance of future regressions.
825 bool is_prerendering = 834 bool is_prerendering =
826 prerender::PrerenderHelper::IsPrerendering(render_frame); 835 prerender::PrerenderHelper::IsPrerendering(render_frame);
827 if (blocked_for_background_tab || is_prerendering || show_poster) { 836 if (blocked_for_background_tab || is_prerendering || show_poster) {
828 placeholder = create_blocked_plugin( 837 placeholder = create_blocked_plugin(
829 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML, 838 show_poster ? IDR_PLUGIN_POSTER_HTML : IDR_BLOCKED_PLUGIN_HTML,
830 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 839 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
831 poster_url); 840 poster_url);
832 placeholder->set_blocked_for_background_tab( 841 placeholder->set_blocked_for_background_tab(
833 blocked_for_background_tab); 842 blocked_for_background_tab);
834 placeholder->set_blocked_for_prerendering(is_prerendering); 843 placeholder->set_blocked_for_prerendering(is_prerendering);
835 placeholder->set_power_saver_mode(power_saver_mode); 844 placeholder->set_power_saver_mode(power_saver_mode);
836 placeholder->set_allow_loading(true); 845 placeholder->set_allow_loading(true);
837 break; 846 break;
838 } else if (cross_origin_main_content) { 847 } else if (cross_origin_main_content) {
839 GURL content_origin = GURL(params.url).GetOrigin(); 848 GURL content_origin = GURL(params.url).GetOrigin();
840 render_frame->WhitelistContentOrigin(content_origin); 849 render_frame->WhitelistContentOrigin(content_origin);
841 } 850 }
842 #endif // defined(ENABLE_PLUGINS) 851 #endif // defined(ENABLE_PLUGINS)
843
844 return render_frame->CreatePlugin(frame, plugin, params, 852 return render_frame->CreatePlugin(frame, plugin, params,
845 power_saver_mode); 853 throttler.Pass());
846 } 854 }
847 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { 855 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: {
848 RenderThread::Get()->RecordAction( 856 RenderThread::Get()->RecordAction(
849 UserMetricsAction("Plugin_NPAPINotSupported")); 857 UserMetricsAction("Plugin_NPAPINotSupported"));
850 placeholder = create_blocked_plugin( 858 placeholder = create_blocked_plugin(
851 IDR_BLOCKED_PLUGIN_HTML, 859 IDR_BLOCKED_PLUGIN_HTML,
852 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO), GURL()); 860 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO), GURL());
853 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( 861 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported(
854 render_frame->GetRoutingID(), identifier)); 862 render_frame->GetRoutingID(), identifier));
855 break; 863 break;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 if (mime_type == content::kBrowserPluginMimeType) { 1589 if (mime_type == content::kBrowserPluginMimeType) {
1582 return new extensions::ExtensionsGuestViewContainer(render_frame); 1590 return new extensions::ExtensionsGuestViewContainer(render_frame);
1583 } else { 1591 } else {
1584 return new extensions::MimeHandlerViewContainer( 1592 return new extensions::MimeHandlerViewContainer(
1585 render_frame, mime_type, original_url); 1593 render_frame, mime_type, original_url);
1586 } 1594 }
1587 #else 1595 #else
1588 return NULL; 1596 return NULL;
1589 #endif 1597 #endif
1590 } 1598 }
OLDNEW
« no previous file with comments | « no previous file | components/plugins/renderer/plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698