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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 601573002: Add UMA stats for new Print Preview UI elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add INVITATION_AVAILABLE UMA stat. Created 6 years, 3 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/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 COLOR, 114 COLOR,
115 BLACK_AND_WHITE, 115 BLACK_AND_WHITE,
116 COLLATE, 116 COLLATE,
117 SIMPLEX, 117 SIMPLEX,
118 DUPLEX, 118 DUPLEX,
119 TOTAL, 119 TOTAL,
120 HEADERS_AND_FOOTERS, 120 HEADERS_AND_FOOTERS,
121 CSS_BACKGROUND, 121 CSS_BACKGROUND,
122 SELECTION_ONLY, 122 SELECTION_ONLY,
123 EXTERNAL_PDF_PREVIEW, 123 EXTERNAL_PDF_PREVIEW,
124 PAGE_RANGE,
125 DEFAULT_MEDIA,
126 NON_DEFAULT_MEDIA,
127 COPIES,
128 NON_DEFAULT_MARGINS,
124 PRINT_SETTINGS_BUCKET_BOUNDARY 129 PRINT_SETTINGS_BUCKET_BOUNDARY
125 }; 130 };
126 131
127 void ReportUserActionHistogram(enum UserActionBuckets event) { 132 void ReportUserActionHistogram(enum UserActionBuckets event) {
128 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, 133 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event,
129 USERACTION_BUCKET_BOUNDARY); 134 USERACTION_BUCKET_BOUNDARY);
130 } 135 }
131 136
132 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { 137 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) {
133 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, 138 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return NULL; 194 return NULL;
190 } 195 }
191 196
192 return settings.release(); 197 return settings.release();
193 } 198 }
194 199
195 // Track the popularity of print settings and report the stats. 200 // Track the popularity of print settings and report the stats.
196 void ReportPrintSettingsStats(const base::DictionaryValue& settings) { 201 void ReportPrintSettingsStats(const base::DictionaryValue& settings) {
197 ReportPrintSettingHistogram(TOTAL); 202 ReportPrintSettingHistogram(TOTAL);
198 203
204 const base::ListValue* page_range_array = NULL;
205 if (settings.GetList(printing::kSettingPageRange, &page_range_array) &&
206 !page_range_array->empty()) {
207 ReportPrintSettingHistogram(PAGE_RANGE);
208 }
209
210 const base::DictionaryValue* media_size_value = NULL;
211 if (settings.GetDictionary(printing::kSettingMediaSize, &media_size_value) &&
212 !media_size_value->empty()) {
213 bool is_default = false;
214 if (media_size_value->GetBoolean(printing::kSettingMediaSizeIsDefault,
215 &is_default) &&
216 is_default) {
217 ReportPrintSettingHistogram(DEFAULT_MEDIA);
218 } else {
219 ReportPrintSettingHistogram(NON_DEFAULT_MEDIA);
220 }
221 }
222
199 bool landscape = false; 223 bool landscape = false;
200 if (settings.GetBoolean(printing::kSettingLandscape, &landscape)) 224 if (settings.GetBoolean(printing::kSettingLandscape, &landscape))
201 ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT); 225 ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT);
202 226
227 int copies = 1;
228 if (settings.GetInteger(printing::kSettingCopies, &copies) && copies > 1)
229 ReportPrintSettingHistogram(COPIES);
230
203 bool collate = false; 231 bool collate = false;
204 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate) 232 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
205 ReportPrintSettingHistogram(COLLATE); 233 ReportPrintSettingHistogram(COLLATE);
206 234
207 int duplex_mode = 0; 235 int duplex_mode = 0;
208 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode)) 236 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
209 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX); 237 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);
210 238
211 int color_mode = 0; 239 int color_mode = 0;
212 if (settings.GetInteger(printing::kSettingColor, &color_mode)) { 240 if (settings.GetInteger(printing::kSettingColor, &color_mode)) {
213 ReportPrintSettingHistogram( 241 ReportPrintSettingHistogram(
214 printing::IsColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE); 242 printing::IsColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE);
215 } 243 }
216 244
245 int margins_type = 0;
246 if (settings.GetInteger(printing::kSettingMarginsType, &margins_type) &&
247 margins_type != 0) {
248 ReportPrintSettingHistogram(NON_DEFAULT_MARGINS);
249 }
250
217 bool headers = false; 251 bool headers = false;
218 if (settings.GetBoolean(printing::kSettingHeaderFooterEnabled, &headers) && 252 if (settings.GetBoolean(printing::kSettingHeaderFooterEnabled, &headers) &&
219 headers) { 253 headers) {
220 ReportPrintSettingHistogram(HEADERS_AND_FOOTERS); 254 ReportPrintSettingHistogram(HEADERS_AND_FOOTERS);
221 } 255 }
222 256
223 bool css_background = false; 257 bool css_background = false;
224 if (settings.GetBoolean(printing::kSettingShouldPrintBackgrounds, 258 if (settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
225 &css_background) && css_background) { 259 &css_background) && css_background) {
226 ReportPrintSettingHistogram(CSS_BACKGROUND); 260 ReportPrintSettingHistogram(CSS_BACKGROUND);
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 785
752 // Record the number of times the user requests to regenerate preview data 786 // Record the number of times the user requests to regenerate preview data
753 // before printing. 787 // before printing.
754 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 788 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
755 regenerate_preview_request_count_); 789 regenerate_preview_request_count_);
756 790
757 scoped_ptr<base::DictionaryValue> settings(GetSettingsDictionary(args)); 791 scoped_ptr<base::DictionaryValue> settings(GetSettingsDictionary(args));
758 if (!settings.get()) 792 if (!settings.get())
759 return; 793 return;
760 794
795 ReportPrintSettingsStats(*settings);
796
761 // Never try to add headers/footers here. It's already in the generated PDF. 797 // Never try to add headers/footers here. It's already in the generated PDF.
762 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); 798 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
763 799
764 bool print_to_pdf = false; 800 bool print_to_pdf = false;
765 bool is_cloud_printer = false; 801 bool is_cloud_printer = false;
766 bool print_with_privet = false; 802 bool print_with_privet = false;
767 803
768 bool open_pdf_in_preview = false; 804 bool open_pdf_in_preview = false;
769 #if defined(OS_MACOSX) 805 #if defined(OS_MACOSX)
770 open_pdf_in_preview = settings->HasKey(printing::kSettingOpenPDFInPreview); 806 open_pdf_in_preview = settings->HasKey(printing::kSettingOpenPDFInPreview);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } else { 865 } else {
830 bool system_dialog = false; 866 bool system_dialog = false;
831 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); 867 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog);
832 if (system_dialog) { 868 if (system_dialog) {
833 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); 869 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count);
834 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); 870 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
835 } else { 871 } else {
836 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); 872 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count);
837 ReportUserActionHistogram(PRINT_TO_PRINTER); 873 ReportUserActionHistogram(PRINT_TO_PRINTER);
838 } 874 }
839 ReportPrintSettingsStats(*settings);
840 875
841 // This tries to activate the initiator as well, so do not clear the 876 // This tries to activate the initiator as well, so do not clear the
842 // association with the initiator yet. 877 // association with the initiator yet.
843 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 878 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
844 web_ui()->GetController()); 879 web_ui()->GetController());
845 print_preview_ui->OnHidePreviewDialog(); 880 print_preview_ui->OnHidePreviewDialog();
846 881
847 // Do this so the initiator can open a new print preview dialog, while the 882 // Do this so the initiator can open a new print preview dialog, while the
848 // current print preview dialog is still handling its print job. 883 // current print preview dialog is still handling its print job.
849 WebContents* initiator = GetInitiator(); 884 WebContents* initiator = GetInitiator();
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 1630
1596 void PrintPreviewHandler::UnregisterForMergeSession() { 1631 void PrintPreviewHandler::UnregisterForMergeSession() {
1597 if (reconcilor_) 1632 if (reconcilor_)
1598 reconcilor_->RemoveMergeSessionObserver(this); 1633 reconcilor_->RemoveMergeSessionObserver(this);
1599 } 1634 }
1600 1635
1601 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1636 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1602 const base::Closure& closure) { 1637 const base::Closure& closure) {
1603 pdf_file_saved_closure_ = closure; 1638 pdf_file_saved_closure_ = closure;
1604 } 1639 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/settings/more_settings.js ('k') | printing/print_job_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698