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