summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 21:13:21 +0000
committeralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 21:13:21 +0000
commit37745db2227954bf1731c5ef4fe8577ee5c8f8ed (patch)
treea02d42b74fc220149fa4e7dff37cdaadab15e2f8
parent05d4acc13011905c79374f699651a32afb2aa28e (diff)
downloadchromium_src-37745db2227954bf1731c5ef4fe8577ee5c8f8ed.zip
chromium_src-37745db2227954bf1731c5ef4fe8577ee5c8f8ed.tar.gz
chromium_src-37745db2227954bf1731c5ef4fe8577ee5c8f8ed.tar.bz2
- Migrate Print Preview metrics from private implementation to
metricsHandler:recordInHistogram - Fix GCP Promo metrics description - Add metrics for print settings UI BUG=397741 Review URL: https://codereview.chromium.org/425853004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286292 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/print_preview/data/destination_store.js21
-rw-r--r--chrome/browser/resources/print_preview/metrics.js144
-rw-r--r--chrome/browser/resources/print_preview/print_preview.js40
-rw-r--r--chrome/browser/resources/print_preview/search/destination_search.js37
-rw-r--r--chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js6
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc73
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui.cc4
-rw-r--r--tools/metrics/histograms/histograms.xml18
8 files changed, 164 insertions, 179 deletions
diff --git a/chrome/browser/resources/print_preview/data/destination_store.js b/chrome/browser/resources/print_preview/data/destination_store.js
index d06d9f3..1012441 100644
--- a/chrome/browser/resources/print_preview/data/destination_store.js
+++ b/chrome/browser/resources/print_preview/data/destination_store.js
@@ -12,11 +12,10 @@ cr.define('print_preview', function() {
* destinations.
* @param {!print_preview.UserInfo} userInfo User information repository.
* @param {!print_preview.AppState} appState Application state.
- * @param {!print_preview.Metrics} metrics Metrics.
* @constructor
* @extends {cr.EventTarget}
*/
- function DestinationStore(nativeLayer, userInfo, appState, metrics) {
+ function DestinationStore(nativeLayer, userInfo, appState) {
cr.EventTarget.call(this);
/**
@@ -42,10 +41,10 @@ cr.define('print_preview', function() {
/**
* Used to track metrics.
- * @type {!print_preview.AppState}
+ * @type {!print_preview.DestinationSearchMetricsContext}
* @private
*/
- this.metrics_ = metrics;
+ this.metrics_ = new print_preview.DestinationSearchMetricsContext();
/**
* Internal backing store for the data store.
@@ -414,15 +413,11 @@ cr.define('print_preview', function() {
return otherDestination.cloudID == destination.cloudID &&
otherDestination != destination;
})) {
- if (destination.isPrivet) {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.
- PRIVET_DUPLICATE_SELECTED);
- } else {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.
- CLOUD_DUPLICATE_SELECTED);
- }
+ this.metrics_.record(destination.isPrivet ?
+ print_preview.Metrics.DestinationSearchBucket.
+ PRIVET_DUPLICATE_SELECTED :
+ print_preview.Metrics.DestinationSearchBucket.
+ CLOUD_DUPLICATE_SELECTED);
}
// Notify about selected destination change.
cr.dispatchSimpleEvent(
diff --git a/chrome/browser/resources/print_preview/metrics.js b/chrome/browser/resources/print_preview/metrics.js
index 081cebe..6a03485 100644
--- a/chrome/browser/resources/print_preview/metrics.js
+++ b/chrome/browser/resources/print_preview/metrics.js
@@ -12,40 +12,28 @@ cr.define('print_preview', function() {
function Metrics() {};
/**
- * Enumeration of metrics bucket groups. Each group describes a set of events
- * that can happen in order. This implies that an event cannot occur twice and
- * an event that occurs semantically before another event, should not occur
- * after.
- * @enum {number}
- */
- Metrics.BucketGroup = {
- DESTINATION_SEARCH: 0,
- GCP_PROMO: 1
- };
-
- /**
* Enumeration of buckets that a user can enter while using the destination
* search widget.
* @enum {number}
*/
Metrics.DestinationSearchBucket = {
// Used when the print destination search widget is shown.
- SHOWN: 0,
+ DESTINATION_SHOWN: 0,
// Used when the user selects a print destination.
- DESTINATION_SELECTED: 1,
+ DESTINATION_CLOSED_CHANGED: 1,
// Used when the print destination search widget is closed without selecting
// a print destination.
- CANCELED: 2,
+ DESTINATION_CLOSED_UNCHANGED: 2,
// Used when the Google Cloud Print promotion (shown in the destination
// search widget) is shown to the user.
- CLOUDPRINT_PROMO_SHOWN: 3,
+ SIGNIN_PROMPT: 3,
// Used when the user chooses to sign-in to their Google account.
SIGNIN_TRIGGERED: 4,
- // Used when a user selects the privet printer in a pair of duplicate
- // privet and cloud printers.
+ // Used when a user selects the Privet printer in a pair of duplicate
+ // Privet and cloud printers.
PRIVET_DUPLICATE_SELECTED: 5,
// Used when a user selects the cloud printer in a pair of duplicate
- // privet and cloud printers.
+ // Privet and cloud printers.
CLOUD_DUPLICATE_SELECTED: 6,
// Used when a user sees a register promo for a cloud print printer.
REGISTER_PROMO_SHOWN: 7,
@@ -54,7 +42,9 @@ cr.define('print_preview', function() {
// User changed active account.
ACCOUNT_CHANGED: 9,
// User tried to log into another account.
- ADD_ACCOUNT_SELECTED: 10
+ ADD_ACCOUNT_SELECTED: 10,
+ // Max value.
+ DESTINATION_SEARCH_MAX_BUCKET: 11
};
/**
@@ -63,47 +53,113 @@ cr.define('print_preview', function() {
* @enum {number}
*/
Metrics.GcpPromoBucket = {
- // Used when the Google Cloud Print pomotion (shown above the pdf preview
+ // Used when the Google Cloud Print promotion (shown above the PDF preview
// plugin) is shown to the user.
- SHOWN: 0,
+ PROMO_SHOWN: 0,
// Used when the user clicks the "Get started" link in the promotion shown
// in CLOUDPRINT_BIG_PROMO_SHOWN.
- CLICKED: 1,
+ PROMO_CLICKED: 1,
// Used when the user dismisses the promotion shown in
// CLOUDPRINT_BIG_PROMO_SHOWN.
- DISMISSED: 2
+ PROMO_CLOSED: 2,
+ // Max value.
+ GCP_PROMO_MAX_BUCKET: 3
};
/**
- * Name of the C++ function to call to increment bucket counts.
- * @type {string}
- * @const
- * @private
+ * Print settings UI usage metrics buckets.
+ * @enum {number}
*/
- Metrics.NATIVE_FUNCTION_NAME_ = 'reportUiEvent';
+ Metrics.PrintSettingsUiBucket = {
+ // Advanced settings dialog is shown.
+ ADVANCED_SETTINGS_DIALOG_SHOWN: 0,
+ // Advanced settings dialog is closed without saving a selection.
+ ADVANCED_SETTINGS_DIALOG_CANCELED: 1,
+ // Max value.
+ PRINT_SETTINGS_UI_MAX_BUCKET: 2
+ };
- Metrics.prototype = {
- /**
- * Increments the counter of a destination-search bucket.
- * @param {!Metrics.DestinationSearchBucket} bucket Bucket to increment.
- */
- incrementDestinationSearchBucket: function(bucket) {
- chrome.send(Metrics.NATIVE_FUNCTION_NAME_,
- [Metrics.BucketGroup.DESTINATION_SEARCH, bucket]);
- },
+ /**
+ * A context for recording a value in a specific UMA histogram.
+ * @param {string} histogram The name of the histogram to be recorded in.
+ * @param {number} maxBucket The max value for the last histogram bucket.
+ * @constructor
+ */
+ function MetricsContext(histogram, maxBucket) {
+ /** @private {string} */
+ this.histogram_ = histogram;
+
+ /** @private {number} */
+ this.maxBucket_ = maxBucket;
+ };
+ MetricsContext.prototype = {
/**
- * Increments the counter of a gcp-promo bucket.
- * @param {!Metrics.GcpPromoBucket} bucket Bucket to increment.
+ * Record a histogram value in UMA. If specified value is larger than the
+ * max bucket value, record the value in the largest bucket
+ * @param {number} bucket Value to record.
*/
- incrementGcpPromoBucket: function(bucket) {
- chrome.send(Metrics.NATIVE_FUNCTION_NAME_,
- [Metrics.BucketGroup.GCP_PROMO, bucket]);
+ record: function(bucket) {
+ chrome.send('metricsHandler:recordInHistogram',
+ [this.histogram_,
+ ((bucket > this.maxBucket_) ? this.maxBucket_ : bucket),
+ this.maxBucket_]);
}
};
+ /**
+ * Destination Search specific usage statistics context.
+ * @constructor
+ * @implements {MetricsContext}
+ */
+ function DestinationSearchMetricsContext() {
+ MetricsContext.call(
+ this,
+ 'PrintPreview.DestinationAction',
+ Metrics.DestinationSearchBucket.DESTINATION_SEARCH_MAX_BUCKET);
+ };
+
+ DestinationSearchMetricsContext.prototype = {
+ __proto__: MetricsContext.prototype
+ };
+
+ /**
+ * GCP promotion specific usage statistics context.
+ * @constructor
+ * @implements {MetricsContext}
+ */
+ function GcpPromoMetricsContext() {
+ MetricsContext.call(this,
+ 'PrintPreview.GcpPromo',
+ Metrics.GcpPromoBucket.GCP_PROMO_MAX_BUCKET);
+ };
+
+ GcpPromoMetricsContext.prototype = {
+ __proto__: MetricsContext.prototype
+ };
+
+ /**
+ * Print settings UI specific usage statistics context.
+ * @constructor
+ * @implements {MetricsContext}
+ */
+ function PrintSettingsUiMetricsContext() {
+ MetricsContext.call(
+ this,
+ 'PrintPreview.PrintSettingsUi',
+ Metrics.PrintSettingsUiBucket.PRINT_SETTINGS_UI_MAX_BUCKET);
+ };
+
+ PrintSettingsUiMetricsContext.prototype = {
+ __proto__: MetricsContext.prototype
+ };
+
// Export
return {
- Metrics: Metrics
+ Metrics: Metrics,
+ MetricsContext: MetricsContext,
+ DestinationSearchMetricsContext: DestinationSearchMetricsContext,
+ GcpPromoMetricsContext: GcpPromoMetricsContext,
+ PrintSettingsUiMetricsContext: PrintSettingsUiMetricsContext
};
});
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 2ed33f2..7f95383 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -35,13 +35,6 @@ cr.define('print_preview', function() {
this.userInfo_ = new print_preview.UserInfo();
/**
- * Metrics object used to report usage statistics.
- * @type {!print_preview.Metrics}
- * @private
- */
- this.metrics_ = new print_preview.Metrics();
-
- /**
* Application state.
* @type {!print_preview.AppState}
* @private
@@ -61,7 +54,7 @@ cr.define('print_preview', function() {
* @private
*/
this.destinationStore_ = new print_preview.DestinationStore(
- this.nativeLayer_, this.userInfo_, this.appState_, this.metrics_);
+ this.nativeLayer_, this.userInfo_, this.appState_);
/**
* Storage of the print ticket used to create the print job.
@@ -86,7 +79,7 @@ cr.define('print_preview', function() {
* @private
*/
this.destinationSearch_ = new print_preview.DestinationSearch(
- this.destinationStore_, this.userInfo_, this.metrics_);
+ this.destinationStore_, this.userInfo_);
this.addChild(this.destinationSearch_);
/**
@@ -170,7 +163,7 @@ cr.define('print_preview', function() {
* @type {!print_preview.AdvancedSettings}
* @private
*/
- this.advancedSettings_ = new print_preview.AdvancedSettings(this.metrics_);
+ this.advancedSettings_ = new print_preview.AdvancedSettings();
this.addChild(this.advancedSettings_);
/**
@@ -777,8 +770,9 @@ cr.define('print_preview', function() {
* @private
*/
onCloudPrintRegisterPromoClick_: function(e) {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.REGISTER_PROMO_SELECTED);
+ new print_preview.DestinationSearchMetricsContext().record(
+ print_preview.Metrics.DestinationSearchBucket.
+ REGISTER_PROMO_SELECTED);
var devicesUrl = 'chrome://devices/register?id=' + e.destination.id;
this.nativeLayer_.startForceOpenNewTab(devicesUrl);
this.destinationStore_.waitForRegister(e.destination.id);
@@ -796,8 +790,9 @@ cr.define('print_preview', function() {
!e.metaKey) {
if (this.destinationSearch_.getIsVisible()) {
this.destinationSearch_.setIsVisible(false);
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.CANCELED);
+ new print_preview.DestinationSearchMetricsContext().record(
+ print_preview.Metrics.DestinationSearchBucket.
+ DESTINATION_CLOSED_UNCHANGED);
} else {
<if expr="toolkit_views">
// On the toolkit_views environment, ESC key is handled by C++-side
@@ -862,8 +857,9 @@ cr.define('print_preview', function() {
this.destinationStore_.startLoadCloudDestinations();
this.destinationStore_.startLoadLocalDestinations();
this.destinationStore_.startLoadPrivetDestinations();
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.SHOWN);
+ new print_preview.DestinationSearchMetricsContext().record(
+ print_preview.Metrics.DestinationSearchBucket.
+ DESTINATION_SHOWN);
},
/**
@@ -1099,8 +1095,8 @@ cr.define('print_preview', function() {
setIsVisible(this.getChildElement('#no-destinations-promo'),
isPromoVisible);
if (isPromoVisible) {
- this.metrics_.incrementGcpPromoBucket(
- print_preview.Metrics.GcpPromoBucket.SHOWN);
+ new print_preview.GcpPromoMetricsContext().record(
+ print_preview.Metrics.GcpPromoBucket.PROMO_SHOWN);
}
},
@@ -1110,8 +1106,8 @@ cr.define('print_preview', function() {
* @private
*/
onNoDestinationsPromoClose_: function() {
- this.metrics_.incrementGcpPromoBucket(
- print_preview.Metrics.GcpPromoBucket.DISMISSED);
+ new print_preview.GcpPromoMetricsContext().record(
+ print_preview.Metrics.GcpPromoBucket.PROMO_CLOSED);
setIsVisible(this.getChildElement('#no-destinations-promo'), false);
this.appState_.persistIsGcpPromoDismissed(true);
},
@@ -1122,8 +1118,8 @@ cr.define('print_preview', function() {
* @private
*/
onNoDestinationsPromoClick_: function() {
- this.metrics_.incrementGcpPromoBucket(
- print_preview.Metrics.GcpPromoBucket.CLICKED);
+ new print_preview.GcpPromoMetricsContext().record(
+ print_preview.Metrics.GcpPromoBucket.PROMO_CLICKED);
this.appState_.persistIsGcpPromoDismissed(true);
window.open(this.cloudPrintInterface_.baseUrl + '?user=' +
this.userInfo_.activeUser + '#printers');
diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js
index f22d90a..5b6c9f9 100644
--- a/chrome/browser/resources/print_preview/search/destination_search.js
+++ b/chrome/browser/resources/print_preview/search/destination_search.js
@@ -14,11 +14,10 @@ cr.define('print_preview', function() {
* containing the destinations to search through.
* @param {!print_preview.UserInfo} userInfo Event target that contains
* information about the logged in user.
- * @param {!print_preview.Metrics} metrics Used to record usage statistics.
* @constructor
* @extends {print_preview.Component}
*/
- function DestinationSearch(destinationStore, userInfo, metrics) {
+ function DestinationSearch(destinationStore, userInfo) {
print_preview.Component.call(this);
/**
@@ -37,15 +36,15 @@ cr.define('print_preview', function() {
/**
* Used to record usage statistics.
- * @type {!print_preview.Metrics}
+ * @type {!print_preview.DestinationSearchMetricsContext}
* @private
*/
- this.metrics_ = metrics;
+ this.metrics_ = new print_preview.DestinationSearchMetricsContext();
/**
* Whether or not a UMA histogram for the register promo being shown was
* already recorded.
- * @type {bool}
+ * @type {boolean}
* @private
*/
this.registerPromoShownMetricRecorded_ = false;
@@ -144,9 +143,8 @@ cr.define('print_preview', function() {
this.searchBox_.focus();
var promoEl = this.getChildElement('.cloudprint-promo');
if (getIsVisible(promoEl)) {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.
- CLOUDPRINT_PROMO_SHOWN);
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.SIGNIN_PROMPT);
}
if (this.userInfo_.initialized) {
this.onUsersChanged_();
@@ -166,9 +164,8 @@ cr.define('print_preview', function() {
showCloudPrintPromo: function() {
setIsVisible(this.getChildElement('.cloudprint-promo'), true);
if (this.getIsVisible()) {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.
- CLOUDPRINT_PROMO_SHOWN);
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.SIGNIN_PROMPT);
}
this.reflowLists_();
},
@@ -337,8 +334,8 @@ cr.define('print_preview', function() {
if (unregisteredCloudDestinations.length != 0 &&
!this.registerPromoShownMetricRecorded_) {
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.REGISTER_PROMO_SHOWN);
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.REGISTER_PROMO_SHOWN);
this.registerPromoShownMetricRecorded_ = true;
}
@@ -484,8 +481,8 @@ cr.define('print_preview', function() {
onCloseClick_: function() {
this.setIsVisible(false);
this.resetSearch_();
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.CANCELED);
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket.
+ DESTINATION_CLOSED_UNCHANGED);
},
/**
@@ -498,8 +495,8 @@ cr.define('print_preview', function() {
this.setIsVisible(false);
this.resetSearch_();
this.destinationStore_.selectDestination(evt.destination);
- this.metrics_.incrementDestinationSearchBucket(
- print_preview.Metrics.DestinationSearchBucket.DESTINATION_SELECTED);
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket.
+ DESTINATION_CLOSED_CHANGED);
},
/**
@@ -568,7 +565,7 @@ cr.define('print_preview', function() {
*/
onSignInActivated_: function() {
cr.dispatchSimpleEvent(this, DestinationSearch.EventType.SIGN_IN);
- this.metrics_.incrementDestinationSearchBucket(
+ this.metrics_.record(
print_preview.Metrics.DestinationSearchBucket.SIGNIN_TRIGGERED);
},
@@ -584,7 +581,7 @@ cr.define('print_preview', function() {
if (account) {
this.userInfo_.activeUser = account;
this.destinationStore_.reloadUserCookieBasedDestinations();
- this.metrics_.incrementDestinationSearchBucket(
+ this.metrics_.record(
print_preview.Metrics.DestinationSearchBucket.ACCOUNT_CHANGED);
} else {
cr.dispatchSimpleEvent(this, DestinationSearch.EventType.ADD_ACCOUNT);
@@ -595,7 +592,7 @@ cr.define('print_preview', function() {
break;
}
}
- this.metrics_.incrementDestinationSearchBucket(
+ this.metrics_.record(
print_preview.Metrics.DestinationSearchBucket.ADD_ACCOUNT_SELECTED);
}
},
diff --git a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js
index 17563dc..06125e3 100644
--- a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js
+++ b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js
@@ -7,16 +7,12 @@ cr.define('print_preview', function() {
/**
* Modal dialog for print destination's advanced settings.
- * @param {!print_preview.Metrics} metrics Used to record usage statistics.
* @constructor
* @extends {print_preview.Component}
*/
- function AdvancedSettings(metrics) {
+ function AdvancedSettings() {
print_preview.Component.call(this);
- /** @private {!print_preview.Metrics} */
- this.metrics_ = metrics;
-
/** @private {!print_preview.SearchBox} */
this.searchBox_ = new print_preview.SearchBox(
localStrings.getString('advancedSettingsSearchBoxPlaceholder'));
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 8f35b4bf..b62d64e 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -123,34 +123,6 @@ enum PrintSettingsBuckets {
PRINT_SETTINGS_BUCKET_BOUNDARY
};
-enum UiBucketGroups {
- DESTINATION_SEARCH,
- GCP_PROMO,
- UI_BUCKET_GROUP_BOUNDARY
-};
-
-enum PrintDestinationBuckets {
- DESTINATION_SHOWN,
- DESTINATION_CLOSED_CHANGED,
- DESTINATION_CLOSED_UNCHANGED,
- SIGNIN_PROMPT,
- SIGNIN_TRIGGERED,
- PRIVET_DUPLICATE_SELECTED,
- CLOUD_DUPLICATE_SELECTED,
- REGISTER_PROMO_SHOWN,
- REGISTER_PROMO_SELECTED,
- ACCOUNT_CHANGED,
- ADD_ACCOUNT_SELECTED,
- PRINT_DESTINATION_BUCKET_BOUNDARY
-};
-
-enum GcpPromoBuckets {
- PROMO_SHOWN,
- PROMO_CLOSED,
- PROMO_CLICKED,
- GCP_PROMO_BUCKET_BOUNDARY
-};
-
void ReportUserActionHistogram(enum UserActionBuckets event) {
UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event,
USERACTION_BUCKET_BOUNDARY);
@@ -161,16 +133,6 @@ void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) {
PRINT_SETTINGS_BUCKET_BOUNDARY);
}
-void ReportPrintDestinationHistogram(enum PrintDestinationBuckets event) {
- UMA_HISTOGRAM_ENUMERATION("PrintPreview.DestinationAction", event,
- PRINT_DESTINATION_BUCKET_BOUNDARY);
-}
-
-void ReportGcpPromoHistogram(enum GcpPromoBuckets event) {
- UMA_HISTOGRAM_ENUMERATION("PrintPreview.GcpPromo", event,
- GCP_PROMO_BUCKET_BOUNDARY);
-}
-
// Name of a dictionary field holding cloud print related data;
const char kAppState[] = "appState";
// Name of a dictionary field holding the initiator title.
@@ -624,9 +586,6 @@ void PrintPreviewHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("getInitialSettings",
base::Bind(&PrintPreviewHandler::HandleGetInitialSettings,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("reportUiEvent",
- base::Bind(&PrintPreviewHandler::HandleReportUiEvent,
- base::Unretained(this)));
web_ui()->RegisterMessageCallback("printWithCloudPrintDialog",
base::Bind(&PrintPreviewHandler::HandlePrintWithCloudPrintDialog,
base::Unretained(this)));
@@ -1134,38 +1093,6 @@ void PrintPreviewHandler::HandleGetInitialSettings(
weak_factory_.GetWeakPtr()));
}
-void PrintPreviewHandler::HandleReportUiEvent(const base::ListValue* args) {
- int event_group, event_number;
- if (!args->GetInteger(0, &event_group) || !args->GetInteger(1, &event_number))
- return;
-
- enum UiBucketGroups ui_bucket_group =
- static_cast<enum UiBucketGroups>(event_group);
- if (ui_bucket_group >= UI_BUCKET_GROUP_BOUNDARY)
- return;
-
- switch (ui_bucket_group) {
- case DESTINATION_SEARCH: {
- enum PrintDestinationBuckets event =
- static_cast<enum PrintDestinationBuckets>(event_number);
- if (event >= PRINT_DESTINATION_BUCKET_BOUNDARY)
- return;
- ReportPrintDestinationHistogram(event);
- break;
- }
- case GCP_PROMO: {
- enum GcpPromoBuckets event =
- static_cast<enum GcpPromoBuckets>(event_number);
- if (event >= GCP_PROMO_BUCKET_BOUNDARY)
- return;
- ReportGcpPromoHistogram(event);
- break;
- }
- default:
- break;
- }
-}
-
void PrintPreviewHandler::HandleForceOpenNewTab(const base::ListValue* args) {
std::string url;
if (!args->GetString(0, &url))
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
index 72e26b0..167a57d 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#include <map>
+#include <vector>
#include "base/id_map.h"
#include "base/lazy_instance.h"
@@ -20,6 +21,7 @@
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_preview_data_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/print_messages.h"
@@ -383,6 +385,8 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui)
handler_ = new PrintPreviewHandler();
web_ui->AddMessageHandler(handler_);
+ web_ui->AddMessageHandler(new MetricsHandler());
+
g_print_preview_request_id_map.Get().Set(id_, -1);
}
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index c391a9c..0320e61 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -23677,6 +23677,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
+<histogram name="PrintPreview.PrintSettingsUi"
+ enum="PrintPreviewPrintSettingsUiBuckets">
+ <owner>alekseys@chromium.org</owner>
+ <owner>vitalybuka@chromium.org</owner>
+ <summary>
+ Actions performed by the user interacting with print settings UI elements.
+ </summary>
+</histogram>
+
<histogram name="PrintPreview.RegeneratePreviewRequest.BeforeCancel">
<owner>vitalybuka@chromium.org</owner>
<summary>
@@ -45532,8 +45541,8 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<enum name="PrintPreviewGcpPromoBuckets" type="int">
<int value="0" label="PROMO_SHOWN"/>
- <int value="1" label="PROMO_CLOSED"/>
- <int value="2" label="GCP_PROMO_BUCKET_BOUNDARY"/>
+ <int value="1" label="PROMO_CLICKED"/>
+ <int value="2" label="PROMO_CLOSED"/>
</enum>
<enum name="PrintPreviewHelperEvents" type="int">
@@ -45557,6 +45566,11 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="10" label="ADD_ACCOUNT_SELECTED"/>
</enum>
+<enum name="PrintPreviewPrintSettingsUiBuckets" type="int">
+ <int value="0" label="ADVANCED_SETTINGS_DIALOG_SHOWN"/>
+ <int value="1" label="ADVANCED_SETTINGS_DIALOG_CANCELED"/>
+</enum>
+
<enum name="PrintPreviewUserActionType" type="int">
<int value="0" label="PRINT_TO_PRINTER"/>
<int value="1" label="PRINT_TO_PDF"/>