Index: chrome/browser/resources/file_manager/js/suggest_apps_dialog.js |
diff --git a/chrome/browser/resources/file_manager/js/suggest_apps_dialog.js b/chrome/browser/resources/file_manager/js/suggest_apps_dialog.js |
index 7e02b6bf13b68cb18266ded0fb996a55bf31abb9..b120e2f7628d962106071d3d489954ab5f6bf4c4 100644 |
--- a/chrome/browser/resources/file_manager/js/suggest_apps_dialog.js |
+++ b/chrome/browser/resources/file_manager/js/suggest_apps_dialog.js |
@@ -111,6 +111,7 @@ SuggestAppsDialog.State = { |
INITIALIZED: 'SuggestAppsDialog.State.INITIALIZED', |
INSTALLING: 'SuggestAppsDialog.State.INSTALLING', |
INSTALLED_CLOSING: 'SuggestAppsDialog.State.INSTALLED_CLOSING', |
+ OPENING_WEBSTORE_CLOSING: 'SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING', |
CANCELED_CLOSING: 'SuggestAppsDialog.State.CANCELED_CLOSING' |
}; |
Object.freeze(SuggestAppsDialog.State); |
@@ -124,6 +125,8 @@ SuggestAppsDialog.Result = { |
INSTALL_SUCCESSFUL: 'SuggestAppsDialog.Result.INSTALL_SUCCESSFUL', |
// User cancelled the suggest app dialog. No message should be shown. |
USER_CANCELL: 'SuggestAppsDialog.Result.USER_CANCELL', |
+ // User clicked the link to web store so the dialog is closed. |
+ WEBSTORE_LINK_OPENED: 'SuggestAppsDialog.Result.WEBSTORE_LINK_OPENED', |
// Failed to load the widget. Error message should be shown. |
FAILED: 'SuggestAppsDialog.Result.FAILED' |
}; |
@@ -198,6 +201,9 @@ SuggestAppsDialog.prototype.show = function(extension, mime, onDialogClosed) { |
this.onDialogClosed_ = onDialogClosed; |
this.state_ = SuggestAppsDialog.State.INITIALIZING; |
+ metrics.recordUserAction('SuggestApps.ShowDialog'); |
+ metrics.startInterval('SuggestApps.LoadTime'); |
+ |
// Makes it sure that the initialization is completed. |
this.initializationTask_.run(function() { |
if (!this.accessToken_) { |
@@ -261,6 +267,7 @@ SuggestAppsDialog.prototype.onWebstoreLinkClicked_ = function(e) { |
var webStoreUrl = |
FileTasks.createWebStoreLink(this.extension_, this.mimeType_); |
chrome.windows.create({url: webStoreUrl}); |
+ this.state_ = SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING; |
this.hide(); |
}; |
@@ -270,6 +277,9 @@ SuggestAppsDialog.prototype.onWebstoreLinkClicked_ = function(e) { |
* @private |
*/ |
SuggestAppsDialog.prototype.onWidgetLoaded_ = function(event) { |
+ metrics.recordInterval('SuggestApps.LoadTime'); |
+ metrics.recordEnum('SuggestApps.Load', 0, 3); // 0: Load success. |
+ |
this.frame_.classList.remove('show-spinner'); |
this.state_ = SuggestAppsDialog.State.INITIALIZED; |
@@ -282,6 +292,8 @@ SuggestAppsDialog.prototype.onWidgetLoaded_ = function(event) { |
* @private |
*/ |
SuggestAppsDialog.prototype.onWidgetLoadFailed_ = function(event) { |
+ metrics.recordEnum('SuggestApps.Load', 2, 3); // 2: Load failure. |
+ |
this.frame_.classList.remove('show-spinner'); |
this.state_ = SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING; |
@@ -335,13 +347,16 @@ SuggestAppsDialog.prototype.onInstallCompleted_ = function(result, error) { |
switch (result) { |
case AppInstaller.Result.SUCCESS: |
+ metrics.recordEnum('SuggestApps.Install', 0, 3); // 0: Install succeeded. |
this.hide(); |
break; |
case AppInstaller.Result.CANCELLED: |
// User cancelled the installation. Do nothing. |
+ metrics.recordEnum('SuggestApps.Install', 1, 3); // 1: Install cancelled. |
break; |
case AppInstaller.Result.ERROR: |
fileManager.error.show(str('SUGGEST_DIALOG_INSTALLATION_FAILED')); |
+ metrics.recordEnum('SuggestApps.Install', 2, 3); // 2: Intall failed. |
mtomasz
2013/10/15 07:51:11
nit: Intall -> Install
yoshiki
2013/10/17 07:15:10
Done.
|
break; |
} |
}; |
@@ -361,8 +376,13 @@ SuggestAppsDialog.prototype.hide = function(opt_originalOnHide) { |
// Assumes closing the dialog as canceling the install. |
this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING; |
break; |
+ case SuggestAppsDialog.State.INITIALIZING: |
+ metrics.recordEnum('SuggestApps.Load', 1, 3); // 1: Load cancelled. |
+ this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING; |
+ break; |
case SuggestAppsDialog.State.INSTALLED_CLOSING: |
case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING: |
+ case SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING: |
// Do nothing. |
break; |
case SuggestAppsDialog.State.INITIALIZED: |
@@ -401,15 +421,26 @@ SuggestAppsDialog.prototype.onHide_ = function(opt_originalOnHide) { |
switch (this.state_) { |
case SuggestAppsDialog.State.INSTALLED_CLOSING: |
result = SuggestAppsDialog.Result.INSTALL_SUCCESSFUL; |
+ // Record the reson of closing. 1: Item installed. |
+ metrics.recordEnum('SuggestApps.CloseDialog', 1, 4); |
break; |
case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING: |
result = SuggestAppsDialog.Result.FAILED; |
break; |
case SuggestAppsDialog.State.CANCELED_CLOSING: |
result = SuggestAppsDialog.Result.USER_CANCELL; |
+ // Record the reson of closing. 2: User cancelled. |
+ metrics.recordEnum('SuggestApps.CloseDialog', 2, 4); |
+ break; |
+ case SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING: |
+ result = SuggestAppsDialog.Result.WEBSTORE_LINK_OPENED; |
+ // Record the reson of closing. 3: Webstore link opened. |
+ metrics.recordEnum('SuggestApps.CloseDialog', 3, 4); |
break; |
default: |
result = SuggestAppsDialog.Result.USER_CANCELL; |
+ // Record the reson of closing. 0: Unknown error. |
mtomasz
2013/10/15 07:51:11
nit: reson -> reason
here and in other places
yoshiki
2013/10/17 07:15:10
Done.
|
+ metrics.recordEnum('SuggestApps.CloseDialog', 0, 4); |
console.error('Invalid state.'); |
} |
this.state_ = SuggestAppsDialog.State.UNINITIALIZED; |