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

Side by Side Diff: chrome/browser/resources/file_manager/js/suggest_apps_dialog.js

Issue 27301002: [Files.app] Record metrics in the suggest apps dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed a comment Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * SuggestAppsDialog contains a list box to select an app to be opened the file 8 * SuggestAppsDialog contains a list box to select an app to be opened the file
9 * with. This dialog should be used as action picker for file operations. 9 * with. This dialog should be used as action picker for file operations.
10 */ 10 */
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 * @const 104 * @const
105 */ 105 */
106 SuggestAppsDialog.State = { 106 SuggestAppsDialog.State = {
107 UNINITIALIZED: 'SuggestAppsDialog.State.UNINITIALIZED', 107 UNINITIALIZED: 'SuggestAppsDialog.State.UNINITIALIZED',
108 INITIALIZING: 'SuggestAppsDialog.State.INITIALIZING', 108 INITIALIZING: 'SuggestAppsDialog.State.INITIALIZING',
109 INITIALIZE_FAILED_CLOSING: 109 INITIALIZE_FAILED_CLOSING:
110 'SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING', 110 'SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING',
111 INITIALIZED: 'SuggestAppsDialog.State.INITIALIZED', 111 INITIALIZED: 'SuggestAppsDialog.State.INITIALIZED',
112 INSTALLING: 'SuggestAppsDialog.State.INSTALLING', 112 INSTALLING: 'SuggestAppsDialog.State.INSTALLING',
113 INSTALLED_CLOSING: 'SuggestAppsDialog.State.INSTALLED_CLOSING', 113 INSTALLED_CLOSING: 'SuggestAppsDialog.State.INSTALLED_CLOSING',
114 OPENING_WEBSTORE_CLOSING: 'SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING',
114 CANCELED_CLOSING: 'SuggestAppsDialog.State.CANCELED_CLOSING' 115 CANCELED_CLOSING: 'SuggestAppsDialog.State.CANCELED_CLOSING'
115 }; 116 };
116 Object.freeze(SuggestAppsDialog.State); 117 Object.freeze(SuggestAppsDialog.State);
117 118
118 /** 119 /**
119 * @enum {string} 120 * @enum {string}
120 * @const 121 * @const
121 */ 122 */
122 SuggestAppsDialog.Result = { 123 SuggestAppsDialog.Result = {
123 // Install is done. The install app should be opened. 124 // Install is done. The install app should be opened.
124 INSTALL_SUCCESSFUL: 'SuggestAppsDialog.Result.INSTALL_SUCCESSFUL', 125 INSTALL_SUCCESSFUL: 'SuggestAppsDialog.Result.INSTALL_SUCCESSFUL',
125 // User cancelled the suggest app dialog. No message should be shown. 126 // User cancelled the suggest app dialog. No message should be shown.
126 USER_CANCELL: 'SuggestAppsDialog.Result.USER_CANCELL', 127 USER_CANCELL: 'SuggestAppsDialog.Result.USER_CANCELL',
128 // User clicked the link to web store so the dialog is closed.
129 WEBSTORE_LINK_OPENED: 'SuggestAppsDialog.Result.WEBSTORE_LINK_OPENED',
127 // Failed to load the widget. Error message should be shown. 130 // Failed to load the widget. Error message should be shown.
128 FAILED: 'SuggestAppsDialog.Result.FAILED' 131 FAILED: 'SuggestAppsDialog.Result.FAILED'
129 }; 132 };
130 Object.freeze(SuggestAppsDialog.Result); 133 Object.freeze(SuggestAppsDialog.Result);
131 134
132 /** 135 /**
133 * @override 136 * @override
134 */ 137 */
135 SuggestAppsDialog.prototype.onInputFocus = function() { 138 SuggestAppsDialog.prototype.onInputFocus = function() {
136 this.webviewContainer_.select(); 139 this.webviewContainer_.select();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (this.state_ != SuggestAppsDialog.State.UNINITIALIZED) { 194 if (this.state_ != SuggestAppsDialog.State.UNINITIALIZED) {
192 console.error('Invalid state.'); 195 console.error('Invalid state.');
193 return; 196 return;
194 } 197 }
195 198
196 this.extension_ = extension; 199 this.extension_ = extension;
197 this.mimeType_ = mime; 200 this.mimeType_ = mime;
198 this.onDialogClosed_ = onDialogClosed; 201 this.onDialogClosed_ = onDialogClosed;
199 this.state_ = SuggestAppsDialog.State.INITIALIZING; 202 this.state_ = SuggestAppsDialog.State.INITIALIZING;
200 203
204 metrics.recordUserAction('SuggestApps.ShowDialog');
Ilya Sherman 2013/10/17 22:13:11 Please run extract_actions.py to add this to chrom
yoshiki 2013/10/28 17:14:18 Thanks for guidance. I didn't know extract_actions
205 metrics.startInterval('SuggestApps.LoadTime');
206
201 // Makes it sure that the initialization is completed. 207 // Makes it sure that the initialization is completed.
202 this.initializationTask_.run(function() { 208 this.initializationTask_.run(function() {
203 if (!this.accessToken_) { 209 if (!this.accessToken_) {
204 this.state_ = SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING; 210 this.state_ = SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING;
205 this.onHide_(); 211 this.onHide_();
206 return; 212 return;
207 } 213 }
208 214
209 var title = str('SUGGEST_DIALOG_TITLE'); 215 var title = str('SUGGEST_DIALOG_TITLE');
210 216
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 260
255 /** 261 /**
256 * Called when the 'See more...' link is clicked to be navigated to Webstore. 262 * Called when the 'See more...' link is clicked to be navigated to Webstore.
257 * @param {Event} e Event. 263 * @param {Event} e Event.
258 * @private 264 * @private
259 */ 265 */
260 SuggestAppsDialog.prototype.onWebstoreLinkClicked_ = function(e) { 266 SuggestAppsDialog.prototype.onWebstoreLinkClicked_ = function(e) {
261 var webStoreUrl = 267 var webStoreUrl =
262 FileTasks.createWebStoreLink(this.extension_, this.mimeType_); 268 FileTasks.createWebStoreLink(this.extension_, this.mimeType_);
263 chrome.windows.create({url: webStoreUrl}); 269 chrome.windows.create({url: webStoreUrl});
270 this.state_ = SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING;
264 this.hide(); 271 this.hide();
265 }; 272 };
266 273
267 /** 274 /**
268 * Called when the widget is loaded successfully. 275 * Called when the widget is loaded successfully.
269 * @param {Event} event Event. 276 * @param {Event} event Event.
270 * @private 277 * @private
271 */ 278 */
272 SuggestAppsDialog.prototype.onWidgetLoaded_ = function(event) { 279 SuggestAppsDialog.prototype.onWidgetLoaded_ = function(event) {
280 metrics.recordInterval('SuggestApps.LoadTime');
281 metrics.recordEnum('SuggestApps.Load', 0, 3); // 0: Load success.
282
273 this.frame_.classList.remove('show-spinner'); 283 this.frame_.classList.remove('show-spinner');
274 this.state_ = SuggestAppsDialog.State.INITIALIZED; 284 this.state_ = SuggestAppsDialog.State.INITIALIZED;
275 285
276 this.webview_.focus(); 286 this.webview_.focus();
277 }; 287 };
278 288
279 /** 289 /**
280 * Called when the widget is failed to load. 290 * Called when the widget is failed to load.
281 * @param {Event} event Event. 291 * @param {Event} event Event.
282 * @private 292 * @private
283 */ 293 */
284 SuggestAppsDialog.prototype.onWidgetLoadFailed_ = function(event) { 294 SuggestAppsDialog.prototype.onWidgetLoadFailed_ = function(event) {
295 metrics.recordEnum('SuggestApps.Load', 2, 3); // 2: Load failure.
Ilya Sherman 2013/10/17 22:13:11 I strongly recommend creating a wrapper function f
yoshiki 2013/10/28 17:14:18 Done.
296
285 this.frame_.classList.remove('show-spinner'); 297 this.frame_.classList.remove('show-spinner');
286 this.state_ = SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING; 298 this.state_ = SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING;
287 299
288 this.hide(); 300 this.hide();
289 }; 301 };
290 302
291 /** 303 /**
292 * Called when the connection status is changed. 304 * Called when the connection status is changed.
293 * @param {util.DriveConnectionType} connectionType Current connection type. 305 * @param {util.DriveConnectionType} connectionType Current connection type.
294 */ 306 */
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 340
329 this.frame_.classList.remove('show-spinner'); 341 this.frame_.classList.remove('show-spinner');
330 this.state_ = success ? 342 this.state_ = success ?
331 SuggestAppsDialog.State.INSTALLED_CLOSING : 343 SuggestAppsDialog.State.INSTALLED_CLOSING :
332 SuggestAppsDialog.State.INITIALIZED; // Back to normal state. 344 SuggestAppsDialog.State.INITIALIZED; // Back to normal state.
333 this.webviewClient_.onInstallCompleted(success, this.installingItemId_); 345 this.webviewClient_.onInstallCompleted(success, this.installingItemId_);
334 this.installingItemId_ = null; 346 this.installingItemId_ = null;
335 347
336 switch (result) { 348 switch (result) {
337 case AppInstaller.Result.SUCCESS: 349 case AppInstaller.Result.SUCCESS:
350 metrics.recordEnum('SuggestApps.Install', 0, 3); // 0: Install succeeded.
338 this.hide(); 351 this.hide();
339 break; 352 break;
340 case AppInstaller.Result.CANCELLED: 353 case AppInstaller.Result.CANCELLED:
341 // User cancelled the installation. Do nothing. 354 // User cancelled the installation. Do nothing.
355 metrics.recordEnum('SuggestApps.Install', 1, 3); // 1: Install cancelled.
342 break; 356 break;
343 case AppInstaller.Result.ERROR: 357 case AppInstaller.Result.ERROR:
344 fileManager.error.show(str('SUGGEST_DIALOG_INSTALLATION_FAILED')); 358 fileManager.error.show(str('SUGGEST_DIALOG_INSTALLATION_FAILED'));
359 metrics.recordEnum('SuggestApps.Install', 2, 3); // 2: Install failed.
345 break; 360 break;
346 } 361 }
347 }; 362 };
348 363
349 /** 364 /**
350 * @override 365 * @override
351 */ 366 */
352 SuggestAppsDialog.prototype.hide = function(opt_originalOnHide) { 367 SuggestAppsDialog.prototype.hide = function(opt_originalOnHide) {
353 switch (this.state_) { 368 switch (this.state_) {
354 case SuggestAppsDialog.State.INSTALLING: 369 case SuggestAppsDialog.State.INSTALLING:
355 // Install is being aborted. Send the failure result. 370 // Install is being aborted. Send the failure result.
356 // Cancels the install. 371 // Cancels the install.
357 if (this.webviewClient_) 372 if (this.webviewClient_)
358 this.webviewClient_.onInstallCompleted(false, this.installingItemId_); 373 this.webviewClient_.onInstallCompleted(false, this.installingItemId_);
359 this.installingItemId_ = null; 374 this.installingItemId_ = null;
360 375
361 // Assumes closing the dialog as canceling the install. 376 // Assumes closing the dialog as canceling the install.
362 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING; 377 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING;
363 break; 378 break;
379 case SuggestAppsDialog.State.INITIALIZING:
380 metrics.recordEnum('SuggestApps.Load', 1, 3); // 1: Load cancelled.
381 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING;
382 break;
364 case SuggestAppsDialog.State.INSTALLED_CLOSING: 383 case SuggestAppsDialog.State.INSTALLED_CLOSING:
365 case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING: 384 case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING:
385 case SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING:
366 // Do nothing. 386 // Do nothing.
367 break; 387 break;
368 case SuggestAppsDialog.State.INITIALIZED: 388 case SuggestAppsDialog.State.INITIALIZED:
369 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING; 389 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING;
370 break; 390 break;
371 default: 391 default:
372 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING; 392 this.state_ = SuggestAppsDialog.State.CANCELED_CLOSING;
373 console.error('Invalid state.'); 393 console.error('Invalid state.');
374 } 394 }
375 395
(...skipping 18 matching lines...) Expand all
394 */ 414 */
395 SuggestAppsDialog.prototype.onHide_ = function(opt_originalOnHide) { 415 SuggestAppsDialog.prototype.onHide_ = function(opt_originalOnHide) {
396 // Calls the callback after the dialog hides. 416 // Calls the callback after the dialog hides.
397 if (opt_originalOnHide) 417 if (opt_originalOnHide)
398 opt_originalOnHide(); 418 opt_originalOnHide();
399 419
400 var result; 420 var result;
401 switch (this.state_) { 421 switch (this.state_) {
402 case SuggestAppsDialog.State.INSTALLED_CLOSING: 422 case SuggestAppsDialog.State.INSTALLED_CLOSING:
403 result = SuggestAppsDialog.Result.INSTALL_SUCCESSFUL; 423 result = SuggestAppsDialog.Result.INSTALL_SUCCESSFUL;
424 // Record the reason of closing. 1: Item installed.
425 metrics.recordEnum('SuggestApps.CloseDialog', 1, 4);
404 break; 426 break;
405 case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING: 427 case SuggestAppsDialog.State.INITIALIZE_FAILED_CLOSING:
406 result = SuggestAppsDialog.Result.FAILED; 428 result = SuggestAppsDialog.Result.FAILED;
407 break; 429 break;
408 case SuggestAppsDialog.State.CANCELED_CLOSING: 430 case SuggestAppsDialog.State.CANCELED_CLOSING:
409 result = SuggestAppsDialog.Result.USER_CANCELL; 431 result = SuggestAppsDialog.Result.USER_CANCELL;
432 // Record the reason of closing. 2: User cancelled.
433 metrics.recordEnum('SuggestApps.CloseDialog', 2, 4);
434 break;
435 case SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING:
436 result = SuggestAppsDialog.Result.WEBSTORE_LINK_OPENED;
437 // Record the reason of closing. 3: Webstore link opened.
438 metrics.recordEnum('SuggestApps.CloseDialog', 3, 4);
410 break; 439 break;
411 default: 440 default:
412 result = SuggestAppsDialog.Result.USER_CANCELL; 441 result = SuggestAppsDialog.Result.USER_CANCELL;
442 // Record the reason of closing. 0: Unknown error.
443 metrics.recordEnum('SuggestApps.CloseDialog', 0, 4);
413 console.error('Invalid state.'); 444 console.error('Invalid state.');
414 } 445 }
415 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; 446 this.state_ = SuggestAppsDialog.State.UNINITIALIZED;
416 447
417 this.onDialogClosed_(result); 448 this.onDialogClosed_(result);
418 }; 449 };
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698