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 = |
| 686 CreateMissingPluginPlaceholder(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 CreateErrorPluginPlaceholder(render_frame, plugin_path)->plugin(); |
675 ChromePluginPlaceholder::CreateErrorPlugin(render_frame, plugin_path); | |
676 return placeholder->plugin(); | |
677 } | 696 } |
678 | 697 |
679 void ChromeContentRendererClient::DeferMediaLoad( | 698 void ChromeContentRendererClient::DeferMediaLoad( |
680 content::RenderFrame* render_frame, | 699 content::RenderFrame* render_frame, |
681 const base::Closure& closure) { | 700 const base::Closure& closure) { |
682 #if defined(OS_ANDROID) | 701 #if defined(OS_ANDROID) |
683 // Chromium for Android doesn't support prerender yet. | 702 // Chromium for Android doesn't support prerender yet. |
684 closure.Run(); | 703 closure.Run(); |
685 return; | 704 return; |
686 #else | 705 #else |
687 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) { | 706 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) { |
688 closure.Run(); | 707 closure.Run(); |
689 return; | 708 return; |
690 } | 709 } |
691 | 710 |
692 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. | 711 // Lifetime is tied to |render_frame| via content::RenderFrameObserver. |
693 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); | 712 new prerender::PrerenderMediaLoadDeferrer(render_frame, closure); |
694 #endif | 713 #endif |
695 } | 714 } |
696 | 715 |
| 716 #if defined(ENABLE_PLUGINS) |
697 WebPlugin* ChromeContentRendererClient::CreatePlugin( | 717 WebPlugin* ChromeContentRendererClient::CreatePlugin( |
698 content::RenderFrame* render_frame, | 718 content::RenderFrame* render_frame, |
699 blink::WebLocalFrame* frame, | 719 blink::WebLocalFrame* frame, |
700 const WebPluginParams& original_params, | 720 const WebPluginParams& original_params, |
701 const ChromeViewHostMsg_GetPluginInfo_Output& output) { | 721 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
702 const WebPluginInfo& info = output.plugin; | 722 const WebPluginInfo& info = output.plugin; |
703 const std::string& actual_mime_type = output.actual_mime_type; | 723 const std::string& actual_mime_type = output.actual_mime_type; |
704 const base::string16& group_name = output.group_name; | 724 const base::string16& group_name = output.group_name; |
705 const std::string& identifier = output.group_identifier; | 725 const std::string& identifier = output.group_identifier; |
706 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; | 726 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; |
707 GURL url(original_params.url); | 727 GURL url(original_params.url); |
708 std::string orig_mime_type = original_params.mimeType.utf8(); | 728 std::string orig_mime_type = original_params.mimeType.utf8(); |
709 ChromePluginPlaceholder* placeholder = NULL; | 729 ChromePluginPlaceholder* placeholder = NULL; |
710 | 730 |
711 // If the browser plugin is to be enabled, this should be handled by the | 731 // 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 | 732 // renderer, so the code won't reach here due to the early exit in |
713 // OverrideCreatePlugin. | 733 // OverrideCreatePlugin. |
714 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || | 734 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || |
715 orig_mime_type == content::kBrowserPluginMimeType) { | 735 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); | 736 PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, url); |
731 placeholder = ChromePluginPlaceholder::CreateMissingPlugin( | 737 placeholder = ChromePluginPlaceholder::CreateLoadableMissingPlugin( |
732 render_frame, frame, original_params); | 738 render_frame, frame, original_params); |
733 } else { | 739 } else { |
734 // TODO(bauerb): This should be in content/. | 740 // TODO(bauerb): This should be in content/. |
735 WebPluginParams params(original_params); | 741 WebPluginParams params(original_params); |
736 for (size_t i = 0; i < info.mime_types.size(); ++i) { | 742 for (size_t i = 0; i < info.mime_types.size(); ++i) { |
737 if (info.mime_types[i].mime_type == actual_mime_type) { | 743 if (info.mime_types[i].mime_type == actual_mime_type) { |
738 AppendParams(info.mime_types[i].additional_param_names, | 744 AppendParams(info.mime_types[i].additional_param_names, |
739 info.mime_types[i].additional_param_values, | 745 info.mime_types[i].additional_param_values, |
740 ¶ms.attributeNames, ¶ms.attributeValues); | 746 ¶ms.attributeNames, ¶ms.attributeValues); |
741 break; | 747 break; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 #if defined(OS_CHROMEOS) | 850 #if defined(OS_CHROMEOS) |
845 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | 851 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); |
846 #else | 852 #else |
847 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 853 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
848 #endif | 854 #endif |
849 break; | 855 break; |
850 } | 856 } |
851 } | 857 } |
852 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 858 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
853 | 859 |
854 #if defined(ENABLE_PLUGINS) | |
855 // Delay loading plugins if prerendering. | 860 // Delay loading plugins if prerendering. |
856 // TODO(mmenke): In the case of prerendering, feed into | 861 // TODO(mmenke): In the case of prerendering, feed into |
857 // ChromeContentRendererClient::CreatePlugin instead, to | 862 // ChromeContentRendererClient::CreatePlugin instead, to |
858 // reduce the chance of future regressions. | 863 // reduce the chance of future regressions. |
859 bool is_prerendering = | 864 bool is_prerendering = |
860 prerender::PrerenderHelper::IsPrerendering(render_frame); | 865 prerender::PrerenderHelper::IsPrerendering(render_frame); |
861 bool power_saver_enabled = | 866 bool power_saver_enabled = |
862 status == | 867 status == |
863 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 868 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
864 bool blocked_for_background_tab = | 869 bool blocked_for_background_tab = |
(...skipping 14 matching lines...) Expand all Loading... |
879 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( | 884 placeholder = ChromePluginPlaceholder::CreateBlockedPlugin( |
880 render_frame, frame, params, info, identifier, group_name, | 885 render_frame, frame, params, info, identifier, group_name, |
881 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML | 886 poster_info.poster_attribute.empty() ? IDR_BLOCKED_PLUGIN_HTML |
882 : IDR_PLUGIN_POSTER_HTML, | 887 : IDR_PLUGIN_POSTER_HTML, |
883 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 888 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
884 poster_info); | 889 poster_info); |
885 placeholder->set_blocked_for_background_tab( | 890 placeholder->set_blocked_for_background_tab( |
886 blocked_for_background_tab); | 891 blocked_for_background_tab); |
887 placeholder->set_blocked_for_prerendering(is_prerendering); | 892 placeholder->set_blocked_for_prerendering(is_prerendering); |
888 placeholder->set_power_saver_enabled(power_saver_enabled); | 893 placeholder->set_power_saver_enabled(power_saver_enabled); |
889 placeholder->set_allow_loading(true); | |
890 break; | 894 break; |
891 } | 895 } |
892 | 896 |
893 scoped_ptr<content::PluginInstanceThrottler> throttler; | 897 scoped_ptr<content::PluginInstanceThrottler> throttler; |
894 if (power_saver_enabled) { | 898 if (power_saver_enabled) { |
895 throttler = PluginInstanceThrottler::Create(); | 899 throttler = PluginInstanceThrottler::Create(); |
896 // PluginPreroller manages its own lifetime. | 900 // PluginPreroller manages its own lifetime. |
897 new PluginPreroller( | 901 new PluginPreroller( |
898 render_frame, frame, params, info, identifier, group_name, | 902 render_frame, frame, params, info, identifier, group_name, |
899 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), | 903 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name), |
900 throttler.get()); | 904 throttler.get()); |
901 } | 905 } |
902 | 906 |
903 return render_frame->CreatePlugin(frame, info, params, | 907 return render_frame->CreatePlugin(frame, info, params, |
904 throttler.Pass()); | 908 throttler.Pass()); |
905 #else // !defined(ENABLE_PLUGINS) | |
906 return render_frame->CreatePlugin(frame, info, params, nullptr); | |
907 #endif // defined(ENABLE_PLUGINS) | |
908 } | 909 } |
909 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { | 910 case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { |
910 RenderThread::Get()->RecordAction( | 911 RenderThread::Get()->RecordAction( |
911 UserMetricsAction("Plugin_NPAPINotSupported")); | 912 UserMetricsAction("Plugin_NPAPINotSupported")); |
912 placeholder = create_blocked_plugin( | 913 placeholder = create_blocked_plugin( |
913 IDR_BLOCKED_PLUGIN_HTML, | 914 IDR_BLOCKED_PLUGIN_HTML, |
914 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO)); | 915 l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED_METRO)); |
915 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( | 916 render_frame->Send(new ChromeViewHostMsg_NPAPINotSupported( |
916 render_frame->GetRoutingID(), identifier)); | 917 render_frame->GetRoutingID(), identifier)); |
917 break; | 918 break; |
918 } | 919 } |
919 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { | 920 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { |
920 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, | 921 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, |
921 url); | 922 url); |
922 placeholder = create_blocked_plugin( | 923 placeholder = create_blocked_plugin( |
923 IDR_DISABLED_PLUGIN_HTML, | 924 IDR_DISABLED_PLUGIN_HTML, |
924 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); | 925 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); |
925 break; | 926 break; |
926 } | 927 } |
927 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { | 928 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { |
928 #if defined(ENABLE_PLUGIN_INSTALLATION) | 929 #if defined(ENABLE_PLUGIN_INSTALLATION) |
929 placeholder = create_blocked_plugin( | 930 placeholder = create_blocked_plugin( |
930 IDR_BLOCKED_PLUGIN_HTML, | 931 IDR_BLOCKED_PLUGIN_HTML, |
931 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); | 932 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); |
932 placeholder->set_allow_loading(true); | |
933 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 933 render_frame->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
934 render_frame->GetRoutingID(), placeholder->CreateRoutingId(), | 934 render_frame->GetRoutingID(), placeholder->CreateRoutingId(), |
935 identifier)); | 935 identifier)); |
936 #else | 936 #else |
937 NOTREACHED(); | 937 NOTREACHED(); |
938 #endif | 938 #endif |
939 break; | 939 break; |
940 } | 940 } |
941 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { | 941 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { |
942 placeholder = create_blocked_plugin( | 942 placeholder = create_blocked_plugin( |
943 IDR_BLOCKED_PLUGIN_HTML, | 943 IDR_BLOCKED_PLUGIN_HTML, |
944 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); | 944 l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED, group_name)); |
945 break; | 945 break; |
946 } | 946 } |
947 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { | 947 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { |
948 placeholder = create_blocked_plugin( | 948 placeholder = create_blocked_plugin( |
949 IDR_BLOCKED_PLUGIN_HTML, | 949 IDR_BLOCKED_PLUGIN_HTML, |
950 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); | 950 l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); |
951 placeholder->set_allow_loading(true); | |
952 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { | 951 if (info.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) { |
953 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( | 952 render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( |
954 render_frame->GetRoutingID(), | 953 render_frame->GetRoutingID(), |
955 group_name, | 954 group_name, |
956 identifier)); | 955 identifier)); |
957 } | 956 } |
958 observer->DidBlockContentType(content_type, group_name); | 957 observer->DidBlockContentType(content_type, group_name); |
959 break; | 958 break; |
960 } | 959 } |
961 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { | 960 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { |
962 placeholder = create_blocked_plugin( | 961 placeholder = create_blocked_plugin( |
963 IDR_BLOCKED_PLUGIN_HTML, | 962 IDR_BLOCKED_PLUGIN_HTML, |
964 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 963 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
965 placeholder->set_allow_loading(true); | |
966 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); | 964 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked")); |
967 observer->DidBlockContentType(content_type, group_name); | 965 observer->DidBlockContentType(content_type, group_name); |
968 break; | 966 break; |
969 } | 967 } |
970 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { | 968 case ChromeViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy: { |
971 placeholder = create_blocked_plugin( | 969 placeholder = create_blocked_plugin( |
972 IDR_BLOCKED_PLUGIN_HTML, | 970 IDR_BLOCKED_PLUGIN_HTML, |
973 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY, | 971 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_BY_POLICY, |
974 group_name)); | 972 group_name)); |
975 placeholder->set_allow_loading(false); | 973 placeholder->DisallowLoading(); |
976 RenderThread::Get()->RecordAction( | 974 RenderThread::Get()->RecordAction( |
977 UserMetricsAction("Plugin_BlockedByPolicy")); | 975 UserMetricsAction("Plugin_BlockedByPolicy")); |
978 observer->DidBlockContentType(content_type, group_name); | 976 observer->DidBlockContentType(content_type, group_name); |
979 break; | 977 break; |
980 } | 978 } |
981 } | 979 } |
982 } | 980 } |
983 placeholder->SetStatus(status); | 981 placeholder->SetStatus(status); |
984 return placeholder->plugin(); | 982 return placeholder->plugin(); |
985 } | 983 } |
| 984 #endif // defined(ENABLE_PLUGINS) |
986 | 985 |
987 // For NaCl content handling plugins, the NaCl manifest is stored in an | 986 // For NaCl content handling plugins, the NaCl manifest is stored in an |
988 // additonal 'nacl' param associated with the MIME type. | 987 // additonal 'nacl' param associated with the MIME type. |
989 // static | 988 // static |
990 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( | 989 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( |
991 const std::string& actual_mime_type, | 990 const std::string& actual_mime_type, |
992 const content::WebPluginInfo& plugin) { | 991 const content::WebPluginInfo& plugin) { |
993 // Look for the manifest URL among the MIME type's additonal parameters. | 992 // Look for the manifest URL among the MIME type's additonal parameters. |
994 const char kNaClPluginManifestAttribute[] = "nacl"; | 993 const char kNaClPluginManifestAttribute[] = "nacl"; |
995 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); | 994 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 const GURL& url) { | 1645 const GURL& url) { |
1647 RenderThread::Get()->Send(new ChromeViewHostMsg_RecordRapporURL(metric, url)); | 1646 RenderThread::Get()->Send(new ChromeViewHostMsg_RecordRapporURL(metric, url)); |
1648 } | 1647 } |
1649 | 1648 |
1650 scoped_ptr<blink::WebAppBannerClient> | 1649 scoped_ptr<blink::WebAppBannerClient> |
1651 ChromeContentRendererClient::CreateAppBannerClient( | 1650 ChromeContentRendererClient::CreateAppBannerClient( |
1652 content::RenderFrame* render_frame) { | 1651 content::RenderFrame* render_frame) { |
1653 return scoped_ptr<blink::WebAppBannerClient>( | 1652 return scoped_ptr<blink::WebAppBannerClient>( |
1654 new AppBannerClient(render_frame)); | 1653 new AppBannerClient(render_frame)); |
1655 } | 1654 } |
OLD | NEW |