diff options
8 files changed, 97 insertions, 3 deletions
diff --git a/chrome/browser/resources/print_preview/metrics.js b/chrome/browser/resources/print_preview/metrics.js index 6a03485..d632d638 100644 --- a/chrome/browser/resources/print_preview/metrics.js +++ b/chrome/browser/resources/print_preview/metrics.js @@ -43,8 +43,14 @@ cr.define('print_preview', function() { ACCOUNT_CHANGED: 9, // User tried to log into another account. ADD_ACCOUNT_SELECTED: 10, + // Printer sharing invitation was shown to the user. + INVITATION_AVAILABLE: 11, + // User accepted printer sharing invitation. + INVITATION_ACCEPTED: 12, + // User rejected printer sharing invitation. + INVITATION_REJECTED: 13, // Max value. - DESTINATION_SEARCH_MAX_BUCKET: 11 + DESTINATION_SEARCH_MAX_BUCKET: 14 }; /** @@ -75,8 +81,16 @@ cr.define('print_preview', function() { ADVANCED_SETTINGS_DIALOG_SHOWN: 0, // Advanced settings dialog is closed without saving a selection. ADVANCED_SETTINGS_DIALOG_CANCELED: 1, + // 'More/less settings' expanded. + MORE_SETTINGS_CLICKED: 2, + // 'More/less settings' collapsed. + LESS_SETTINGS_CLICKED: 3, + // User printed with extra settings expanded. + PRINT_WITH_SETTINGS_EXPANDED: 4, + // User printed with extra settings collapsed. + PRINT_WITH_SETTINGS_COLLAPSED: 5, // Max value. - PRINT_SETTINGS_UI_MAX_BUCKET: 2 + PRINT_SETTINGS_UI_MAX_BUCKET: 6 }; /** diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index d6de02f..49e4b1f 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -555,6 +555,14 @@ cr.define('print_preview', function() { this.nativeLayer_.startShowCloudPrintDialog( this.printTicketStore_.pageRange.getPageNumberSet().size); } else { + if (getIsVisible(this.moreSettings_.getElement())) { + new print_preview.PrintSettingsUiMetricsContext().record( + this.moreSettings_.isExpanded ? + print_preview.Metrics.PrintSettingsUiBucket. + PRINT_WITH_SETTINGS_EXPANDED : + print_preview.Metrics.PrintSettingsUiBucket. + PRINT_WITH_SETTINGS_COLLAPSED); + } this.nativeLayer_.startPrint( this.destinationStore_.selectedDestination, this.printTicketStore_, diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js index 1335e22..955984a 100644 --- a/chrome/browser/resources/print_preview/search/destination_search.js +++ b/chrome/browser/resources/print_preview/search/destination_search.js @@ -458,6 +458,10 @@ cr.define('print_preview', function() { var invitations = this.userInfo_.activeUser ? this.invitationStore_.invitations(this.userInfo_.activeUser) : []; if (invitations.length > 0) { + if (this.invitation_ != invitations[0]) { + this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. + INVITATION_AVAILABLE); + } this.invitation_ = invitations[0]; this.showInvitation_(this.invitation_); } else { @@ -660,6 +664,9 @@ cr.define('print_preview', function() { * @private */ onInvitationProcessButtonClick_: function(accept) { + this.metrics_.record(accept ? + print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED : + print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED); this.invitationStore_.processInvitation(this.invitation_, accept); this.updateInvitations_(); }, diff --git a/chrome/browser/resources/print_preview/settings/more_settings.js b/chrome/browser/resources/print_preview/settings/more_settings.js index 7f924ee..8a3d5f6 100644 --- a/chrome/browser/resources/print_preview/settings/more_settings.js +++ b/chrome/browser/resources/print_preview/settings/more_settings.js @@ -31,6 +31,12 @@ cr.define('print_preview', function() { /** @private {boolean} */ this.firstDestinationReady_ = false; + + /** + * Used to record usage statistics. + * @private {!print_preview.PrintSettingsUiMetricsContext} + */ + this.metrics_ = new print_preview.PrintSettingsUiMetricsContext(); }; /** @@ -45,6 +51,11 @@ cr.define('print_preview', function() { MoreSettings.prototype = { __proto__: print_preview.Component.prototype, + /** @return {boolean} Returns {@code true} if settings are expanded. */ + get isExpanded() { + return this.settingsToShow_ == MoreSettings.SettingsToShow.ALL; + }, + /** @override */ enterDocument: function() { print_preview.Component.prototype.enterDocument.call(this); @@ -80,6 +91,9 @@ cr.define('print_preview', function() { MoreSettings.SettingsToShow.ALL : MoreSettings.SettingsToShow.MOST_POPULAR; this.updateState_(false); + this.metrics_.record(this.isExpanded ? + print_preview.Metrics.PrintSettingsUiBucket.MORE_SETTINGS_CLICKED : + print_preview.Metrics.PrintSettingsUiBucket.LESS_SETTINGS_CLICKED); }, /** diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index f757b59..ed2c3d5 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -121,6 +121,11 @@ enum PrintSettingsBuckets { CSS_BACKGROUND, SELECTION_ONLY, EXTERNAL_PDF_PREVIEW, + PAGE_RANGE, + DEFAULT_MEDIA, + NON_DEFAULT_MEDIA, + COPIES, + NON_DEFAULT_MARGINS, PRINT_SETTINGS_BUCKET_BOUNDARY }; @@ -196,10 +201,33 @@ base::DictionaryValue* GetSettingsDictionary(const base::ListValue* args) { void ReportPrintSettingsStats(const base::DictionaryValue& settings) { ReportPrintSettingHistogram(TOTAL); + const base::ListValue* page_range_array = NULL; + if (settings.GetList(printing::kSettingPageRange, &page_range_array) && + !page_range_array->empty()) { + ReportPrintSettingHistogram(PAGE_RANGE); + } + + const base::DictionaryValue* media_size_value = NULL; + if (settings.GetDictionary(printing::kSettingMediaSize, &media_size_value) && + !media_size_value->empty()) { + bool is_default = false; + if (media_size_value->GetBoolean(printing::kSettingMediaSizeIsDefault, + &is_default) && + is_default) { + ReportPrintSettingHistogram(DEFAULT_MEDIA); + } else { + ReportPrintSettingHistogram(NON_DEFAULT_MEDIA); + } + } + bool landscape = false; if (settings.GetBoolean(printing::kSettingLandscape, &landscape)) ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT); + int copies = 1; + if (settings.GetInteger(printing::kSettingCopies, &copies) && copies > 1) + ReportPrintSettingHistogram(COPIES); + bool collate = false; if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate) ReportPrintSettingHistogram(COLLATE); @@ -214,6 +242,12 @@ void ReportPrintSettingsStats(const base::DictionaryValue& settings) { printing::IsColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE); } + int margins_type = 0; + if (settings.GetInteger(printing::kSettingMarginsType, &margins_type) && + margins_type != 0) { + ReportPrintSettingHistogram(NON_DEFAULT_MARGINS); + } + bool headers = false; if (settings.GetBoolean(printing::kSettingHeaderFooterEnabled, &headers) && headers) { @@ -758,6 +792,8 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { if (!settings.get()) return; + ReportPrintSettingsStats(*settings); + // Never try to add headers/footers here. It's already in the generated PDF. settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); @@ -836,7 +872,6 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); ReportUserActionHistogram(PRINT_TO_PRINTER); } - ReportPrintSettingsStats(*settings); // This tries to activate the initiator as well, so do not clear the // association with the initiator yet. diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc index ed4d1e2..8d36199 100644 --- a/printing/print_job_constants.cc +++ b/printing/print_job_constants.cc @@ -95,6 +95,9 @@ const char kSettingMediaSizeWidthMicrons[] = "width_microns"; // Key that specifies the requested media platform specific vendor id. const char kSettingMediaSizeVendorId[] = "vendor_id"; +// Key that specifies whether the requested media is a default one. +const char kSettingMediaSizeIsDefault[] = "is_default"; + // Key that specifies the bottom margin of the page. const char kSettingMarginBottom[] = "marginBottom"; diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h index 35f036d..fcce6ee 100644 --- a/printing/print_job_constants.h +++ b/printing/print_job_constants.h @@ -38,6 +38,7 @@ PRINTING_EXPORT extern const char kSettingMediaSize[]; PRINTING_EXPORT extern const char kSettingMediaSizeHeightMicrons[]; PRINTING_EXPORT extern const char kSettingMediaSizeWidthMicrons[]; PRINTING_EXPORT extern const char kSettingMediaSizeVendorId[]; +PRINTING_EXPORT extern const char kSettingMediaSizeIsDefault[]; PRINTING_EXPORT extern const char kSettingMarginBottom[]; PRINTING_EXPORT extern const char kSettingMarginLeft[]; PRINTING_EXPORT extern const char kSettingMarginRight[]; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 6feef49..61306c6 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -49004,11 +49004,18 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="8" label="REGISTER_PROMO_SELECTED"/> <int value="9" label="ACCOUNT_CHANGED"/> <int value="10" label="ADD_ACCOUNT_SELECTED"/> + <int value="11" label="INVITATION_AVAILABLE"/> + <int value="12" label="INVITATION_ACCEPTED"/> + <int value="13" label="INVITATION_REJECTED"/> </enum> <enum name="PrintPreviewPrintSettingsUiBuckets" type="int"> <int value="0" label="ADVANCED_SETTINGS_DIALOG_SHOWN"/> <int value="1" label="ADVANCED_SETTINGS_DIALOG_CANCELED"/> + <int value="2" label="MORE_SETTINGS_CLICKED"/> + <int value="3" label="LESS_SETTINGS_CLICKED"/> + <int value="4" label="PRINT_WITH_SETTINGS_EXPANDED"/> + <int value="5" label="PRINT_WITH_SETTINGS_COLLAPSED"/> </enum> <enum name="PrintPreviewUserActionType" type="int"> @@ -49037,6 +49044,11 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="9" label="CSS_BACKGROUND"/> <int value="10" label="SELECTION_ONLY"/> <int value="11" label="EXTERNAL_PDF_PREVIEW"/> + <int value="12" label="PAGE_RANGE"/> + <int value="13" label="DEFAULT_MEDIA"/> + <int value="14" label="NON_DEFAULT_MEDIA"/> + <int value="15" label="COPIES"/> + <int value="16" label="NON_DEFAULT_MARGINS"/> </enum> <enum name="PrivetNotificationsEvent" type="int"> |
