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

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

Issue 1126073003: Plugin Placeholders: Refactor for platforms that don't support plugins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The version that was reverted. 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/guest_view_container.h" 126 #include "extensions/renderer/guest_view/guest_view_container.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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 bool guest_view_api_available = false; 646 bool guest_view_api_available = false;
641 extension_dispatcher_->script_context_set().ForEach( 647 extension_dispatcher_->script_context_set().ForEach(
642 render_frame->GetRenderView(), 648 render_frame->GetRenderView(),
643 base::Bind(&IsGuestViewApiAvailableToScriptContext, 649 base::Bind(&IsGuestViewApiAvailableToScriptContext,
644 &guest_view_api_available)); 650 &guest_view_api_available));
645 if (guest_view_api_available) 651 if (guest_view_api_available)
646 return false; 652 return false;
647 } 653 }
648 #endif 654 #endif
649 655
656 GURL url(params.url);
657 #if defined(ENABLE_PLUGINS)
650 ChromeViewHostMsg_GetPluginInfo_Output output; 658 ChromeViewHostMsg_GetPluginInfo_Output output;
651 #if defined(ENABLE_PLUGINS)
652 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo( 659 render_frame->Send(new ChromeViewHostMsg_GetPluginInfo(
653 render_frame->GetRoutingID(), GURL(params.url), 660 render_frame->GetRoutingID(), url, frame->top()->document().url(),
654 frame->top()->document().url(), orig_mime_type, &output)); 661 orig_mime_type, &output));
662 *plugin = CreatePlugin(render_frame, frame, params, output);
663 #else // !defined(ENABLE_PLUGINS)
655 664
656 #else 665 #if defined(OS_ANDROID)
657 output.status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; 666 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) {
658 #endif 667 base::StringPiece template_html(
659 *plugin = CreatePlugin(render_frame, frame, params, output); 668 ResourceBundle::GetSharedInstance().GetRawDataResource(
669 IDR_MOBILE_YOUTUBE_PLUGIN_HTML));
670 *plugin = (new plugins::MobileYouTubePlugin(render_frame, frame, params,
671 template_html))->plugin();
672 return true;
673 }
674 #endif // defined(OS_ANDROID)
675
676 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url);
677 *plugin = NonLoadablePluginPlaceholder::CreateNotSupportedPlugin(
678 render_frame, frame, params)->plugin();
679
680 #endif // defined(ENABLE_PLUGINS)
660 return true; 681 return true;
661 } 682 }
662 683
663 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( 684 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement(
664 content::RenderFrame* render_frame, 685 content::RenderFrame* render_frame,
665 const base::FilePath& plugin_path) { 686 const base::FilePath& plugin_path) {
666 ChromePluginPlaceholder* placeholder = 687 return NonLoadablePluginPlaceholder::CreateErrorPlugin(render_frame,
667 ChromePluginPlaceholder::CreateErrorPlugin(render_frame, plugin_path); 688 plugin_path)->plugin();
668 return placeholder->plugin();
669 } 689 }
670 690
671 void ChromeContentRendererClient::DeferMediaLoad( 691 void ChromeContentRendererClient::DeferMediaLoad(
672 content::RenderFrame* render_frame, 692 content::RenderFrame* render_frame,
673 const base::Closure& closure) { 693 const base::Closure& closure) {
674 #if defined(OS_ANDROID) 694 #if defined(OS_ANDROID)
675 // Chromium for Android doesn't support prerender yet. 695 // Chromium for Android doesn't support prerender yet.
676 closure.Run(); 696 closure.Run();
677 return; 697 return;
678 #else 698 #else
679 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) { 699 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) {
680 closure.Run(); 700 closure.Run();
681 return; 701 return;
682 } 702 }
683 703
684 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. 704 // Lifetime is tied to |render_frame| via content::RenderFrameObserver.
685 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); 705 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure);
686 #endif 706 #endif
687 } 707 }
688 708
709 #if defined(ENABLE_PLUGINS)
689 WebPlugin* ChromeContentRendererClient::CreatePlugin( 710 WebPlugin* ChromeContentRendererClient::CreatePlugin(
690 content::RenderFrame* render_frame, 711 content::RenderFrame* render_frame,
691 blink::WebLocalFrame* frame, 712 blink::WebLocalFrame* frame,
692 const WebPluginParams& original_params, 713 const WebPluginParams& original_params,
693 const ChromeViewHostMsg_GetPluginInfo_Output& output) { 714 const ChromeViewHostMsg_GetPluginInfo_Output& output) {
694 const WebPluginInfo& info = output.plugin; 715 const WebPluginInfo& info = output.plugin;
695 const std::string& actual_mime_type = output.actual_mime_type; 716 const std::string& actual_mime_type = output.actual_mime_type;
696 const base::string16& group_name = output.group_name; 717 const base::string16& group_name = output.group_name;
697 const std::string& identifier = output.group_identifier; 718 const std::string& identifier = output.group_identifier;
698 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; 719 ChromeViewHostMsg_GetPluginInfo_Status status = output.status;
699 GURL url(original_params.url); 720 GURL url(original_params.url);
700 std::string orig_mime_type = original_params.mimeType.utf8(); 721 std::string orig_mime_type = original_params.mimeType.utf8();
701 ChromePluginPlaceholder* placeholder = NULL; 722 ChromePluginPlaceholder* placeholder = NULL;
702 723
703 // If the browser plugin is to be enabled, this should be handled by the 724 // If the browser plugin is to be enabled, this should be handled by the
704 // renderer, so the code won't reach here due to the early exit in 725 // renderer, so the code won't reach here due to the early exit in
705 // OverrideCreatePlugin. 726 // OverrideCreatePlugin.
706 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || 727 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound ||
707 orig_mime_type == content::kBrowserPluginMimeType) { 728 orig_mime_type == content::kBrowserPluginMimeType) {
708 #if defined(OS_ANDROID)
709 if (plugins::MobileYouTubePlugin::IsYouTubeURL(url, orig_mime_type)) {
710 base::StringPiece template_html(
711 ResourceBundle::GetSharedInstance().GetRawDataResource(
712 IDR_MOBILE_YOUTUBE_PLUGIN_HTML));
713 return (new plugins::MobileYouTubePlugin(
714 render_frame,
715 frame,
716 original_params,
717 template_html,
718 GURL(ChromePluginPlaceholder::kPluginPlaceholderDataURL)))
719 ->plugin();
720 }
721 #endif
722 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url); 729 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url);
723 placeholder = ChromePluginPlaceholder::CreateMissingPlugin( 730 placeholder = ChromePluginPlaceholder::CreateLoadableMissingPlugin(
724 render_frame, frame, original_params); 731 render_frame, frame, original_params);
725 } else { 732 } else {
726 // TODO(bauerb): This should be in content/. 733 // TODO(bauerb): This should be in content/.
727 WebPluginParams params(original_params); 734 WebPluginParams params(original_params);
728 for (size_t i = 0; i < info.mime_types.size(); ++i) { 735 for (size_t i = 0; i < info.mime_types.size(); ++i) {
729 if (info.mime_types[i].mime_type == actual_mime_type) { 736 if (info.mime_types[i].mime_type == actual_mime_type) {
730 AppendParams(info.mime_types[i].additional_param_names, 737 AppendParams(info.mime_types[i].additional_param_names,
731 info.mime_types[i].additional_param_values, 738 info.mime_types[i].additional_param_values,
732 &params.attributeNames, &params.attributeValues); 739 &params.attributeNames, &params.attributeValues);
733 break; 740 break;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 #if defined(OS_CHROMEOS) 843 #if defined(OS_CHROMEOS)
837 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); 844 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
838 #else 845 #else
839 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 846 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
840 #endif 847 #endif
841 break; 848 break;
842 } 849 }
843 } 850 }
844 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) 851 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
845 852
846 #if defined(ENABLE_PLUGINS)
847 // Delay loading plugins if prerendering. 853 // Delay loading plugins if prerendering.
848 // TODO(mmenke): In the case of prerendering, feed into 854 // TODO(mmenke): In the case of prerendering, feed into
849 // ChromeContentRendererClient::CreatePlugin instead, to 855 // ChromeContentRendererClient::CreatePlugin instead, to
850 // reduce the chance of future regressions. 856 // reduce the chance of future regressions.
851 bool is_prerendering = 857 bool is_prerendering =
852 prerender::PrerenderHelper::IsPrerendering(render_frame); 858 prerender::PrerenderHelper::IsPrerendering(render_frame);
853 bool power_saver_enabled = 859 bool power_saver_enabled =
854 status == 860 status ==
855 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; 861 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
856 bool blocked_for_background_tab = 862 bool blocked_for_background_tab =
(...skipping 14 matching lines...) Expand all
871 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( 877 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin(
872 render_frame, frame, params, info, identifier, group_name, 878 render_frame, frame, params, info, identifier, group_name,
873 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML 879 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML
874 : IDR_PLUGIN_POSTER_HTML, 880 : IDR_PLUGIN_POSTER_HTML,
875 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 881 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
876 poster_info); 882 poster_info);
877 placeholder->set_blocked_for_background_tab( 883 placeholder->set_blocked_for_background_tab(
878 blocked_for_background_tab); 884 blocked_for_background_tab);
879 placeholder->set_blocked_for_prerendering(is_prerendering); 885 placeholder->set_blocked_for_prerendering(is_prerendering);
880 placeholder->set_power_saver_enabled(power_saver_enabled); 886 placeholder->set_power_saver_enabled(power_saver_enabled);
881 placeholder->set_allow_loading(true);
882 break; 887 break;
883 } 888 }
884 889
885 scoped_ptr<content::PluginInstanceThrottler> throttler; 890 scoped_ptr<content::PluginInstanceThrottler> throttler;
886 if (power_saver_enabled) { 891 if (power_saver_enabled) {
887 throttler = PluginInstanceThrottler::Create(); 892 throttler = PluginInstanceThrottler::Create();
888 // PluginPreroller manages its own lifetime. 893 // PluginPreroller manages its own lifetime.
889 new PluginPreroller( 894 new PluginPreroller(
890 render_frame, frame, params, info, identifier, group_name, 895 render_frame, frame, params, info, identifier, group_name,
891 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), 896 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name),
892 throttler.get()); 897 throttler.get());
893 } 898 }
894 899
895 return render_frame->CreatePlugin(frame, info, params, 900 return render_frame->CreatePlugin(frame, info, params,
896 throttler.Pass()); 901 throttler.Pass());
897 #else // !defined(ENABLE_PLUGINS)
898 return render_frame->CreatePlugin(frame, info, params, nullptr);
899 #endif // defined(ENABLE_PLUGINS)
900 } 902 }
901 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { 903 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: {
902 RenderThread::Get()->RecordAction( 904 RenderThread::Get()->RecordAction(
903 UserMetricsAction("Plugin_NPAPINotSupported")); 905 UserMetricsAction("Plugin_NPAPINotSupported"));
904 placeholder = create_blocked_plugin( 906 placeholder = create_blocked_plugin(
905 IDR_BLOCKED_PLUGIN_HTML, 907 IDR_BLOCKED_PLUGIN_HTML,
906 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO)); 908 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO));
907 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( 909 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported(
908 render_frame->GetRoutingID(), identifier)); 910 render_frame->GetRoutingID(), identifier));
909 break; 911 break;
910 } 912 }
911 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { 913 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: {
912 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, 914 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type,
913 url); 915 url);
914 placeholder = create_blocked_plugin( 916 placeholder = create_blocked_plugin(
915 IDR_DISABLED_PLUGIN_HTML, 917 IDR_DISABLED_PLUGIN_HTML,
916 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); 918 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name));
917 break; 919 break;
918 } 920 }
919 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { 921 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
920 #if defined(ENABLE_PLUGIN_INSTALLATION) 922 #if defined(ENABLE_PLUGIN_INSTALLATION)
921 placeholder = create_blocked_plugin( 923 placeholder = create_blocked_plugin(
922 IDR_BLOCKED_PLUGIN_HTML, 924 IDR_BLOCKED_PLUGIN_HTML,
923 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); 925 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
924 placeholder->set_allow_loading(true);
925 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( 926 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
926 render_frame->GetRoutingID(), placeholder->CreateRoutingId(), 927 render_frame->GetRoutingID(), placeholder->CreateRoutingId(),
927 identifier)); 928 identifier));
928 #else 929 #else
929 NOTREACHED(); 930 NOTREACHED();
930 #endif 931 #endif
931 break; 932 break;
932 } 933 }
933 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { 934 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
934 placeholder = create_blocked_plugin( 935 placeholder = create_blocked_plugin(
935 IDR_BLOCKED_PLUGIN_HTML, 936 IDR_BLOCKED_PLUGIN_HTML,
936 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); 937 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name));
937 break; 938 break;
938 } 939 }
939 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { 940 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
940 placeholder = create_blocked_plugin( 941 placeholder = create_blocked_plugin(
941 IDR_BLOCKED_PLUGIN_HTML, 942 IDR_BLOCKED_PLUGIN_HTML,
942 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); 943 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name));
943 placeholder->set_allow_loading(true);
944 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { 944 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
945 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( 945 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
946 render_frame->GetRoutingID(), 946 render_frame->GetRoutingID(),
947 group_name, 947 group_name,
948 identifier)); 948 identifier));
949 } 949 }
950 observer->DidBlockContentType(content_type, group_name); 950 observer->DidBlockContentType(content_type, group_name);
951 break; 951 break;
952 } 952 }
953 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { 953 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: {
954 placeholder = create_blocked_plugin( 954 placeholder = create_blocked_plugin(
955 IDR_BLOCKED_PLUGIN_HTML, 955 IDR_BLOCKED_PLUGIN_HTML,
956 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 956 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
957 placeholder->set_allow_loading(true);
958 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); 957 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked"));
959 observer->DidBlockContentType(content_type, group_name); 958 observer->DidBlockContentType(content_type, group_name);
960 break; 959 break;
961 } 960 }
962 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { 961 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: {
963 placeholder = create_blocked_plugin( 962 placeholder = create_blocked_plugin(
964 IDR_BLOCKED_PLUGIN_HTML, 963 IDR_BLOCKED_PLUGIN_HTML,
965 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY, 964 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY,
966 group_name)); 965 group_name));
967 placeholder->set_allow_loading(false); 966 placeholder->DisallowLoading();
968 RenderThread::Get()->RecordAction( 967 RenderThread::Get()->RecordAction(
969 UserMetricsAction("Plugin_BlockedByPolicy")); 968 UserMetricsAction("Plugin_BlockedByPolicy"));
970 observer->DidBlockContentType(content_type, group_name); 969 observer->DidBlockContentType(content_type, group_name);
971 break; 970 break;
972 } 971 }
973 } 972 }
974 } 973 }
975 placeholder->SetStatus(status); 974 placeholder->SetStatus(status);
976 return placeholder->plugin(); 975 return placeholder->plugin();
977 } 976 }
977 #endif // defined(ENABLE_PLUGINS)
978 978
979 // For NaCl content handling plugins, the NaCl manifest is stored in an 979 // For NaCl content handling plugins, the NaCl manifest is stored in an
980 // additonal 'nacl' param associated with the MIME type. 980 // additonal 'nacl' param associated with the MIME type.
981 // static 981 // static
982 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( 982 GURL ChromeContentRendererClient::GetNaClContentHandlerURL(
983 const std::string& actual_mime_type, 983 const std::string& actual_mime_type,
984 const content::WebPluginInfo& plugin) { 984 const content::WebPluginInfo& plugin) {
985 // Look for the manifest URL among the MIME type's additonal parameters. 985 // Look for the manifest URL among the MIME type's additonal parameters.
986 const char kNaClPluginManifestAttribute[] = "nacl"; 986 const char kNaClPluginManifestAttribute[] = "nacl";
987 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); 987 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute);
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 WebString header_key(ASCIIToUTF16( 1653 WebString header_key(ASCIIToUTF16(
1654 data_reduction_proxy::chrome_proxy_header())); 1654 data_reduction_proxy::chrome_proxy_header()));
1655 if (!response.httpHeaderField(header_key).isNull() && 1655 if (!response.httpHeaderField(header_key).isNull() &&
1656 response.httpHeaderField(header_key).utf8().find( 1656 response.httpHeaderField(header_key).utf8().find(
1657 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != 1657 data_reduction_proxy::chrome_proxy_lo_fi_directive()) !=
1658 std::string::npos) { 1658 std::string::npos) {
1659 (*properties)[data_reduction_proxy::chrome_proxy_header()] = 1659 (*properties)[data_reduction_proxy::chrome_proxy_header()] =
1660 data_reduction_proxy::chrome_proxy_lo_fi_directive(); 1660 data_reduction_proxy::chrome_proxy_lo_fi_directive();
1661 } 1661 }
1662 } 1662 }
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