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

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

Issue 2852193002: PDF: Add UMA to track successful / failed PDF loads (Closed)
Patch Set: reformat Created 3 years, 7 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 <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"
Lei Zhang 2017/05/03 23:50:34 Remove existing entry from line 158 then?
tommycli 2017/05/04 00:08:30 Done.
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
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"
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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 #if defined(OS_CHROMEOS) 807 #if defined(OS_CHROMEOS)
806 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); 808 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
807 #else 809 #else
808 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 810 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
809 #endif 811 #endif
810 break; 812 break;
811 } 813 }
812 } 814 }
813 #endif // !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS) 815 #endif // !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS)
814 816
817 // Report PDF load metrics. Since the PDF plugin is comprised of an
818 // extension that loads another plugin, make sure we don't double count.
Lei Zhang 2017/05/03 23:50:34 extension that loads a second plugin, avoid double
tommycli 2017/05/04 00:08:30 Done.
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 frame->View()->MainFrame()->IsWebLocalFrame() &&
Lei Zhang 2017/05/03 23:50:34 I think the following does the same, without havin
tommycli 2017/05/04 00:08:31 Done.
824 frame->View()->MainFrame()->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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/plugins/plugin_uma.h » ('j') | chrome/renderer/plugins/plugin_uma.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698