Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/metrics/user_metrics_action.h" | 17 #include "base/metrics/user_metrics_action.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/common/channel_info.h" | 24 #include "chrome/common/channel_info.h" |
| 25 #include "chrome/common/chrome_content_client.h" | |
| 25 #include "chrome/common/chrome_features.h" | 26 #include "chrome/common/chrome_features.h" |
| 26 #include "chrome/common/chrome_isolated_world_ids.h" | 27 #include "chrome/common/chrome_isolated_world_ids.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/crash_keys.h" | 30 #include "chrome/common/crash_keys.h" |
| 30 #include "chrome/common/features.h" | 31 #include "chrome/common/features.h" |
| 31 #include "chrome/common/pause_tabs_field_trial.h" | 32 #include "chrome/common/pause_tabs_field_trial.h" |
| 32 #include "chrome/common/pepper_permission_util.h" | 33 #include "chrome/common/pepper_permission_util.h" |
| 33 #include "chrome/common/prerender_types.h" | 34 #include "chrome/common/prerender_types.h" |
| 34 #include "chrome/common/render_messages.h" | 35 #include "chrome/common/render_messages.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 #include "third_party/WebKit/public/platform/WebURLError.h" | 114 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 114 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 115 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 115 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 116 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 116 #include "third_party/WebKit/public/web/WebDataSource.h" | 117 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 117 #include "third_party/WebKit/public/web/WebDocument.h" | 118 #include "third_party/WebKit/public/web/WebDocument.h" |
| 118 #include "third_party/WebKit/public/web/WebElement.h" | 119 #include "third_party/WebKit/public/web/WebElement.h" |
| 119 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 120 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 120 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 121 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 121 #include "third_party/WebKit/public/web/WebPluginParams.h" | 122 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 122 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 123 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 124 #include "third_party/WebKit/public/web/WebView.h" | |
|
Lei Zhang
2017/05/04 00:19:11
No longer needed?
tommycli
2017/05/08 16:17:52
Done.
| |
| 123 #include "ui/base/l10n/l10n_util.h" | 125 #include "ui/base/l10n/l10n_util.h" |
| 124 #include "ui/base/layout.h" | 126 #include "ui/base/layout.h" |
| 125 #include "ui/base/resource/resource_bundle.h" | 127 #include "ui/base/resource/resource_bundle.h" |
| 126 #include "ui/base/webui/jstemplate_builder.h" | 128 #include "ui/base/webui/jstemplate_builder.h" |
| 127 #include "url/origin.h" | 129 #include "url/origin.h" |
| 128 | 130 |
| 129 #if defined(OS_ANDROID) | 131 #if defined(OS_ANDROID) |
| 130 #include "chrome/renderer/sandbox_status_extension_android.h" | 132 #include "chrome/renderer/sandbox_status_extension_android.h" |
| 131 #endif | 133 #endif |
| 132 | 134 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 146 | 148 |
| 147 #if BUILDFLAG(ENABLE_PLUGINS) | 149 #if BUILDFLAG(ENABLE_PLUGINS) |
| 148 #include "chrome/common/plugin_utils.h" | 150 #include "chrome/common/plugin_utils.h" |
| 149 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" | 151 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
| 150 #include "chrome/renderer/plugins/power_saver_info.h" | 152 #include "chrome/renderer/plugins/power_saver_info.h" |
| 151 #else | 153 #else |
| 152 #include "components/plugins/renderer/plugin_placeholder.h" | 154 #include "components/plugins/renderer/plugin_placeholder.h" |
| 153 #endif | 155 #endif |
| 154 | 156 |
| 155 #if BUILDFLAG(ENABLE_PRINTING) | 157 #if BUILDFLAG(ENABLE_PRINTING) |
| 156 #include "chrome/common/chrome_content_client.h" | |
| 157 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h" | 158 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h" |
| 158 #include "components/printing/renderer/print_web_view_helper.h" | 159 #include "components/printing/renderer/print_web_view_helper.h" |
| 159 #include "printing/print_settings.h" | 160 #include "printing/print_settings.h" |
| 160 #endif | 161 #endif |
| 161 | 162 |
| 162 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 163 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 163 #include "chrome/renderer/pepper/chrome_pdf_print_client.h" | 164 #include "chrome/renderer/pepper/chrome_pdf_print_client.h" |
| 164 #endif | 165 #endif |
| 165 | 166 |
| 166 #if BUILDFLAG(ENABLE_SPELLCHECK) | 167 #if BUILDFLAG(ENABLE_SPELLCHECK) |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 #if defined(OS_CHROMEOS) | 806 #if defined(OS_CHROMEOS) |
| 806 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | 807 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); |
| 807 #else | 808 #else |
| 808 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 809 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
| 809 #endif | 810 #endif |
| 810 break; | 811 break; |
| 811 } | 812 } |
| 812 } | 813 } |
| 813 #endif // !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS) | 814 #endif // !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS) |
| 814 | 815 |
| 816 // Report PDF load metrics. Since the PDF plugin is comprised of an | |
| 817 // extension that loads a second plugin, avoid double counting by | |
| 818 // ignoring the creation of the second plugin. | |
| 819 if (info.name == ASCIIToUTF16(ChromeContentClient::kPDFPluginName) && | |
| 820 GURL(frame->GetDocument().Url()).host_piece() != | |
| 821 extension_misc::kPdfExtensionId) { | |
| 822 bool is_main_frame_plugin_document = | |
| 823 render_frame->IsMainFrame() && | |
| 824 render_frame->GetWebFrame()->GetDocument().IsPluginDocument(); | |
| 825 PluginUMAReporter::ReportPDFLoadStatus( | |
| 826 is_main_frame_plugin_document | |
| 827 ? PluginUMAReporter::LOADED_FULL_PAGE_PDF_WITH_PDFIUM | |
| 828 : PluginUMAReporter::LOADED_EMBEDDED_PDF_WITH_PDFIUM); | |
| 829 } | |
| 830 | |
| 815 // Delay loading plugins if prerendering. | 831 // Delay loading plugins if prerendering. |
| 816 // TODO(mmenke): In the case of prerendering, feed into | 832 // TODO(mmenke): In the case of prerendering, feed into |
| 817 // ChromeContentRendererClient::CreatePlugin instead, to | 833 // ChromeContentRendererClient::CreatePlugin instead, to |
| 818 // reduce the chance of future regressions. | 834 // reduce the chance of future regressions. |
| 819 bool is_prerendering = | 835 bool is_prerendering = |
| 820 prerender::PrerenderHelper::IsPrerendering(render_frame); | 836 prerender::PrerenderHelper::IsPrerendering(render_frame); |
| 821 | 837 |
| 822 bool power_saver_setting_on = | 838 bool power_saver_setting_on = |
| 823 status == | 839 status == |
| 824 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 840 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 845 placeholder->AllowLoading(); | 861 placeholder->AllowLoading(); |
| 846 break; | 862 break; |
| 847 } | 863 } |
| 848 | 864 |
| 849 // Same-origin and whitelisted-origin plugins skip the placeholder. | 865 // Same-origin and whitelisted-origin plugins skip the placeholder. |
| 850 return render_frame->CreatePlugin(frame, info, params, nullptr); | 866 return render_frame->CreatePlugin(frame, info, params, nullptr); |
| 851 } | 867 } |
| 852 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { | 868 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { |
| 853 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, | 869 PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type, |
| 854 url); | 870 url); |
| 871 if (info.name == ASCIIToUTF16(ChromeContentClient::kPDFPluginName)) { | |
| 872 PluginUMAReporter::ReportPDFLoadStatus( | |
| 873 PluginUMAReporter:: | |
| 874 SHOWED_DISABLED_PLUGIN_PLACEHOLDER_FOR_EMBEDDED_PDF); | |
| 875 } | |
| 876 | |
| 855 placeholder = create_blocked_plugin( | 877 placeholder = create_blocked_plugin( |
| 856 IDR_DISABLED_PLUGIN_HTML, | 878 IDR_DISABLED_PLUGIN_HTML, |
| 857 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); | 879 l10n_util::GetStringFUTF16(IDS_PLUGIN_DISABLED, group_name)); |
| 858 break; | 880 break; |
| 859 } | 881 } |
| 860 case ChromeViewHostMsg_GetPluginInfo_Status::kFlashHiddenPreferHtml: { | 882 case ChromeViewHostMsg_GetPluginInfo_Status::kFlashHiddenPreferHtml: { |
| 861 placeholder = create_blocked_plugin( | 883 placeholder = create_blocked_plugin( |
| 862 IDR_PREFER_HTML_PLUGIN_HTML, | 884 IDR_PREFER_HTML_PLUGIN_HTML, |
| 863 l10n_util::GetStringFUTF16(IDS_PLUGIN_PREFER_HTML_BY_DEFAULT, | 885 l10n_util::GetStringFUTF16(IDS_PLUGIN_PREFER_HTML_BY_DEFAULT, |
| 864 group_name)); | 886 group_name)); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 | 1574 |
| 1553 RecordYouTubeRewriteUMA(result); | 1575 RecordYouTubeRewriteUMA(result); |
| 1554 return corrected_url.ReplaceComponents(r); | 1576 return corrected_url.ReplaceComponents(r); |
| 1555 } | 1577 } |
| 1556 | 1578 |
| 1557 std::unique_ptr<base::TaskScheduler::InitParams> | 1579 std::unique_ptr<base::TaskScheduler::InitParams> |
| 1558 ChromeContentRendererClient::GetTaskSchedulerInitParams() { | 1580 ChromeContentRendererClient::GetTaskSchedulerInitParams() { |
| 1559 return task_scheduler_util:: | 1581 return task_scheduler_util:: |
| 1560 GetRendererTaskSchedulerInitParamsFromCommandLine(); | 1582 GetRendererTaskSchedulerInitParamsFromCommandLine(); |
| 1561 } | 1583 } |
| OLD | NEW |