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

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

Issue 1161923004: Reland: Plugin Placeholders: Refactor for platforms that don't support plugins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove some enable_plugins that are no longer needed Created 5 years, 6 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
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 22 matching lines...) Expand all
33 #include "chrome/renderer/chrome_render_process_observer.h" 33 #include "chrome/renderer/chrome_render_process_observer.h"
34 #include "chrome/renderer/chrome_render_view_observer.h" 34 #include "chrome/renderer/chrome_render_view_observer.h"
35 #include "chrome/renderer/content_settings_observer.h" 35 #include "chrome/renderer/content_settings_observer.h"
36 #include "chrome/renderer/external_extension.h" 36 #include "chrome/renderer/external_extension.h"
37 #include "chrome/renderer/loadtimes_extension_bindings.h" 37 #include "chrome/renderer/loadtimes_extension_bindings.h"
38 #include "chrome/renderer/media/chrome_key_systems.h" 38 #include "chrome/renderer/media/chrome_key_systems.h"
39 #include "chrome/renderer/net/net_error_helper.h" 39 #include "chrome/renderer/net/net_error_helper.h"
40 #include "chrome/renderer/net_benchmarking_extension.h" 40 #include "chrome/renderer/net_benchmarking_extension.h"
41 #include "chrome/renderer/page_load_histograms.h" 41 #include "chrome/renderer/page_load_histograms.h"
42 #include "chrome/renderer/pepper/pepper_helper.h" 42 #include "chrome/renderer/pepper/pepper_helper.h"
43 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" 43 #include "chrome/renderer/plugins/non_loadable_plugin_placeholder.h"
44 #include "chrome/renderer/plugins/plugin_preroller.h" 44 #include "chrome/renderer/plugins/plugin_preroller.h"
45 #include "chrome/renderer/plugins/plugin_uma.h" 45 #include "chrome/renderer/plugins/plugin_uma.h"
46 #include "chrome/renderer/plugins/shadow_dom_plugin_placeholder.h" 46 #include "chrome/renderer/plugins/shadow_dom_plugin_placeholder.h"
47 #include "chrome/renderer/prerender/prerender_dispatcher.h" 47 #include "chrome/renderer/prerender/prerender_dispatcher.h"
48 #include "chrome/renderer/prerender/prerender_helper.h" 48 #include "chrome/renderer/prerender/prerender_helper.h"
49 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" 49 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h"
50 #include "chrome/renderer/prerender/prerenderer_client.h" 50 #include "chrome/renderer/prerender/prerenderer_client.h"
51 #include "chrome/renderer/safe_browsing/malware_dom_details.h" 51 #include "chrome/renderer/safe_browsing/malware_dom_details.h"
52 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 52 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
53 #include "chrome/renderer/searchbox/search_bouncer.h" 53 #include "chrome/renderer/searchbox/search_bouncer.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #include "extensions/renderer/guest_view/extensions_guest_view_container.h" 125 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
126 #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatc her.h" 126 #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatc her.h"
127 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" 127 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h"
128 #include "extensions/renderer/script_context.h" 128 #include "extensions/renderer/script_context.h"
129 #endif 129 #endif
130 130
131 #if defined(ENABLE_IPC_FUZZER) 131 #if defined(ENABLE_IPC_FUZZER)
132 #include "chrome/common/external_ipc_dumper.h" 132 #include "chrome/common/external_ipc_dumper.h"
133 #endif 133 #endif
134 134
135 #if defined(ENABLE_PLUGINS)
136 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
137 #endif
138
135 #if defined(ENABLE_PRINTING) 139 #if defined(ENABLE_PRINTING)
136 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h" 140 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h"
137 #include "components/printing/renderer/print_web_view_helper.h" 141 #include "components/printing/renderer/print_web_view_helper.h"
138 #endif 142 #endif
139 143
140 #if defined(ENABLE_PRINT_PREVIEW) 144 #if defined(ENABLE_PRINT_PREVIEW)
141 #include "chrome/renderer/pepper/chrome_pdf_print_client.h" 145 #include "chrome/renderer/pepper/chrome_pdf_print_client.h"
142 #endif 146 #endif
143 147
144 #if defined(ENABLE_SPELLCHECK) 148 #if defined(ENABLE_SPELLCHECK)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", 193 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
190 "4EB74897CB187C7633357C2FE832E0AD6A44883A" 194 "4EB74897CB187C7633357C2FE832E0AD6A44883A"
191 }; 195 };
192 196
193 const char* const kPredefinedAllowedCompositorOrigins[] = { 197 const char* const kPredefinedAllowedCompositorOrigins[] = {
194 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", 198 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
195 "4EB74897CB187C7633357C2FE832E0AD6A44883A" 199 "4EB74897CB187C7633357C2FE832E0AD6A44883A"
196 }; 200 };
197 #endif 201 #endif
198 202
203 #if defined(ENABLE_PLUGINS)
199 void AppendParams(const std::vector<base::string16>& additional_names, 204 void AppendParams(const std::vector<base::string16>& additional_names,
200 const std::vector<base::string16>& additional_values, 205 const std::vector<base::string16>& additional_values,
201 WebVector<WebString>* existing_names, 206 WebVector<WebString>* existing_names,
202 WebVector<WebString>* existing_values) { 207 WebVector<WebString>* existing_values) {
203 DCHECK(additional_names.size() == additional_values.size()); 208 DCHECK(additional_names.size() == additional_values.size());
204 DCHECK(existing_names->size() == existing_values->size()); 209 DCHECK(existing_names->size() == existing_values->size());
205 210
206 size_t existing_size = existing_names->size(); 211 size_t existing_size = existing_names->size();
207 size_t total_size = existing_size + additional_names.size(); 212 size_t total_size = existing_size + additional_names.size();
208 213
209 WebVector<WebString> names(total_size); 214 WebVector<WebString> names(total_size);
210 WebVector<WebString> values(total_size); 215 WebVector<WebString> values(total_size);
211 216
212 for (size_t i = 0; i < existing_size; ++i) { 217 for (size_t i = 0; i < existing_size; ++i) {
213 names[i] = (*existing_names)[i]; 218 names[i] = (*existing_names)[i];
214 values[i] = (*existing_values)[i]; 219 values[i] = (*existing_values)[i];
215 } 220 }
216 221
217 for (size_t i = 0; i < additional_names.size(); ++i) { 222 for (size_t i = 0; i < additional_names.size(); ++i) {
218 names[existing_size + i] = additional_names[i]; 223 names[existing_size + i] = additional_names[i];
219 values[existing_size + i] = additional_values[i]; 224 values[existing_size + i] = additional_values[i];
220 } 225 }
221 226
222 existing_names->swap(names); 227 existing_names->swap(names);
223 existing_values->swap(values); 228 existing_values->swap(values);
224 } 229 }
225 230
226 #if defined(ENABLE_SPELLCHECK)
227 class SpellCheckReplacer : public content::RenderViewVisitor {
228 public:
229 explicit SpellCheckReplacer(SpellCheck* spellcheck)
230 : spellcheck_(spellcheck) {}
231 bool Visit(content::RenderView* render_view) override;
232
233 private:
234 SpellCheck* spellcheck_; // New shared spellcheck for all views. Weak Ptr.
235 DISALLOW_COPY_AND_ASSIGN(SpellCheckReplacer);
236 };
237
238 bool SpellCheckReplacer::Visit(content::RenderView* render_view) {
239 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view);
240 DCHECK(provider);
241 provider->set_spellcheck(spellcheck_);
242 return true;
243 }
244 #endif
245
246 // For certain sandboxed Pepper plugins, use the JavaScript Content Settings. 231 // For certain sandboxed Pepper plugins, use the JavaScript Content Settings.
247 bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { 232 bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) {
248 if (plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS && 233 if (plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS &&
249 plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) { 234 plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) {
250 return false; 235 return false;
251 } 236 }
252 237
253 #if !defined(DISABLE_NACL) 238 #if !defined(DISABLE_NACL)
254 // Treat Native Client invocations like JavaScript. 239 // Treat Native Client invocations like JavaScript.
255 if (plugin.name == ASCIIToUTF16(nacl::kNaClPluginName)) 240 if (plugin.name == ASCIIToUTF16(nacl::kNaClPluginName))
256 return true; 241 return true;
257 #endif 242 #endif
258 243
259 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) 244 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
260 // Treat CDM invocations like JavaScript. 245 // Treat CDM invocations like JavaScript.
261 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { 246 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) {
262 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); 247 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS);
263 return true; 248 return true;
264 } 249 }
265 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) 250 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
266 251
267 return false; 252 return false;
268 } 253 }
254 #endif // defined(ENABLE_PLUGINS)
255
256 #if defined(ENABLE_SPELLCHECK)
257 class SpellCheckReplacer : public content::RenderViewVisitor {
258 public:
259 explicit SpellCheckReplacer(SpellCheck* spellcheck)
260 : spellcheck_(spellcheck) {}
261 bool Visit(content::RenderView* render_view) override;
262
263 private:
264 SpellCheck* spellcheck_; // New shared spellcheck for all views. Weak Ptr.
265 DISALLOW_COPY_AND_ASSIGN(SpellCheckReplacer);
266 };
267
268 bool SpellCheckReplacer::Visit(content::RenderView* render_view) {
269 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view);
270 DCHECK(provider);
271 provider->set_spellcheck(spellcheck_);
272 return true;
273 }
274 #endif
269 275
270 #if defined(ENABLE_EXTENSIONS) 276 #if defined(ENABLE_EXTENSIONS)
271 void IsGuestViewApiAvailableToScriptContext( 277 void IsGuestViewApiAvailableToScriptContext(
272 bool* api_is_available, 278 bool* api_is_available,
273 extensions::ScriptContext* context) { 279 extensions::ScriptContext* context) {
274 if (context->GetAvailability("guestViewInternal").is_available()) { 280 if (context->GetAvailability("guestViewInternal").is_available()) {
275 *api_is_available = true; 281 *api_is_available = true;
276 } 282 }
277 } 283 }
278 #endif 284 #endif
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 bool guest_view_api_available = false; 649 bool guest_view_api_available = false;
644 extension_dispatcher_->script_context_set().ForEach( 650 extension_dispatcher_->script_context_set().ForEach(
645 render_frame->GetRenderView(), 651 render_frame->GetRenderView(),
646 base::Bind(&IsGuestViewApiAvailableToScriptContext, 652 base::Bind(&IsGuestViewApiAvailableToScriptContext,
647 &guest_view_api_available)); 653 &guest_view_api_available));
648 if (guest_view_api_available) 654 if (guest_view_api_available)
649 return false; 655 return false;
650 } 656 }
651 #endif 657 #endif
652 658
659 GURL url(params.url);
660 #if defined(ENABLE_PLUGINS)
653 ChromeViewHostMsg_GetPluginInfo_Output output; 661 ChromeViewHostMsg_GetPluginInfo_Output output;
654 #if defined(ENABLE_PLUGINS)
655 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( 662 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo(
656 render_frame->GetRoutingID(), GURL(params.url), 663 render_frame->GetRoutingID(), url, frame->top()->document().url(),
657 frame->top()->document().url(), orig_mime_type, &output)); 664 orig_mime_type, &output));
665 *plugin = CreatePlugin(render_frame, frame, params, output);
666 #else // !defined(ENABLE_PLUGINS)
658 667
659 #else 668 #if defined(OS_ANDROID)
660 output.status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; 669 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) {
661 #endif 670 base::StringPiece template_html(
662 *plugin = CreatePlugin(render_frame, frame, params, output); 671 ResourceBundle::GetSharedInstance().GetRawDataResource(
672 IDR_MOBILE_YOUTUBE_PLUGIN_HTML));
673 *plugin = (new plugins::MobileYouTubePlugin(render_frame, frame, params,
674 template_html))->plugin();
675 return true;
676 }
677 #endif // defined(OS_ANDROID)
678
679 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url);
680 *plugin = NonLoadablePluginPlaceholder::CreateNotSupportedPlugin(
681 render_frame, frame, params)->plugin();
682
683 #endif // defined(ENABLE_PLUGINS)
663 return true; 684 return true;
664 } 685 }
665 686
666 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( 687 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement(
667 content::RenderFrame* render_frame, 688 content::RenderFrame* render_frame,
668 const base::FilePath& plugin_path) { 689 const base::FilePath& plugin_path) {
669 ChromePluginPlaceholder* placeholder = 690 return NonLoadablePluginPlaceholder::CreateErrorPlugin(render_frame,
670 ChromePluginPlaceholder::CreateErrorPlugin(render_frame, plugin_path); 691 plugin_path)->plugin();
671 return placeholder->plugin();
672 } 692 }
673 693
674 void ChromeContentRendererClient::DeferMediaLoad( 694 void ChromeContentRendererClient::DeferMediaLoad(
675 content::RenderFrame* render_frame, 695 content::RenderFrame* render_frame,
676 const base::Closure& closure) { 696 const base::Closure& closure) {
677 #if defined(OS_ANDROID) 697 #if defined(OS_ANDROID)
678 // Chromium for Android doesn't support prerender yet. 698 // Chromium for Android doesn't support prerender yet.
679 closure.Run(); 699 closure.Run();
680 return; 700 return;
681 #else 701 #else
682 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) { 702 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) {
683 closure.Run(); 703 closure.Run();
684 return; 704 return;
685 } 705 }
686 706
687 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. 707 // Lifetime is tied to |render_frame| via content::RenderFrameObserver.
688 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); 708 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure);
689 #endif 709 #endif
690 } 710 }
691 711
712 #if defined(ENABLE_PLUGINS)
692 WebPlugin* ChromeContentRendererClient::CreatePlugin( 713 WebPlugin* ChromeContentRendererClient::CreatePlugin(
693 content::RenderFrame* render_frame, 714 content::RenderFrame* render_frame,
694 blink::WebLocalFrame* frame, 715 blink::WebLocalFrame* frame,
695 const WebPluginParams& original_params, 716 const WebPluginParams& original_params,
696 const ChromeViewHostMsg_GetPluginInfo_Output& output) { 717 const ChromeViewHostMsg_GetPluginInfo_Output& output) {
697 const WebPluginInfo& info = output.plugin; 718 const WebPluginInfo& info = output.plugin;
698 const std::string& actual_mime_type = output.actual_mime_type; 719 const std::string& actual_mime_type = output.actual_mime_type;
699 const base::string16& group_name = output.group_name; 720 const base::string16& group_name = output.group_name;
700 const std::string& identifier = output.group_identifier; 721 const std::string& identifier = output.group_identifier;
701 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; 722 ChromeViewHostMsg_GetPluginInfo_Status status = output.status;
702 GURL url(original_params.url); 723 GURL url(original_params.url);
703 std::string orig_mime_type = original_params.mimeType.utf8(); 724 std::string orig_mime_type = original_params.mimeType.utf8();
704 ChromePluginPlaceholder* placeholder = NULL; 725 ChromePluginPlaceholder* placeholder = NULL;
705 726
706 // If the browser plugin is to be enabled, this should be handled by the 727 // If the browser plugin is to be enabled, this should be handled by the
707 // renderer, so the code won't reach here due to the early exit in 728 // renderer, so the code won't reach here due to the early exit in
708 // OverrideCreatePlugin. 729 // OverrideCreatePlugin.
709 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || 730 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound ||
710 orig_mime_type == content::kBrowserPluginMimeType) { 731 orig_mime_type == content::kBrowserPluginMimeType) {
711 #if defined(OS_ANDROID)
712 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) {
713 base::StringPiece template_html(
714 ResourceBundle::GetSharedInstance().GetRawDataResource(
715 IDR_MOBILE_YOUTUBE_PLUGIN_HTML));
716 return (new plugins::MobileYouTubePlugin(
717 render_frame,
718 frame,
719 original_params,
720 template_html,
721 GURL(ChromePluginPlaceholder::kPluginPlaceholderDataURL)))
722 ->plugin();
723 }
724 #endif
725 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url); 732 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url);
726 placeholder = ChromePluginPlaceholder::CreateMissingPlugin( 733 placeholder = ChromePluginPlaceholder::CreateLoadableMissingPlugin(
727 render_frame, frame, original_params); 734 render_frame, frame, original_params);
728 } else { 735 } else {
729 // TODO(bauerb): This should be in content/. 736 // TODO(bauerb): This should be in content/.
730 WebPluginParams params(original_params); 737 WebPluginParams params(original_params);
731 for (size_t i = 0; i < info.mime_types.size(); ++i) { 738 for (size_t i = 0; i < info.mime_types.size(); ++i) {
732 if (info.mime_types[i].mime_type == actual_mime_type) { 739 if (info.mime_types[i].mime_type == actual_mime_type) {
733 AppendParams(info.mime_types[i].additional_param_names, 740 AppendParams(info.mime_types[i].additional_param_names,
734 info.mime_types[i].additional_param_values, 741 info.mime_types[i].additional_param_values,
735 &params.attributeNames, &params.attributeValues); 742 &params.attributeNames, &params.attributeValues);
736 break; 743 break;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 #if defined(OS_CHROMEOS) 846 #if defined(OS_CHROMEOS)
840 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); 847 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
841 #else 848 #else
842 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 849 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
843 #endif 850 #endif
844 break; 851 break;
845 } 852 }
846 } 853 }
847 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 854 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
848 855
849 #if defined(ENABLE_PLUGINS)
850 // Delay loading plugins if prerendering. 856 // Delay loading plugins if prerendering.
851 // TODO(mmenke): In the case of prerendering, feed into 857 // TODO(mmenke): In the case of prerendering, feed into
852 // ChromeContentRendererClient::CreatePlugin instead, to 858 // ChromeContentRendererClient::CreatePlugin instead, to
853 // reduce the chance of future regressions. 859 // reduce the chance of future regressions.
854 bool is_prerendering = 860 bool is_prerendering =
855 prerender::PrerenderHelper::IsPrerendering(render_frame); 861 prerender::PrerenderHelper::IsPrerendering(render_frame);
856 bool power_saver_enabled = 862 bool power_saver_enabled =
857 status == 863 status ==
858 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 864 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
859 bool blocked_for_background_tab = 865 bool blocked_for_background_tab =
(...skipping 14 matching lines...) Expand all
874 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( 880 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin(
875 render_frame, frame, params, info, identifier, group_name, 881 render_frame, frame, params, info, identifier, group_name,
876 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML 882 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML
877 : IDR_PLUGIN_POSTER_HTML, 883 : IDR_PLUGIN_POSTER_HTML,
878 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 884 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
879 poster_info); 885 poster_info);
880 placeholder->set_blocked_for_background_tab( 886 placeholder->set_blocked_for_background_tab(
881 blocked_for_background_tab); 887 blocked_for_background_tab);
882 placeholder->set_blocked_for_prerendering(is_prerendering); 888 placeholder->set_blocked_for_prerendering(is_prerendering);
883 placeholder->set_power_saver_enabled(power_saver_enabled); 889 placeholder->set_power_saver_enabled(power_saver_enabled);
884 placeholder->set_allow_loading(true);
885 break; 890 break;
886 } 891 }
887 892
888 scoped_ptr<content::PluginInstanceThrottler> throttler; 893 scoped_ptr<content::PluginInstanceThrottler> throttler;
889 if (power_saver_enabled) { 894 if (power_saver_enabled) {
890 throttler = PluginInstanceThrottler::Create(); 895 throttler = PluginInstanceThrottler::Create();
891 // PluginPreroller manages its own lifetime. 896 // PluginPreroller manages its own lifetime.
892 new PluginPreroller( 897 new PluginPreroller(
893 render_frame, frame, params, info, identifier, group_name, 898 render_frame, frame, params, info, identifier, group_name,
894 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 899 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
895 throttler.get()); 900 throttler.get());
896 } 901 }
897 902
898 return render_frame->CreatePlugin(frame, info, params, 903 return render_frame->CreatePlugin(frame, info, params,
899 throttler.Pass()); 904 throttler.Pass());
900 #else // !defined(ENABLE_PLUGINS)
901 return render_frame->CreatePlugin(frame, info, params, nullptr);
902 #endif // defined(ENABLE_PLUGINS)
903 } 905 }
904 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { 906 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: {
905 RenderThread::Get()->RecordAction( 907 RenderThread::Get()->RecordAction(
906 UserMetricsAction("Plugin_NPAPINotSupported")); 908 UserMetricsAction("Plugin_NPAPINotSupported"));
907 placeholder = create_blocked_plugin( 909 placeholder = create_blocked_plugin(
908 IDR_BLOCKED_PLUGIN_HTML, 910 IDR_BLOCKED_PLUGIN_HTML,
909 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO)); 911 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO));
910 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( 912 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported(
911 render_frame->GetRoutingID(), identifier)); 913 render_frame->GetRoutingID(), identifier));
912 break; 914 break;
913 } 915 }
914 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { 916 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: {
915 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, 917 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type,
916 url); 918 url);
917 placeholder = create_blocked_plugin( 919 placeholder = create_blocked_plugin(
918 IDR_DISABLED_PLUGIN_HTML, 920 IDR_DISABLED_PLUGIN_HTML,
919 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); 921 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name));
920 break; 922 break;
921 } 923 }
922 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { 924 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
923 #if defined(ENABLE_PLUGIN_INSTALLATION) 925 #if defined(ENABLE_PLUGIN_INSTALLATION)
924 placeholder = create_blocked_plugin( 926 placeholder = create_blocked_plugin(
925 IDR_BLOCKED_PLUGIN_HTML, 927 IDR_BLOCKED_PLUGIN_HTML,
926 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); 928 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
927 placeholder->set_allow_loading(true);
928 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( 929 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
929 render_frame->GetRoutingID(), placeholder->CreateRoutingId(), 930 render_frame->GetRoutingID(), placeholder->CreateRoutingId(),
930 identifier)); 931 identifier));
931 #else 932 #else
932 NOTREACHED(); 933 NOTREACHED();
933 #endif 934 #endif
934 break; 935 break;
935 } 936 }
936 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { 937 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
937 placeholder = create_blocked_plugin( 938 placeholder = create_blocked_plugin(
938 IDR_BLOCKED_PLUGIN_HTML, 939 IDR_BLOCKED_PLUGIN_HTML,
939 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); 940 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
940 break; 941 break;
941 } 942 }
942 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { 943 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
943 placeholder = create_blocked_plugin( 944 placeholder = create_blocked_plugin(
944 IDR_BLOCKED_PLUGIN_HTML, 945 IDR_BLOCKED_PLUGIN_HTML,
945 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); 946 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name));
946 placeholder->set_allow_loading(true);
947 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { 947 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
948 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( 948 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
949 render_frame->GetRoutingID(), 949 render_frame->GetRoutingID(),
950 group_name, 950 group_name,
951 identifier)); 951 identifier));
952 } 952 }
953 observer->DidBlockContentType(content_type, group_name); 953 observer->DidBlockContentType(content_type, group_name);
954 break; 954 break;
955 } 955 }
956 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { 956 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: {
957 placeholder = create_blocked_plugin( 957 placeholder = create_blocked_plugin(
958 IDR_BLOCKED_PLUGIN_HTML, 958 IDR_BLOCKED_PLUGIN_HTML,
959 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 959 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
960 placeholder->set_allow_loading(true);
961 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); 960 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked"));
962 observer->DidBlockContentType(content_type, group_name); 961 observer->DidBlockContentType(content_type, group_name);
963 break; 962 break;
964 } 963 }
965 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { 964 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: {
966 placeholder = create_blocked_plugin( 965 placeholder = create_blocked_plugin(
967 IDR_BLOCKED_PLUGIN_HTML, 966 IDR_BLOCKED_PLUGIN_HTML,
968 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY, 967 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY,
969 group_name)); 968 group_name));
970 placeholder->set_allow_loading(false); 969 placeholder->DisallowLoading();
971 RenderThread::Get()->RecordAction( 970 RenderThread::Get()->RecordAction(
972 UserMetricsAction("Plugin_BlockedByPolicy")); 971 UserMetricsAction("Plugin_BlockedByPolicy"));
973 observer->DidBlockContentType(content_type, group_name); 972 observer->DidBlockContentType(content_type, group_name);
974 break; 973 break;
975 } 974 }
976 } 975 }
977 } 976 }
978 placeholder->SetStatus(status); 977 placeholder->SetStatus(status);
979 return placeholder->plugin(); 978 return placeholder->plugin();
980 } 979 }
980 #endif // defined(ENABLE_PLUGINS)
981 981
982 // For NaCl content handling plugins, the NaCl manifest is stored in an 982 // For NaCl content handling plugins, the NaCl manifest is stored in an
983 // additonal 'nacl' param associated with the MIME type. 983 // additonal 'nacl' param associated with the MIME type.
984 // static 984 // static
985 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( 985 GURL ChromeContentRendererClient::GetNaClContentHandlerURL(
986 const std::string& actual_mime_type, 986 const std::string& actual_mime_type,
987 const content::WebPluginInfo& plugin) { 987 const content::WebPluginInfo& plugin) {
988 // Look for the manifest URL among the MIME type's additonal parameters. 988 // Look for the manifest URL among the MIME type's additonal parameters.
989 const char kNaClPluginManifestAttribute[] = "nacl"; 989 const char kNaClPluginManifestAttribute[] = "nacl";
990 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); 990 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute);
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 WebString header_key(ASCIIToUTF16( 1648 WebString header_key(ASCIIToUTF16(
1649 data_reduction_proxy::chrome_proxy_header())); 1649 data_reduction_proxy::chrome_proxy_header()));
1650 if (!response.httpHeaderField(header_key).isNull() && 1650 if (!response.httpHeaderField(header_key).isNull() &&
1651 response.httpHeaderField(header_key).utf8().find( 1651 response.httpHeaderField(header_key).utf8().find(
1652 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != 1652 data_reduction_proxy::chrome_proxy_lo_fi_directive()) !=
1653 std::string::npos) { 1653 std::string::npos) {
1654 (*properties)[data_reduction_proxy::chrome_proxy_header()] = 1654 (*properties)[data_reduction_proxy::chrome_proxy_header()] =
1655 data_reduction_proxy::chrome_proxy_lo_fi_directive(); 1655 data_reduction_proxy::chrome_proxy_lo_fi_directive();
1656 } 1656 }
1657 } 1657 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/plugins/chrome_plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698